Vladimir_tyutenkov Posted August 15, 2019 Share Posted August 15, 2019 Is there a method to access the node if the property that contains this node is known? or need to iterate and compare all the nodes? Link to comment
morbid Posted August 16, 2019 Share Posted August 16, 2019 Hello Vladimir, Please, explain what you want to do. At this point the task is unclear to me. Thanks. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Vladimir_tyutenkov Posted August 16, 2019 Author Share Posted August 16, 2019 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 propertyPropertyPtr 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
morbid Posted August 16, 2019 Share Posted August 16, 2019 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: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Vladimir_tyutenkov Posted August 16, 2019 Author Share Posted August 16, 2019 ok , Thank you. Link to comment
Recommended Posts