LOD system : obj.visible=False vs empty mesh

Hi,

In a lod system, what is the best way to free logic/memory/anything else usage?

  • Make a very low poly object invisible
  • Replace the current mesh with an empty mesh

Thank you!

I don’t know, but I know a good way to find out- benchmarks!

Make a ton of copies of one method, and note the framerate and stats. Quit, make the same number of copies of the other method, note that one’s speed and stats, and compare.

I will :slight_smile:
Until then, I hope I can get more explanations about how the game engine makes a difference between invisible and empty. I would like to understand a bit more about the “inside”.

cray , i would wait for ideasman’s dynamic freeing pledge to be finished this will help a lot with any kindof lod system.

Well, as far as I know, when you make an object invisible the object and its mesh is still there, just is not rendered…but still it eats memory, when you swich the mesh with an empty mesh blender frees up the memory from it.

I’m pretty sure when a blend is loaded, the entire thing sits in memory, including all unused scenes (maybe not the unused scenes part) but until the dynamic loading/freeing is implemented, memory is not dynamically freed.

Hi,

planaria

cray , i would wait for ideasman’s dynamic freeing pledge to be finished this will help a lot with any kindof lod system.
Yes, this is true . But that would not be the best solution in all cases : a simple transition before having to end an object is what I am looking for, especially to keep his logic even when he is far.
Also, I’m afraid Ending / Adding objects would mean additional loading time that wouldn’t fit [[in some cases]].

haidme

when you swich the mesh with an empty mesh blender frees up the memory from it.
I thought so too but

I’m pretty sure when a blend is loaded, the entire thing sits in memory, including all unused scenes
this is what I had understood from reading ideasman’s threads.

that’s why I ask : if every mesh is taken in account and loaded, and memory is not dynamically freed, is empty better than invisible or it doesn’t change anything at all?

TEST
294912 in the scene : 2 spheres (subdivide multi, subdivide smooth)
Visible and not empty : Rasterizer 99%
Invisible and not empty : Rasterizer 1%
Visible and empty : Rasterizer 1%
Invisible and empty : Rasterizer 1%

I provide a .blend with only one sphere (2 were too long to load).
press I to make it invisible/visible.
press space to make it empty/sphere.

I don’t know if one sphere is enough to make some conclusions, but both (empty, invisible) return 1% Rasterizer, with no loading time. That means the memory was not freed (unless the object is too little so we can’t notice loading time? but my pc can’t handle much more.)

Note : I had to replace the sphere with a light one so the .blend is easy to downlad.
Please subdivide it yourself.

Attachments

empty_invisible.blend (198 KB)

I’m not familar with the replace mesh actuator, and how to deal with multiple meshes. But I suspect that the only way to replace the current mesh with an empty one is to have another object, with another mesh (by creating it on blender with space->add->empty), then using that object’s mesh name in another object’s replace mesh actuator. Is this correct or is there a better method?

Because if this is the case then you’re wasting memory with the variables of the empty object where you got your mesh from. It is a brand new KX_GameObject with all those class members that you’ll never use for anything just sitting on memory.

So using the empty wastes memory with a new object while simply setting an existing object to invisible will just change the value of an existing boolean variable. And according to your test, it doesn’t seem to matter which method you use for the Rasterizer. But toggling invisibility would be lighter on the logic calculations.

Unless there’s a better way of adding meshes to objects without actually adding a new object only for that, that I’m not aware of?

Hi vibrunazo,
you are right.
The empty mesh is just loaded once at startup. This isn’t much, but it’s true that it takes part in the calculation.

(Note : There surely is a way to create an empty mesh with python.)