From 3d3527eb6dc44a386ed5ac486af3e087af3c7be0 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 21 Aug 2008 21:04:42 +0000 Subject: BGE bug #17411 fixed: the always sensor is called before the the scale of the object is applied. The scale is now applied to the shape before the creation of the rigid body. --- source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 5 ++--- source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index c95ab954022..d6997ee29a8 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -801,9 +801,6 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, } bm->setMargin(0.06); - if (objprop->m_dyna) - bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); - if (objprop->m_isCompoundChild) @@ -905,6 +902,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter); ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter); ci.m_bRigid = objprop->m_dyna && objprop->m_angular_rigidbody; + MT_Vector3 scaling = gameobj->NodeGetWorldScaling(); + ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]); KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna); // shapeInfo is reference counted, decrement now as we don't use it anymore if (shapeInfo) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 312e3258f61..d6a32dfd9c0 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -48,6 +48,10 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) // copy pointers locally to allow smart release m_MotionState = ci.m_MotionState; m_collisionShape = ci.m_collisionShape; + // apply scaling before creating rigid body + m_collisionShape->setLocalScaling(m_cci.m_scaling); + if (m_cci.m_mass) + m_collisionShape->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor); // shape info is shared, increment ref count m_shapeInfo = ci.m_shapeInfo; if (m_shapeInfo) -- cgit v1.2.3