add back 2.4x mesh vertex sort/randomize operators, were called xsort and hash in...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 23 Feb 2011 05:17:29 +0000 (05:17 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 23 Feb 2011 05:17:29 +0000 (05:17 +0000)
available from vertex menu.

release/scripts/ui/space_view3d.py
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c

index e6d546dda228942e7bcfa3f3e0300b4f36db8c3c..69dfb7c99a957c84e26a9162e23a2126c853cec0 100644 (file)
@@ -1507,6 +1507,8 @@ class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
 
         layout.operator("mesh.vertices_smooth")
         layout.operator("mesh.remove_doubles")
+        layout.operator("mesh.vertices_sort")
+        layout.operator("mesh.vertices_randomize")
 
         layout.operator("mesh.select_vertex_path")
 
index 24c4e887ecce66bdcee0884716ca3e2d36fd942b..4a0b1cb9e5e04c80670c9f59f77222efb7ac42d2 100644 (file)
@@ -563,6 +563,29 @@ static void xsortvert_flag(bContext *C, int flag)
 
 }
 
+static int mesh_vertices_sort_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       xsortvert_flag(C, SELECT);
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_vertices_sort(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Vertex Sort";
+       ot->description= "Sort vertex order";
+       ot->idname= "MESH_OT_vertices_sort";
+
+       /* api callbacks */
+       ot->exec= mesh_vertices_sort_exec;
+
+       ot->poll= EM_view3d_poll; /* uses view relative X axis to sort verts */
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+
 /* called from buttons */
 static void hashvert_flag(EditMesh *em, int flag)
 {
@@ -621,6 +644,31 @@ static void hashvert_flag(EditMesh *em, int flag)
 
 }
 
+static int mesh_vertices_randomize_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       Object *obedit= CTX_data_edit_object(C);
+       EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
+       hashvert_flag(em, SELECT);
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_vertices_randomize(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Vertex Randomize";
+       ot->description= "Randomize vertex order";
+       ot->idname= "MESH_OT_vertices_randomize";
+
+       /* api callbacks */
+       ot->exec= mesh_vertices_randomize_exec;
+
+       ot->poll= ED_operator_editmesh;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+
 /* generic extern called extruder */
 static void extrude_mesh(Object *obedit, EditMesh *em, wmOperator *op, short type)
 {
index 1a9fdcea9925673b6bf514b7e7444dafdf1bfeda..9fea30fab98c11983344af81fea9d5cfc27a0800 100644 (file)
@@ -205,6 +205,8 @@ int EdgeSlide(EditMesh *em, struct wmOperator *op, short immediate, float imperc
 void MESH_OT_merge(struct wmOperatorType *ot);
 void MESH_OT_subdivide(struct wmOperatorType *ot);
 void MESH_OT_remove_doubles(struct wmOperatorType *ot);
+void MESH_OT_vertices_randomize(struct wmOperatorType *ot);
+void MESH_OT_vertices_sort(struct wmOperatorType *ot);
 void MESH_OT_extrude(struct wmOperatorType *ot);
 void MESH_OT_spin(struct wmOperatorType *ot);
 void MESH_OT_screw(struct wmOperatorType *ot);
index f144ae605181a3f556f211b70dd440ad7a5023e5..639fdd7c119a9c0058ee4abd5655b7eecb56d109 100644 (file)
@@ -86,6 +86,8 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_fgon_make);
        WM_operatortype_append(MESH_OT_duplicate);
        WM_operatortype_append(MESH_OT_remove_doubles);
+       WM_operatortype_append(MESH_OT_vertices_sort);
+       WM_operatortype_append(MESH_OT_vertices_randomize);
        WM_operatortype_append(MESH_OT_extrude);
        WM_operatortype_append(MESH_OT_spin);
        WM_operatortype_append(MESH_OT_screw);
@@ -146,6 +148,7 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_select_nth);
 }
 
+#if 0 /* UNUSED, remove? */
 static int ED_operator_editmesh_face_select(bContext *C)
 {
        Object *obedit= CTX_data_edit_object(C);
@@ -157,6 +160,7 @@ static int ED_operator_editmesh_face_select(bContext *C)
        }
        return 0;
 }
+#endif
 
 void ED_operatormacros_mesh(void)
 {