[SOLVED] Node.setScale() different behaviour in System/World Script


photo

Recommended Posts

I have a DummyNode with a child ObjectMesh, both created via System-script function NewNode(), and the pointers are managed by C++. Child was attached by Unigine::Node::addChild().

I used SetScale() from World script to set parent node scale - all was Ok.

BUT.

When I moved SetScale() to the System script, it began to set the scale BOTH to parent and child nodes.

 

 

(C++) - by switching which line, I get different sizes of objects on the scene (of size Scale or Scale^2)

...

static void SetScale(NodePtr parentNode, float scale)

{

//Engine::get()->runSystem("NodeSetScale", Variable("Node",node.get()), Variable(scale));

Engine::get()->runWorld("NodeSetScale", Variable("Node",node.get()), Variable(scale));

}

 

 

 

(unigine.cpp) - indeed sets Node's and Node's child scale

...

void NodeSetScale(Node node, float scale)

{

return node.setScale(vec3(scale, scale, scale));

}

 

 

(Earth.cpp) - indeed sets Node's scale only

...

void NodeSetScale(Node node, float scale)

{

return node.setScale(vec3(scale, scale, scale));

}

Link to post

Fixed!

I found that the C++ NodeSetScale() was run from the World script -called function. Solved like this:

 

(C++)

...

Unigine::Engine::get()->pushSystem();

Script::Node::SetScale(node, NewScale);

Unigine::Engine::get()->popSystem();

...

 

now System script callback works fine.

Link to post