From 4d55ecfdbed5c09c21e7ea7bb59c675f3b007203 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Mon, 18 Jun 2012 13:03:00 -0400 Subject: [PATCH] Deleting scaled shapes; scaleObject() --- apps/openmw/mwworld/physicssystem.cpp | 10 +++++++++- libs/openengine/bullet/physic.cpp | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 46b72956d5..530881ec92 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -300,7 +300,15 @@ namespace MWWorld void PhysicsSystem::scaleObject (const std::string& handle, float scale) { - + if(handleToMesh.find(handle) != handleToMesh.end()) + { + btTransform transform = mEngine->getRigidBody(handle)->getWorldTransform(); + removeObject(handle); + + Ogre::Quaternion quat = Ogre::Quaternion(transform.getRotation().getW(), transform.getRotation().getX(), transform.getRotation().getY(), transform.getRotation().getZ()); + Ogre::Vector3 vec = Ogre::Vector3(transform.getOrigin().getX(), transform.getOrigin().getY(), transform.getOrigin().getZ()); + addObject(handle, handleToMesh[handle], quat, scale, vec); + } } bool PhysicsSystem::toggleCollisionMode() diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 6c4e426973..1dc38475d5 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -398,10 +398,16 @@ namespace Physic if (it != RigidBodyMap.end() ) { RigidBody* body = it->second; + btScaledBvhTriangleMeshShape* scaled = dynamic_cast (body->getCollisionShape()); + if(body != NULL) { delete body; } + if(scaled != NULL) + { + delete scaled; + } RigidBodyMap.erase(it); } }