yay triangle patterns work in new bmesh esubdivide.
authorJoseph Eagar <joeedh@gmail.com>
Sun, 8 Feb 2009 08:52:25 +0000 (08:52 +0000)
committerJoseph Eagar <joeedh@gmail.com>
Sun, 8 Feb 2009 08:52:25 +0000 (08:52 +0000)
source/blender/bmesh/operators/subdivideop.c
source/blender/editors/mesh/mesh_ops.c

index e8da75996423eb1a13db1894f2f2ffb909400d49..4868cf37d54a3ff8b2ff4d73c52ab10a518528de 100644 (file)
@@ -382,6 +382,136 @@ static void q_4edge_split(BMesh *bm, BMFace *face, BMVert **vlist, int numcuts,
        MEM_freeN(lines);
 }
 
+/*    v3
+     / \
+    /   \
+   /     \
+  /       \
+ /         \
+v4--v0--v1--v2
+    s    s
+*/
+static void t_1edge_split(BMesh *bm, BMFace *face, BMVert **vlist, 
+                            int numcuts, int flag, float rad) {
+       BMFace *nf;
+       int i;
+       
+       for (i=0; i<numcuts; i++) {
+               BM_Connect_Verts(bm, vlist[i], vlist[numcuts+1], &nf);
+       }
+}
+
+subdpattern t_1edge = {
+       {1, 0, 0},
+       t_1edge_split,
+       3,
+};
+
+/*    v5
+     / \
+    /   \ v4 s
+   /     \
+  /       \ v3 s
+ /         \
+v6--v0--v1--v2
+    s   s
+*/
+static void t_2edge_split(BMesh *bm, BMFace *face, BMVert **vlist, 
+                            int numcuts, int flag, float rad) {
+       BMFace *nf;
+       int i;
+       
+       for (i=0; i<numcuts; i++) {
+               BM_Connect_Verts(bm, vlist[i], vlist[numcuts+numcuts-i], &nf);
+       }
+}
+
+subdpattern t_2edge = {
+       {1, 1, 0},
+       t_2edge_split,
+       3,
+};
+
+
+/*     v5
+      / \
+ s v6/---\ v4 s
+    / \ / \
+sv7/---v---\ v3 s
+  /  \/  \/ \
+ v8--v0--v1--v2
+    s    s
+*/
+static void t_3edge_split(BMesh *bm, BMFace *face, BMVert **vlist, 
+                            int numcuts, int flag, float rad) {
+       BMFace *nf;
+       BMEdge *e, *ne;
+       BMVert ***lines, *v;
+       void *stackarr[1];
+       int i, j, u, a, b;
+       
+       /*number of verts in each line*/
+       lines = MEM_callocN(sizeof(void*)*(numcuts+2), "triangle vert table");
+       
+       lines[0] = stackarr;
+       lines[0][0] = vlist[numcuts*2+1];
+       
+       lines[1+numcuts] = MEM_callocN(sizeof(void*)*(numcuts+2), 
+                                      "triangle vert table 2");
+       for (i=0; i<numcuts; i++) {
+               lines[1+numcuts][1+i] = vlist[i];
+       }
+       lines[1+numcuts][0] = vlist[numcuts*3+2];
+       lines[1+numcuts][1+numcuts] = vlist[numcuts];
+
+       for (i=0; i<numcuts; i++) {
+               lines[i+1] = MEM_callocN(sizeof(void*)*(2+i), 
+                                      "triangle vert table row");
+               a = numcuts*2 + 2 + i;
+               b = numcuts + numcuts - i;
+               e = BM_Connect_Verts(bm, vlist[a], vlist[b], &nf);
+
+               lines[i+1][0] = vlist[a];
+               lines[i+1][1+i] = vlist[b];
+
+               for (j=0; j<i; j++) {
+                       v = subdivideedgenum(bm, e, j, i, rad, flag, &ne,
+                                            vlist[a], vlist[b]);
+                       lines[i+1][j+1] = v;
+               }
+       }
+       
+
+/*     v5
+      / \
+ s v6/---\ v4 s
+    / \ / \
+sv7/---v---\ v3 s
+  /  \/  \/ \
+ v8--v0--v1--v2
+    s    s
+*/
+       for (i=1; i<numcuts+1; i++) {
+               for (j=0; j<i; j++) {
+                       BM_Connect_Verts(bm, lines[i][j], lines[i+1][j+1],&nf);
+                       BM_Connect_Verts(bm,lines[i][j+1],lines[i+1][j+1],&nf);
+               }
+       }
+
+       for (i=0; i<numcuts; i++) {
+               MEM_freeN(lines[i]);
+       }
+
+       MEM_freeN(lines);
+}
+
+subdpattern t_3edge = {
+       {1, 1, 1},
+       t_3edge_split,
+       3,
+};
+
+
 subdpattern q_4edge = {
        {1, 1, 1, 1},
        q_4edge_split,
@@ -394,6 +524,9 @@ subdpattern *patterns[] = {
        &q_4edge,
        &q_3edge,
        &q_2edge,
+       &t_1edge,
+       &t_2edge,
+       &t_3edge,
 };
 
 #define PLEN   (sizeof(patterns) / sizeof(void*))
index 53c80708e9edb2cc0f92760036ba2738fc431b05..8f5a63b484f1ee2d1c0075e3019c3d183fb78920 100644 (file)
@@ -110,13 +110,15 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_bmesh_test);
        WM_operatortype_append(MESH_OT_select_more);
        WM_operatortype_append(MESH_OT_select_less);
