how to cast void* to shared_ptr<mytype>
Since you are storing a pointer to an instance of std::shared_ptr
you need to cast the value returned by getUserPointer
to std::shared_ptr<>*
instead of just std::shared_ptr<>
.
std::shared_ptr<disk_node>* u_poi
= static_cast< std::shared_ptr<disk_node>* >(RayCallback.m_collisionObject->getUserPointer());