Jump to content

Propeprty and node


photo

Recommended Posts

Hello morbid?

Everything is very simple.
There are several nodes that have a manual property set, a plugin was created to handle the events of this property.

When changing the parameters of this property in the editor, the plugin through an overloaded method

virtual void propertyChanged (const Unigine :: UGUID & guid) override;

receives information that one of the property parameters is changed,
so we get a pointer to a mutable property
PropertyPtr prop = properties-> findPropertyByGUID (guid);
how to get a pointer to the node where the property parameter changed?

only by sequential enumeration of all nodes in the editor?
or is it possible to directly access the node having a pointer to a property?

auto editor = Editor :: get ();
const int nodes_cnt = editor-> getNumNodes ();
for (int i = 0; i <nodes_cnt; ++ i)
{
    if (auto node = editor-> getNode (i))
     {
         for (int j = 0, cnt = node-> getNumProperties (); j <cnt; ++ j)
           {
              if (auto prop_ = node-> getProperty (j))
                 if (prop _-> getID () == prop-> getID ())
                  {

                          // node - node with the desired property

                  }

           }

      }

}

Link to comment

At this point the only option to do this is to check all nodes and find one with the modified property.

However, you can add a new field (<parameter name="node" type="node"></parameter>) to your manual property that will store the exact node it's assigned to.

Depending on the number of nodes you can add value to this field manually or via API by checking all nodes n the world once. With this hack you'll be able to get the node pointer without checking all of them, for instance:

	// getting property by name
	PropertyPtr prop = properties->findPropertyByGUID(guid);
	if (prop)
	{
		// getting parameter by name
		PropertyParameterPtr param = prop->getParameterPtr("name_of_the_parameter_that_contain_the_node");
		if (param->isExist())
		{
			// get node
			NodePtr node = param->getValueNode();
		}
	}

Alternatively, you can create a map with nodes and properties, like std map.

Thank you.

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

Link to comment
×
×
  • Create New...