BGE: Fix T19377 restore dynamics after unparenting object.
authorPorteries Tristan <republicthunderbolt9@gmail.com>
Mon, 10 Aug 2015 12:36:54 +0000 (14:36 +0200)
committerPorteries Tristan <republicthunderbolt9@gmail.com>
Mon, 10 Aug 2015 15:08:11 +0000 (17:08 +0200)
Reviewers: scorpion81

source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

index 7021d527abb33c77ebc4f5760c97071a47fef4d1..c3da80bc14fed93a46f98c8491db9a3ef518a02e 100644 (file)
@@ -1616,7 +1616,8 @@ void KX_GameObject::Resume(void)
 {
        if (m_suspended) {
                SCA_IObject::Resume();
-               if (GetPhysicsController())
+               // Child objects must be static, so we block changing to dynamic
+               if (GetPhysicsController() && !GetParent())
                        GetPhysicsController()->RestoreDynamics();
 
                m_suspended = false;
@@ -3438,7 +3439,8 @@ PyObject *KX_GameObject::PySuspendDynamics(PyObject *args)
 
 PyObject *KX_GameObject::PyRestoreDynamics()
 {
-       if (GetPhysicsController())
+       // Child objects must be static, so we block changing to dynamic
+       if (GetPhysicsController() && !GetParent())
                GetPhysicsController()->RestoreDynamics();
        Py_RETURN_NONE;
 }
index e02eca3db6324e6f0c39bd400c3751af62da95a0..96e1cc29de363214f0ca91f4976bfb54f7cda6f4 100644 (file)
@@ -121,7 +121,9 @@ bool KX_SCA_DynamicActuator::Update()
        switch (m_dyn_operation)
        {
                case 0:
-                       controller->RestoreDynamics();
+                       // Child objects must be static, so we block changing to dynamic
+                       if (!obj->GetParent())
+                               controller->RestoreDynamics();
                        break;
                case 1:
                        controller->SuspendDynamics();
index fd709a87defb8c9b47b2e2bde17109072f4fcb59..83126e88ce50a718818d279e4084953269d5b2bf 100644 (file)
@@ -584,6 +584,10 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
                newctrl->SetNewClientInfo(newobj->getClientInfo());
                newobj->SetPhysicsController(newctrl, newobj->IsDynamic());
                newctrl->PostProcessReplica(motionstate, parentctrl);
+
+               // Child objects must be static
+               if (parent)
+                       newctrl->SuspendDynamics();
        }
 
        return newobj;
index 759e8bd6f7e4471f9c3bd58ca5718edb678481e9..53c007f256ce4732b47ae53257fccde9a77b3737 100644 (file)
@@ -3122,9 +3122,7 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject
        {
                KX_BlenderSceneConverter *converter = (KX_BlenderSceneConverter*)KX_GetActiveEngine()->GetSceneConverter();
                parent = converter->FindGameObject(blenderparent);
-               isbulletdyna = false;
                isbulletsoftbody = false;
-               shapeprops->m_mass = 0.f;
        }
 
        if (!isbulletdyna)
@@ -3581,6 +3579,9 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject
                }
        }
 
+       if (parent)
+               physicscontroller->SuspendDynamics(false);
+
        CcdPhysicsController* parentCtrl = parent ? (CcdPhysicsController*)parent->GetPhysicsController() : 0;
        physicscontroller->SetParentCtrl(parentCtrl);