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
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2008-07-17 19:33:27 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2008-07-17 19:33:27 +0400
commit439e474e4e6ba3c2fe6eb498e225c442d025a4ee (patch)
tree0c2574f53abd7b9443b31bd04406ee022f7f5a39 /source/gameengine/Ketsji/KX_Scene.cpp
parent5848fee125790e1d8f28dd13d5b4809687d7375f (diff)
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
Diffstat (limited to 'source/gameengine/Ketsji/KX_Scene.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index ffb39bc0fb6..891cd9b3d85 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -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
// 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
- MT_Vector3 newscale = groupobj->GetSGNode()->GetRootSGParent()->GetLocalScale();
-
+ MT_Vector3 newscale = groupobj->NodeGetWorldScaling();
// set the replica's relative scale with the rootnode's scale
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())
{
replica->GetPhysicsController()->setPosition(newpos);