Partial revert commit 39878 "Fix #28280: Insert Hook wrong index"
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 5 Sep 2011 08:20:11 +0000 (08:20 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 5 Sep 2011 08:20:11 +0000 (08:20 +0000)
Such load/make edit structures introduced regression into iterators
via object's geometry (vertices, edges, control points and so) when
adding hooks in the body of this iterator.

Fix for wrong index should be non-destructable for geometry.

This will fix #28506: Unusual behavior in curves.

source/blender/editors/object/object_hook.c
source/blender/editors/object/object_relations.c

index 266556773f09c22a2e6fb6655641d79c343ab318..bb32869469ac74b21bd22e6f5e1f20b048bd51b6 100644 (file)
@@ -64,7 +64,6 @@
 
 #include "ED_curve.h"
 #include "ED_mesh.h"
-#include "ED_lattice.h"
 #include "ED_screen.h"
 
 #include "WM_types.h"
@@ -293,7 +292,7 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo
        return totvert;
 }
 
-static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int **indexar, char *name, float *cent_r)
+static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char *name, float *cent_r)
 {
        *indexar= NULL;
        *tot= 0;
@@ -303,12 +302,7 @@ static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int *
                case OB_MESH:
                {
                        Mesh *me= obedit->data;
-                       EditMesh *em;
-
-                       load_editMesh(scene, obedit);
-                       make_editMesh(scene, obedit);
-
-                       em = BKE_mesh_get_editmesh(me);
+                       EditMesh *em = BKE_mesh_get_editmesh(me);
 
                        /* check selected vertices first */
                        if( return_editmesh_indexar(em, tot, indexar, cent_r)) {
@@ -322,17 +316,10 @@ static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int *
                }
                case OB_CURVE:
                case OB_SURF:
-                       load_editNurb(obedit);
-                       make_editNurb(obedit);
-
                        return return_editcurve_indexar(obedit, tot, indexar, cent_r);
                case OB_LATTICE:
                {
                        Lattice *lt= obedit->data;
-
-                       load_editLatt(obedit);
-                       make_editLatt(obedit);
-
                        return return_editlattice_indexar(lt->editlatt->latt, tot, indexar, cent_r);
                }
                default:
@@ -440,7 +427,7 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o
        int tot, ok, *indexar;
        char name[32];
        
-       ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent);
+       ok = object_hook_index_array(obedit, &tot, &indexar, name, cent);
        
        if (!ok) return;        // XXX error("Requires selected vertices or active Vertex Group");
        
@@ -773,7 +760,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op)
        
        /* assign functionality */
        
-       if(!object_hook_index_array(CTX_data_scene(C), ob, &tot, &indexar, name, cent)) {
+       if(!object_hook_index_array(ob, &tot, &indexar, name, cent)) {
                BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group");
                return OPERATOR_CANCELLED;
        }
index b9208e778c7e52d80e4deea3776bf0e25c03305d..e9418ca9f9f995d2c922b44026b5c7719369a648 100644 (file)
@@ -91,8 +91,6 @@
 
 #include "ED_armature.h"
 #include "ED_curve.h"
-#include "ED_lattice.h"
-#include "ED_mesh.h"
 #include "ED_keyframing.h"
 #include "ED_object.h"
 #include "ED_screen.h"
@@ -124,12 +122,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
        
        if(obedit->type==OB_MESH) {
                Mesh *me= obedit->data;
-               EditMesh *em;
-
-               load_editMesh(scene, obedit);
-               make_editMesh(scene, obedit);
-
-               em = BKE_mesh_get_editmesh(me);
+               EditMesh *em = BKE_mesh_get_editmesh(me);
 
                eve= em->verts.first;
                while(eve) {
@@ -147,12 +140,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
                BKE_mesh_end_editmesh(me, em);
        }
        else if(ELEM(obedit->type, OB_SURF, OB_CURVE)) {
-               ListBase *editnurb;
-
-               load_editNurb(obedit);
-               make_editNurb(obedit);
-
-               editnurb= curve_get_editcurve(obedit);
+               ListBase *editnurb= curve_get_editcurve(obedit);
                
                cu= obedit->data;
 
@@ -192,13 +180,8 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
                }
        }
        else if(obedit->type==OB_LATTICE) {
-               Lattice *lt;
-
-               load_editLatt(obedit);
-               make_editLatt(obedit);
-
-               lt= obedit->data;
-
+               Lattice *lt= obedit->data;
+               
                a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw;
                bp= lt->editlatt->latt->def;
                while(a--) {