COW Fix: Transforming animated objects would jump when starting transforms
Just as with my earlier fix for bones (0492e56fec
),
here we're reading evaluated object values into the "i" versions of each transform
property, and using the original/non-evaluated data for the pointers.
XXX:
What's not clear though is what we should be doing with the "BKE_object_where_is_calc()"
calls here. They currently use ob, but that probably shouldn't happen... and ob_eval
should in theory have a more up-to-date version of what it would need to evaluate!
This commit is contained in:
parent
51926de7f0
commit
988a14aa14
Notes:
blender-bot
2023-02-14 05:57:10 +01:00
Referenced by issue #54831, COW Operators: Transform
|
@ -5583,39 +5583,41 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list)
|
|||
/* transcribe given object into TransData for Transforming */
|
||||
static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
|
||||
{
|
||||
Depsgraph *depsgraph = t->depsgraph;
|
||||
Scene *scene = t->scene;
|
||||
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
|
||||
bool constinv;
|
||||
bool skip_invert = false;
|
||||
|
||||
if (t->mode != TFM_DUMMY && ob->rigidbody_object) {
|
||||
float rot[3][3], scale[3];
|
||||
float ctime = BKE_scene_frame_get(scene);
|
||||
float ctime = DEG_get_ctime(depsgraph);
|
||||
|
||||
/* only use rigid body transform if simulation is running, avoids problems with initial setup of rigid bodies */
|
||||
// XXX: This needs fixing for COW. May need rigidbody_world from scene
|
||||
if (BKE_rigidbody_check_sim_running(scene->rigidbody_world, ctime)) {
|
||||
|
||||
/* save original object transform */
|
||||
copy_v3_v3(td->ext->oloc, ob->loc);
|
||||
copy_v3_v3(td->ext->oloc, ob_eval->loc);
|
||||
|
||||
if (ob->rotmode > 0) {
|
||||
copy_v3_v3(td->ext->orot, ob->rot);
|
||||
copy_v3_v3(td->ext->orot, ob_eval->rot);
|
||||
}
|
||||
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
|
||||
td->ext->orotAngle = ob->rotAngle;
|
||||
copy_v3_v3(td->ext->orotAxis, ob->rotAxis);
|
||||
td->ext->orotAngle = ob_eval->rotAngle;
|
||||
copy_v3_v3(td->ext->orotAxis, ob_eval->rotAxis);
|
||||
}
|
||||
else {
|
||||
copy_qt_qt(td->ext->oquat, ob->quat);
|
||||
copy_qt_qt(td->ext->oquat, ob_eval->quat);
|
||||
}
|
||||
/* update object's loc/rot to get current rigid body transform */
|
||||
mat4_to_loc_rot_size(ob->loc, rot, scale, ob->obmat);
|
||||
sub_v3_v3(ob->loc, ob->dloc);
|
||||
mat4_to_loc_rot_size(ob->loc, rot, scale, ob_eval->obmat);
|
||||
sub_v3_v3(ob->loc, ob_eval->dloc);
|
||||
BKE_object_mat3_to_rot(ob, rot, false); /* drot is already corrected here */
|
||||
}
|
||||
}
|
||||
|
||||
/* axismtx has the real orientation */
|
||||
copy_m3_m4(td->axismtx, ob->obmat);
|
||||
copy_m3_m4(td->axismtx, ob_eval->obmat);
|
||||
normalize_m3(td->axismtx);
|
||||
|
||||
td->con = ob->constraints.first;
|
||||
|
@ -5628,6 +5630,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
|
|||
constinv = constraints_list_needinv(t, &ob->constraints);
|
||||
|
||||
/* disable constraints inversion for dummy pass */
|
||||
// XXX: Should this use ob or ob_eval?! It's not clear!
|
||||
if (t->mode == TFM_DUMMY)
|
||||
skip_invert = true;
|
||||
|
||||
|
@ -5642,7 +5645,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
|
|||
td->ob = ob;
|
||||
|
||||
td->loc = ob->loc;
|
||||
copy_v3_v3(td->iloc, td->loc);
|
||||
copy_v3_v3(td->iloc, ob_eval->loc);
|
||||
|
||||
if (ob->rotmode > 0) {
|
||||
td->ext->rot = ob->rot;
|
||||
|
@ -5650,8 +5653,8 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
|
|||
td->ext->rotAngle = NULL;
|
||||
td->ext->quat = NULL;
|
||||
|
||||
copy_v3_v3(td->ext->irot, ob->rot);
|
||||
copy_v3_v3(td->ext->drot, ob->drot);
|
||||
copy_v3_v3(td->ext->irot, ob_eval->rot);
|
||||
copy_v3_v3(td->ext->drot, ob_eval->drot);
|
||||
}
|
||||
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
|
||||
td->ext->rot = NULL;
|
||||
|
@ -5659,10 +5662,10 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
|
|||
td->ext->rotAngle = &ob->rotAngle;
|
||||
td->ext->quat = NULL;
|
||||
|
||||
td->ext->irotAngle = ob->rotAngle;
|
||||
copy_v3_v3(td->ext->irotAxis, ob->rotAxis);
|
||||
// td->ext->drotAngle = ob->drotAngle; // XXX, not implemented
|
||||
// copy_v3_v3(td->ext->drotAxis, ob->drotAxis); // XXX, not implemented
|
||||
td->ext->irotAngle = ob_eval->rotAngle;
|
||||
copy_v3_v3(td->ext->irotAxis, ob_eval->rotAxis);
|
||||
// td->ext->drotAngle = ob_eval->drotAngle; // XXX, not implemented
|
||||
// copy_v3_v3(td->ext->drotAxis, ob_eval->drotAxis); // XXX, not implemented
|
||||
}
|
||||
else {
|
||||
td->ext->rot = NULL;
|
||||
|
@ -5670,18 +5673,18 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
|
|||
td->ext->rotAngle = NULL;
|
||||
td->ext->quat = ob->quat;
|
||||
|
||||
copy_qt_qt(td->ext->iquat, ob->quat);
|
||||
copy_qt_qt(td->ext->dquat, ob->dquat);
|
||||
copy_qt_qt(td->ext->iquat, ob_eval->quat);
|
||||
copy_qt_qt(td->ext->dquat, ob_eval->dquat);
|
||||
}
|
||||
td->ext->rotOrder = ob->rotmode;
|
||||
td->ext->rotOrder = ob_eval->rotmode;
|
||||
|
||||
td->ext->size = ob->size;
|
||||
copy_v3_v3(td->ext->isize, ob->size);
|
||||
copy_v3_v3(td->ext->dscale, ob->dscale);
|
||||
copy_v3_v3(td->ext->isize, ob_eval->size);
|
||||
copy_v3_v3(td->ext->dscale, ob_eval->dscale);
|
||||
|
||||
copy_v3_v3(td->center, ob->obmat[3]);
|
||||
copy_v3_v3(td->center, ob_eval->obmat[3]);
|
||||
|
||||
copy_m4_m4(td->ext->obmat, ob->obmat);
|
||||
copy_m4_m4(td->ext->obmat, ob_eval->obmat);
|
||||
|
||||
/* is there a need to set the global<->data space conversion matrices? */
|
||||
if (ob->parent || constinv) {
|
||||
|
@ -5691,8 +5694,8 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
|
|||
* NOTE: some Constraints, and also Tracking should never get this
|
||||
* done, as it doesn't work well.
|
||||
*/
|
||||
BKE_object_to_mat3(ob, obmtx);
|
||||
copy_m3_m4(totmat, ob->obmat);
|
||||
BKE_object_to_mat3(ob_eval, obmtx);
|
||||
copy_m3_m4(totmat, ob_eval->obmat);
|
||||
invert_m3_m3(obinv, totmat);
|
||||
mul_m3_m3m3(td->smtx, obmtx, obinv);
|
||||
invert_m3_m3(td->mtx, td->smtx);
|
||||
|
|
Loading…
Reference in New Issue