Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-07-31 16:21:30 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-07-31 16:21:57 +0400
commite042c8428f8c0c0a72cdd23d2c058c20ab5745ed (patch)
tree11c1cff6ba70d5714b9201b8ca3ec63ea7066e86 /source/blender/editors
parentcba027c8c3699374f4b1a13716fb367382b8650d (diff)
Fix T41226: Wrong Undo on curves and hooks
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/curve/editcurve.c59
1 files changed, 43 insertions, 16 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index b0371b8dd6c..4db22154e68 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1165,7 +1165,7 @@ int ED_curve_updateAnimPaths(Curve *cu)
/* ********************* LOAD and MAKE *************** */
-static int *initialize_index_map(Object *obedit, int *r_old_totvert)
+static int *initialize_index_map(Object *obedit, int *r_old_totvert, bool reverse)
{
Curve *curve = (Curve *) obedit->data;
EditNurb *editnurb = curve->editnurb;
@@ -1200,15 +1200,29 @@ static int *initialize_index_map(Object *obedit, int *r_old_totvert)
while (a--) {
keyIndex = getCVKeyIndex(editnurb, bezt);
if (keyIndex) {
- 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;
+ 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;
+ }
}
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;
+ 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;
+ }
}
}
vertex_index += 3;
@@ -1222,7 +1236,12 @@ static int *initialize_index_map(Object *obedit, int *r_old_totvert)
while (a--) {
keyIndex = getCVKeyIndex(editnurb, bp);
if (keyIndex) {
- old_to_new_map[keyIndex->vertex_index] = vertex_index;
+ if (reverse) {
+ old_to_new_map[vertex_index] = keyIndex->vertex_index;
+ }
+ else {
+ old_to_new_map[keyIndex->vertex_index] = vertex_index;
+ }
}
vertex_index++;
bp++;
@@ -1234,7 +1253,7 @@ static int *initialize_index_map(Object *obedit, int *r_old_totvert)
return old_to_new_map;
}
-static void remap_hooks_and_vertex_parents(Object *obedit)
+static void remap_hooks_and_vertex_parents(Object *obedit, bool reverse)
{
Object *object;
Curve *curve = (Curve *) obedit->data;
@@ -1249,7 +1268,9 @@ static void remap_hooks_and_vertex_parents(Object *obedit)
ELEM(object->partype, PARVERT1, PARVERT3))
{
if (old_to_new_map == NULL) {
- old_to_new_map = initialize_index_map(obedit, &old_totvert);
+ old_to_new_map = initialize_index_map(obedit,
+ &old_totvert,
+ reverse);
}
if (object->par1 < old_totvert) {
@@ -1278,7 +1299,9 @@ static void remap_hooks_and_vertex_parents(Object *obedit)
int i, j;
if (old_to_new_map == NULL) {
- old_to_new_map = initialize_index_map(obedit, &old_totvert);
+ old_to_new_map = initialize_index_map(obedit,
+ &old_totvert,
+ reverse);
}
for (i = j = 0; i < hmd->totindex; i++) {
@@ -1315,8 +1338,6 @@ 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);
@@ -6871,8 +6892,9 @@ void CURVE_OT_tilt_clear(wmOperatorType *ot)
/****************** undo for curves ****************/
-static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v)
+static void undoCurve_to_editCurve(void *ucu, void *edata, void *cu_v)
{
+ Object *obedit = (Object *) edata;
Curve *cu = cu_v;
UndoCurve *undoCurve = ucu;
ListBase *undobase = &undoCurve->nubase;
@@ -6881,6 +6903,8 @@ static void undoCurve_to_editCurve(void *ucu, void *UNUSED(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) {
@@ -6914,8 +6938,9 @@ static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v)
ED_curve_updateAnimPaths(cu);
}
-static void *editCurve_to_undoCurve(void *UNUSED(edata), void *cu_v)
+static void *editCurve_to_undoCurve(void *edata, void *cu_v)
{
+ Object *obedit = (Object *) edata;
Curve *cu = cu_v;
ListBase *nubase = BKE_curve_editNurbs_get(cu);
UndoCurve *undoCurve;
@@ -6951,6 +6976,8 @@ static void *editCurve_to_undoCurve(void *UNUSED(edata), void *cu_v)
undoCurve->actvert = cu->actvert;
undoCurve->actnu = cu->actnu;
+ remap_hooks_and_vertex_parents(obedit, false);
+
return undoCurve;
}