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:
authorCampbell Barton <ideasman42@gmail.com>2010-02-26 11:47:20 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-02-26 11:47:20 +0300
commit2cf6141e7ca40daeaae845246ffa22258eefc579 (patch)
treed039e8f71e3f0e14328f55eaaa2c5da4865dec3a /source/blender
parentcf4ba30f79991e9804a6fb2b8c746b50e5cf1878 (diff)
fix for fly mode restoring non-euler rotations
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_object.h3
-rw-r--r--source/blender/blenkernel/intern/object.c60
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c26
3 files changed, 77 insertions, 12 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 5443a5b4513..a6a641a3219 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -116,6 +116,9 @@ int minmax_object_duplis(struct Scene *scene, struct Object *ob, float *min, flo
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);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 1c0f9390496..46c26524f47 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2393,7 +2393,6 @@ int minmax_object_duplis(Scene *scene, Object *ob, float *min, float *max)
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,6 +2405,65 @@ int minmax_object_duplis(Scene *scene, Object *ob, float *min, float *max)
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 */
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 1e3017214e2..cbebbd5cc91 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1962,6 +1962,8 @@ typedef struct FlyInfo {
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 @@ static int initFlyInfo (bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *even
/* 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 @@ static int flyEnd(bContext *C, FlyInfo *fly)
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 @@ static int flyEnd(bContext *C, FlyInfo *fly)
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 @@ static int flyApply(FlyInfo *fly)
}
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 */