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 e6d546d..69dfb7c 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 24c4e88..4a0b1cb 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 1a9fdce..9fea30f 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 f144ae6..639fdd7 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)
 {