fix for fly mode restoring non-euler rotations
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user