Fix #33487: game engine did not convert objects with rotation modes other than
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 17 Dec 2012 21:40:28 +0000 (21:40 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 17 Dec 2012 21:40:28 +0000 (21:40 +0000)
Euler XYZ correctly, was never implemented;

source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/intern/object.c
source/blender/editors/object/object_transform.c
source/blender/editors/space_clip/tracking_ops.c
source/gameengine/Converter/BL_BlenderDataConversion.cpp

index 885bb6f..bfae1bd 100644 (file)
@@ -89,7 +89,7 @@ int  BKE_object_is_libdata(struct Object *ob);
 int  BKE_object_obdata_is_libdata(struct Object *ob);
 
 void BKE_object_scale_to_mat3(struct Object *ob, float mat[3][3]);
-void BKE_object_rot_to_mat3(struct Object *ob, float mat[3][3]);
+void BKE_object_rot_to_mat3(struct Object *ob, float mat[3][3], short use_drot);
 void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], short use_compat);
 void BKE_object_to_mat3(struct Object *ob, float mat[3][3]);
 void BKE_object_to_mat4(struct Object *ob, float mat[4][4]);
index 20a718e..56af426 100644 (file)
@@ -1539,7 +1539,7 @@ void BKE_object_scale_to_mat3(Object *ob, float mat[3][3])
        size_to_mat3(mat, vec);
 }
 
-void BKE_object_rot_to_mat3(Object *ob, float mat[3][3])
+void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], short use_drot)
 {
        float rmat[3][3], dmat[3][3];
        
@@ -1570,7 +1570,10 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[3][3])
        }
        
        /* combine these rotations */
-       mul_m3_m3m3(mat, dmat, rmat);
+       if(use_drot)
+               mul_m3_m3m3(mat, dmat, rmat);
+       else
+               copy_m3_m3(mat, rmat);
 }
 
 void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], short use_compat)
@@ -1715,7 +1718,7 @@ void BKE_object_to_mat3(Object *ob, float mat[3][3]) /* no parent */
        BKE_object_scale_to_mat3(ob, smat);
 
        /* rot */
-       BKE_object_rot_to_mat3(ob, rmat);
+       BKE_object_rot_to_mat3(ob, rmat, TRUE);
        mul_m3_m3m3(mat, rmat, smat);
 }
 
index 900bf57..7a2eb56 100644 (file)
@@ -447,7 +447,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
                        float tmat[3][3], timat[3][3];
 
                        /* simple rotation matrix */
-                       BKE_object_rot_to_mat3(ob, rsmat);
+                       BKE_object_rot_to_mat3(ob, rsmat, TRUE);
 
                        /* correct for scale, note mul_m3_m3m3 has swapped args! */
                        BKE_object_scale_to_mat3(ob, tmat);
index a29524d..77662d8 100644 (file)
@@ -2025,7 +2025,7 @@ static void set_axis(Scene *scene,  Object *ob, MovieClip *clip, MovieTrackingOb
                if (!flip) {
                        float lmat[4][4], ilmat[4][4], rmat[3][3];
 
-                       BKE_object_rot_to_mat3(ob, rmat);
+                       BKE_object_rot_to_mat3(ob, rmat, TRUE);
                        invert_m3(rmat);
                        mul_m4_m4m3(mat, mat, rmat);
 
index eb695e6..ab0630b 100644 (file)
@@ -2187,26 +2187,37 @@ static void bl_ConvertBlenderObject_Single(
                blenderobject->loc[1]+blenderobject->dloc[1],
                blenderobject->loc[2]+blenderobject->dloc[2]
        );
-       MT_Vector3 eulxyz(blenderobject->rot);
+
+       MT_Matrix3x3 rotation;
+       float rotmat[3][3];
+       BKE_object_rot_to_mat3(blenderobject, rotmat, FALSE);
+       rotation.setValue3x3((float*)rotmat);
+
        MT_Vector3 scale(blenderobject->size);
+
        if (converter->addInitFromFrame) {//rcruiz
-               float eulxyzPrev[3];
                blenderscene->r.cfra=blenderscene->r.sfra-1;
                //XXX update_for_newframe();
                MT_Vector3 tmp=pos-MT_Point3(blenderobject->loc[0]+blenderobject->dloc[0],
                                             blenderobject->loc[1]+blenderobject->dloc[1],
                                             blenderobject->loc[2]+blenderobject->dloc[2]
                                             );
-               eulxyzPrev[0]=blenderobject->rot[0];
-               eulxyzPrev[1]=blenderobject->rot[1];
-               eulxyzPrev[2]=blenderobject->rot[2];
+
+               float rotmatPrev[3][3];
+               BKE_object_rot_to_mat3(blenderobject, rotmatPrev, FALSE);
+
+               float eulxyz[3], eulxyzPrev[3];
+               mat3_to_eul(eulxyz, rotmat);
+               mat3_to_eul(eulxyzPrev, rotmatPrev);
 
                double fps = (double) blenderscene->r.frs_sec/
                        (double) blenderscene->r.frs_sec_base;
 
                tmp.scale(fps, fps, fps);
                inivel.push_back(tmp);
-               tmp=eulxyz-eulxyzPrev;
+               tmp[0]=eulxyz[0]-eulxyzPrev[0];
+               tmp[1]=eulxyz[1]-eulxyzPrev[1];
+               tmp[2]=eulxyz[2]-eulxyzPrev[2];
                tmp.scale(fps, fps, fps);
                iniang.push_back(tmp);
                blenderscene->r.cfra=blenderscene->r.sfra;
@@ -2214,7 +2225,7 @@ static void bl_ConvertBlenderObject_Single(
        }
 
        gameobj->NodeSetLocalPosition(pos);
-       gameobj->NodeSetLocalOrientation(MT_Matrix3x3(eulxyz));
+       gameobj->NodeSetLocalOrientation(rotation);
        gameobj->NodeSetLocalScale(scale);
        gameobj->NodeUpdateGS(0);