Fix T103783: crash when canceling vertex crease having vertex groups

`transdata_restore_basic` uses `copy_v3_v3` to restore a pointer that is 1D.
This commit is contained in:
Germano Cavalcante 2023-01-11 11:50:45 -03:00
parent a6b6f5db10
commit 3b761901b6
Notes: blender-bot 2023-04-17 15:06:08 +02:00
Referenced by commit debd912bef, Fix T103906: Crash when canceling transform operation with the mirror options set
Referenced by commit 5029f3e483, Fix crease and bevel weight unaffected when transforming
Referenced by issue #103906, Crash when canceling transform operation with the mirror options set
Referenced by issue #103783, Regression: Canceling vertex crease operation causes crash when mesh has vertex groups
Referenced by issue #107020, Regression: Mesh Symmetry + Skin Modifier, Skin Resize Cancel causes Crash
5 changed files with 17 additions and 17 deletions

View File

@ -49,8 +49,8 @@ static void tc_mesh_cdata_transdata_create(TransDataBasic *td,
{
BLI_assert(BM_elem_flag_test(eve, BM_ELEM_HIDDEN) == 0);
td->loc = weight;
td->iloc[0] = *weight;
td->val = weight;
td->ival = *weight;
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
td->flag |= TD_SELECTED;
@ -268,7 +268,7 @@ static void tc_mesh_cdata_apply_to_mirror(TransInfo *t)
if (tc->use_mirror_axis_any) {
TransDataMirror *td_mirror = tc->data_mirror;
for (int i = 0; i < tc->data_mirror_len; i++, td_mirror++) {
td_mirror->loc[0] = td_mirror->loc_src[0];
*td_mirror->val = td_mirror->loc_src[0];
}
}
}

View File

@ -20,6 +20,10 @@ struct bConstraint;
float iloc[3]; \
/** Individual data center. */ \
float center[3]; \
/** Value pointer for special transforms. */ \
float *val; \
/** Old value. */ \
float ival; \
/** Various flags. */ \
int flag
@ -114,10 +118,6 @@ typedef struct TransData {
float rdist;
/** Factor of the transformation (for Proportional Editing). */
float factor;
/** Value pointer for special transforms. */
float *val;
/** Old value. */
float ival;
/** Transformation matrix from data space to global space. */
float mtx[3][3];
/** Transformation matrix from global space to data space. */

View File

@ -815,16 +815,16 @@ static void transdata_restore_basic(TransDataBasic *td_basic)
if (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;
}
}
static void restoreElement(TransData *td)
{
transdata_restore_basic((TransDataBasic *)td);
if (td->val && td->val != td->loc) {
*td->val = td->ival;
}
if (td->ext && (td->flag & TD_NO_EXT) == 0) {
if (td->ext->rot) {
copy_v3_v3(td->ext->rot, td->ext->irot);

View File

@ -44,11 +44,11 @@ static void transdata_elem_bevel_weight(const TransInfo *UNUSED(t),
TransData *td,
const float weight)
{
if (td->loc == NULL) {
if (td->val == NULL) {
return;
}
*td->loc = td->iloc[0] + weight * td->factor;
CLAMP(*td->loc, 0.0f, 1.0f);
*td->val = td->ival + weight * td->factor;
CLAMP(*td->val, 0.0f, 1.0f);
}
static void transdata_elem_bevel_weight_fn(void *__restrict iter_data_v,

View File

@ -44,12 +44,12 @@ static void transdata_elem_crease(const TransInfo *UNUSED(t),
TransData *td,
const float crease)
{
if (td->loc == NULL) {
if (td->val == NULL) {
return;
}
*td->loc = td->iloc[0] + crease * td->factor;
CLAMP(*td->loc, 0.0f, 1.0f);
*td->val = td->ival + crease * td->factor;
CLAMP(*td->val, 0.0f, 1.0f);
}
static void transdata_elem_crease_fn(void *__restrict iter_data_v,