Transform: remove restricted assert

`t-val` and `t->loc` can share same pointer, as long as `t->loc` is 3D.

This partially reverts 9dcf73c715
This commit is contained in:
Germano Cavalcante
2023-11-17 08:54:31 -03:00
parent f6569b7726
commit e581dde40f
4 changed files with 18 additions and 14 deletions

View File

@@ -1092,9 +1092,6 @@ void create_trans_data(bContext *C, TransInfo *t)
t->obedit_type = -1;
}
t->data_type->create_trans_data(C, t);
BLI_assert_msg(!t->data_container || !t->data_container->data ||
(t->data_container->data[0].val != t->data_container->data[0].loc),
"td->val is only for 1D values");
}
countAndCleanTransDataContainer(t);

View File

@@ -423,8 +423,11 @@ static int GPLayerToTransData(TransData *td,
tfd->val = float(gpf->framenum);
tfd->sdata = &gpf->framenum;
td->val = td->loc = &tfd->val;
td->ival = td->iloc[0] = tfd->val;
td->loc = tfd->loc;
td->iloc[0] = tfd->loc[0];
td->val = &tfd->val;
td->ival = tfd->val;
td->center[0] = td->ival;
td->center[1] = ypos;
@@ -535,8 +538,11 @@ static int MaskLayerToTransData(TransData *td,
tfd->val = float(masklay_shape->frame);
tfd->sdata = &masklay_shape->frame;
td->val = td->loc = &tfd->val;
td->ival = td->iloc[0] = tfd->val;
td->loc = tfd->loc;
td->iloc[0] = tfd->loc[0];
td->val = &tfd->val;
td->ival = tfd->val;
td->center[0] = td->ival;
td->center[1] = ypos;

View File

@@ -221,6 +221,10 @@ static TransData *SeqToTransData(Scene *scene,
unit_m3(td->mtx);
unit_m3(td->smtx);
/* Time Transform (extend) */
td->val = td2d->loc;
td->ival = td2d->loc[0];
return td;
}

View File

@@ -841,18 +841,15 @@ void applyTransObjects(TransInfo *t)
static void transdata_restore_basic(TransDataBasic *td_basic)
{
BLI_assert_msg(td_basic->val != td_basic->loc,
"it shouldn't happen. `val` is for 1D, `loc` is for 3D");
if (td_basic->val) {
*td_basic->val = td_basic->ival;
if (td_basic->loc) {
copy_v3_v3(td_basic->loc, td_basic->iloc);
}
/* TODO(mano-wii): Only use 3D or larger vectors in `td->loc`.
* If `loc` and `val` point to the same address, it may indicate that `loc` is not 3D which is
* not safe for `copy_v3_v3`. */
if (td_basic->loc && td_basic->val != td_basic->loc) {
copy_v3_v3(td_basic->loc, td_basic->iloc);
if (td_basic->val && td_basic->val != td_basic->loc) {
*td_basic->val = td_basic->ival;
}
}