Cleanup Process - Collision Nodes

I just wanted to know, do you have to call del on Nodes that were created, filled with a collision solid, and attached to a Model, if that Model is cleaned up and removed?

I first thought the Nodes that hold collision solids will be deleted with the Model they are attached to, but decided to call a del statement on those Nodes anyway.

I haven’t received any error messages, but I wonder if it’s necessary?

Also, what about an attribute in base like base.cTrav?
I called del on it too (del base.cTrav). Is that also necessary?

In general, no, you don’t have to call del explicitly on nodes when you’re deleting the parent node. And you don’t have to call del on members of an object when you’re deleting the containing object.

There are exceptions. When an object contains a back-pointer to its containing object, then it creates a circular reference count, which cannot be deleted properly unless you explicitly remove the back-pointer or del the object. Typically this is only an issue for things that store member functions, for instance, if you call self.accept(‘blahblah’, self.doodah), then you have created a circular reference count by storing self.doodah, so you have to break that reference by calling self.ignoreAll() eventually.

There are a few discussions on this topic in the forums.


What about the Travs? Should I call delet on the base.cTravs, of an object/actor?

No, but since it is recommended that you keep one global CollisionTraverser for all of your collision needs, you will probably want to call cTrav.removeCollider() for each time you called cTrav.addCollder(), to remove the references to the collision objects so the cTrav can be re-used for something else.

But if your intention is to let the entire CollisionTraverser go away, and create a new one for the next purpose, then you don’t need to do this.