Game Development Community

Preventing Object Deletion

by Matthias Georgi · in Torque Game Engine · 01/10/2006 (3:01 am) · 2 replies

I'm currently writing a binding for the Ruby language.
Looking at the source code for the Python binding, it wasn't too hard until now.

The tricky part is to track the lifecycle of SimObjetcs.
I tried to wrap my SimObjects into another instance of a custom SimObject and added a delete notifier. Fore some strange reason the SimObject pointer transmuted into a NULL pointer and crashed my application. I did not call registerReference which would explain this behaviour. Nor did the engine call the delete notifier either.

In some other thread it was said, that i don't have to call registerObject for SimObject subclasses, but without calling it my SimObject was not registered to the global name.

Generally it would be the best option to keep the Torque Engine from deleting my objects.
How does the Engine detect unused objects?
Reference counting or what ist the mechanism behind that?

#1
01/10/2006 (3:36 am)
I just looked into this deleteObject stuff and it seems, that deletion is triggered explicitly in several places of the engine and not really changeable.

So I have to take the approach of the intermediate SimObject and find this annoying NULL pointer bug.
But again I'm not sure if I should call registerObject or just assignName...
#2
01/10/2006 (5:02 am)
I found the mentioned bug, a very stupid one. Just assigned the wrong pointer to my ruby struct.
I think the best solution is not to keep references from the scripting side, maybe only as local variables. SimObject::findObject should be fast enough.
Sorry for the noise ...