[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27150] trunk/blender/source/blender: fix for fly mode restoring non-euler rotations
Campbell Barton
ideasman42 at gmail.com
Fri Feb 26 09:47:23 CET 2010
Revision: 27150
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27150
Author: campbellbarton
Date: 2010-02-26 09:47:20 +0100 (Fri, 26 Feb 2010)
Log Message:
-----------
fix for fly mode restoring non-euler rotations
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_object.h
trunk/blender/source/blender/blenkernel/intern/object.c
trunk/blender/source/blender/editors/space_view3d/view3d_view.c
Modified: trunk/blender/source/blender/blenkernel/BKE_object.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_object.h 2010-02-26 03:24:21 UTC (rev 27149)
+++ trunk/blender/source/blender/blenkernel/BKE_object.h 2010-02-26 08:47:20 UTC (rev 27150)
@@ -116,6 +116,9 @@
void solve_tracking (struct Object *ob, float targetmat[][4]);
int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]);
+void *object_tfm_backup(struct Object *ob);
+void object_tfm_restore(struct Object *ob, void *obtfm_pt);
+
void object_handle_update(struct Scene *scene, struct Object *ob);
float give_timeoffset(struct Object *ob);
Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c 2010-02-26 03:24:21 UTC (rev 27149)
+++ trunk/blender/source/blender/blenkernel/intern/object.c 2010-02-26 08:47:20 UTC (rev 27150)
@@ -2393,7 +2393,6 @@
float vec[3];
mul_v3_m4v3(vec, dob->mat, bb->vec[i]);
DO_MINMAX(vec, min, max);
- // print_v3(dob->ob->id.name, vec); // some dupligroups give odd results - campbell
}
ok= 1;
@@ -2406,7 +2405,66 @@
return ok;
}
+/* copied from DNA_object_types.h */
+typedef struct ObTfmBack {
+ float loc[3], dloc[3], orig[3];
+ float size[3], dsize[3]; /* scale and delta scale */
+ float rot[3], drot[3]; /* euler rotation */
+ float quat[4], dquat[4]; /* quaternion rotation */
+ float rotAxis[3], drotAxis[3]; /* axis angle rotation - axis part */
+ float rotAngle, drotAngle; /* axis angle rotation - angle part */
+ float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */
+ float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */
+ float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */
+ float imat[4][4]; /* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform */
+} ObTfmBack;
+void *object_tfm_backup(Object *ob)
+{
+ ObTfmBack *obtfm= MEM_mallocN(sizeof(ObTfmBack), "ObTfmBack");
+ copy_v3_v3(obtfm->loc, ob->loc);
+ copy_v3_v3(obtfm->dloc, ob->dloc);
+ copy_v3_v3(obtfm->orig, ob->orig);
+ copy_v3_v3(obtfm->size, ob->size);
+ copy_v3_v3(obtfm->dsize, ob->dsize);
+ copy_v3_v3(obtfm->rot, ob->rot);
+ copy_v3_v3(obtfm->drot, ob->drot);
+ copy_qt_qt(obtfm->quat, ob->quat);
+ copy_qt_qt(obtfm->dquat, ob->dquat);
+ copy_v3_v3(obtfm->rotAxis, ob->rotAxis);
+ copy_v3_v3(obtfm->drotAxis, ob->drotAxis);
+ obtfm->rotAngle= ob->rotAngle;
+ obtfm->drotAngle= ob->drotAngle;
+ copy_m4_m4(obtfm->obmat, ob->obmat);
+ copy_m4_m4(obtfm->parentinv, ob->parentinv);
+ copy_m4_m4(obtfm->constinv, ob->constinv);
+ copy_m4_m4(obtfm->imat, ob->imat);
+
+ return (void *)obtfm;
+}
+
+void object_tfm_restore(Object *ob, void *obtfm_pt)
+{
+ ObTfmBack *obtfm= (ObTfmBack *)obtfm_pt;
+ copy_v3_v3(ob->loc, obtfm->loc);
+ copy_v3_v3(ob->dloc, obtfm->dloc);
+ copy_v3_v3(ob->orig, obtfm->orig);
+ copy_v3_v3(ob->size, obtfm->size);
+ copy_v3_v3(ob->dsize, obtfm->dsize);
+ copy_v3_v3(ob->rot, obtfm->rot);
+ copy_v3_v3(ob->drot, obtfm->drot);
+ copy_qt_qt(ob->quat, obtfm->quat);
+ copy_qt_qt(ob->dquat, obtfm->dquat);
+ copy_v3_v3(ob->rotAxis, obtfm->rotAxis);
+ copy_v3_v3(ob->drotAxis, obtfm->drotAxis);
+ ob->rotAngle= obtfm->rotAngle;
+ ob->drotAngle= obtfm->drotAngle;
+ copy_m4_m4(ob->obmat, obtfm->obmat);
+ copy_m4_m4(ob->parentinv, obtfm->parentinv);
+ copy_m4_m4(ob->constinv, obtfm->constinv);
+ copy_m4_m4(ob->imat, obtfm->imat);
+}
+
/* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */
/* local_object->proxy == pointer to library object, saved in files and read */
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_view.c 2010-02-26 03:24:21 UTC (rev 27149)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_view.c 2010-02-26 08:47:20 UTC (rev 27150)
@@ -1962,6 +1962,8 @@
float rot_backup[4]; /* backup the views quat incase the user cancels flying in non camera mode. (quat for view, eul for camera) */
short persp_backup; /* remember if were ortho or not, only used for restoring the view if it was a ortho view */
+ void *obtfm; /* backup the objects transform */
+
/* compare between last state */
double time_lastwheel; /* used to accelerate when using the mousewheel a lot */
double time_lastdraw; /* time between draws */
@@ -2047,11 +2049,11 @@
/* store the original camera loc and rot */
/* TODO. axis angle etc */
- VECCOPY(fly->ofs_backup, ob_back->loc);
- VECCOPY(fly->rot_backup, ob_back->rot);
+ fly->obtfm= object_tfm_backup(ob_back);
+
where_is_object(fly->scene, fly->v3d->camera);
- VECCOPY(fly->rv3d->ofs, fly->v3d->camera->obmat[3]);
+ copy_v3_v3(fly->rv3d->ofs, fly->v3d->camera->obmat[3]);
mul_v3_fl(fly->rv3d->ofs, -1.0f); /*flip the vector*/
fly->rv3d->dist=0.0;
@@ -2098,9 +2100,7 @@
else ob_back= fly->v3d->camera;
/* store the original camera loc and rot */
- /* TODO. axis angle etc */
- VECCOPY(ob_back->loc, fly->ofs_backup);
- VECCOPY(ob_back->rot, fly->rot_backup);
+ object_tfm_restore(ob_back, fly->obtfm);
DAG_id_flush_update(&ob_back->id, OB_RECALC_OB);
} else {
@@ -2145,6 +2145,8 @@
rv3d->rflag &= ~(RV3D_FLYMODE|RV3D_NAVIGATING);
//XXX2.5 BIF_view3d_previewrender_signal(fly->sa, PR_DBASE|PR_DISPRECT); /* not working at the moment not sure why */
+ if(fly->obtfm)
+ MEM_freeN(fly->obtfm);
if(fly->state == FLY_CONFIRM) {
MEM_freeN(fly);
@@ -2507,15 +2509,17 @@
}
add_v3_v3v3(rv3d->ofs, rv3d->ofs, dvec);
-#if 0 //XXX2.5
+
+ /* todo, dynamic keys */
+#if 0
if (fly->zlock && fly->xlock)
- headerprint("FlyKeys Speed:(+/- | Wheel), Upright Axis:X on/Z on, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
+ ED_area_headerprint(fly->ar, "FlyKeys Speed:(+/- | Wheel), Upright Axis:X on/Z on, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
else if (fly->zlock)
- headerprint("FlyKeys Speed:(+/- | Wheel), Upright Axis:X off/Z on, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
+ ED_area_headerprint(fly->ar, "FlyKeys Speed:(+/- | Wheel), Upright Axis:X off/Z on, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
else if (fly->xlock)
- headerprint("FlyKeys Speed:(+/- | Wheel), Upright Axis:X on/Z off, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
+ ED_area_headerprint(fly->ar, "FlyKeys Speed:(+/- | Wheel), Upright Axis:X on/Z off, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
else
- headerprint("FlyKeys Speed:(+/- | Wheel), Upright Axis:X off/Z off, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
+ ED_area_headerprint(fly->ar, "FlyKeys Speed:(+/- | Wheel), Upright Axis:X off/Z off, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB");
#endif
/* we are in camera view so apply the view ofs and quat to the view matrix and set the camera to the view */
More information about the Bf-blender-cvs
mailing list