Game Development Community

Lag-Stutter) Adding objects to a scengraph

by Jeremy Easoz · in Torque Game Builder · 10/01/2008 (11:05 pm) · 6 replies

Does anyone experience a pause/lag lock/stuttering when adding a batch of objects to a scenegraph.

Is there a thresh-hold / limit that I should be weary of when adding batches of objects to a scenegraph?

#1
10/02/2008 (12:11 pm)
Are these objects already created (pooled) that you are just adding to the scene? I wouldn't expect that to be to big a hit, but if so, you could try leaving your pooled objects in the scene and setting enabled = false, things like that.
#2
10/02/2008 (1:28 pm)
It also depends on what type of object you are adding and how many. If you try to add a million tilelayers, then yes; a million blank scene objects, probably not.
#3
10/02/2008 (1:50 pm)
Yes the objects are already pooled but not added to a scenegraph.
The objects are T2DAnimatedSprites.
I can't really say how many are being spawned.
Less than 300, more then 1.
I would say on average, less than 100.
#4
10/02/2008 (2:05 pm)
If you need to add/remove large numbers at a time and during runtime, (i'm guessing for your blocks), its probably a good idea to leave them in the scene rather than adding/removing them.
#5
10/07/2008 (11:31 pm)
Hi Jeremy. I had an object pooling system for many of our game elements, actually, its an entity manager behavior attached to a scene object so one can easily change the number of pre-allocated entities when the scene is loaded. All these entities are added to the scene automatically (as they are cloned from a template) and disabled upon their creation. Having a lot of disabled objects floating around the scene does not appear to have a large negative impact on performance.
#6
10/09/2008 (9:20 pm)
If you're running through a loop several times in a row per frame/tick, then yes, you can expect delays when adding objects to scenes.

I've also noticed that when I print out echo statements (for debugging) during loops that it makes the loops take considerably longer than without the echos.