bugfix [#24376] Fly mode disturbs the rotation or scale of the camera object
authorCampbell Barton <ideasman42@gmail.com>
Mon, 25 Oct 2010 07:12:29 +0000 (07:12 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 25 Oct 2010 07:12:29 +0000 (07:12 +0000)
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/intern/object.c
source/blender/editors/armature/editarmature.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_transform.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/rna_object.c

index 7451d43..b64011a 100644 (file)
@@ -98,10 +98,10 @@ void disable_speed_curve(int val);
 float bsystem_time(struct Scene *scene, struct Object *ob, float cfra, float ofs);
 void object_scale_to_mat3(struct Object *ob, float mat[][3]);
 void object_rot_to_mat3(struct Object *ob, float mat[][3]);
-void object_mat3_to_rot(struct Object *ob, float mat[][3], int use_compat);
+void object_mat3_to_rot(struct Object *ob, float mat[][3], short use_compat);
 void object_to_mat3(struct Object *ob, float mat[][3]);
 void object_to_mat4(struct Object *ob, float mat[][4]);
-void object_apply_mat4(struct Object *ob, float mat[][4]);
+void object_apply_mat4(struct Object *ob, float mat[][4], short use_compat);
 
 void set_no_parent_ipo(int val);
 
index 96f9047..9d93fac 100644 (file)
@@ -1550,7 +1550,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
        if(gob) {
                ob->rotmode= target->rotmode;
                mul_m4_m4m4(ob->obmat, target->obmat, gob->obmat);
-               object_apply_mat4(ob, ob->obmat);
+               object_apply_mat4(ob, ob->obmat, FALSE);
        }
        else {
                copy_object_transform(ob, target);
@@ -1678,7 +1678,7 @@ void object_rot_to_mat3(Object *ob, float mat[][3])
        mul_m3_m3m3(mat, dmat, rmat);
 }
 
-void object_mat3_to_rot(Object *ob, float mat[][3], int use_compat)
+void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
 {
        if (ob->rotmode == ROT_MODE_QUAT)
                mat3_to_quat(ob->quat, mat);
@@ -1696,7 +1696,7 @@ void object_mat3_to_rot(Object *ob, float mat[][3], int use_compat)
 }
 
 /* see pchan_apply_mat4() for the equivalent 'pchan' function */
-void object_apply_mat4(Object *ob, float mat[][4])
+void object_apply_mat4(Object *ob, float mat[][4], short use_compat)
 {
        float mat3[3][3];    /* obmat -> 3x3 */
        float mat3_n[3][3];  /* obmat -> normalized, 3x3 */
@@ -1718,7 +1718,7 @@ void object_apply_mat4(Object *ob, float mat[][4])
        }
 
        /* rotation */
-       object_mat3_to_rot(ob, mat3_n, 0);
+       object_mat3_to_rot(ob, mat3_n, use_compat);
 
        /* scale */
        /* note: mat4_to_size(ob->size, mat) fails for negative scale */
index c8c0a4e..28165c0 100644 (file)
@@ -546,7 +546,7 @@ static void applyarmature_fix_boneparents (Scene *scene, Object *armob)
                        /* apply current transform from parent (not yet destroyed), 
                         * then calculate new parent inverse matrix
                         */
-                       object_apply_mat4(ob, ob->obmat);
+                       object_apply_mat4(ob, ob->obmat, FALSE);
                        
                        what_does_parent(scene, ob, &workob);
                        invert_m4_m4(ob->parentinv, workob.obmat);
index 56af4ce..f9d0bdd 100644 (file)
@@ -985,7 +985,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base)
                ob->lay= base->lay;
                
                copy_m4_m4(ob->obmat, dob->mat);
-               object_apply_mat4(ob, ob->obmat);
+               object_apply_mat4(ob, ob->obmat, FALSE);
        }
        
        copy_object_set_idnew(C, 0);
index b1c027a..5f9eeb0 100644 (file)
@@ -431,7 +431,7 @@ static int parent_clear_exec(bContext *C, wmOperator *op)
                }                       
                else if(type == 1) {
                        ob->parent= NULL;
-                       object_apply_mat4(ob, ob->obmat);
+                       object_apply_mat4(ob, ob->obmat, TRUE);
                }
                else if(type == 2)
                        unit_m4(ob->parentinv);
@@ -906,7 +906,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
                }
                
                if(type == 1)
-                       object_apply_mat4(ob, ob->obmat);
+                       object_apply_mat4(ob, ob->obmat, TRUE);
        }
        CTX_DATA_END;
 
