burakdogancay Posted October 9, 2019 Share Posted October 9, 2019 Here I have simple added node to the editor and I'm transferring this nodptr to another global nodeptr as a reference.So i am manging the object with this global nodeptr like movement, rotation and so on.When I'm done with this nodeptr that I added to the editor, I don't want it to appear in the editor anymore, but I can't delete it. Here is the code, Nodeptr objectnode2 //this is global node and available in header file as public Unigine::NodeReferencePtr tobjectnode1 = Unigine::NodeReference::create("External/Entities/STA/Missile_folder/Missile_Left.node"); tobjectnode1->release(); Unigine::Editor::get()->addNode(tobjectnode1->getNode(),0); objectnode2 = tobjectnode2->getReference(); //----------Above function works correctly, i am able to move the objectnode2------------ Finally i expect below function to delete the node from editor. void removenodefromeditor(){ Unigine::Editor::get()->removeNode(object2->getNode(),0); } It throw an error and does not delete added node from editor Editor::removeNode(): 0000018E7942B380 node is not managed by the editor fFinally It throws an error and does not delete added node from editor Editor::removeNode(): 0000018E7942B380 node is not managed by the editor Link to comment
alexander Posted October 10, 2019 Share Posted October 10, 2019 Hi, You are trying to remove from the Editor objectnode2 (reference of the NodeReference), but the Editor manages the tobjectnode1 (NodeReference itself). NodeReference's content doesn't add to the Editor. Use this: void removenodefromeditor() { NodePtr node_reference = objectnode2->getPossessor(); objectnode2 = NodePtr(); // set ptr to null Unigine::Editor::get()->removeNode(node_reference,0); } And... If you don't use NodeReference itself, it would be better to use World::get()->loadNode() instead of NodeReference::create(). There is no performance or memory benefits of using NodeReference. It is just containers for the Editor. Best regards, Alexander Link to comment
burakdogancay Posted October 11, 2019 Author Share Posted October 11, 2019 Thank you for your feedback , it works like a charm. Link to comment
Recommended Posts