Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-05-21 23:38:49 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-05-21 23:38:49 +0400
commit7f5acd68755cb36aa7f679ffbd41cc3c6d9cbf58 (patch)
tree16cc7a33b1b7e263cf1d053a17b45d2e138b81e1 /source
parent036ebc55233241bf9bd8149f855185cfcfb1ab67 (diff)
BGE remove parent: unparented object keeps the linear and angular velocity it had while being parented.
Diffstat (limited to 'source')
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 0c191257f41..3740972ba29 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -312,6 +312,18 @@ void KX_GameObject::RemoveParent(KX_Scene *scene)
rootobj->m_pPhysicsController1->RemoveCompoundChild(m_pPhysicsController1);
}
m_pPhysicsController1->RestoreDynamics();
+ if (m_pPhysicsController1->IsDyna() && rootobj->m_pPhysicsController1)
+ {
+ // dynamic object should remember the velocity they had while being parented
+ MT_Point3 childPoint = GetSGNode()->GetWorldPosition();
+ MT_Point3 rootPoint = rootobj->GetSGNode()->GetWorldPosition();
+ MT_Point3 relPoint;
+ relPoint = (childPoint-rootPoint);
+ MT_Vector3 linVel = rootobj->m_pPhysicsController1->GetVelocity(relPoint);
+ MT_Vector3 angVel = rootobj->m_pPhysicsController1->GetAngularVelocity();
+ m_pPhysicsController1->SetLinearVelocity(linVel, false);
+ m_pPhysicsController1->SetAngularVelocity(angVel, false);
+ }
}
// graphically, the object hasn't change place, no need to update m_pGraphicController
}