Game Development Community

Console Error: addToScene() - Object '1234' is already in a SceneGraph!

by Brian Wilson · in Torque Game Builder · 07/03/2011 (1:52 pm) · 5 replies

So every time I spawn an object via:
%newObject = ObjectTemplate.cloneWithBehaviors();
objectSimSet.add(%newObject);

I get the following console error with each instantiation of an object:
t2dSceneGraph::addToScene() - Object '1323' is already in a SceneGraph!.

... where 1323 is the object ID that was added.

The object adds in and functions perfectly, but I'm curious about the console error. Any pointers on what's causing this? Or is it just a standard behavior?


Thanks in advance...

#1
07/03/2011 (11:56 pm)
Hm.. Just what it says, your objects seems to be already in a scenegraph by the time you're trying to add them.

Since it's working fine after that, I assume your ObjectTemplate is in the objectSimSet, so it's clones go there too.
#2
07/04/2011 (12:42 am)
I would normally agree, but the template is just an object I built out of the range of the camera in the GUI. At no point do I add the Template to any SimSet.

Perhaps I should use a different method to build objects from a template?
#3
07/05/2011 (5:52 am)
This has been around as long as I can remember. I do recall seeing a thread about how to fix it (in source) but I couldn't locate it.

As far as I know, that's the way to do it; although the console spam is annoying.
#4
07/05/2011 (7:09 am)
Thanks Patrick. I haven't used the engine in quite some time and didn't recall seeing it before. If this is indeed a minor engine bug, I'll definitely have to do a source mod at some point because:

1) I'll be spawning thousands of objects in short periods of time, so I'm sure I can get minor performance improvements by fixing it,
2) Because OCD accepts no excuses.
#5
07/05/2011 (8:41 am)
There is a nice handy flag you can use to disable these warnings - $pref::T2D::warnSceneOccupancy - it is defined within defaultPrefs.cs .

Other option is (just a guess) to set cloned object's scenegraph field to "". Even though there appears to be not much use in having this warning, I would prefer to keep it working since it is already there.