@@ -811,7 +811,7 @@ void CcdPhysicsEnvironment::ProcessFhSprings(double curTime, float interval)
811
811
if (body && (ctrl->GetConstructionInfo ().m_do_fh || ctrl->GetConstructionInfo ().m_do_rot_fh )) {
812
812
// re-implement SM_FhObject.cpp using btCollisionWorld::rayTest and info from ctrl->getConstructionInfo()
813
813
// send a ray from {0.0, 0.0, 0.0} towards {0.0, 0.0, -10.0}, in local coordinates
814
- CcdPhysicsController *parentCtrl = ctrl->GetParentCtrl ();
814
+ CcdPhysicsController *parentCtrl = ctrl->GetParentRoot ();
815
815
btRigidBody *parentBody = parentCtrl ? parentCtrl->GetRigidBody () : nullptr ;
816
816
btRigidBody *cl_object = parentBody ? parentBody : body;
817
817
@@ -2692,21 +2692,34 @@ void CcdPhysicsEnvironment::ConvertObject(BL_BlenderSceneConverter& converter, K
2692
2692
CcdConstructionInfo ci;
2693
2693
class CcdShapeConstructionInfo *shapeInfo = new CcdShapeConstructionInfo ();
2694
2694
2695
- Object *blenderparent = blenderobject->parent ;
2696
- Object *rootparent = nullptr ;
2697
- // Find the upper parent object using compound shape.
2698
- while (blenderparent) {
2699
- if ((blenderparent->gameflag & OB_CHILD) && (blenderobject->gameflag & (OB_COLLISION | OB_DYNAMIC | OB_RIGID_BODY)) &&
2700
- !(blenderobject->gameflag & OB_SOFT_BODY))
2701
- {
2702
- rootparent = blenderparent;
2695
+ Object *blenderRoot = blenderobject->parent ;
2696
+ Object *blenderCompoundRoot = nullptr ;
2697
+ // Iterate over all parents in the object tree.
2698
+ {
2699
+ Object *parentit = blenderobject->parent ;
2700
+ while (parentit) {
2701
+ // If the parent is valid for compound parent shape, update blenderCompoundRoot.
2702
+ if ((parentit->gameflag & OB_CHILD) && (blenderobject->gameflag & (OB_COLLISION | OB_DYNAMIC | OB_RIGID_BODY)) &&
2703
+ !(blenderobject->gameflag & OB_SOFT_BODY))
2704
+ {
2705
+ blenderCompoundRoot = parentit;
2706
+ }
2707
+ // Continue looking for root parent.
2708
+ blenderRoot = parentit;
2709
+
2710
+ parentit = parentit->parent ;
2703
2711
}
2704
- blenderparent = blenderparent->parent ;
2705
2712
}
2706
2713
2707
- KX_GameObject *parent = nullptr ;
2708
- if (rootparent) {
2709
- parent = converter.FindGameObject (rootparent);
2714
+ KX_GameObject *compoundParent = nullptr ;
2715
+ if (blenderCompoundRoot) {
2716
+ compoundParent = converter.FindGameObject (blenderCompoundRoot);
2717
+ isbulletsoftbody = false ;
2718
+ }
2719
+
2720
+ KX_GameObject *parentRoot = nullptr ;
2721
+ if (blenderRoot) {
2722
+ parentRoot = converter.FindGameObject (blenderRoot);
2710
2723
isbulletsoftbody = false ;
2711
2724
}
2712
2725
@@ -2982,7 +2995,7 @@ void CcdPhysicsEnvironment::ConvertObject(BL_BlenderSceneConverter& converter, K
2982
2995
if (isCompoundChild) {
2983
2996
// find parent, compound shape and add to it
2984
2997
// take relative transform into account!
2985
- CcdPhysicsController *parentCtrl = (CcdPhysicsController *)parent ->GetPhysicsController ();
2998
+ CcdPhysicsController *parentCtrl = (CcdPhysicsController *)compoundParent ->GetPhysicsController ();
2986
2999
BLI_assert (parentCtrl);
2987
3000
2988
3001
// only makes compound shape if parent has a physics controller (i.e not an empty, etc)
@@ -2995,7 +3008,7 @@ void CcdPhysicsEnvironment::ConvertObject(BL_BlenderSceneConverter& converter, K
2995
3008
2996
3009
// compute the local transform from parent, this may include several node in the chain
2997
3010
SG_Node *gameNode = gameobj->GetSGNode ();
2998
- SG_Node *parentNode = parent ->GetSGNode ();
3011
+ SG_Node *parentNode = compoundParent ->GetSGNode ();
2999
3012
// relative transform
3000
3013
MT_Vector3 parentScale = parentNode->GetWorldScaling ();
3001
3014
parentScale[0 ] = MT_Scalar (1 .0f ) / parentScale[0 ];
@@ -3136,11 +3149,12 @@ void CcdPhysicsEnvironment::ConvertObject(BL_BlenderSceneConverter& converter, K
3136
3149
}
3137
3150
}
3138
3151
3139
- if (parent)
3152
+ if (parentRoot) {
3140
3153
physicscontroller->SuspendDynamics (false );
3154
+ }
3141
3155
3142
- CcdPhysicsController *parentCtrl = parent ? ( CcdPhysicsController *)parent ->GetPhysicsController () : 0 ;
3143
- physicscontroller->SetParentCtrl (parentCtrl);
3156
+ CcdPhysicsController *parentCtrl = parentRoot ? static_cast < CcdPhysicsController *>(parentRoot ->GetPhysicsController ()) : nullptr ;
3157
+ physicscontroller->SetParentRoot (parentCtrl);
3144
3158
}
3145
3159
3146
3160
void CcdPhysicsEnvironment::SetupObjectConstraints (KX_GameObject *obj_src, KX_GameObject *obj_dest,
0 commit comments