From 014c68388e676e6809ed412ddc6633b4e6a7c2ad Mon Sep 17 00:00:00 2001 From: erwincoumans Date: Wed, 30 Jan 2019 15:29:43 -0800 Subject: [PATCH] fix createVisualShape.py ray vertical/horizontal and retina scale, fixes Issue 2085 fix memory leak in removeBody, fixes issue 2086 --- examples/ExampleBrowser/OpenGLGuiHelper.cpp | 12 ++++++------ .../SharedMemory/PhysicsServerCommandProcessor.cpp | 8 +++++--- .../Featherstone/btMultiBodyLinkCollider.h | 4 ++++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/ExampleBrowser/OpenGLGuiHelper.cpp b/examples/ExampleBrowser/OpenGLGuiHelper.cpp index 7e615a379..cfd4840e4 100644 --- a/examples/ExampleBrowser/OpenGLGuiHelper.cpp +++ b/examples/ExampleBrowser/OpenGLGuiHelper.cpp @@ -1043,12 +1043,12 @@ bool OpenGLGuiHelper::getCameraInfo(int* width, int* height, float viewMatrix[16 btScalar aspect = float(*width) / float(*height); hori *= aspect; //compute 'hor' and 'vert' vectors, useful to generate raytracer rays - hor[0] = hori[0]; - hor[1] = hori[1]; - hor[2] = hori[2]; - vert[0] = vertical[0]; - vert[1] = vertical[1]; - vert[2] = vertical[2]; + hor[0] = hori[0]* m_data->m_glApp->m_window->getRetinaScale(); + hor[1] = hori[1]* m_data->m_glApp->m_window->getRetinaScale(); + hor[2] = hori[2]* m_data->m_glApp->m_window->getRetinaScale(); + vert[0] = vertical[0]* m_data->m_glApp->m_window->getRetinaScale(); + vert[1] = vertical[1]* m_data->m_glApp->m_window->getRetinaScale(); + vert[2] = vertical[2]* m_data->m_glApp->m_window->getRetinaScale(); *yaw = getRenderInterface()->getActiveCamera()->getCameraYaw(); *pitch = getRenderInterface()->getActiveCamera()->getCameraPitch(); diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index 3c995149f..bf912342a 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -9234,10 +9234,12 @@ bool PhysicsServerCommandProcessor::processRemoveBodyCommand(const struct Shared m_data->m_dynamicsWorld->removeCollisionObject(bodyHandle->m_multiBody->getBaseCollider()); int graphicsIndex = bodyHandle->m_multiBody->getBaseCollider()->getUserIndex(); m_data->m_guiHelper->removeGraphicsInstance(graphicsIndex); + delete bodyHandle->m_multiBody->getBaseCollider(); } for (int link = 0; link < bodyHandle->m_multiBody->getNumLinks(); link++) { - if (bodyHandle->m_multiBody->getLink(link).m_collider) + btCollisionObject* colObj = bodyHandle->m_multiBody->getLink(link).m_collider; + if (colObj) { if (m_data->m_pluginManager.getRenderInterface()) { @@ -9246,13 +9248,13 @@ bool PhysicsServerCommandProcessor::processRemoveBodyCommand(const struct Shared m_data->m_dynamicsWorld->removeCollisionObject(bodyHandle->m_multiBody->getLink(link).m_collider); int graphicsIndex = bodyHandle->m_multiBody->getLink(link).m_collider->getUserIndex(); m_data->m_guiHelper->removeGraphicsInstance(graphicsIndex); + delete colObj; } } int numCollisionObjects = m_data->m_dynamicsWorld->getNumCollisionObjects(); m_data->m_dynamicsWorld->removeMultiBody(bodyHandle->m_multiBody); numCollisionObjects = m_data->m_dynamicsWorld->getNumCollisionObjects(); - //todo: clear all other remaining data, release memory etc - + delete bodyHandle->m_multiBody; bodyHandle->m_multiBody = 0; serverCmd.m_type = CMD_REMOVE_BODY_COMPLETED; diff --git a/src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h b/src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h index f91c001f1..bc909990c 100644 --- a/src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h +++ b/src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h @@ -36,6 +36,10 @@ public: btMultiBody* m_multiBody; int m_link; + virtual ~btMultiBodyLinkCollider() + { + + } btMultiBodyLinkCollider(btMultiBody* multiBody, int link) : m_multiBody(multiBody), m_link(link)