Revert "Fix T41226: Wrong Undo on curves and hooks"

This reverts commit e042c8428f.

Proper fix will come later, or be declared a TODO.
This commit is contained in:
Sergey Sharybin 2014-08-01 10:56:20 +06:00
parent 3e607f61b5
commit 2f2bf513e9
Notes: blender-bot 2023-02-14 11:18:07 +01:00
Referenced by issue #41226, Wrong Undo on curves
1 changed files with 16 additions and 43 deletions

View File

@ -1165,7 +1165,7 @@ int ED_curve_updateAnimPaths(Curve *cu)
/* ********************* LOAD and MAKE *************** */
static int *initialize_index_map(Object *obedit, int *r_old_totvert, bool reverse)
static int *initialize_index_map(Object *obedit, int *r_old_totvert)
{
Curve *curve = (Curve *) obedit->data;
EditNurb *editnurb = curve->editnurb;
@ -1200,29 +1200,15 @@ static int *initialize_index_map(Object *obedit, int *r_old_totvert, bool revers
while (a--) {
keyIndex = getCVKeyIndex(editnurb, bezt);
if (keyIndex) {
if (reverse) {
if (keyIndex->switched) {
old_to_new_map[vertex_index] = keyIndex->vertex_index + 2;
old_to_new_map[vertex_index + 1] = keyIndex->vertex_index + 1;
old_to_new_map[vertex_index + 2] = keyIndex->vertex_index;
}
else {
old_to_new_map[vertex_index] = keyIndex->vertex_index;
old_to_new_map[vertex_index + 1] = keyIndex->vertex_index + 1;
old_to_new_map[vertex_index + 2] = keyIndex->vertex_index + 2;
}
if (keyIndex->switched) {
old_to_new_map[keyIndex->vertex_index] = vertex_index + 2;
old_to_new_map[keyIndex->vertex_index + 1] = vertex_index + 1;
old_to_new_map[keyIndex->vertex_index + 2] = vertex_index;
}
else {
if (keyIndex->switched) {
old_to_new_map[keyIndex->vertex_index] = vertex_index + 2;
old_to_new_map[keyIndex->vertex_index + 1] = vertex_index + 1;
old_to_new_map[keyIndex->vertex_index + 2] = vertex_index;
}
else {
old_to_new_map[keyIndex->vertex_index] = vertex_index;
old_to_new_map[keyIndex->vertex_index + 1] = vertex_index + 1;
old_to_new_map[keyIndex->vertex_index + 2] = vertex_index + 2;
}
old_to_new_map[keyIndex->vertex_index] = vertex_index;
old_to_new_map[keyIndex->vertex_index + 1] = vertex_index + 1;
old_to_new_map[keyIndex->vertex_index + 2] = vertex_index + 2;
}
}
vertex_index += 3;
@ -1236,12 +1222,7 @@ static int *initialize_index_map(Object *obedit, int *r_old_totvert, bool revers
while (a--) {
keyIndex = getCVKeyIndex(editnurb, bp);
if (keyIndex) {
if (reverse) {
old_to_new_map[vertex_index] = keyIndex->vertex_index;
}
else {
old_to_new_map[keyIndex->vertex_index] = vertex_index;
}
old_to_new_map[keyIndex->vertex_index] = vertex_index;
}
vertex_index++;
bp++;
@ -1253,7 +1234,7 @@ static int *initialize_index_map(Object *obedit, int *r_old_totvert, bool revers
return old_to_new_map;
}
static void remap_hooks_and_vertex_parents(Object *obedit, bool reverse)
static void remap_hooks_and_vertex_parents(Object *obedit)
{
Object *object;
Curve *curve = (Curve *) obedit->data;
@ -1268,9 +1249,7 @@ static void remap_hooks_and_vertex_parents(Object *obedit, bool reverse)
ELEM(object->partype, PARVERT1, PARVERT3))
{
if (old_to_new_map == NULL) {
old_to_new_map = initialize_index_map(obedit,
&old_totvert,
reverse);
old_to_new_map = initialize_index_map(obedit, &old_totvert);
}
if (object->par1 < old_totvert) {
@ -1299,9 +1278,7 @@ static void remap_hooks_and_vertex_parents(Object *obedit, bool reverse)
int i, j;
if (old_to_new_map == NULL) {
old_to_new_map = initialize_index_map(obedit,
&old_totvert,
reverse);
old_to_new_map = initialize_index_map(obedit, &old_totvert);
}
for (i = j = 0; i < hmd->totindex; i++) {
@ -1338,6 +1315,8 @@ void load_editNurb(Object *obedit)
Nurb *nu, *newnu;
ListBase newnurb = {NULL, NULL}, oldnurb = cu->nurb;
remap_hooks_and_vertex_parents(obedit);
for (nu = editnurb->first; nu; nu = nu->next) {
newnu = BKE_nurb_duplicate(nu);
BLI_addtail(&newnurb, newnu);
@ -6892,9 +6871,8 @@ void CURVE_OT_tilt_clear(wmOperatorType *ot)
/****************** undo for curves ****************/
static void undoCurve_to_editCurve(void *ucu, void *edata, void *cu_v)
static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v)
{
Object *obedit = (Object *) edata;
Curve *cu = cu_v;
UndoCurve *undoCurve = ucu;
ListBase *undobase = &undoCurve->nubase;
@ -6903,8 +6881,6 @@ static void undoCurve_to_editCurve(void *ucu, void *edata, void *cu_v)
EditNurb *editnurb = cu->editnurb;
AnimData *ad = BKE_animdata_from_id(&cu->id);
remap_hooks_and_vertex_parents(obedit, true);
BKE_nurbList_free(editbase);
if (undoCurve->undoIndex) {
@ -6938,9 +6914,8 @@ static void undoCurve_to_editCurve(void *ucu, void *edata, void *cu_v)
ED_curve_updateAnimPaths(cu);
}
static void *editCurve_to_undoCurve(void *edata, void *cu_v)
static void *editCurve_to_undoCurve(void *UNUSED(edata), void *cu_v)
{
Object *obedit = (Object *) edata;
Curve *cu = cu_v;
ListBase *nubase = BKE_curve_editNurbs_get(cu);
UndoCurve *undoCurve;
@ -6976,8 +6951,6 @@ static void *editCurve_to_undoCurve(void *edata, void *cu_v)
undoCurve->actvert = cu->actvert;
undoCurve->actnu = cu->actnu;
remap_hooks_and_vertex_parents(obedit, false);
return undoCurve;
}