index 66c5ab4..7be03a4 100644 (file)
@@ -390,7 +390,7 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob )
        /* a change was made, adjust the children to compensate */
        for(ob_child=bmain->object.first; ob_child; ob_child=ob_child->id.next) {
                if(ob_child->parent == ob) {
-                       object_apply_mat4(ob_child, ob_child->obmat);
+                       object_apply_mat4(ob_child, ob_child->obmat, TRUE);
                        what_does_parent(scene, ob_child, &workob);
                        invert_m4_m4(ob_child->parentinv, workob.obmat);
                }
@@ -574,7 +574,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
        
        CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
                where_is_object(scene, ob);
-               object_apply_mat4(ob, ob->obmat);
+               object_apply_mat4(ob, ob->obmat, TRUE);
                where_is_object(scene, ob);
                
                change = 1;
index db83cd4..5f4c551 100644 (file)
@@ -377,15 +377,7 @@ static int flyEnd(bContext *C, FlyInfo *fly)
                }
        }
        else if (fly->persp_backup==RV3D_CAMOB) {       /* camera */
-               float mat3[3][3];
-               if(fly->root_parent) {
-                       DAG_id_flush_update(&fly->root_parent->id, OB_RECALC_OB);
-               }
-               else {
-                       copy_m3_m4(mat3, v3d->camera->obmat);
-                       object_mat3_to_rot(v3d->camera, mat3, TRUE);
-                       DAG_id_flush_update(&v3d->camera->id, OB_RECALC_OB);
-               }
+               DAG_id_flush_update(fly->root_parent ? &fly->root_parent->id : &v3d->camera->id, OB_RECALC_OB);
        }
        else { /* not camera */
                /* Apply the fly mode view */
@@ -802,7 +794,7 @@ static int flyApply(bContext *C, FlyInfo *fly)
                                        view3d_persp_mat4(rv3d, view_mat);
                                        mul_m4_m4m4(diff_mat, prev_view_imat, view_mat);
                                        mul_m4_m4m4(parent_mat, fly->root_parent->obmat, diff_mat);
-                                       object_apply_mat4(fly->root_parent, parent_mat);
+                                       object_apply_mat4(fly->root_parent, parent_mat, TRUE);
 
                                        // where_is_object(scene, fly->root_parent);
 
@@ -820,7 +812,7 @@ static int flyApply(bContext *C, FlyInfo *fly)
                                else {
                                        float view_mat[4][4];
                                        view3d_persp_mat4(rv3d, view_mat);
-                                       object_apply_mat4(v3d->camera, view_mat);
+                                       object_apply_mat4(v3d->camera, view_mat, TRUE);
                                        id_key= &v3d->camera->id;
                                }
 
@@ -901,7 +893,7 @@ static int fly_cancel(bContext *C, wmOperator *op)
 static int fly_modal(bContext *C, wmOperator *op, wmEvent *event)
 {
        int exit_code;
-
+       short do_draw= FALSE;
        FlyInfo *fly = op->customdata;
 
        fly->redraw= 0;
@@ -911,14 +903,20 @@ static int fly_modal(bContext *C, wmOperator *op, wmEvent *event)
        if(event->type==TIMER && event->customdata == fly->timer)
                flyApply(C, fly);
 
-       if(fly->redraw) {
-               ED_region_tag_redraw(CTX_wm_region(C));
-       }
+       do_draw |= fly->redraw;
 
        exit_code = flyEnd(C, fly);
 
        if(exit_code!=OPERATOR_RUNNING_MODAL)
+               do_draw= TRUE;
+       
+       if(do_draw) {
+               if(fly->rv3d->persp==RV3D_CAMOB) {
+                       WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, fly->root_parent ? fly->root_parent : fly->v3d->camera);
+               }
+
                ED_region_tag_redraw(CTX_wm_region(C));
+       }
 
        return exit_code;
 }
index 5fd7ae1..ed84e4a 100644 (file)
 # Generated code has some unused vars we can ignore.
 REMOVE_STRICT_FLAGS()
 
+MESSAGE(STATUS "Configuring makesrna")
+
 FILE(GLOB DEFSRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
 FILE(GLOB APISRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*_api.c")
 LIST(REMOVE_ITEM DEFSRC rna_access.c rna_define.c makesrna.c)
 LIST(REMOVE_ITEM DEFSRC ${APISRC})
  
 STRING(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}")
+SET_SOURCE_FILES_PROPERTIES(GENSRC PROPERTIES GENERATED true)
+
 
 SET(SRC
        makesrna.c
@@ -147,5 +151,3 @@ ADD_CUSTOM_COMMAND(
 # Build bf_rna
 SET(SRC rna_access.c ${GENSRC})
 BLENDERLIB(bf_rna "${SRC}" "${INC}")
-
-MESSAGE(STATUS "Configuring makesrna")
index c29ad0d..599aa4a 100644 (file)
@@ -143,7 +143,8 @@ static void rna_Object_internal_update(Main *bmain, Scene *scene, PointerRNA *pt
 
 static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
-       object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat);
+       /* dont use compat so we get pradictable rotation */
+       object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat, FALSE);
        rna_Object_internal_update(bmain, scene, ptr);
 }
 
@@ -177,7 +178,8 @@ static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
                copy_m4_m4(ob->obmat, (float(*)[4])values);
        }
 
-       object_apply_mat4(ob, ob->obmat);
+       /* dont use compat so we get pradictable rotation */
+       object_apply_mat4(ob, ob->obmat, FALSE);
 }
 
 void rna_Object_internal_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)