diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index e9ceedf7ce2..ff4703ffcb9 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -168,41 +168,37 @@ static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase) if (orignu->bezt) { a = orignu->pntsu; bezt = nu->bezt; - origbezt = orignu->bezt; pt_index = 0; while (a--) { /* We cannot keep *any* reference to curve obdata, * it might be replaced and freed while editcurve remain in use * (in viewport render case e.g.). Note that we could use a pool to avoid * lots of malloc's here, but... not really a problem for now. */ - BezTriple *origbezt_cpy = MEM_mallocN(sizeof(*origbezt), __func__); - *origbezt_cpy = *origbezt; + BezTriple *origbezt_cpy = MEM_mallocN(sizeof(*bezt), __func__); + *origbezt_cpy = *bezt; keyIndex = init_cvKeyIndex(origbezt_cpy, key_index, nu_index, pt_index, vertex_index); BLI_ghash_insert(gh, bezt, keyIndex); key_index += KEYELEM_FLOAT_LEN_BEZTRIPLE; vertex_index += 3; bezt++; - origbezt++; pt_index++; } } else { a = orignu->pntsu * orignu->pntsv; bp = nu->bp; - origbp = orignu->bp; pt_index = 0; while (a--) { /* We cannot keep *any* reference to curve obdata, * it might be replaced and freed while editcurve remain in use * (in viewport render case e.g.). Note that we could use a pool to avoid * lots of malloc's here, but... not really a problem for now. */ - BPoint *origbp_cpy = MEM_mallocN(sizeof(*origbp_cpy), __func__); - *origbp_cpy = *origbp; + BPoint *origbp_cpy = MEM_mallocN(sizeof(*bp), __func__); + *origbp_cpy = *bp; keyIndex = init_cvKeyIndex(origbp_cpy, key_index, nu_index, pt_index, vertex_index); BLI_ghash_insert(gh, bp, keyIndex); key_index += KEYELEM_FLOAT_LEN_BPOINT; bp++; - origbp++; pt_index++; vertex_index++; } @@ -1318,10 +1314,6 @@ void ED_curve_editnurb_make(Object *obedit) BLI_addtail(&editnurb->nurbs, newnu); } - /* animation could be added in editmode even if there was no animdata in - * object mode hence we always need CVs index be created */ - init_editNurb_keyIndex(editnurb, &cu->nurb); - if (actkey) { editnurb->shapenr = obedit->shapenr; /* Apply shapekey to new nurbs of editnurb, not those of original curve @@ -1329,6 +1321,12 @@ void ED_curve_editnurb_make(Object *obedit) * to properly restore curve when leaving editmode. */ BKE_keyblock_convert_to_curve(actkey, cu, &editnurb->nurbs); } + + /* animation could be added in editmode even if there was no animdata in + * object mode hence we always need CVs index be created */ + init_editNurb_keyIndex(editnurb, &cu->nurb); + + } }