BGE patch: use the Blender convention to duplicate groups in the BGE so that the objects will be created with the location and orientation as in Blender. Note that the BGE handles scaling in a parent tree differently than Blender. To avoid discrepencies between the 3D view and the BGE, use only isotropic scaling on all your objects except the leaf objects (i.e. without children) that can have anisotropic scaling

This commit is contained in:
Benoit Bolsee 2008-07-17 15:33:27 +00:00
parent 5848fee125
commit 439e474e4e

@ -672,19 +672,22 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level)
} }
// don't replicate logic now: we assume that the objects in the group can have // don't replicate logic now: we assume that the objects in the group can have
// logic relationship, even outside parent relationship // logic relationship, even outside parent relationship
// In order to match 3D view, the position of groupobj is used as a
// transformation matrix instead of the new position. This means that
// the group reference point is 0,0,0
MT_Point3 newpos = groupobj->NodeGetWorldPosition();
replica->NodeSetLocalPosition(newpos);
MT_Matrix3x3 newori = groupobj->NodeGetWorldOrientation();
replica->NodeSetLocalOrientation(newori);
// get the rootnode's scale // get the rootnode's scale
MT_Vector3 newscale = groupobj->GetSGNode()->GetRootSGParent()->GetLocalScale(); MT_Vector3 newscale = groupobj->NodeGetWorldScaling();
// set the replica's relative scale with the rootnode's scale // set the replica's relative scale with the rootnode's scale
replica->NodeSetRelativeScale(newscale); replica->NodeSetRelativeScale(newscale);
MT_Matrix3x3 newori = groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldOrientation();
replica->NodeSetLocalOrientation(newori);
MT_Point3 newpos = groupobj->NodeGetWorldPosition() +
newscale*(groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldPosition());
replica->NodeSetLocalPosition(newpos);
if (replica->GetPhysicsController()) if (replica->GetPhysicsController())
{ {
replica->GetPhysicsController()->setPosition(newpos); replica->GetPhysicsController()->setPosition(newpos);