|
Author Topic:   Garbage Collection
ostra
Member
posted September 10, 1999 09:33 AM            
Does anybody use some kind of garbage collection or other type of memory managment?
I'm currently using some kind of pool for textures. They are stored in a hashtable and I retrieve them asking for them to the TextureManager (that's who I called this tetxure pool). If the tetxure is not in memory, I load it from disk. If it's already resident, I only return it from the hashtable. So objects with the same texture can share them. Each texture also has an id number corresponding to its texture object in OpenGL.
But I'm not sure of doing this with meshes. I could easily benefit (memory usage) sharing meshes between objects, but what if I need to deform the mesh? I'll have to make a copy of it, or all other objects sharing the mesh will be affected. Or I oculd use some kind of mixed approach.

On another topic, I think it wil be a good idea to start a thread talking about who is who in this bulletin board: some kind of introduction, what are we working at, etc.

By!
Marco

IP:

LDA Seumas
unregistered
posted September 10, 1999 02:01 PM           
Hi Marco,

Heh, I do almost exactly the same thing with my resource management right now too.

I ask the Resource Manager for a file name, and it either loads it in, or returns a pointer to the existing resource. I do the same for meshes and sounds, as well. I allow for custom modified versions of textures by letting the app "create" named textures in the resource manager, which they can then fill with custom modified image data, perhaps partly pulled from a normally loaded image. Again there is sharing, as if another entity asks for the same special name as the created image, it'll just get a pointer.

For meshes, I've circumvented the deformation problem by doing all deformations in real-time as the object is being rendered. When tanks get damaged, the points of their mesh are put through a Perlin Noise function to perturb them before being rendered. If I really needed full deformation, I could just get the resource manager to make a couple of temporary copies of a mesh to screw around with.

And sure, feel free to start a topic for introductions.

------------------
-- Seumas McNally, Lead Programmer, Longbow Digital Arts

IP:

ostra
Member
posted September 10, 1999 02:59 PM            
Seumas, thanks for replying!! That copy stuff seems to be a good idea, I'll have to think better about my intended architecture. I'll explain a bit:
All 3d objects are descendants of the Object3D class (not very original name). Then I have the MeshObject class (descendant from Object3D) which has a Mesh and a Texture. In this case there is no problem in sharing the Mesh. But iŽd like to implement some kind of "controllers", like modifiers in 3ds Max. In Max, you have an object and then you can apply modifiers (such as skew, bend, or more complex), which are stored in the modifier stack. Before rendering the object, Max transforms the mesh with the modifiers in the stack. One nice benefit is to have unlimited undo (since you can always delete a modifier from the stack, or change parameters). I could have then a spherify modifier, for example, or like you, a noise modifier. But I think I would need two meshes in the object, one is the original and the other one to work with (apply modifiers). Mmmhh... better check Max SDK help again to see how they do it
But the primary goal for controllers was not to modify meshes, but to control object parameters, like controlling a particle system or a "face to camera" controller (for making billboards, or a flock controller. Definetely I'll have to think more about it.
If anyone has any thoughts about this, I'll be glad to hear them.
By
Marco

IP:

LDA Seumas
unregistered
posted September 13, 1999 05:30 AM           
Unless your modifiers are going to be so static (and the most fun type of modifiers are dynamically changing modifiers) that you'll save a lot of work by caching the results for a number of frames, then you don't need a copy of the mesh, but simply a temporary vertex array in your rendering code. If an object has a modifier, run the modifier on its vertices with the output going to the temporary array. If it has more modifiers, run them on the temporary array as well. Then render the temporary array, and use it (or not) for the next object. That's what I do in my engine; if an object doesn't need to be modified, its native vertex array is used out of the shared mesh.

------------------
-- Seumas McNally, Lead Programmer, Longbow Digital Arts

IP: