Commit: 3c77822f96e6ef6972c3a87467a4941d7a114744
Author: Porteries Tristan
Date: Mon Aug 10 14:36:54 2015 +0200
Branches: master
https://developer.blender.org/rB3c77822f96e6ef6972c3a87467a4941d7a114744
BGE: Fix T19377 restore dynamics after unparenting object.
Reviewers: scorpion81
===================================================================
M source/gameengine/Ketsji/KX_GameObject.cpp
M source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
M source/gameengine/Ketsji/KX_Scene.cpp
M source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
===================================================================
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp
b/source/gameengine/Ketsji/KX_GameObject.cpp
index 7021d52..c3da80b 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -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;
}
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
index e02eca3..96e1cc2 100644
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
@@ -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();
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp
b/source/gameengine/Ketsji/KX_Scene.cpp
index fd709a8..83126e8 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -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;
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 759e8bd..53c007f 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -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);
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs