Jump to content

Delete a node with lights


photo

Recommended Posts

Hey,

 

What is the proper way to delete a node reference that has lights on it.  Right now we have a node file with 4 child nodes on it all which are LightOmni nodes(2 are clones of the other two).  When we use Unigine::Editor::get()->removeNode( node, 1 ); I see a destructor for LightOmni get triggered twice, but there are still lights on the ground where the object use to be.  Is there an additional clean up call we need?  we are on Unigine 2.2.1-2 right now.

 

Thanks,

Dusty

Link to comment

Hi Dusty,

 

There was a bug in 2.2.1 with recursive deletion of the nodes. Could you please check the same case in 2.3.1 or 2.3 SDKs? Also, I'm not completely sure that i understand your nodes hierarchy - could you please provide a screenshot with it?

 

More likely (if you don't have plan to upgrade to 2.3.x) you will have to write your own method that will delete all the nodes in NodeReference and then delete NodeReference itself.

 

Sorry for the inconvenience caused.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hi Dusty,

 

Also, keep in mind that editor->removeNode() will remove nodes only from Node list inside Editor. They will be available in the world.

 

So, correct code (that working as expected in 2.3.x SDKs) will look like this:

using namespace Unigine;

void destroyNode(NodePtr &node)
{
	for (int i = node->getNumChildren() - 1; i >= 0; i--)
	{
		NodePtr c = node->getChild(i);
		destroyNode(c);
	}
	node.destroy();
}

<...>
int AppWorldLogic::init() {
	// Write here code to be called on world initialization: initialize resources for your world scene during the world start.

	Editor *editor = Editor::get();
	NodePtr delete_me = editor->getNodeByName("delete_me");
	editor->removeNode(delete_me, 1);

	destroyNode(delete_me);
	
	return 1;
}

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...