-       WM_operatortype_append(MESH_OT_selectswap_mesh);
+       WM_operatortype_append(MESH_OT_select_invert);
        WM_operatortype_append(MESH_OT_select_non_manifold);
-       WM_operatortype_append(MESH_OT_selectconnected_mesh_all);
-       WM_operatortype_append(MESH_OT_selectconnected_mesh);
-       WM_operatortype_append(MESH_OT_hide_mesh);
-       WM_operatortype_append(MESH_OT_reveal_mesh);
-       WM_operatortype_append(MESH_OT_righthandfaces);
+       WM_operatortype_append(MESH_OT_select_linked);
+       WM_operatortype_append(MESH_OT_select_linked_pick);
+       WM_operatortype_append(MESH_OT_select_random);
+       WM_operatortype_append(MESH_OT_selection_type);
+       WM_operatortype_append(MESH_OT_hide);
+       WM_operatortype_append(MESH_OT_reveal);
+       WM_operatortype_append(MESH_OT_consistant_normals);
        WM_operatortype_append(MESH_OT_subdivide);
        WM_operatortype_append(MESH_OT_subdivide_multi);
        WM_operatortype_append(MESH_OT_subdivide_multi_fractal);
@@ -134,10 +136,32 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_add_primitive_monkey);
        WM_operatortype_append(MESH_OT_add_primitive_uv_sphere);
        WM_operatortype_append(MESH_OT_add_primitive_ico_sphere);
+       WM_operatortype_append(MESH_OT_clear_fgon);
+       WM_operatortype_append(MESH_OT_make_fgon);
        WM_operatortype_append(MESH_OT_add_duplicate);
        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_extrude);
+       WM_operatortype_append(MESH_OT_vertices_to_sphere);
+
+       WM_operatortype_append(MESH_OT_fill);
+       WM_operatortype_append(MESH_OT_beauty_fill);
+       WM_operatortype_append(MESH_OT_convert_quads_to_tris);
+       WM_operatortype_append(MESH_OT_convert_tris_to_quads);
+       WM_operatortype_append(MESH_OT_edge_flip);
+       WM_operatortype_append(MESH_OT_faces_shade_smooth);
+       WM_operatortype_append(MESH_OT_faces_shade_solid);
+
+       WM_operatortype_append(MESH_OT_delete);
+
+       WM_operatortype_append(MESH_OT_separate);
+       WM_operatortype_append(MESH_OT_dupli_extrude_cursor);
+       WM_operatortype_append(MESH_OT_loop_select);
+       WM_operatortype_append(MESH_OT_add_edge_face);
+       WM_operatortype_append(MESH_OT_shortest_path_select);
+       WM_operatortype_append(MESH_OT_similar_vertex_select);
+       WM_operatortype_append(MESH_OT_similar_edge_select);
+       WM_operatortype_append(MESH_OT_similar_face_select);
+       WM_operatortype_append(MESH_OT_select_multi_loop);
        WM_operatortype_append(MESH_OT_separate);
        
 }
