Revision: 20328
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20328
Author: ben2610
Date: 2009-05-21 21:38:49 +0200 (Thu, 21 May 2009)
Log Message:
-----------
BGE remove parent: unparented object keeps the linear and angular velocity it
had while being parented.
Modified Paths:
--------------
trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2009-05-21
18:22:35 UTC (rev 20327)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2009-05-21
19:38:49 UTC (rev 20328)
@@ -312,6 +312,18 @@
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
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs