ken.mayfield Posted June 9, 2011 Posted June 9, 2011 We are getting a random crash which is tied directly to a function we stole from Unigine samples. void remove_editor(Node node) { engine.editor.removeNode(node); } This function is used throughout the Unigine samples. We are calling this function at times once per frame (but no more than once per frame) and are getting random crashes. Also, this is ONLY being called during a physics contact callback. Our solution here provides a temp remedy, but in no way fixes the problem. void remove_editor(Node node) { node.setEnabled(0); //engine.editor.removeNode(node); } It appears that when engine.editor.removeNode(node) is called rapidly, crashes randomly appear. Is this the best way to add/remove nodes from the world?
manguste Posted June 10, 2011 Posted June 10, 2011 You cannot immediately delete, create and translate/transform nodes that were returned by physics callbacks, because physics is calculated in parallel with rendering. Here is described what can be and what cannot be done in flush(). Basically, you need to do the following: Set callbacks in flush() function. Store nodes that were returned by your callback in a queue. Delete your nodes in update(). As for deleting nodes, it depends on their owner. Take a look at Memory Management article for more details how to safely delete and add nodes.
Recommended Posts