@@ -146,43 +170,81 @@ void ED_operatortypes_mesh(void)
 void ED_keymap_mesh(wmWindowManager *wm)
 {      
        ListBase *keymap= WM_keymap_listbase(wm, "EditMesh", 0, 0);
+       wmKeymapItem *kmi;
        
        /* selecting */
+       /* standard mouse selection goes via space_view3d */
+       WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
+       kmi= WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0);
+       RNA_boolean_set(kmi->ptr, "extend", 1);
+       kmi= WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT|KM_CTRL, 0);
+       RNA_boolean_set(kmi->ptr, "ring", 1);
+       kmi= WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT|KM_CTRL, 0);
+       RNA_boolean_set(kmi->ptr, "extend", 1);
+       RNA_boolean_set(kmi->ptr, "ring", 1);
+
+       WM_keymap_add_item(keymap, "MESH_OT_shortest_path_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
+       
        WM_keymap_add_item(keymap, "MESH_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "MESH_OT_bmesh_test", JKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "MESH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "MESH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
-       WM_keymap_add_item(keymap, "MESH_OT_selectswap_mesh", IKEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_select_invert", IKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0);
        
-       WM_keymap_add_item(keymap, "MESH_OT_selectconnected_mesh_all", LKEY, KM_PRESS, KM_CTRL, 0);
-       WM_keymap_add_item(keymap, "MESH_OT_selectconnected_mesh", LKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_selectconnected_mesh", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1);
+       WM_keymap_add_item(keymap, "MESH_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
+       RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1);
        
        RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_select_linked_flat_faces", FKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"sharpness",135.0);
-       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);           
+       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_select_random", 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);
+       WM_keymap_add_item(keymap, "MESH_OT_similar_edge_select", GKEY, KM_PRESS, KM_SHIFT2|KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_similar_face_select", GKEY, KM_PRESS, KM_SHIFT|KM_CTRL2, 0);
+       
+       /* selection mode */
+       
+       WM_keymap_add_item(keymap, "MESH_OT_selection_type", TABKEY, KM_PRESS, KM_CTRL, 0);
        
        /* hide */
-       WM_keymap_add_item(keymap, "MESH_OT_hide_mesh", HKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_hide_mesh", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "swap", 1);
-       WM_keymap_add_item(keymap, "MESH_OT_reveal_mesh", HKEY, KM_PRESS, KM_ALT, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0);
+       RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "invert", 1);
+       WM_keymap_add_item(keymap, "MESH_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
        
        /* tools */
-       RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_righthandfaces", NKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "select", 2);
-       RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_righthandfaces", NKEY, KM_PRESS, KM_CTRL, 0)->ptr, "select", 1);
+       WM_keymap_add_item(keymap, "MESH_OT_consistant_normals", NKEY, KM_PRESS, KM_CTRL, 0);
+       RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_consistant_normals", NKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "inside", 1);
        
        WM_keymap_add_item(keymap, "MESH_OT_subdivs", WKEY, KM_PRESS, 0, 0); // this is the menu
        /*WM_keymap_add_item(keymap, "MESH_OT_subdivide_multi", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "MESH_OT_subdivide_multi_fractal", WKEY, KM_PRESS, KM_ALT, 0);
        WM_keymap_add_item(keymap, "MESH_OT_subdivide_smooth", WKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);*/
        WM_keymap_add_item(keymap, "MESH_OT_removedoublesflag", VKEY, KM_PRESS, KM_CTRL, 0);
-       WM_keymap_add_item(keymap, "MESH_OT_extrude_mesh", EKEY, KM_PRESS, 0, 0);
-       WM_keymap_add_item(keymap, "MESH_OT_edit_faces", PKEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_extrude", EKEY, KM_PRESS, 0, 0);
        
-       /* add */
+       WM_keymap_add_item(keymap, "VIEW3D_OT_editmesh_face_toolbox", FKEY, KM_PRESS, KM_CTRL, 0); /* operators below are in this toolbox */
+       WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_SHIFT, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_beauty_fill", FKEY, KM_PRESS, KM_ALT, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_convert_quads_to_tris", TKEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_convert_tris_to_quads", JKEY, KM_PRESS, KM_ALT, 0);
+       
+       /* add/remove */
+       WM_keymap_add_item(keymap, "MESH_OT_add_edge_face", FKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "MESH_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "OBJECT_OT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, KM_SHIFT, 0);
+                                               /* use KM_RELEASE because same key is used for tweaks */
+       WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", LEFTMOUSE, KM_RELEASE, KM_CTRL, 0);
+       
+       WM_keymap_add_item(keymap, "MESH_OT_delete", XKEY, KM_PRESS, 0, 0);
+       
+       WM_keymap_add_item(keymap, "MESH_OT_make_fgon", FKEY, KM_PRESS, KM_ALT, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_clear_fgon", FKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
        
        
 }