Jump to content

Returning a NodePtr from runSystem()


photo

Recommended Posts

This snippet from our code shows how we use the return value of runSystem() to return a vec3 from UnigineScript

 

Unigine::Variable var = GLib::GetSingletonImpl()->GetEngine()->runSystem(

"Model::GetPosition",

Unigine::Variable(m_idNode) );

 

Unigine:::vec3 vPos = var.getVec3() etc. and this works just fine

 

But this fails when we try to return a Node through a Unigine::Variable

 

Unigine::Variable var = GLib::GetSingletonImpl()->GetEngine()->runSystem(

"Model::SetColorScale",

Unigine::Variable(m_idNode),

CGLibHelper::CVector3DToVariable(vColor) );

 

followed by var.getNode() causes an access violation.

 

Is returning a NodePtr through runSystem's return value not supported?

 

UnigineScript

===================

Node SetColorScale(int idNode, vec3 vColor)

{

Node node = engine.world.getNode(idNode);

Object obj = node_cast(node);

if( obj.getNumSurfaces() > 0 )

obj.setMaterialParameter("color_scale", vec4(vColor, 0.f), 0);

 

return node;

}

 

 

Thanks,

Ashwin.

Link to comment

Add Engine::pushSystem() before calling runSystem() and Engine::popSystem() after it.

It will set appropriate runtime.

 

See details here (Create Variable in Extern Function section)

Link to comment

Add Engine::pushSystem() before calling runSystem() and Engine::popSystem() after it.

It will set appropriate runtime.

 

See details here (Create Variable in Extern Function section)

Thanks! that did it.

Link to comment
×
×
  • Create New...