dongju.jeong Posted December 28, 2018 Share Posted December 28, 2018 Is camera.release() also required in init() to clear the camera from the shutdown function? Link to comment
alexander Posted December 28, 2018 Share Posted December 28, 2018 Hi dongju.jeong, There are two types of objects: one of them destroys the internal engine object in the ~Ptr() destructor and another one not. If you see these methods:->grab();->release();->isOwner(); This is an indicator that the engine object will be destroyed in the ~Ptr() destructor (if you haven't transferred ownership of this object through release() -> grab() functions). If you don't see this, ~Ptr() destructor will not destroy the engine object. But at this point a memory leak is possible. If this object wasn't attached to another one (Camera to Player, MeshDynamic to ObjectMeshDynamic, etc.) then you need to use Camera::release_ptr(my_camera_pointer.get()) to manually destroy the internal engine object.Is camera.release() also required in init() to clear the camera from the shutdown function? So, no, it is not required. Best regards, Alexander Link to comment
dongju.jeong Posted December 31, 2018 Author Share Posted December 31, 2018 Is it mean Ownership is automatically reassigned on playerspectator? so, camera is automically cleared too? then, What is this process? Is this required only in UnigineScript? Link to comment
alexander Posted January 9, 2019 Share Posted January 9, 2019 Hi dongju.jeong,Is it mean Ownership is automatically reassigned on playerspectator? so, camera is automically cleared too? There is some "secret feature" (bad design): when you use PlayerSpectator::setCamera(CameraPtr cam) you don't pass the pointer of the Camera to the PlayerSpectator. You just make a copy and apply it to the inner Camera object. For example: CameraPtr cam = Camera::create(); cam->setFov(110.0f); playerSpectator->setCamera(cam); cam->setFov(30.0f); // this will not change in the PlayerSpectator! playerSpecator->setCamera(cam); // you need to call setCamera() again Is this required only in UnigineScript? Yes, it is. Best regards, Alexander Link to comment
Recommended Posts