diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-07-03 04:02:45 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-07-03 04:02:45 +0400 |
commit | 98a7ca61fa905792bd3fdfa6c29f44691c9582ac (patch) | |
tree | 47455f2482f6eca0352c10c57482641eec6afb57 /source/blender/bmesh | |
parent | 4e39a854b4589cddff484649d95cce4c71d4e9f4 (diff) | |
parent | 2ed69a95f499081aacc15c0295f3461c38430554 (diff) |
Merged changes in the trunk up to revision 48505.
Diffstat (limited to 'source/blender/bmesh')
24 files changed, 646 insertions, 518 deletions
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt index 730b741fa38..4bce7a6ff51 100644 --- a/source/blender/bmesh/CMakeLists.txt +++ b/source/blender/bmesh/CMakeLists.txt @@ -32,6 +32,10 @@ set(INC ../../../intern/guardedalloc ) +set(INC_SYS + +) + set(SRC operators/bmo_bevel.c operators/bmo_connect.c diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 8d9f2ed7336..385572cceff 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -318,10 +318,10 @@ static void bm_rationalize_normals(BMesh *bm, int undo) return; } - BMO_op_initf(bm, &bmop, "righthandfaces faces=%af do_flip=%b", FALSE); + BMO_op_initf(bm, &bmop, "recalc_face_normals faces=%af do_flip=%b", FALSE); BMO_push(bm, &bmop); - bmo_righthandfaces_exec(bm, &bmop); + bmo_recalc_face_normals_exec(bm, &bmop); BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { BM_elem_flag_set(f, BM_ELEM_TAG, BMO_elem_flag_test(bm, f, FACE_FLIP)); diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 2c7007d1961..b29970dc886 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -354,12 +354,12 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { - BM_loop_interp_from_face(bm, l_iter, of, FALSE, TRUE); + BM_loop_interp_multires(bm, l_iter, of); } while ((l_iter = l_iter->next) != l_first); l_iter = l_first = BM_FACE_FIRST_LOOP(nf); do { - BM_loop_interp_from_face(bm, l_iter, of, FALSE, TRUE); + BM_loop_interp_multires(bm, l_iter, of); } while ((l_iter = l_iter->next) != l_first); BM_face_kill(bm, of); diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 4186f5d47eb..931937263e4 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -97,8 +97,8 @@ * * Smooths vertices by using a basic vertex averaging scheme. */ -static BMOpDefine bmo_vertexsmooth_def = { - "vertexsmooth", +static BMOpDefine bmo_smooth_vert_def = { + "smooth_vert", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, //set vertices close to the x axis before the operation to 0 {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, //set vertices close to the y axis before the operation to 0 @@ -106,7 +106,7 @@ static BMOpDefine bmo_vertexsmooth_def = { {BMO_OP_SLOT_FLT, "clipdist"}, //clipping threshod for the above three slots {0} /* null-terminating sentinel */, }, - bmo_vertexsmooth_exec, + bmo_smooth_vert_exec, 0 }; @@ -116,13 +116,13 @@ static BMOpDefine bmo_vertexsmooth_def = { * Computes an "outside" normal for the specified input faces. */ -static BMOpDefine bmo_righthandfaces_def = { - "righthandfaces", +static BMOpDefine bmo_recalc_face_normals_def = { + "recalc_face_normals", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, {BMO_OP_SLOT_BOOL, "do_flip"}, //internal flag, used by bmesh_rationalize_normals {0} /* null-terminating sentinel */, }, - bmo_righthandfaces_exec, + bmo_recalc_face_normals_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -136,15 +136,15 @@ static BMOpDefine bmo_righthandfaces_def = { * if usefaces is 0 then geomout spits out verts and edges, * otherwise it spits out faces. */ -static BMOpDefine bmo_regionextend_def = { - "regionextend", +static BMOpDefine bmo_region_extend_def = { + "region_extend", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, //output slot, computed boundary geometry. {BMO_OP_SLOT_BOOL, "constrict"}, //find boundary inside the regions, not outside. {BMO_OP_SLOT_BOOL, "use_faces"}, //extend from faces instead of edges {0} /* null-terminating sentinel */, }, - bmo_regionextend_exec, + bmo_region_extend_exec, 0 }; @@ -154,14 +154,14 @@ static BMOpDefine bmo_regionextend_def = { * Rotates edges topologically. Also known as "spin edge" to some people. * Simple example: [/] becomes [|] then [\]. */ -static BMOpDefine bmo_edgerotate_def = { - "edgerotate", +static BMOpDefine bmo_rotate_edges_def = { + "rotate_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, //newly spun edges {BMO_OP_SLOT_BOOL, "ccw"}, //rotate edge counter-clockwise if true, othewise clockwise {0} /* null-terminating sentinel */, }, - bmo_edgerotate_exec, + bmo_rotate_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -171,12 +171,12 @@ static BMOpDefine bmo_edgerotate_def = { * Reverses the winding (vertex order) of faces. This has the effect of * flipping the normal. */ -static BMOpDefine bmo_reversefaces_def = { - "reversefaces", +static BMOpDefine bmo_reverse_faces_def = { + "reverse_faces", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input faces {0} /* null-terminating sentinel */, }, - bmo_reversefaces_exec, + bmo_reverse_faces_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -186,14 +186,14 @@ static BMOpDefine bmo_reversefaces_def = { * Splits input edges (but doesn't do anything else). * This creates a 2-valence vert. */ -static BMOpDefine bmo_edgebisect_def = { - "edgebisect", +static BMOpDefine bmo_bisect_edges_def = { + "bisect_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges {BMO_OP_SLOT_INT, "numcuts"}, //number of cuts {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, //newly created vertices and edges {0} /* null-terminating sentinel */, }, - bmo_edgebisect_exec, + bmo_bisect_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -225,17 +225,17 @@ static BMOpDefine bmo_mirror_def = { * Takes input verts and find vertices they should weld to. Outputs a * mapping slot suitable for use with the weld verts bmop. * - * If keepverts is used, vertices outside that set can only be merged + * If keep_verts is used, vertices outside that set can only be merged * with vertices in that set. */ -static BMOpDefine bmo_finddoubles_def = { - "finddoubles", +static BMOpDefine bmo_find_doubles_def = { + "find_doubles", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices - {BMO_OP_SLOT_ELEMENT_BUF, "keepverts"}, //list of verts to keep + {BMO_OP_SLOT_ELEMENT_BUF, "keep_verts"}, //list of verts to keep {BMO_OP_SLOT_FLT, "dist"}, //minimum distance {BMO_OP_SLOT_MAPPING, "targetmapout"}, {0, /* null-terminating sentinel */}}, - bmo_finddoubles_exec, + bmo_find_doubles_exec, 0, }; @@ -245,12 +245,12 @@ static BMOpDefine bmo_finddoubles_def = { * Finds groups of vertices closer then dist and merges them together, * using the weld verts bmop. */ -static BMOpDefine bmo_removedoubles_def = { - "removedoubles", +static BMOpDefine bmo_remove_doubles_def = { + "remove_doubles", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input verts {BMO_OP_SLOT_FLT, "dist"}, //minimum distance {0, /* null-terminating sentinel */}}, - bmo_removedoubles_exec, + bmo_remove_doubles_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -305,11 +305,11 @@ static BMOpDefine bmo_pointmerge_facedata_def = { * the bounding box center. (I know, it's not averaging but * the vert_snap_to_bb_center is just too long). */ -static BMOpDefine bmo_vert_average_facedata_def = { - "vert_average_facedata", +static BMOpDefine bmo_average_vert_facedata_def = { + "average_vert_facedata", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ {0, /* null-terminating sentinel */}}, - bmo_vert_average_facedata_exec, + bmo_average_vert_facedata_exec, 0, }; @@ -321,7 +321,7 @@ static BMOpDefine bmo_vert_average_facedata_def = { static BMOpDefine bmo_pointmerge_def = { "pointmerge", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ - {BMO_OP_SLOT_VEC, "mergeco"}, + {BMO_OP_SLOT_VEC, "merge_co"}, {0, /* null-terminating sentinel */}}, bmo_pointmerge_exec, BMO_OP_FLAG_UNTAN_MULTIRES, @@ -347,11 +347,11 @@ static BMOpDefine bmo_collapse_uvs_def = { * use or will use this bmop). You pass in mappings from vertices to the vertices * they weld with. */ -static BMOpDefine bmo_weldverts_def = { - "weldverts", +static BMOpDefine bmo_weld_verts_def = { + "weld_verts", {{BMO_OP_SLOT_MAPPING, "targetmap"}, /* maps welded vertices to verts they should weld to */ {0, /* null-terminating sentinel */}}, - bmo_weldverts_exec, + bmo_weld_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -361,12 +361,12 @@ static BMOpDefine bmo_weldverts_def = { * Creates a single vertex; this bmop was necessary * for click-create-vertex. */ -static BMOpDefine bmo_makevert_def = { - "makevert", +static BMOpDefine bmo_create_vert_def = { + "create_vert", {{BMO_OP_SLOT_VEC, "co"}, //the coordinate of the new vert {BMO_OP_SLOT_ELEMENT_BUF, "newvertout"}, //the new vert {0, /* null-terminating sentinel */}}, - bmo_makevert_exec, + bmo_create_vert_exec, 0, }; @@ -528,8 +528,8 @@ static BMOpDefine bmo_transform_def = { */ static BMOpDefine bmo_object_load_bmesh_def = { "object_load_bmesh", - {{BMO_OP_SLOT_PNT, "scene"}, - {BMO_OP_SLOT_PNT, "object"}, + {{BMO_OP_SLOT_PTR, "scene"}, + {BMO_OP_SLOT_PTR, "object"}, {0, /* null-terminating sentinel */}}, bmo_object_load_bmesh_exec, 0, @@ -543,8 +543,8 @@ static BMOpDefine bmo_object_load_bmesh_def = { */ static BMOpDefine bmo_bmesh_to_mesh_def = { "bmesh_to_mesh", - {{BMO_OP_SLOT_PNT, "mesh"}, //pointer to a mesh structure to fill in - {BMO_OP_SLOT_PNT, "object"}, //pointer to an object structure + {{BMO_OP_SLOT_PTR, "mesh"}, //pointer to a mesh structure to fill in + {BMO_OP_SLOT_PTR, "object"}, //pointer to an object structure {BMO_OP_SLOT_BOOL, "notessellation"}, //don't calculate mfaces {0, /* null-terminating sentinel */}}, bmo_bmesh_to_mesh_exec, @@ -559,8 +559,8 @@ static BMOpDefine bmo_bmesh_to_mesh_def = { */ static BMOpDefine bmo_mesh_to_bmesh_def = { "mesh_to_bmesh", - {{BMO_OP_SLOT_PNT, "mesh"}, //pointer to a Mesh structure - {BMO_OP_SLOT_PNT, "object"}, //pointer to an Object structure + {{BMO_OP_SLOT_PTR, "mesh"}, //pointer to a Mesh structure + {BMO_OP_SLOT_PTR, "object"}, //pointer to an Object structure {BMO_OP_SLOT_BOOL, "set_shapekey"}, //load active shapekey coordinates into verts {0, /* null-terminating sentinel */}}, bmo_mesh_to_bmesh_exec, @@ -572,13 +572,13 @@ static BMOpDefine bmo_mesh_to_bmesh_def = { * * Extrudes faces individually. */ -static BMOpDefine bmo_extrude_indivface_def = { - "extrude_face_indiv", +static BMOpDefine bmo_extrude_discrete_faces_def = { + "extrude_discrete_faces", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input faces {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, //output faces {BMO_OP_SLOT_ELEMENT_BUF, "skirtout"}, //output skirt geometry, faces and edges {0} /* null-terminating sentinel */}, - bmo_extrude_face_indiv_exec, + bmo_extrude_discrete_faces_exec, 0 }; @@ -612,12 +612,12 @@ static BMOpDefine bmo_extrude_vert_indiv_def = { 0 }; -static BMOpDefine bmo_connectverts_def = { - "connectverts", +static BMOpDefine bmo_connect_verts_def = { + "connect_verts", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, {0} /* null-terminating sentinel */}, - bmo_connectverts_exec, + bmo_connect_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -691,8 +691,8 @@ static BMOpDefine bmo_triangulate_def = { BMO_OP_FLAG_UNTAN_MULTIRES }; -static BMOpDefine bmo_esubd_def = { - "esubd", +static BMOpDefine bmo_subdivide_edges_def = { + "subdivide_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, {BMO_OP_SLOT_FLT, "smooth"}, {BMO_OP_SLOT_FLT, "fractal"}, @@ -714,21 +714,21 @@ static BMOpDefine bmo_esubd_def = { {0} /* null-terminating sentinel */, }, - bmo_esubd_exec, + bmo_subdivide_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; -static BMOpDefine bmo_del_def = { - "del", +static BMOpDefine bmo_delete_def = { + "delete", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, {BMO_OP_SLOT_INT, "context"}, {0} /* null-terminating sentinel */}, - bmo_del_exec, + bmo_delete_exec, 0 }; -static BMOpDefine bmo_dupe_def = { - "dupe", +static BMOpDefine bmo_duplicate_def = { + "duplicate", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, {BMO_OP_SLOT_ELEMENT_BUF, "origout"}, {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, @@ -737,9 +737,9 @@ static BMOpDefine bmo_dupe_def = { {BMO_OP_SLOT_MAPPING, "facemap"}, {BMO_OP_SLOT_MAPPING, "boundarymap"}, {BMO_OP_SLOT_MAPPING, "isovertmap"}, - {BMO_OP_SLOT_PNT, "dest"}, /* destination bmesh, if NULL will use current on */ + {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */ {0} /* null-terminating sentinel */}, - bmo_dupe_exec, + bmo_duplicate_exec, 0 }; @@ -749,7 +749,7 @@ static BMOpDefine bmo_split_def = { {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, {BMO_OP_SLOT_MAPPING, "boundarymap"}, {BMO_OP_SLOT_MAPPING, "isovertmap"}, - {BMO_OP_SLOT_PNT, "dest"}, /* destination bmesh, if NULL will use current on */ + {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */ {BMO_OP_SLOT_BOOL, "use_only_faces"}, /* when enabled. don't duplicate loose verts/edges */ {0} /* null-terminating sentinel */}, bmo_split_exec, @@ -783,14 +783,14 @@ static BMOpDefine bmo_spin_def = { * * Find similar faces (area/material/perimeter, ...). */ -static BMOpDefine bmo_similarfaces_def = { - "similarfaces", +static BMOpDefine bmo_similar_faces_def = { + "similar_faces", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {0} /* null-terminating sentinel */}, - bmo_similarfaces_exec, + bmo_similar_faces_exec, 0 }; @@ -799,14 +799,14 @@ static BMOpDefine bmo_similarfaces_def = { * * Find similar edges (length, direction, edge, seam, ...). */ -static BMOpDefine bmo_similaredges_def = { - "similaredges", +static BMOpDefine bmo_similar_edges_def = { + "similar_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output edges */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {0} /* null-terminating sentinel */}, - bmo_similaredges_exec, + bmo_similar_edges_exec, 0 }; @@ -815,14 +815,14 @@ static BMOpDefine bmo_similaredges_def = { * * Find similar vertices (normal, face, vertex group, ...). */ -static BMOpDefine bmo_similarverts_def = { - "similarverts", +static BMOpDefine bmo_similar_verts_def = { + "similar_verts", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {0} /* null-terminating sentinel */}, - bmo_similarverts_exec, + bmo_similar_verts_exec, 0 }; @@ -830,12 +830,12 @@ static BMOpDefine bmo_similarverts_def = { * uv rotation * cycle the uvs */ -static BMOpDefine bmo_face_rotateuvs_def = { - "face_rotateuvs", +static BMOpDefine bmo_rotate_uvs_def = { + "rotate_uvs", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_INT, "dir"}, /* direction */ {0} /* null-terminating sentinel */}, - bmo_face_rotateuvs_exec, + bmo_rotate_uvs_exec, 0 }; @@ -843,11 +843,11 @@ static BMOpDefine bmo_face_rotateuvs_def = { * uv reverse * reverse the uvs */ -static BMOpDefine bmo_face_reverseuvs_def = { - "face_reverseuvs", +static BMOpDefine bmo_reverse_uvs_def = { + "reverse_uvs", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {0} /* null-terminating sentinel */}, - bmo_face_reverseuvs_exec, + bmo_reverse_uvs_exec, 0 }; @@ -855,12 +855,12 @@ static BMOpDefine bmo_face_reverseuvs_def = { * color rotation * cycle the colors */ -static BMOpDefine bmo_face_rotatecolors_def = { - "face_rotatecolors", +static BMOpDefine bmo_rotate_colors_def = { + "rotate_colors", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_INT, "dir"}, /* direction */ {0} /* null-terminating sentinel */}, - bmo_rotatecolors_exec, + bmo_rotate_colors_exec, 0 }; @@ -868,11 +868,11 @@ static BMOpDefine bmo_face_rotatecolors_def = { * color reverse * reverse the colors */ -static BMOpDefine bmo_face_reversecolors_def = { - "face_reversecolors", +static BMOpDefine bmo_reverse_colors_def = { + "reverse_colors", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {0} /* null-terminating sentinel */}, - bmo_face_reversecolors_exec, + bmo_reverse_colors_exec, 0 }; @@ -881,14 +881,14 @@ static BMOpDefine bmo_face_reversecolors_def = { * * Find similar vertices (normal, face, vertex group, ...). */ -static BMOpDefine bmo_vertexshortestpath_def = { - "vertexshortestpath", +static BMOpDefine bmo_shortest_path_def = { + "shortest_path", {{BMO_OP_SLOT_ELEMENT_BUF, "startv"}, /* start vertex */ {BMO_OP_SLOT_ELEMENT_BUF, "endv"}, /* end vertex */ {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {0} /* null-terminating sentinel */}, - bmo_vertexshortestpath_exec, + bmo_shortest_path_exec, 0 }; @@ -897,15 +897,15 @@ static BMOpDefine bmo_vertexshortestpath_def = { * * Disconnects faces along input edges. */ -static BMOpDefine bmo_edgesplit_def = { - "edgesplit", +static BMOpDefine bmo_split_edges_def = { + "split_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* old output disconnected edges */ /* needed for vertex rip so we can rip only half an edge at a boundary wich would otherwise split off */ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* optional tag verts, use to have greater control of splits */ {BMO_OP_SLOT_BOOL, "use_verts"}, /* use 'verts' for splitting, else just find verts to split from edges */ {0} /* null-terminating sentinel */}, - bmo_edgesplit_exec, + bmo_split_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1034,7 +1034,7 @@ static BMOpDefine bmo_bevel_def = { {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */ {BMO_OP_SLOT_ELEMENT_BUF, "face_spans"}, /* new geometry */ {BMO_OP_SLOT_ELEMENT_BUF, "face_holes"}, /* new geometry */ - {BMO_OP_SLOT_BOOL, "use_lengths"}, /* grab edge lengths from a PROP_FLT customdata laye */ + {BMO_OP_SLOT_BOOL, "use_lengths"}, /* grab edge lengths from a PROP_FLT customdata layer */ {BMO_OP_SLOT_BOOL, "use_even"}, /* corner vert placement: use shell/angle calculations */ {BMO_OP_SLOT_BOOL, "use_dist"}, /* corner vert placement: evaluate percent as a distance, * modifier uses this. We could do this as another float setting */ @@ -1134,14 +1134,14 @@ static BMOpDefine bmo_wireframe_def = { * * Translates vertes along an edge */ -static BMOpDefine bmo_vertex_slide_def = { - "vertex_slide", +static BMOpDefine bmo_slide_vert_def = { + "slide_vert", {{BMO_OP_SLOT_ELEMENT_BUF, "vert"}, {BMO_OP_SLOT_ELEMENT_BUF, "edge"}, {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, {BMO_OP_SLOT_FLT, "distance_t"}, {0} /* null-terminating sentinel */}, - bmo_vertex_slide_exec, + bmo_slide_vert_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1176,75 +1176,76 @@ static BMOpDefine bmo_convex_hull_def = { }; BMOpDefine *opdefines[] = { - &bmo_split_def, - &bmo_spin_def, - &bmo_dupe_def, - &bmo_del_def, - &bmo_esubd_def, - &bmo_triangulate_def, - &bmo_dissolve_faces_def, - &bmo_dissolve_edges_def, + &bmo_automerge_def, + &bmo_average_vert_facedata_def, + &bmo_beautify_fill_def, + &bmo_bevel_def, + &bmo_bisect_edges_def, + &bmo_bmesh_to_mesh_def, + &bmo_bridge_loops_def, + &bmo_collapse_def, + &bmo_collapse_uvs_def, + &bmo_connect_verts_def, + &bmo_contextual_create_def, + &bmo_convex_hull_def, + &bmo_create_circle_def, + &bmo_create_cone_def, + &bmo_create_cube_def, + &bmo_create_grid_def, + &bmo_create_icosphere_def, + &bmo_create_monkey_def, + &bmo_create_uvsphere_def, + &bmo_create_vert_def, + &bmo_delete_def, &bmo_dissolve_edge_loop_def, - &bmo_dissolve_verts_def, + &bmo_dissolve_edges_def, + &bmo_dissolve_faces_def, &bmo_dissolve_limit_def, + &bmo_dissolve_verts_def, + &bmo_duplicate_def, + &bmo_edgenet_fill_def, + &bmo_edgenet_prepare_def, + &bmo_extrude_discrete_faces_def, + &bmo_extrude_edge_only_def, &bmo_extrude_face_region_def, - &bmo_connectverts_def, &bmo_extrude_vert_indiv_def, + &bmo_find_doubles_def, + &bmo_inset_def, + &bmo_join_triangles_def, &bmo_mesh_to_bmesh_def, - &bmo_object_load_bmesh_def, - &bmo_transform_def, - &bmo_translate_def, - &bmo_rotate_def, - &bmo_edgenet_fill_def, - &bmo_contextual_create_def, - &bmo_makevert_def, - &bmo_weldverts_def, - &bmo_removedoubles_def, - &bmo_finddoubles_def, &bmo_mirror_def, - &bmo_edgebisect_def, - &bmo_reversefaces_def, - &bmo_edgerotate_def, - &bmo_regionextend_def, - &bmo_righthandfaces_def, - &bmo_vertexsmooth_def, - &bmo_extrude_edge_only_def, - &bmo_extrude_indivface_def, - &bmo_collapse_uvs_def, + &bmo_object_load_bmesh_def, &bmo_pointmerge_def, - &bmo_collapse_def, - &bmo_similarfaces_def, - &bmo_similaredges_def, - &bmo_similarverts_def, &bmo_pointmerge_facedata_def, - &bmo_vert_average_facedata_def, - &bmo_face_rotateuvs_def, - &bmo_bmesh_to_mesh_def, - &bmo_face_reverseuvs_def, - &bmo_edgenet_prepare_def, - &bmo_face_rotatecolors_def, - &bmo_face_reversecolors_def, - &bmo_vertexshortestpath_def, + &bmo_recalc_face_normals_def, + &bmo_region_extend_def, + &bmo_remove_doubles_def, + &bmo_reverse_colors_def, + &bmo_reverse_faces_def, + &bmo_reverse_uvs_def, + &bmo_rotate_colors_def, + &bmo_rotate_def, + &bmo_rotate_edges_def, + &bmo_rotate_uvs_def, &bmo_scale_def, - &bmo_edgesplit_def, - &bmo_automerge_def, - &bmo_create_uvsphere_def, - &bmo_create_grid_def, - &bmo_create_icosphere_def, - &bmo_create_monkey_def, - &bmo_create_cube_def, - &bmo_create_circle_def, - &bmo_create_cone_def, - &bmo_join_triangles_def, - &bmo_bevel_def, - &bmo_beautify_fill_def, - &bmo_triangle_fill_def, - &bmo_bridge_loops_def, + &bmo_shortest_path_def, + &bmo_similar_edges_def, + &bmo_similar_faces_def, + &bmo_similar_verts_def, + &bmo_slide_vert_def, + &bmo_smooth_vert_def, &bmo_solidify_def, - &bmo_inset_def, + &bmo_spin_def, + &bmo_split_def, + &bmo_split_edges_def, + &bmo_subdivide_edges_def, + &bmo_transform_def, + &bmo_translate_def, + &bmo_triangle_fill_def, + &bmo_triangulate_def, + &bmo_weld_verts_def, &bmo_wireframe_def, - &bmo_vertex_slide_def, - &bmo_convex_hull_def, + }; int bmesh_total_ops = (sizeof(opdefines) / sizeof(void *)); diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index b5e6534de3e..74087c00940 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -99,7 +99,7 @@ enum { /* normally store pointers to object, scene, * _never_ store arrays corresponding to mesh elements with this */ - BMO_OP_SLOT_PNT = 4, + BMO_OP_SLOT_PTR = 4, BMO_OP_SLOT_MAT = 5, BMO_OP_SLOT_VEC = 8, @@ -116,7 +116,7 @@ enum { * for when your defining an operator with BMOpDefine.*/ typedef struct BMOpSlot { - int slottype; + int slot_type; int len; int flag; int index; /* index within slot array */ @@ -132,16 +132,13 @@ typedef struct BMOpSlot { #define BMO_OP_MAX_SLOTS 16 /* way more than probably needed */ -#ifdef slots -#undef slots -#endif - typedef struct BMOperator { int type; - int slottype; + int slot_type; int needflag; int flag; - struct BMOpSlot slots[BMO_OP_MAX_SLOTS]; void (*exec)(BMesh *bm, struct BMOperator *op); + struct BMOpSlot slot_args[BMO_OP_MAX_SLOTS]; + void (*exec)(BMesh *bm, struct BMOperator *op); struct MemArena *arena; } BMOperator; @@ -154,7 +151,7 @@ typedef struct BMOSlotType { typedef struct BMOpDefine { const char *name; - BMOSlotType slottypes[BMO_OP_MAX_SLOTS]; + BMOSlotType slot_types[BMO_OP_MAX_SLOTS]; void (*exec)(BMesh *bm, BMOperator *op); int flag; } BMOpDefine; @@ -197,11 +194,11 @@ int BMO_mesh_disabled_flag_count(BMesh *bm, const char htype, const short oflag) * this system is used to execute or initialize an operator, * using a formatted-string system. * - * for example, BMO_op_callf(bm, "del geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES); + * for example, BMO_op_callf(bm, "delete geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES); * . . .will execute the delete operator, feeding in selected faces, deleting them. * * the basic format for the format string is: - * [operatorname] [slotname]=%[code] [slotname]=%[code] + * [operatorname] [slot_name]=%[code] [slot_name]=%[code] * * as in printf, you pass in one additional argument to the function * for every code. @@ -246,10 +243,10 @@ int BMO_op_initf(BMesh *bm, BMOperator *op, const char *fmt, ...); int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *fmt, va_list vlist); /* test whether a named slot exists */ -int BMO_slot_exists(BMOperator *op, const char *slotname); +int BMO_slot_exists(BMOperator *op, const char *slot_name); /* get a pointer to a slot. this may be removed layer on from the public API. */ -BMOpSlot *BMO_slot_get(BMOperator *op, const char *slotname); +BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name); /* copies the data of a slot from one operator to another. src and dst are the * source/destination slot codes, respectively. */ @@ -270,30 +267,30 @@ enum { void BMO_op_flag_enable(BMesh *bm, BMOperator *op, const int op_flag); void BMO_op_flag_disable(BMesh *bm, BMOperator *op, const int op_flag); -void BMO_slot_float_set(BMOperator *op, const char *slotname, const float f); -float BMO_slot_float_get(BMOperator *op, const char *slotname); -void BMO_slot_int_set(BMOperator *op, const char *slotname, const int i); -int BMO_slot_int_get(BMOperator *op, const char *slotname); -void BMO_slot_bool_set(BMOperator *op, const char *slotname, const int i); -int BMO_slot_bool_get(BMOperator *op, const char *slotname); +void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f); +float BMO_slot_float_get(BMOperator *op, const char *slot_name); +void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i); +int BMO_slot_int_get(BMOperator *op, const char *slot_name); +void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i); +int BMO_slot_bool_get(BMOperator *op, const char *slot_name); /* don't pass in arrays that are supposed to map to elements this way. * * so, e.g. passing in list of floats per element in another slot is bad. * passing in, e.g. pointer to an editmesh for the conversion operator is fine * though. */ -void BMO_slot_ptr_set(BMOperator *op, const char *slotname, void *p); -void *BMO_slot_ptr_get(BMOperator *op, const char *slotname); -void BMO_slot_vec_set(BMOperator *op, const char *slotname, const float vec[3]); -void BMO_slot_vec_get(BMOperator *op, const char *slotname, float r_vec[3]); +void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p); +void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name); +void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]); +void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]); /* only supports square mats */ /* size must be 3 or 4; this api is meant only for transformation matrices. * note that internally the matrix is stored in 4x4 form, and it's safe to * call whichever BMO_Get_Mat* function you want. */ -void BMO_slot_mat_set(BMOperator *op, const char *slotname, const float *mat, int size); -void BMO_slot_mat4_get(BMOperator *op, const char *slotname, float r_mat[4][4]); -void BMO_slot_mat3_set(BMOperator *op, const char *slotname, float r_mat[3][3]); +void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size); +void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]); +void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]); void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *op, const char htype, const short oflag); @@ -303,47 +300,47 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_op_slot, /* puts every element of type 'type' (which is a bitmask) with tool * flag 'flag', into a slot. */ -void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* puts every element of type 'type' (which is a bitmask) without tool * flag 'flag', into a slot. */ -void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* tool-flags all elements inside an element slot array with flag flag. */ -void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* clears tool-flag flag from all elements inside a slot array. */ -void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* tool-flags all elements inside an element slot array with flag flag. */ -void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush); /* clears tool-flag flag from all elements inside a slot array. */ -void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush); /* puts every element of type 'type' (which is a bitmask) with header * flag 'flag', into a slot. note: ignores hidden elements * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, - const char *slotname, + const char *slot_name, const char htype, const char hflag); /* puts every element of type 'type' (which is a bitmask) without * header flag 'flag', into a slot. note: ignores hidden elements * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, - const char *slotname, + const char *slot_name, const char htype, const char hflag); /* counts number of elements inside a slot array. */ -int BMO_slot_buffer_count(BMesh *bm, BMOperator *op, const char *slotname); -int BMO_slot_map_count(BMesh *bm, BMOperator *op, const char *slotname); +int BMO_slot_buffer_count(BMesh *bm, BMOperator *op, const char *slot_name); +int BMO_slot_map_count(BMesh *bm, BMOperator *op, const char *slot_name); -void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, +void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element, void *data, int len); /* Counts the number of edges with tool flag toolflag around @@ -352,9 +349,14 @@ int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag); /* flags all elements in a mapping. note that the mapping must only have * bmesh elements in it.*/ -void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char hflag, const short oflag); +void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len); + +void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, + const char htype); + /* this part of the API is used to iterate over element buffer or * mapping slots. * @@ -363,7 +365,7 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, * BMOIter oiter; * BMFace *f; * - * f = BMO_iter_new(&oiter, bm, some_operator, "slotname", BM_FACE); + * f = BMO_iter_new(&oiter, bm, some_operator, "slot_name", BM_FACE); * for (; f; f = BMO_iter_step(&oiter)) { * /do something with the face * } @@ -373,7 +375,7 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, * void *key; * void *val; * - * key = BMO_iter_new(&oiter, bm, some_operator, "slotname", 0); + * key = BMO_iter_new(&oiter, bm, some_operator, "slot_name", 0); * for (; key; key = BMO_iter_step(&oiter)) { * val = BMO_iter_map_value(&oiter); * //do something with the key/val pair @@ -396,10 +398,10 @@ typedef struct BMOIter { char restrictmask; /* bitwise '&' with BMHeader.htype */ } BMOIter; -void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slotname); +void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name); void *BMO_iter_new(BMOIter *iter, BMesh *bm, BMOperator *op, - const char *slotname, const char restrictmask); + const char *slot_name, const char restrictmask); void *BMO_iter_step(BMOIter *iter); /* returns a pointer to the key value when iterating over mappings. @@ -412,8 +414,8 @@ void *BMO_iter_map_value_p(BMOIter *iter); /* use this for float mappings */ float BMO_iter_map_value_f(BMOIter *iter); -#define BMO_ITER(ele, iter, bm, op, slotname, restrict) \ - for (ele = BMO_iter_new(iter, bm, op, slotname, restrict); ele; ele = BMO_iter_step(iter)) +#define BMO_ITER(ele, iter, bm, op, slot_name, restrict) \ + for (ele = BMO_iter_new(iter, bm, op, slot_name, restrict); ele; ele = BMO_iter_step(iter)) /******************* Inlined Functions********************/ typedef void (*opexec)(BMesh *bm, BMOperator *op); diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h index e04079f42c9..16c2b8b0505 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h +++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h @@ -69,16 +69,16 @@ BLI_INLINE void _bmo_elem_flag_toggle(BMesh *bm, BMFlagLayer *oflags, const shor oflags[bm->stackdepth - 1].f ^= oflag; } -BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slot_name, void *element, int val) { - BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(int)); + BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(int)); } -BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slot_name, void *element, float val) { - BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(float)); + BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(float)); } @@ -87,16 +87,16 @@ BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char * do NOT use these for non-operator-api-allocated memory! instead * use BMO_slot_map_data_get and BMO_slot_map_insert, which copies the data. */ -BLI_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slot_name, void *element, void *val) { - BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(void *)); + BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(void *)); } -BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, void *element) +BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ if (!slot->data.ghash) return 0; @@ -104,12 +104,12 @@ BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const ch return BLI_ghash_haskey(slot->data.ghash, element); } -BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, +BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element) { BMOElemMapping *mapping; - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ if (!slot->data.ghash) return NULL; @@ -121,28 +121,28 @@ BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const return mapping + 1; } -BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slot_name, void *element) { - float *val = (float *) BMO_slot_map_data_get(bm, op, slotname, element); + float *val = (float *) BMO_slot_map_data_get(bm, op, slot_name, element); if (val) return *val; return 0.0f; } -BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slot_name, void *element) { - int *val = (int *) BMO_slot_map_data_get(bm, op, slotname, element); + int *val = (int *) BMO_slot_map_data_get(bm, op, slot_name, element); if (val) return *val; return 0; } -BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slot_name, void *element) { - void **val = (void **) BMO_slot_map_data_get(bm, op, slotname, element); + void **val = (void **) BMO_slot_map_data_get(bm, op, slot_name, element); if (val) return *val; return NULL; diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 65288522b3b..5447e6b5a55 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -145,9 +145,9 @@ void BMO_op_init(BMesh *bm, BMOperator *op, const char *opname) op->flag = opdefines[opcode]->flag; /* initialize the operator slot types */ - for (i = 0; opdefines[opcode]->slottypes[i].type; i++) { - op->slots[i].slottype = opdefines[opcode]->slottypes[i].type; - op->slots[i].index = i; + for (i = 0; opdefines[opcode]->slot_types[i].type; i++) { + op->slot_args[i].slot_type = opdefines[opcode]->slot_types[i].type; + op->slot_args[i].index = i; } /* callback */ @@ -192,9 +192,9 @@ void BMO_op_finish(BMesh *bm, BMOperator *op) BMOpSlot *slot; int i; - for (i = 0; opdefines[op->type]->slottypes[i].type; i++) { - slot = &op->slots[i]; - if (slot->slottype == BMO_OP_SLOT_MAPPING) { + for (i = 0; opdefines[op->type]->slot_types[i].type; i++) { + slot = &op->slot_args[i]; + if (slot->slot_type == BMO_OP_SLOT_MAPPING) { if (slot->data.ghash) BLI_ghash_free(slot->data.ghash, NULL, NULL); } @@ -214,26 +214,26 @@ void BMO_op_finish(BMesh *bm, BMOperator *op) * * \return Success if the slot if found. */ -int BMO_slot_exists(BMOperator *op, const char *slotname) +int BMO_slot_exists(BMOperator *op, const char *slot_name) { - int slotcode = bmo_name_to_slotcode(opdefines[op->type], slotname); - return (slotcode >= 0); + int slot_code = bmo_name_to_slotcode(opdefines[op->type], slot_name); + return (slot_code >= 0); } /** * \brief BMESH OPSTACK GET SLOT * - * Returns a pointer to the slot of type 'slotcode' + * Returns a pointer to the slot of type 'slot_code' */ -BMOpSlot *BMO_slot_get(BMOperator *op, const char *slotname) +BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name) { - int slotcode = bmo_name_to_slotcode_check(opdefines[op->type], slotname); + int slot_code = bmo_name_to_slotcode_check(opdefines[op->type], slot_name); - if (slotcode < 0) { + if (slot_code < 0) { return &BMOpEmptySlot; } - return &(op->slots[slotcode]); + return &(op->slot_args[slot_code]); } /** @@ -249,22 +249,22 @@ void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src, if (source_slot == dest_slot) return; - if (source_slot->slottype != dest_slot->slottype) { + if (source_slot->slot_type != dest_slot->slot_type) { /* possibly assert here? */ return; } - if (dest_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF) { + if (dest_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF) { /* do buffer copy */ dest_slot->data.buf = NULL; dest_slot->len = source_slot->len; if (dest_slot->len) { - const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[dest_slot->slottype] * dest_slot->len; + const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[dest_slot->slot_type] * dest_slot->len; dest_slot->data.buf = BLI_memarena_alloc(dest_op->arena, slot_alloc_size); memcpy(dest_slot->data.buf, source_slot->data.buf, slot_alloc_size); } } - else if (dest_slot->slottype == BMO_OP_SLOT_MAPPING) { + else if (dest_slot->slot_type == BMO_OP_SLOT_MAPPING) { GHashIterator it; BMOElemMapping *srcmap, *dstmap; @@ -301,42 +301,42 @@ void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src, * Sets the value of a slot depending on it's type */ -void BMO_slot_float_set(BMOperator *op, const char *slotname, const float f) +void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_FLT); - if (!(slot->slottype == BMO_OP_SLOT_FLT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); + if (!(slot->slot_type == BMO_OP_SLOT_FLT)) return; slot->data.f = f; } -void BMO_slot_int_set(BMOperator *op, const char *slotname, const int i) +void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_INT); - if (!(slot->slottype == BMO_OP_SLOT_INT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); + if (!(slot->slot_type == BMO_OP_SLOT_INT)) return; slot->data.i = i; } -void BMO_slot_bool_set(BMOperator *op, const char *slotname, const int i) +void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_BOOL); - if (!(slot->slottype == BMO_OP_SLOT_BOOL)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); + if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) return; slot->data.i = i; } /* only supports square mats */ -void BMO_slot_mat_set(BMOperator *op, const char *slotname, const float *mat, int size) +void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAT); - if (!(slot->slottype == BMO_OP_SLOT_MAT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; slot->len = 4; @@ -355,93 +355,93 @@ void BMO_slot_mat_set(BMOperator *op, const char *slotname, const float *mat, in } } -void BMO_slot_mat4_get(BMOperator *op, const char *slotname, float r_mat[4][4]) +void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAT); - if (!(slot->slottype == BMO_OP_SLOT_MAT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; copy_m4_m4(r_mat, (float (*)[4])slot->data.p); } -void BMO_slot_mat3_set(BMOperator *op, const char *slotname, float r_mat[3][3]) +void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAT); - if (!(slot->slottype == BMO_OP_SLOT_MAT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; copy_m3_m4(r_mat, slot->data.p); } -void BMO_slot_ptr_set(BMOperator *op, const char *slotname, void *p) +void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_PNT); - if (!(slot->slottype == BMO_OP_SLOT_PNT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); + if (!(slot->slot_type == BMO_OP_SLOT_PTR)) return; slot->data.p = p; } -void BMO_slot_vec_set(BMOperator *op, const char *slotname, const float vec[3]) +void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_VEC); - if (!(slot->slottype == BMO_OP_SLOT_VEC)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); + if (!(slot->slot_type == BMO_OP_SLOT_VEC)) return; copy_v3_v3(slot->data.vec, vec); } -float BMO_slot_float_get(BMOperator *op, const char *slotname) +float BMO_slot_float_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_FLT); - if (!(slot->slottype == BMO_OP_SLOT_FLT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); + if (!(slot->slot_type == BMO_OP_SLOT_FLT)) return 0.0f; return slot->data.f; } -int BMO_slot_int_get(BMOperator *op, const char *slotname) +int BMO_slot_int_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_INT); - if (!(slot->slottype == BMO_OP_SLOT_INT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); + if (!(slot->slot_type == BMO_OP_SLOT_INT)) return 0; return slot->data.i; } -int BMO_slot_bool_get(BMOperator *op, const char *slotname) +int BMO_slot_bool_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_BOOL); - if (!(slot->slottype == BMO_OP_SLOT_BOOL)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); + if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) return 0; return slot->data.i; } -void *BMO_slot_ptr_get(BMOperator *op, const char *slotname) +void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_PNT); - if (!(slot->slottype == BMO_OP_SLOT_PNT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); + if (!(slot->slot_type == BMO_OP_SLOT_PTR)) return NULL; return slot->data.p; } -void BMO_slot_vec_get(BMOperator *op, const char *slotname, float r_vec[3]) +void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_VEC); - if (!(slot->slottype == BMO_OP_SLOT_VEC)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); + if (!(slot->slot_type == BMO_OP_SLOT_VEC)) return; copy_v3_v3(r_vec, slot->data.vec); @@ -515,25 +515,25 @@ void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char hty } } -int BMO_slot_buffer_count(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) +int BMO_slot_buffer_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); /* check if its actually a buffer */ - if (slot->slottype != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return 0; return slot->len; } -int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) +int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* check if its actually a buffer */ - if (!(slot->slottype == BMO_OP_SLOT_MAPPING)) + if (!(slot->slot_type == BMO_OP_SLOT_MAPPING)) return 0; return slot->data.ghash ? BLI_ghash_size(slot->data.ghash) : 0; @@ -542,12 +542,12 @@ int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) /* inserts a key/value mapping into a mapping slot. note that it copies the * value, it doesn't store a reference to it. */ -void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, +void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element, void *data, int len) { BMOElemMapping *mapping; - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); mapping = (BMOElemMapping *) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len); @@ -563,9 +563,9 @@ void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname } #if 0 -void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) +void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slot_code, int totadd) { - BMOpSlot *slot = &op->slots[slotcode]; + BMOpSlot *slot = &op->slots[slot_code]; void *tmp; ssize_t allocsize; @@ -579,7 +579,7 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) if (slot->len >= slot->size) { slot->size = (slot->size + 1 + totadd) * 2; - allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slottypes[slotcode].type] * slot->size; + allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slot_types[slot_code].type] * slot->size; tmp = slot->data.buf; slot->data.buf = MEM_callocN(allocsize, "opslot dynamic array"); @@ -594,7 +594,7 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) slot->len += totadd; slot->size = slot->len + 2; - allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slottypes[slotcode].type] * slot->len; + allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slot_types[slot_code].type] * slot->len; tmp = slot->data.buf; slot->data.buf = MEM_callocN(allocsize, "opslot dynamic array"); @@ -605,14 +605,14 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) } #endif -void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { GHashIterator it; - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMElemF *ele_f; - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ if (!slot->data.ghash) return; @@ -625,18 +625,18 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, } } -static void *bmo_slot_buffer_alloc(BMOperator *op, const char *slotname, int len) +void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); /* check if its actually a buffer */ - if (slot->slottype != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return NULL; slot->len = len; if (len) - slot->data.buf = BLI_memarena_alloc(op->arena, BMO_OPSLOT_TYPEINFO[slot->slottype] * len); + slot->data.buf = BLI_memarena_alloc(op->arena, BMO_OPSLOT_TYPEINFO[slot->slot_type] * len); return slot->data.buf; } @@ -645,9 +645,9 @@ static void *bmo_slot_buffer_alloc(BMOperator *op, const char *slotname, int len * * Copies all elements of a certain type into an operator slot. */ -static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slotname, const char htype) +void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, const char htype) { - BMOpSlot *output = BMO_slot_get(op, slotname); + BMOpSlot *output = BMO_slot_get(op, slot_name); int totelement = 0, i = 0; if (htype & BM_VERT) totelement += bm->totvert; @@ -658,7 +658,7 @@ static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot BMIter iter; BMHeader *ele; - bmo_slot_buffer_alloc(op, slotname, totelement); + BMO_slot_buffer_alloc(op, slot_name, totelement); /* TODO - collapse these loops into one */ @@ -691,11 +691,11 @@ static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot * Copies elements of a certain type, which have a certain header flag * enabled/disabled into a slot for an operator. */ -static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *slotname, +static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const short test_for_enabled) { - BMOpSlot *output = BMO_slot_get(op, slotname); + BMOpSlot *output = BMO_slot_get(op, slot_name); int totelement = 0, i = 0; BLI_assert(ELEM(test_for_enabled, TRUE, FALSE)); @@ -709,7 +709,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl BMIter iter; BMElem *ele; - bmo_slot_buffer_alloc(op, slotname, totelement); + BMO_slot_buffer_alloc(op, slot_name, totelement); /* TODO - collapse these loops into one */ @@ -751,16 +751,16 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl } } -void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slotname, htype, hflag, TRUE); + bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, TRUE); } -void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slotname, htype, hflag, FALSE); + bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, FALSE); } /** @@ -772,15 +772,15 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, BMOpSlot *output_slot = BMO_slot_get(output_op, output_slot_name); BMOpSlot *other_slot = BMO_slot_get(other_op, other_slot_name); - BLI_assert(output_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF && - other_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(output_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF && + other_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); if (output_slot->len == 0) { /* output slot is empty, copy rather than append */ BMO_slot_copy(other_op, output_op, other_slot_name, output_slot_name); } else if (other_slot->len != 0) { - int elem_size = BMO_OPSLOT_TYPEINFO[output_slot->slottype]; + int elem_size = BMO_OPSLOT_TYPEINFO[output_slot->slot_type]; int alloc_size = elem_size * (output_slot->len + other_slot->len); /* allocate new buffer */ void *buf = BLI_memarena_alloc(output_op->arena, alloc_size); @@ -800,11 +800,11 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, * Copies elements of a certain type, which have a certain flag set * into an output slot for an operator. */ -static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slotname, +static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag, const short test_for_enabled) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); int totelement, i = 0; BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); @@ -814,14 +814,14 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo else totelement = BMO_mesh_disabled_flag_count(bm, htype, oflag); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); if (totelement) { BMIter iter; BMHeader *ele; BMHeader **ele_array; - bmo_slot_buffer_alloc(op, slotname, totelement); + BMO_slot_buffer_alloc(op, slot_name, totelement); ele_array = (BMHeader **)slot->data.p; @@ -859,16 +859,16 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo } } -void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slotname, htype, oflag, TRUE); + bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, TRUE); } -void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slotname, htype, oflag, FALSE); + bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, FALSE); } /** @@ -877,16 +877,16 @@ void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *s * Header Flags elements in a slots buffer, automatically * using the selection API where appropriate. */ -void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMElem **data = slot->data.p; int i; const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++, data++) { if (!(htype & (*data)->head.htype)) @@ -910,16 +910,16 @@ void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotnam * Removes flags from elements in a slots buffer, automatically * using the selection API where appropriate. */ -void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMElem **data = slot->data.p; int i; const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++, data++) { if (!(htype & (*data)->head.htype)) @@ -961,14 +961,14 @@ int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag) * * Flags elements in a slots buffer */ -void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMHeader **data = slot->data.p; int i; - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) @@ -983,14 +983,14 @@ void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname * * Removes flags from elements in a slots buffer */ -void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMHeader **data = slot->data.p; int i; - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) @@ -1131,11 +1131,11 @@ static void bmo_flag_layer_clear(BMesh *bm) bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE); } -void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slotname) +void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); - if (slot->slottype != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return NULL; return slot->data.buf ? *(void **)slot->data.buf : NULL; @@ -1148,9 +1148,9 @@ void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slotname) * (e.g. combination of BM_VERT, BM_EDGE, BM_FACE), if iterating * over an element buffer (not a mapping). */ void *BMO_iter_new(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, - const char *slotname, const char restrictmask) + const char *slot_name, const char restrictmask) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); memset(iter, 0, sizeof(BMOIter)); @@ -1158,7 +1158,7 @@ void *BMO_iter_new(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, iter->cur = 0; iter->restrictmask = restrictmask; - if (iter->slot->slottype == BMO_OP_SLOT_MAPPING) { + if (iter->slot->slot_type == BMO_OP_SLOT_MAPPING) { if (iter->slot->data.ghash) { BLI_ghashIterator_init(&iter->giter, slot->data.ghash); } @@ -1172,7 +1172,7 @@ void *BMO_iter_new(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, void *BMO_iter_step(BMOIter *iter) { - if (iter->slot->slottype == BMO_OP_SLOT_ELEMENT_BUF) { + if (iter->slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF) { BMHeader *h; if (iter->cur >= iter->slot->len) { @@ -1190,7 +1190,7 @@ void *BMO_iter_step(BMOIter *iter) return h; } - else if (iter->slot->slottype == BMO_OP_SLOT_MAPPING) { + else if (iter->slot->slot_type == BMO_OP_SLOT_MAPPING) { BMOElemMapping *map; void *ret = BLI_ghashIterator_getKey(&iter->giter); map = BLI_ghashIterator_getValue(&iter->giter); @@ -1286,8 +1286,8 @@ static int bmo_name_to_slotcode(BMOpDefine *def, const char *name) { int i; - for (i = 0; def->slottypes[i].type; i++) { - if (!strncmp(name, def->slottypes[i].name, MAX_SLOTNAME)) { + for (i = 0; def->slot_types[i].type; i++) { + if (!strncmp(name, def->slot_types[i].name, MAX_SLOTNAME)) { return i; } } @@ -1320,7 +1320,7 @@ static int bmo_opname_to_opcode(const char *opname) } /* Example: - * BMO_op_callf(bm, "del %i %hv", DEL_ONLYFACES, BM_ELEM_SELECT); + * BMO_op_callf(bm, "delete %i %hv", DEL_ONLYFACES, BM_ELEM_SELECT); * * i - int * b - boolean (same as int but 1/0 only) @@ -1331,14 +1331,17 @@ static int bmo_opname_to_opcode(const char *opname) * fv - flagged verts (oflag) * fe - flagged edges (oflag) * ff - flagged faces (oflag) + * + * capitals - H, F to use the flag flipped (when the flag is off) + * Hv, He, Hf, Fv, Fe, Ff, */ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) { BMOpDefine *def; char *opname, *ofmt, *fmt; - char slotname[64] = {0}; - int i /*, n = strlen(fmt) */, stop /*, slotcode = -1 */, type, state; + char slot_name[64] = {0}; + int i /*, n = strlen(fmt) */, stop /*, slot_code = -1 */, type, state; char htype; int noslot = 0; @@ -1377,7 +1380,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) def = opdefines[i]; i = 0; - state = 1; /* 0: not inside slotcode name, 1: inside slotcode name */ + state = 1; /* 0: not inside slot_code name, 1: inside slot_code name */ while (*fmt) { if (state) { @@ -1401,7 +1404,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) GOTO_ERROR("name to slot code check failed"); } - BLI_strncpy(slotname, fmt, sizeof(slotname)); + BLI_strncpy(slot_name, fmt, sizeof(slot_name)); state = 0; fmt += i; @@ -1422,18 +1425,18 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) else if (c == '4') size = 4; else GOTO_ERROR("matrix size was not 3 or 4"); - BMO_slot_mat_set(op, slotname, va_arg(vlist, void *), size); + BMO_slot_mat_set(op, slot_name, va_arg(vlist, void *), size); state = 1; break; } case 'v': { - BMO_slot_vec_set(op, slotname, va_arg(vlist, float *)); + BMO_slot_vec_set(op, slot_name, va_arg(vlist, float *)); state = 1; break; } case 'e': { BMHeader *ele = va_arg(vlist, void *); - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(void *) * 4); slot->len = 1; @@ -1444,22 +1447,22 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) } case 's': { BMOperator *op2 = va_arg(vlist, void *); - const char *slotname2 = va_arg(vlist, char *); + const char *slot_name2 = va_arg(vlist, char *); - BMO_slot_copy(op2, op, slotname2, slotname); + BMO_slot_copy(op2, op, slot_name2, slot_name); state = 1; break; } case 'i': - BMO_slot_int_set(op, slotname, va_arg(vlist, int)); + BMO_slot_int_set(op, slot_name, va_arg(vlist, int)); state = 1; break; case 'b': - BMO_slot_bool_set(op, slotname, va_arg(vlist, int)); + BMO_slot_bool_set(op, slot_name, va_arg(vlist, int)); state = 1; break; case 'p': - BMO_slot_ptr_set(op, slotname, va_arg(vlist, void *)); + BMO_slot_ptr_set(op, slot_name, va_arg(vlist, void *)); state = 1; break; case 'f': @@ -1470,7 +1473,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) type = *fmt; if (NEXT_CHAR(fmt) == ' ' || NEXT_CHAR(fmt) == '\0') { - BMO_slot_float_set(op, slotname, va_arg(vlist, double)); + BMO_slot_float_set(op, slot_name, va_arg(vlist, double)); } else { htype = 0; @@ -1492,19 +1495,19 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) } if (type == 'h') { - BMO_slot_buffer_from_enabled_hflag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_enabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int)); } else if (type == 'H') { - BMO_slot_buffer_from_disabled_hflag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_disabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int)); } else if (type == 'a') { - BMO_slot_buffer_from_all(bm, op, slotname, htype); + BMO_slot_buffer_from_all(bm, op, slot_name, htype); } else if (type == 'f') { - BMO_slot_buffer_from_enabled_flag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_enabled_flag(bm, op, slot_name, htype, va_arg(vlist, int)); } else if (type == 'F') { - BMO_slot_buffer_from_disabled_flag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_disabled_flag(bm, op, slot_name, htype, va_arg(vlist, int)); } } diff --git a/source/blender/bmesh/intern/bmesh_operators_private.h b/source/blender/bmesh/intern/bmesh_operators_private.h index df48ec8468f..dc1bdaa4689 100644 --- a/source/blender/bmesh/intern/bmesh_operators_private.h +++ b/source/blender/bmesh/intern/bmesh_operators_private.h @@ -33,74 +33,74 @@ struct BMOperator; void BMO_push(BMesh *bm, BMOperator *op); void BMO_pop(BMesh *bm); -void bmo_split_exec(BMesh *bm, BMOperator *op); -void bmo_spin_exec(BMesh *bm, BMOperator *op); -void bmo_dupe_exec(BMesh *bm, BMOperator *op); -void bmo_del_exec(BMesh *bm, BMOperator *op); -void bmo_esubd_exec(BMesh *bm, BMOperator *op); -void bmo_triangulate_exec(BMesh *bm, BMOperator *op); +void bmo_automerge_exec(BMesh *bm, BMOperator *op); +void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op); +void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op); +void bmo_bevel_exec(BMesh *bm, BMOperator *op); +void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op); +void bmo_bmesh_to_mesh_exec(BMesh *bm, BMOperator *op); +void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op); +void bmo_collapse_exec(BMesh *bm, BMOperator *op); +void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op); +void bmo_connect_verts_exec(BMesh *bm, BMOperator *op); +void bmo_contextual_create_exec(BMesh *bm, BMOperator *op); +void bmo_convex_hull_exec(BMesh *bm, BMOperator *op); +void bmo_create_circle_exec(BMesh *bm, BMOperator *op); +void bmo_create_cone_exec(BMesh *bm, BMOperator *op); +void bmo_create_cube_exec(BMesh *bm, BMOperator *op); +void bmo_create_grid_exec(BMesh *bm, BMOperator *op); +void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op); +void bmo_create_monkey_exec(BMesh *bm, BMOperator *op); +void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op); +void bmo_create_vert_exec(BMesh *bm, BMOperator *op); +void bmo_delete_exec(BMesh *bm, BMOperator *op); +void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op); +void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op); void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op); -void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op); void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op); +void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op); +void bmo_duplicate_exec(BMesh *bm, BMOperator *op); +void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op); +void bmo_edgenet_prepare(BMesh *bm, BMOperator *op); +void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op); +void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op); void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op); -void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op); -void bmo_connectverts_exec(BMesh *bm, BMOperator *op); void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op); +void bmo_find_doubles_exec(BMesh *bm, BMOperator *op); +void bmo_inset_exec(BMesh *bm, BMOperator *op); +void bmo_join_triangles_exec(BMesh *bm, BMOperator *op); void bmo_mesh_to_bmesh_exec(BMesh *bm, BMOperator *op); -void bmo_bmesh_to_mesh_exec(BMesh *bm, BMOperator *op); -void bmo_translate_exec(BMesh *bm, BMOperator *op); -void bmo_transform_exec(BMesh *bm, BMOperator *op); -void bmo_contextual_create_exec(BMesh *bm, BMOperator *op); -void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op); -void bmo_rotate_exec(BMesh *bm, BMOperator *op); -void bmo_makevert_exec(BMesh *bm, BMOperator *op); -void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op); -void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op); -void bmo_weldverts_exec(BMesh *bm, BMOperator *op); -void bmo_removedoubles_exec(BMesh *bm, BMOperator *op); -void bmo_finddoubles_exec(BMesh *bm, BMOperator *op); void bmo_mirror_exec(BMesh *bm, BMOperator *op); -void bmo_edgebisect_exec(BMesh *bm, BMOperator *op); -void bmo_reversefaces_exec(BMesh *bm, BMOperator *op); -void bmo_edgerotate_exec(BMesh *bm, BMOperator *op); -void bmo_regionextend_exec(BMesh *bm, BMOperator *op); -void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op); -void bmo_vertexsmooth_exec(BMesh *bm, BMOperator *op); -void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op); -void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op); -void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op); +void bmo_object_load_bmesh_exec(BMesh *bm, BMOperator *op); void bmo_pointmerge_exec(BMesh *bm, BMOperator *op); -void bmo_collapse_exec(BMesh *bm, BMOperator *op); -void bmo_similarfaces_exec(BMesh *bm, BMOperator *op); -void bmo_similaredges_exec(BMesh *bm, BMOperator *op); -void bmo_similarverts_exec(BMesh *bm, BMOperator *op); void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op); -void bmo_vert_average_facedata_exec(BMesh *bm, BMOperator *op); -void bmo_face_rotateuvs_exec(BMesh *bm, BMOperator *op); -void bmo_object_load_bmesh_exec(BMesh *bm, BMOperator *op); -void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op); -void bmo_edgenet_prepare(BMesh *bm, BMOperator *op); -void bmo_rotatecolors_exec(BMesh *bm, BMOperator *op); -void bmo_face_reversecolors_exec(BMesh *bm, BMOperator *op); -void bmo_vertexshortestpath_exec(BMesh *bm, BMOperator *op); +void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op); +void bmo_region_extend_exec(BMesh *bm, BMOperator *op); +void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op); +void bmo_reverse_colors_exec(BMesh *bm, BMOperator *op); +void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op); +void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op); void bmo_scale_exec(BMesh *bm, BMOperator *op); -void bmo_edgesplit_exec(BMesh *bm, BMOperator *op); -void bmo_automerge_exec(BMesh *bm, BMOperator *op); -void bmo_create_cone_exec(BMesh *bm, BMOperator *op); -void bmo_create_monkey_exec(BMesh *bm, BMOperator *op); -void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op); -void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op); -void bmo_create_grid_exec(BMesh *bm, BMOperator *op); -void bmo_create_cube_exec(BMesh *bm, BMOperator *op); -void bmo_join_triangles_exec(BMesh *bm, BMOperator *op); -void bmo_bevel_exec(BMesh *bm, BMOperator *op); -void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op); -void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op); -void bmo_create_circle_exec(BMesh *bm, BMOperator *op); -void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op); +void bmo_shortest_path_exec(BMesh *bm, BMOperator *op); +void bmo_similar_edges_exec(BMesh *bm, BMOperator *op); +void bmo_similar_faces_exec(BMesh *bm, BMOperator *op); +void bmo_similar_verts_exec(BMesh *bm, BMOperator *op); +void bmo_slide_vert_exec(BMesh *bm, BMOperator *op); +void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op); void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op); -void bmo_inset_exec(BMesh *bm, BMOperator *op); +void bmo_spin_exec(BMesh *bm, BMOperator *op); +void bmo_split_edges_exec(BMesh *bm, BMOperator *op); +void bmo_split_exec(BMesh *bm, BMOperator *op); +void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op); +void bmo_transform_exec(BMesh *bm, BMOperator *op); +void bmo_translate_exec(BMesh *bm, BMOperator *op); +void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op); +void bmo_triangulate_exec(BMesh *bm, BMOperator *op); +void bmo_weld_verts_exec(BMesh *bm, BMOperator *op); void bmo_wireframe_exec(BMesh *bm, BMOperator *op); -void bmo_convex_hull_exec(BMesh *bm, BMOperator *op); #endif /* __BMESH_OPERATORS_PRIVATE_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 72eb4cb89e9..094b5af9a00 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -642,7 +642,7 @@ static int bm_face_goodline(float const (*projectverts)[3], BMFace *f, //if (linecrossesf(pv1, pv2, v1, v3)) return FALSE; if (isect_point_tri_v2(pv1, v1, v2, v3) || - isect_point_tri_v2(pv1, v3, v2, v1)) + isect_point_tri_v2(pv2, v3, v2, v1)) { return FALSE; } @@ -658,18 +658,22 @@ static int bm_face_goodline(float const (*projectverts)[3], BMFace *f, * of a polygon while tessellating. * * \param use_beauty Currently only applies to quads, can be extended later on. + * \param abscoss Must be allocated by caller, and at least f->len length + * (allow to avoid allocating a new one for each tri!). */ -static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int use_beauty) +static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int use_beauty, float *abscoss) { BMLoop *bestear = NULL; BMLoop *l_iter; BMLoop *l_first; + const float cos_threshold = 0.9f; + if (f->len == 4) { BMLoop *larr[4]; - int i = 0; - + int i = 0, i4; + float cos1, cos2; l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { larr[i] = l_iter; @@ -677,17 +681,64 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int } while ((l_iter = l_iter->next) != l_first); /* pick 0/1 based on best lenth */ - bestear = larr[(((len_squared_v3v3(larr[0]->v->co, larr[2]->v->co) > - len_squared_v3v3(larr[1]->v->co, larr[3]->v->co))) != use_beauty)]; + /* XXX Can't only rely on such test, also must check we do not get (too much) degenerated triangles!!! */ + i = (((len_squared_v3v3(larr[0]->v->co, larr[2]->v->co) > + len_squared_v3v3(larr[1]->v->co, larr[3]->v->co))) != use_beauty); + i4 = (i + 3) % 4; + /* Check produced tris aren’t too flat/narrow... + * Probably not the best test, but is quite efficient and should at least avoid null-area faces! */ + cos1 = fabsf(cos_v3v3v3(larr[i4]->v->co, larr[i]->v->co, larr[i + 1]->v->co)); + cos2 = fabsf(cos_v3v3v3(larr[i4]->v->co, larr[i + 2]->v->co, larr[i + 1]->v->co)); +#if 0 + printf("%d, (%f, %f), (%f, %f)\n", i, cos1, cos2, + fabsf(cos_v3v3v3(larr[i]->v->co, larr[i4]->v->co, larr[i + 2]->v->co)), + fabsf(cos_v3v3v3(larr[i]->v->co, larr[i + 1]->v->co, larr[i + 2]->v->co))); +#endif + if (cos1 < cos2) + cos1 = cos2; + if (cos1 > cos_threshold) { + if (cos1 > fabsf(cos_v3v3v3(larr[i]->v->co, larr[i4]->v->co, larr[i + 2]->v->co)) && + cos1 > fabsf(cos_v3v3v3(larr[i]->v->co, larr[i + 1]->v->co, larr[i + 2]->v->co))) + { + i = !i; + } + } + /* Last check we do not get overlapping triangles + * (as much as possible, ther are some cases with no good solution!) */ + i4 = (i + 3) % 4; + if (!bm_face_goodline((float const (*)[3])verts, f, BM_elem_index_get(larr[i4]->v), BM_elem_index_get(larr[i]->v), + BM_elem_index_get(larr[i + 1]->v), nvert)) + { + i = !i; + } +/* printf("%d\n", i);*/ + bestear = larr[i]; } else { BMVert *v1, *v2, *v3; /* float angle, bestangle = 180.0f; */ - int isear /*, i = 0 */; + float cos, tcos, bestcos = 1.0f; + float *tcoss; + int isear, i = 0, j, len; + /* Compute cos of all corners! */ l_iter = l_first = BM_FACE_FIRST_LOOP(f); + len = l_iter->f->len; + tcoss = abscoss; + do { + v1 = l_iter->prev->v; + v2 = l_iter->v; + v3 = l_iter->next->v; + + *tcoss = fabsf(cos_v3v3v3(v1->co, v2->co, v3->co)); +/* printf("tcoss: %f\n", *tcoss);*/ + tcoss++; + } while ((l_iter = l_iter->next) != l_first); + + l_iter = l_first; + tcoss = abscoss; do { isear = TRUE; @@ -695,6 +746,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int v2 = l_iter->v; v3 = l_iter->next->v; + /* We may have already internal edges... */ if (BM_edge_exists(v1, v3)) { isear = FALSE; } @@ -706,7 +758,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int } if (isear) { - #if 0 +#if 0 /* Old, already commented code */ /* if this code comes back, it needs to be converted to radians */ angle = angle_v3v3v3(verts[v1->head.eflag2], verts[v2->head.eflag2], verts[v3->head.eflag2]); if (!bestear || ABS(angle - 45.0f) < bestangle) { @@ -717,11 +769,46 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int if (angle > 20 && angle < 90) break; if (angle < 100 && i > 5) break; i += 1; - #endif +#endif - bestear = l_iter; - break; + /* Compute highest cos (i.e. narrowest angle) of this tri. */ + cos = *tcoss; + tcos = fabsf(cos_v3v3v3(v2->co, v3->co, v1->co)); + if (tcos > cos) + cos = tcos; + tcos = fabsf(cos_v3v3v3(v3->co, v1->co, v2->co)); + if (tcos > cos) + cos = tcos; + + /* Compare to prev best (i.e. lowest) cos. */ + if (cos < bestcos) { + /* We must check this tri would not leave a (too much) degenerated remaining face! */ + /* For now just assume if the average of cos of all "remaining face"'s corners is below a given threshold, it’s OK. */ + float avgcos = fabsf(cos_v3v3v3(v1->co, v3->co, l_iter->next->next->v->co)); + const int i_limit = (i - 1 + len) % len; + avgcos += fabsf(cos_v3v3v3(l_iter->prev->prev->v->co, v1->co, v3->co)); + j = (i + 2) % len; + do { + avgcos += abscoss[j]; + } while ((j = (j + 1) % len) != i_limit); + avgcos /= len - 1; + + /* We need a best ear in any case... */ + if (avgcos < cos_threshold || (!bestear && avgcos < 1.0f)) { + /* OKI, keep this ear (corner...) as a potential best one! */ + bestear = l_iter; + bestcos = cos; + } +#if 0 + else + printf("Had a nice tri (higest cos of %f, current bestcos is %f), " + "but average cos of all \"remaining face\"'s corners is too high (%f)!\n", + cos, bestcos, avgcos); +#endif + } } + tcoss++; + i++; } while ((l_iter = l_iter->next) != l_first); } @@ -731,14 +818,20 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int /** * \brief BMESH TRIANGULATE FACE * + * --- Prev description (wasn’t correct, ear clipping was currently simply picking the first tri in the loop!) * Triangulates a face using a simple 'ear clipping' algorithm that tries to * favor non-skinny triangles (angles less than 90 degrees). * * If the triangulator has bits left over (or cannot triangulate at all) * it uses a simple fan triangulation, + * --- End of prev description + * + * Currently tries to repeatedly find the best triangle (i.e. the most "open" one), provided it does not + * produces a "remaining" face with too much wide/narrow angles + * (using cos (i.e. dot product of normalized vectors) of angles). * * newfaces, if non-null, must be an array of BMFace pointers, - * with a length equal to f->len. it will be filled with the new + * with a length equal to f->len. It will be filled with the new * triangles, and will be NULL-terminated. * * \note newedgeflag sets a flag layer flag, obviously not the header flag. @@ -748,10 +841,11 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], const short use_beauty) { int i, done, nvert, nf_i = 0; - BMLoop *newl, *nextloop; + BMLoop *newl; BMLoop *l_iter; BMLoop *l_first; - /* BMVert *v; */ /* UNUSED */ + float *abscoss = NULL; + BLI_array_fixedstack_declare(abscoss, 16, f->len, "BM_face_triangulate: temp absolute cosines of face corners"); /* copy vertex coordinates to vertspace arra */ i = 0; @@ -764,14 +858,14 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], bm->elem_index_dirty |= BM_VERT; /* see above */ - ///bmesh_face_normal_update(bm, f, f->no, projectverts); + /* bmesh_face_normal_update(bm, f, f->no, projectverts); */ calc_poly_normal(f->no, projectverts, f->len); poly_rotate_plane(f->no, projectverts, i); nvert = f->len; - //calc_poly_plane(projectverts, i); + /* calc_poly_plane(projectverts, i); */ for (i = 0; i < nvert; i++) { projectverts[i][2] = 0.0f; } @@ -779,10 +873,10 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], done = FALSE; while (!done && f->len > 3) { done = TRUE; - l_iter = find_ear(f, projectverts, nvert, use_beauty); + l_iter = find_ear(f, projectverts, nvert, use_beauty, abscoss); if (l_iter) { done = FALSE; - /* v = l->v; */ /* UNUSED */ +/* printf("Subdividing face...\n");*/ f = BM_face_split(bm, l_iter->f, l_iter->prev->v, l_iter->next->v, &newl, NULL, TRUE); @@ -812,6 +906,7 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], } } +#if 0 /* XXX find_ear should now always return a corner, so no more need for this piece of code... */ if (f->len > 3) { l_iter = BM_FACE_FIRST_LOOP(f); while (l_iter->f->len > 3) { @@ -833,7 +928,10 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], l_iter = nextloop; } } - +#endif + + BLI_array_fixedstack_free(abscoss); + /* NULL-terminate */ if (newfaces) newfaces[nf_i] = NULL; } diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 3ec4c51bcb1..b6a56e64dcf 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -190,6 +190,22 @@ BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v) } /** + * Get the first loop of a vert. Uses the same initialization code for the first loop of the + * iterator API + */ + +BMLoop *BM_vert_find_first_loop(BMVert *v) +{ + BMEdge *e; + + if(!v || !v->e) + return NULL; + + e = bmesh_disk_faceedge_find_first(v->e, v); + return bmesh_radial_faceloop_find_first(e->l, v); +} + +/** * Returns TRUE if the vertex is used in a given face. */ diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index 2df5adcfae3..36ffc296759 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -42,6 +42,7 @@ BMVert *BM_edge_other_vert(BMEdge *e, BMVert *v); BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v); BMLoop *BM_face_other_vert_loop(BMFace *f, BMVert *v_prev, BMVert *v); BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v); +BMLoop *BM_vert_find_first_loop(BMVert *v); int BM_vert_edge_count_nonwire(BMVert *v); int BM_vert_edge_count(BMVert *v); diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index f02b88c5b05..0b036c6ff2b 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -865,7 +865,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) } #endif - BMO_op_callf(bm, "del geom=%fv context=%i", BEVEL_DEL, DEL_VERTS); + BMO_op_callf(bm, "delete geom=%fv context=%i", BEVEL_DEL, DEL_VERTS); /* clean up any edges that might not get properly delete */ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { @@ -873,8 +873,8 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_enable(bm, e, BEVEL_DEL); } - BMO_op_callf(bm, "del geom=%fe context=%i", BEVEL_DEL, DEL_EDGES); - BMO_op_callf(bm, "del geom=%ff context=%i", BEVEL_DEL, DEL_FACES); + BMO_op_callf(bm, "delete geom=%fe context=%i", BEVEL_DEL, DEL_EDGES); + BMO_op_callf(bm, "delete geom=%ff context=%i", BEVEL_DEL, DEL_FACES); BLI_smallhash_release(&hash); BLI_array_free(tags); diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index 653bbaf8602..7418be3565c 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -40,7 +40,7 @@ #define EDGE_MARK 4 #define EDGE_DONE 8 -void bmo_connectverts_exec(BMesh *bm, BMOperator *op) +void bmo_connect_verts_exec(BMesh *bm, BMOperator *op) { BMIter iter, liter; BMFace *f, *nf; diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 1451625d3bb..8e69696f771 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -164,7 +164,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op) } - BMO_op_callf(bm, "del geom=%ff context=%i", FACE_ORIG, DEL_FACES); + BMO_op_callf(bm, "delete geom=%ff context=%i", FACE_ORIG, DEL_FACES); if (use_verts) { diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index 6e6037239b9..1421ae294bc 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -314,7 +314,7 @@ static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) * BMOP_DUPE_FNEW: Buffer containing pointers to the new mesh faces */ -void bmo_dupe_exec(BMesh *bm, BMOperator *op) +void bmo_duplicate_exec(BMesh *bm, BMOperator *op) { BMOperator *dupeop = op; BMesh *bm2 = BMO_slot_ptr_get(op, "dest"); @@ -345,7 +345,7 @@ void BMO_dupe_from_flag(BMesh *bm, int htype, const char hflag) { BMOperator dupeop; - BMO_op_init(bm, &dupeop, "dupe"); + BMO_op_init(bm, &dupeop, "duplicate"); BMO_slot_buffer_from_enabled_hflag(bm, &dupeop, "geom", htype, hflag); BMO_op_exec(bm, &dupeop); @@ -381,8 +381,8 @@ void bmo_split_exec(BMesh *bm, BMOperator *op) const short use_only_faces = BMO_slot_bool_get(op, "use_only_faces"); /* initialize our sub-operator */ - BMO_op_init(bm, &dupeop, "dupe"); - BMO_op_init(bm, &delop, "del"); + BMO_op_init(bm, &dupeop, "duplicate"); + BMO_op_init(bm, &delop, "delete"); BMO_slot_copy(splitop, &dupeop, "geom", "geom"); BMO_op_exec(bm, &dupeop); @@ -443,7 +443,7 @@ void bmo_split_exec(BMesh *bm, BMOperator *op) } -void bmo_del_exec(BMesh *bm, BMOperator *op) +void bmo_delete_exec(BMesh *bm, BMOperator *op) { #define DEL_INPUT 1 @@ -487,7 +487,7 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op) BMO_slot_copy(op, op, "geom", "lastout"); for (a = 0; a < steps; a++) { if (do_dupli) { - BMO_op_initf(bm, &dupop, "dupe geom=%s", op, "lastout"); + BMO_op_initf(bm, &dupop, "duplicate geom=%s", op, "lastout"); BMO_op_exec(bm, &dupop); BMO_op_callf(bm, "rotate cent=%v mat=%m3 verts=%s", cent, rmat, &dupop, "newout"); diff --git a/source/blender/bmesh/operators/bmo_edgesplit.c b/source/blender/bmesh/operators/bmo_edgesplit.c index ccbcb293915..1f6689ed06c 100644 --- a/source/blender/bmesh/operators/bmo_edgesplit.c +++ b/source/blender/bmesh/operators/bmo_edgesplit.c @@ -100,7 +100,7 @@ static void bm_edgesplit_validate_seams(BMesh *bm, BMOperator *op) } /* keep this operator fast, its used in a modifier */ -void bmo_edgesplit_exec(BMesh *bm, BMOperator *op) +void bmo_split_edges_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMEdge *e; diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 09b79376ff6..b8993b41caf 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -49,7 +49,7 @@ enum { #define VERT_NONMAN 2 #define EDGE_NONMAN 2 -void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op) +void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMIter liter, liter2; @@ -118,7 +118,7 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op) BLI_array_free(edges); - BMO_op_callf(bm, "del geom=%ff context=%i", EXT_DEL, DEL_ONLYFACES); + BMO_op_callf(bm, "delete geom=%ff context=%i", EXT_DEL, DEL_ONLYFACES); BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, EXT_KEEP); } @@ -172,7 +172,7 @@ static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f, BMEdge *e } /* Disable the skin root flag on the input vert, assumes that the vert - data includes an CD_MVERT_SKIN layer */ + * data includes an CD_MVERT_SKIN layer */ static void bm_extrude_disable_skin_root(BMesh *bm, BMVert *v) { MVertSkin *vs; @@ -195,7 +195,7 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_enable(bm, e->v2, EXT_INPUT); } - BMO_op_initf(bm, &dupeop, "dupe geom=%fve", EXT_INPUT); + BMO_op_initf(bm, &dupeop, "duplicate geom=%fve", EXT_INPUT); BMO_op_exec(bm, &dupeop); /* disable root flag on all new skin nodes */ @@ -273,7 +273,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) int found, fwd, delorig = FALSE; /* initialize our sub-operators */ - BMO_op_init(bm, &dupeop, "dupe"); + BMO_op_init(bm, &dupeop, "duplicate"); BMO_slot_buffer_flag_enable(bm, op, "edgefacein", BM_EDGE | BM_FACE, EXT_INPUT); @@ -341,7 +341,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) } if (delorig == TRUE) { - BMO_op_initf(bm, &delop, "del geom=%fvef context=%i", + BMO_op_initf(bm, &delop, "delete geom=%fvef context=%i", EXT_DEL, DEL_ONLYTAGGED); } @@ -647,7 +647,7 @@ void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op) thickness = BMO_slot_float_get(op, "thickness"); /* Flip original faces (so the shell is extruded inward) */ - BMO_op_init(bm, &reverseop, "reversefaces"); + BMO_op_init(bm, &reverseop, "reverse_faces"); BMO_slot_copy(op, &reverseop, "geom", "faces"); BMO_op_exec(bm, &reverseop); BMO_op_finish(bm, &reverseop); diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index 160db7cba75..1bd2f41209b 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -140,11 +140,14 @@ static void hull_add_triangle(BMesh *bm, GHash *hull_triangles, BLI_mempool *poo static int hull_point_tri_side(const HullTriangle *t, const float co[3]) { - float p[3], d; + /* Added epsilon to fix bug [#31941], improves output when some + * vertices are nearly coplanar. Might need further tweaking for + * other cases though. */ + float p[3], d, epsilon = 0.0001; sub_v3_v3v3(p, co, t->v[0]->co); d = dot_v3v3(t->no, p); - if (d < 0) return -1; - else if (d > 0) return 1; + if (d < -epsilon) return -1; + else if (d > epsilon) return 1; else return 0; } diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c index 53c51dfd483..1ab439b38bb 100644 --- a/source/blender/bmesh/operators/bmo_mirror.c +++ b/source/blender/bmesh/operators/bmo_mirror.c @@ -62,7 +62,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) BMO_slot_mat4_get(op, "mat", mtx); invert_m4_m4(imtx, mtx); - BMO_op_initf(bm, &dupeop, "dupe geom=%s", op, "geom"); + BMO_op_initf(bm, &dupeop, "duplicate geom=%s", op, "geom"); BMO_op_exec(bm, &dupeop); BMO_slot_buffer_flag_enable(bm, &dupeop, "newout", BM_ALL, ELE_NEW); @@ -84,7 +84,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) BMO_op_callf(bm, "scale verts=%fv vec=%v", ELE_NEW, scale); BMO_op_callf(bm, "transform verts=%fv mat=%m4", ELE_NEW, imtx); - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); for (i = 0; i < ototvert; i++) { diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c index 08cd3835b2d..d59a90ba3a1 100644 --- a/source/blender/bmesh/operators/bmo_primitive.c +++ b/source/blender/bmesh/operators/bmo_primitive.c @@ -365,7 +365,7 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op) len2 = len_v3v3(vec, vec2); /* use shortest segment length divided by 3 as merge threshold */ - BMO_op_callf(bm, "removedoubles verts=%fv dist=%f", VERT_MARK, MIN2(len, len2) / 3.0f); + BMO_op_callf(bm, "remove_doubles verts=%fv dist=%f", VERT_MARK, MIN2(len, len2) / 3.0f); } /* and now do imat */ @@ -427,7 +427,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op) BMOperator bmop; BMO_op_initf(bm, &bmop, - "esubd edges=%fe " + "subdivide_edges edges=%fe " "smooth=%f " "numcuts=%i " "use_gridfill=%b use_sphere=%b", @@ -661,7 +661,7 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op) BM_face_create_quad_tri(bm, v1, v2, firstv2, firstv1, NULL, FALSE); - BMO_op_callf(bm, "removedoubles verts=%fv dist=%f", VERT_MARK, 0.000001); + BMO_op_callf(bm, "remove_doubles verts=%fv dist=%f", VERT_MARK, 0.000001); BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); } diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index 52c693efc84..b3c348a330c 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -96,7 +96,7 @@ int remdoubles_face_overlaps(BMesh *bm, BMVert **varr, } #endif -void bmo_weldverts_exec(BMesh *bm, BMOperator *op) +void bmo_weld_verts_exec(BMesh *bm, BMOperator *op) { BMIter iter, liter; BMVert *v, *v2; @@ -227,7 +227,7 @@ void bmo_weldverts_exec(BMesh *bm, BMOperator *op) } } - BMO_op_callf(bm, "del geom=%fvef context=%i", ELE_DEL, DEL_ONLYTAGGED); + BMO_op_callf(bm, "delete geom=%fvef context=%i", ELE_DEL, DEL_ONLYTAGGED); BLI_array_free(edges); BLI_array_free(loops); @@ -301,7 +301,7 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op) } } -void bmo_vert_average_facedata_exec(BMesh *bm, BMOperator *op) +void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMIter iter; @@ -345,10 +345,10 @@ void bmo_pointmerge_exec(BMesh *bm, BMOperator *op) BMVert *v, *snapv = NULL; float vec[3]; - BMO_slot_vec_get(op, "mergeco", vec); + BMO_slot_vec_get(op, "merge_co", vec); //BMO_op_callf(bm, "collapse_uvs edges=%s", op, "edges"); - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { if (!snapv) { @@ -375,7 +375,7 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op) int i, tot; BMO_op_callf(bm, "collapse_uvs edges=%s", op, "edges"); - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK); @@ -487,7 +487,7 @@ void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op) } } -void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname) +void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname) { BMOIter oiter; BMVert *v, *v2; @@ -505,17 +505,17 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c verts[i++] = v; } - /* Test whether keepverts arg exists and is non-empty */ - if (BMO_slot_exists(op, "keepverts")) { - keepvert = BMO_iter_new(&oiter, bm, op, "keepverts", BM_VERT) != NULL; + /* Test whether keep_verts arg exists and is non-empty */ + if (BMO_slot_exists(op, "keep_verts")) { + keepvert = BMO_iter_new(&oiter, bm, op, "keep_verts", BM_VERT) != NULL; } /* sort by vertex coordinates added together */ qsort(verts, BLI_array_count(verts), sizeof(void *), vergaverco); - /* Flag keepverts */ + /* Flag keep_verts */ if (keepvert) { - BMO_slot_buffer_flag_enable(bm, op, "keepverts", BM_VERT, VERT_KEEP); + BMO_slot_buffer_flag_enable(bm, op, "keep_verts", BM_VERT, VERT_KEEP); } len = BLI_array_count(verts); @@ -557,20 +557,20 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c BLI_array_free(verts); } -void bmo_removedoubles_exec(BMesh *bm, BMOperator *op) +void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op) { BMOperator weldop; - BMO_op_init(bm, &weldop, "weldverts"); - bmesh_finddoubles_common(bm, op, &weldop, "targetmap"); + BMO_op_init(bm, &weldop, "weld_verts"); + bmesh_find_doubles_common(bm, op, &weldop, "targetmap"); BMO_op_exec(bm, &weldop); BMO_op_finish(bm, &weldop); } -void bmo_finddoubles_exec(BMesh *bm, BMOperator *op) +void bmo_find_doubles_exec(BMesh *bm, BMOperator *op) { - bmesh_finddoubles_common(bm, op, op, "targetmapout"); + bmesh_find_doubles_common(bm, op, op, "targetmapout"); } void bmo_automerge_exec(BMesh *bm, BMOperator *op) @@ -591,12 +591,12 @@ void bmo_automerge_exec(BMesh *bm, BMOperator *op) /* Search for doubles among all vertices, but only merge non-VERT_KEEP * vertices into VERT_KEEP vertices. */ - BMO_op_initf(bm, &findop, "finddoubles verts=%av keepverts=%fv", VERT_KEEP); + BMO_op_initf(bm, &findop, "find_doubles verts=%av keep_verts=%fv", VERT_KEEP); BMO_slot_copy(op, &findop, "dist", "dist"); BMO_op_exec(bm, &findop); /* weld the vertices */ - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); BMO_slot_copy(&findop, &weldop, "targetmapout", "targetmap"); BMO_op_exec(bm, &weldop); diff --git a/source/blender/bmesh/operators/bmo_slide.c b/source/blender/bmesh/operators/bmo_slide.c index 238cc5ac66f..0036f095d00 100644 --- a/source/blender/bmesh/operators/bmo_slide.c +++ b/source/blender/bmesh/operators/bmo_slide.c @@ -40,7 +40,7 @@ * Slides a vertex along a connected edge * */ -void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op) +void bmo_slide_vert_exec(BMesh *bm, BMOperator *op) { BMOIter oiter; BMIter iter; @@ -61,7 +61,7 @@ void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op) if (!vertex) { if (G.debug & G_DEBUG) { - fprintf(stderr, "vertex_slide: No vertex selected..."); + fprintf(stderr, "slide_vert: No vertex selected..."); } BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide Error: Invalid selection."); return; @@ -81,7 +81,7 @@ void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op) /* Only allow sliding if an edge is selected */ if (selected_edges == 0) { if (G.debug & G_DEBUG) { - fprintf(stderr, "vertex_slide: select a single edge\n"); + fprintf(stderr, "slide_vert: select a single edge\n"); } BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide Error: Invalid selection."); return; diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index 03a691e3e9c..ee3e34c527f 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -672,7 +672,7 @@ typedef struct SubDFaceData { BMFace *face; } SubDFaceData; -void bmo_esubd_exec(BMesh *bm, BMOperator *op) +void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) { BMOpSlot *einput; SubDPattern *pat; @@ -1038,7 +1038,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, /* use_sphere isnt exposed here since its only used for new primitives */ BMO_op_initf(bm, &op, - "esubd edges=%he " + "subdivide_edges edges=%he " "smooth=%f fractal=%f along_normal=%f " "numcuts=%i " "quadcornertype=%i " @@ -1096,7 +1096,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, BMO_op_finish(bm, &op); } -void bmo_edgebisect_exec(BMesh *bm, BMOperator *op) +void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMEdge *e; diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index b076d835ea1..f47781241e8 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -41,7 +41,7 @@ #include "intern/bmesh_operators_private.h" /* own include */ -void bmo_makevert_exec(BMesh *bm, BMOperator *op) +void bmo_create_vert_exec(BMesh *bm, BMOperator *op) { float vec[3]; @@ -108,7 +108,7 @@ void bmo_rotate_exec(BMesh *bm, BMOperator *op) BMO_op_callf(bm, "translate verts=%s vec=%v", op, "verts", vec); } -void bmo_reversefaces_exec(BMesh *bm, BMOperator *op) +void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMFace *f; @@ -118,7 +118,7 @@ void bmo_reversefaces_exec(BMesh *bm, BMOperator *op) } } -void bmo_edgerotate_exec(BMesh *bm, BMOperator *op) +void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMEdge *e, *e2; @@ -172,7 +172,7 @@ void bmo_edgerotate_exec(BMesh *bm, BMOperator *op) #define SEL_FLAG 1 #define SEL_ORIG 2 -static void bmo_regionextend_extend(BMesh *bm, BMOperator *op, int usefaces) +static void bmo_region_extend_extend(BMesh *bm, BMOperator *op, int usefaces) { BMVert *v; BMEdge *e; @@ -211,7 +211,7 @@ static void bmo_regionextend_extend(BMesh *bm, BMOperator *op, int usefaces) } } -static void bmo_regionextend_constrict(BMesh *bm, BMOperator *op, int usefaces) +static void bmo_region_extend_constrict(BMesh *bm, BMOperator *op, int usefaces) { BMVert *v; BMEdge *e; @@ -253,7 +253,7 @@ static void bmo_regionextend_constrict(BMesh *bm, BMOperator *op, int usefaces) } } -void bmo_regionextend_exec(BMesh *bm, BMOperator *op) +void bmo_region_extend_exec(BMesh *bm, BMOperator *op) { int use_faces = BMO_slot_bool_get(op, "use_faces"); int constrict = BMO_slot_bool_get(op, "constrict"); @@ -261,9 +261,9 @@ void bmo_regionextend_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_flag_enable(bm, op, "geom", BM_ALL, SEL_ORIG); if (constrict) - bmo_regionextend_constrict(bm, op, use_faces); + bmo_region_extend_constrict(bm, op, use_faces); else - bmo_regionextend_extend(bm, op, use_faces); + bmo_region_extend_extend(bm, op, use_faces); BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, SEL_FLAG); } @@ -275,7 +275,7 @@ void bmo_regionextend_exec(BMesh *bm, BMOperator *op) #define FACE_MARK 4 #define FACE_FLIP 8 -/* NOTE: these are the original righthandfaces comment in editmesh_mods.c, +/* NOTE: these are the original recalc_face_normals comment in editmesh_mods.c, * copied here for reference. */ /* based at a select-connected to witness loose objects */ @@ -296,7 +296,7 @@ void bmo_regionextend_exec(BMesh *bm, BMOperator *op) /* NOTE: BM_ELEM_TAG is used on faces to tell if they are flipped. */ -void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op) +void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op) { BMIter liter, liter2; BMOIter siter; @@ -397,13 +397,13 @@ void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op) /* check if we have faces yet to do. if so, recurse */ BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) { if (!BMO_elem_flag_test(bm, f, FACE_VIS)) { - bmo_righthandfaces_exec(bm, op); + bmo_recalc_face_normals_exec(bm, op); break; } } } -void bmo_vertexsmooth_exec(BMesh *bm, BMOperator *op) +void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMIter iter; @@ -511,7 +511,7 @@ typedef struct SimSel_FaceExt { * Select similar faces, the choices are in the enum in source/blender/bmesh/bmesh_operators.h * We select either similar faces based on material, image, area, perimeter, normal, or the coplanar faces */ -void bmo_similarfaces_exec(BMesh *bm, BMOperator *op) +void bmo_similar_faces_exec(BMesh *bm, BMOperator *op) { BMIter fm_iter; BMFace *fs, *fm; @@ -691,7 +691,7 @@ typedef struct SimSel_EdgeExt { * select similar edges: the choices are in the enum in source/blender/bmesh/bmesh_operators.h * choices are length, direction, face, ... */ -void bmo_similaredges_exec(BMesh *bm, BMOperator *op) +void bmo_similar_edges_exec(BMesh *bm, BMOperator *op) { BMOIter es_iter; /* selected edges iterator */ BMIter e_iter; /* mesh edges iterator */ @@ -896,7 +896,7 @@ typedef struct SimSel_VertExt { * select similar vertices: the choices are in the enum in source/blender/bmesh/bmesh_operators.h * choices are normal, face, vertex group... */ -void bmo_similarverts_exec(BMesh *bm, BMOperator *op) +void bmo_similar_verts_exec(BMesh *bm, BMOperator *op) { BMOIter vs_iter; /* selected verts iterator */ BMIter v_iter; /* mesh verts iterator */ @@ -1010,7 +1010,7 @@ void bmo_similarverts_exec(BMesh *bm, BMOperator *op) * Cycle UVs for a face **************************************************************************** */ -void bmo_face_rotateuvs_exec(BMesh *bm, BMOperator *op) +void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1077,7 +1077,7 @@ void bmo_face_rotateuvs_exec(BMesh *bm, BMOperator *op) * Reverse UVs for a face **************************************************************************** */ -void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op) +void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1117,7 +1117,7 @@ void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op) * Cycle colors for a face **************************************************************************** */ -void bmo_rotatecolors_exec(BMesh *bm, BMOperator *op) +void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1183,7 +1183,7 @@ void bmo_rotatecolors_exec(BMesh *bm, BMOperator *op) * Reverse colors for a face *************************************************************************** */ -void bmo_face_reversecolors_exec(BMesh *bm, BMOperator *op) +void bmo_reverse_colors_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1227,7 +1227,7 @@ typedef struct ElemNode { HeapNode *hn; /* heap node */ } ElemNode; -void bmo_vertexshortestpath_exec(BMesh *bm, BMOperator *op) +void bmo_shortest_path_exec(BMesh *bm, BMOperator *op) { BMOIter vs_iter /* , vs2_iter */; /* selected verts iterator */ BMIter v_iter; /* mesh verts iterator */ |