Jump to content

cast nodeptr


photo

Recommended Posts

dynamic_cast<ObjectMeshSkinned*>(dynamic_cast<NodeReference*>(World::getNodeByName("Hand_rigged").get())->getReference().get());

 

When using dynamic_cast, is it correct for objects like NodePtr to use .get()?

 

and Among the functions of the node class, getNode() disappeared and only getNode(int id) remained.

Is it used like ptr->getNode(ptr->getID())?  for getNode().

Edited by dongju.jeong
Link to comment

Hello!
 

no. we strongly advise against using raw pointers.

in addition, we recommend checking that the nodes exist. this will help you find the error immediately if some node changes in the editor, not as you expected.

auto node_hang_rigged  = World::getNodeByName("Hand_rigged");
if (!node_hang_rigged)
{
    Log::error("can`t find 'Hang_rigged' node in world!\n");
    return; // or do smth else
}
auto ref_hang_rigged = checked_ptr_cast<NodeReference>(node_hang_rigged)
{
    Log::error("node 'Hang_rigged' in not NodeReference\n");
    return; // or do smth else
}
auto mesh_hang_rigged = checked_ptr_cast<ObjectMeshSkinned>(ref_hang_rigged->getReference())
{
    Log::error("reference inside 'Hang_rigged' in not ObjectMeshSkinned\n");
    return; // or do smth else
}
// ... do smth with mesh_hang_rigged

 

  • Like 1
Link to comment
×
×
  • Create New...