vert to sphere - S + ctrl + shift keys
authorShaul Kedem <shaul_kedem@yahoo.com>
Sun, 1 Feb 2009 00:18:45 +0000 (00:18 +0000)
committerShaul Kedem <shaul_kedem@yahoo.com>
Sun, 1 Feb 2009 00:18:45 +0000 (00:18 +0000)
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c

index ce3d2dc4b101c0087f5ab62579328c1bdecbd198..294c46b03f3b19efa15a0dc9ce9cebb28901259d 100644 (file)
@@ -3625,7 +3625,7 @@ void MESH_OT_selectrandom_mesh(wmOperatorType *ot)
        /* props */
 
        
-       RNA_def_int(ot->srna, "percentage", 50, 0, 100, "percentage", "", 0, 100);
+       RNA_def_int(ot->srna, "percentage", 50, 0, 100, "Percentage", "", 0, 100);
 }
 
 void editmesh_select_by_material(EditMesh *em, int index) 
@@ -4499,12 +4499,11 @@ void vertexnoise(Object *obedit, EditMesh *em)
 
 }
 
-void vertices_to_sphere(Scene *scene, View3D *v3d, Object *obedit, EditMesh *em)
+void vertices_to_sphere(Scene *scene, View3D *v3d, Object *obedit, EditMesh *em, int perc)
 {
        EditVert *eve;
        float *curs, len, vec[3], cent[3], fac, facm, imat[3][3], bmat[3][3];
        int tot;
-       short perc=100;
        
 // XXX if(button(&perc, 1, 100, "Percentage:")==0) return;
        
@@ -4557,3 +4556,35 @@ void vertices_to_sphere(Scene *scene, View3D *v3d, Object *obedit, EditMesh *em)
 
 }
 
+static int vertices_to_sphere_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       View3D *v3d = CTX_wm_view3d(C);
+       Scene *scene = CTX_data_scene(C);
+       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       
+       vertices_to_sphere(scene, v3d, obedit, em, RNA_int_get(op->ptr,"percentage"));
+               
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       
+       return OPERATOR_FINISHED;       
+}
+
+void MESH_OT_vertices_to_sphere(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Vertices to Sphere";
+       ot->idname= "MESH_OT_vertices_to_sphere";
+       
+       /* api callbacks */
+       ot->exec= vertices_to_sphere_exec;
+       ot->poll= ED_operator_editmesh;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+       
+       /* props */
+
+       
+       RNA_def_int(ot->srna, "percentage", 100, 0, 100, "Percentage", "", 0, 100);
+}
index 64adc45aeeb17c9040b5c0382a677301e98035f9..c7efae4a88c87088eab45f357b9fa9d83d018b43 100644 (file)
@@ -190,6 +190,7 @@ void MESH_OT_similar_vertex_select(struct wmOperatorType *ot);
 void MESH_OT_similar_edge_select(struct wmOperatorType *ot);
 void MESH_OT_similar_face_select(struct wmOperatorType *ot);
 void MESH_OT_selectrandom_mesh(struct wmOperatorType *ot);
+void MESH_OT_vertices_to_sphere(struct wmOperatorType *ot);
 
 extern EditEdge *findnearestedge(ViewContext *vc, int *dist);
 extern void EM_automerge(int update);
index 40fa6917564f55fe54537cd0d2abff825f5d5453..14b2069371eee101c8d4d5dc462ff8b668a13607 100644 (file)
@@ -140,6 +140,7 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_removedoublesflag);
        WM_operatortype_append(MESH_OT_extrude_mesh);
        WM_operatortype_append(MESH_OT_edit_faces);
+       WM_operatortype_append(MESH_OT_vertices_to_sphere);
 
        WM_operatortype_append(MESH_OT_delete_mesh);
 
@@ -186,6 +187,7 @@ void ED_keymap_mesh(wmWindowManager *wm)
        RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_select_sharp_edges", SKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"sharpness",135.0);
        
        WM_keymap_add_item(keymap, "MESH_OT_selectrandom_mesh", SPACEKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_vertices_to_sphere", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT , 0);
        
        /* temp hotkeys! */
        WM_keymap_add_item(keymap, "MESH_OT_similar_vertex_select", GKEY, KM_PRESS, KM_SHIFT, 0);