diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-19 18:58:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-19 18:58:31 +0400 |
commit | 48639af5f89e08e81cd68fce0a7138007d4ebe1d (patch) | |
tree | 54df28f67a3222efed63e145b06f8773dc2165ed /source/blender/bmesh/intern | |
parent | 312abf8cb236b72e3e20ce8850da7448897f6aa9 (diff) |
use input and output slots for bmesh operators, needed for the python api to get return values.
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 461 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operator_api.h | 115 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operator_api_inline.h | 35 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.c | 364 |
4 files changed, 612 insertions, 363 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 1700e5c47fd..539682454ea 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -109,6 +109,7 @@ static BMOpDefine bmo_smooth_vert_def = { {BMO_OP_SLOT_BOOL, "use_axis_z"}, /* smooth vertices along Z axis */ {0} /* null-terminating sentinel */, }, + {{0}}, /* no output */ bmo_smooth_vert_exec, 0 }; @@ -129,6 +130,7 @@ static BMOpDefine bmo_smooth_laplacian_vert_def = { {BMO_OP_SLOT_BOOL, "volume_preservation"}, //Apply volume preservation after smooth {0} /* null-terminating sentinel */, }, + {{0}}, /* no output */ bmo_smooth_laplacian_vert_exec, 0 }; @@ -145,6 +147,7 @@ static BMOpDefine bmo_recalc_face_normals_def = { {BMO_OP_SLOT_BOOL, "do_flip"}, /* internal flag, used by bmesh_rationalize_normals */ {0} /* null-terminating sentinel */, }, + {{0}}, /* no output */ bmo_recalc_face_normals_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -162,11 +165,13 @@ static BMOpDefine bmo_recalc_face_normals_def = { 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_OP_SLOT_ELEMENT_BUF, "geomout"}, /* output slot, computed boundary geometry. */ + {0} /* null-terminating sentinel */, + }, bmo_region_extend_exec, 0 }; @@ -180,10 +185,12 @@ static BMOpDefine bmo_region_extend_def = { 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_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* newly spun edges */ + {0} /* null-terminating sentinel */, + }, bmo_rotate_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -199,6 +206,7 @@ static BMOpDefine bmo_reverse_faces_def = { {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {0} /* null-terminating sentinel */, }, + {{0}}, /* no output */ bmo_reverse_faces_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -213,7 +221,9 @@ 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_OP_SLOT_ELEMENT_BUF, "splitout"}, /* newly created vertices and edges */ {0} /* null-terminating sentinel */, }, bmo_bisect_edges_exec, @@ -233,11 +243,14 @@ static BMOpDefine bmo_mirror_def = { {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */ {BMO_OP_SLOT_MAT, "mat"}, /* matrix defining the mirror transformation */ {BMO_OP_SLOT_FLT, "mergedist"}, /* maximum distance for merging. does no merging if 0. */ - {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, /* output geometry, mirrored */ {BMO_OP_SLOT_INT, "axis"}, /* the axis to use, 0, 1, or 2 for x, y, z */ {BMO_OP_SLOT_BOOL, "mirror_u"}, /* mirror UVs across the u axis */ {BMO_OP_SLOT_BOOL, "mirror_v"}, /* mirror UVs across the v axis */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "newout"}, /* output geometry, mirrored */ + {0} /* null-terminating sentinel */, + }, bmo_mirror_exec, 0, }; @@ -256,8 +269,11 @@ static BMOpDefine bmo_find_doubles_def = { {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {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 */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_MAPPING, "targetmapout"}, + {0} /* null-terminating sentinel */, + }, bmo_find_doubles_exec, 0, }; @@ -272,7 +288,9 @@ 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 */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_remove_doubles_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -288,7 +306,9 @@ static BMOpDefine bmo_automerge_def = { "automerge", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input verts */ {BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_automerge_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -301,7 +321,9 @@ static BMOpDefine bmo_automerge_def = { static BMOpDefine bmo_collapse_def = { "collapse", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_collapse_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -316,7 +338,9 @@ static BMOpDefine bmo_pointmerge_facedata_def = { "pointmerge_facedata", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ {BMO_OP_SLOT_ELEMENT_BUF, "snapv"}, /* snap verte */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_pointmerge_facedata_exec, 0, }; @@ -331,7 +355,9 @@ static BMOpDefine bmo_pointmerge_facedata_def = { static BMOpDefine bmo_average_vert_facedata_def = { "average_vert_facedata", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_average_vert_facedata_exec, 0, }; @@ -345,7 +371,9 @@ static BMOpDefine bmo_pointmerge_def = { "pointmerge", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ {BMO_OP_SLOT_VEC, "merge_co"}, - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_pointmerge_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -358,7 +386,9 @@ static BMOpDefine bmo_pointmerge_def = { static BMOpDefine bmo_collapse_uvs_def = { "collapse_uvs", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_collapse_uvs_exec, 0, }; @@ -373,7 +403,9 @@ static BMOpDefine bmo_collapse_uvs_def = { 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 */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_weld_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -387,8 +419,11 @@ static BMOpDefine bmo_weld_verts_def = { 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 */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "newvertout"}, /* the new vert */ + {0} /* null-terminating sentinel */, + }, bmo_create_vert_exec, 0, }; @@ -402,13 +437,16 @@ static BMOpDefine bmo_create_vert_def = { static BMOpDefine bmo_join_triangles_def = { "join_triangles", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input geometry. */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* joined faces */ {BMO_OP_SLOT_BOOL, "cmp_sharp"}, {BMO_OP_SLOT_BOOL, "cmp_uvs"}, {BMO_OP_SLOT_BOOL, "cmp_vcols"}, {BMO_OP_SLOT_BOOL, "cmp_materials"}, {BMO_OP_SLOT_FLT, "limit"}, - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* joined faces */ + {0} /* null-terminating sentinel */, + }, bmo_join_triangles_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -427,12 +465,15 @@ static BMOpDefine bmo_join_triangles_def = { static BMOpDefine bmo_contextual_create_def = { "contextual_create", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry. */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* newly-made face(s) */ + {BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */ + {BMO_OP_SLOT_BOOL, "use_smooth"}, /* smooth to use */ + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* newly-made face(s) */ /* note, this is for stand-alone edges only, not edges which are apart of newly created faces */ {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* newly-made edge(s) */ - {BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */ - {BMO_OP_SLOT_BOOL, "use_smooth"}, /* material to use */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, bmo_contextual_create_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -443,10 +484,13 @@ static BMOpDefine bmo_contextual_create_def = { static BMOpDefine bmo_bridge_loops_def = { "bridge_loops", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */ {BMO_OP_SLOT_BOOL, "use_merge"}, {BMO_OP_SLOT_FLT, "merge_factor"}, - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new faces */ + {0} /* null-terminating sentinel */, + }, bmo_bridge_loops_exec, 0, }; @@ -458,11 +502,14 @@ static BMOpDefine bmo_edgenet_fill_def = { {BMO_OP_SLOT_BOOL, "use_restrict"}, {BMO_OP_SLOT_BOOL, "use_fill_check"}, {BMO_OP_SLOT_ELEMENT_BUF, "excludefaces"}, /* list of faces to ignore for manifold check */ - {BMO_OP_SLOT_MAPPING, "faceout_groupmap"}, /* maps new faces to the group numbers they came fro */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */ {BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */ {BMO_OP_SLOT_BOOL, "use_smooth"}, /* material to use */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_MAPPING, "face_groupmap_out"}, /* maps new faces to the group numbers they came fro */ + {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */ + {0} /* null-terminating sentinel */, + }, bmo_edgenet_fill_exec, 0, }; @@ -480,8 +527,11 @@ static BMOpDefine bmo_edgenet_fill_def = { static BMOpDefine bmo_edgenet_prepare_def = { "edgenet_prepare", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* new edges */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* new edges */ + {0} /* null-terminating sentinel */, + }, bmo_edgenet_prepare, 0, }; @@ -497,7 +547,9 @@ static BMOpDefine bmo_rotate_def = { {{BMO_OP_SLOT_VEC, "cent"}, /* center of rotation */ {BMO_OP_SLOT_MAT, "mat"}, /* matrix defining rotation */ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_rotate_exec, 0, }; @@ -512,7 +564,9 @@ static BMOpDefine bmo_translate_def = { "translate", {{BMO_OP_SLOT_VEC, "vec"}, /* translation offset */ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_translate_exec, 0, }; @@ -526,7 +580,9 @@ static BMOpDefine bmo_scale_def = { "scale", {{BMO_OP_SLOT_VEC, "vec"}, /* scale factor */ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_scale_exec, 0, }; @@ -542,7 +598,9 @@ static BMOpDefine bmo_transform_def = { "transform", {{BMO_OP_SLOT_MAT, "mat"}, /* transform matrix */ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_transform_exec, 0, }; @@ -557,7 +615,9 @@ static BMOpDefine bmo_object_load_bmesh_def = { "object_load_bmesh", {{BMO_OP_SLOT_PTR, "scene"}, {BMO_OP_SLOT_PTR, "object"}, - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_object_load_bmesh_exec, 0, }; @@ -573,7 +633,9 @@ static BMOpDefine bmo_bmesh_to_mesh_def = { {{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 */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_bmesh_to_mesh_exec, 0, }; @@ -589,7 +651,9 @@ static BMOpDefine bmo_mesh_to_bmesh_def = { {{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 */}}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_mesh_to_bmesh_exec, 0 }; @@ -602,9 +666,12 @@ static BMOpDefine bmo_mesh_to_bmesh_def = { 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 */ + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ {BMO_OP_SLOT_ELEMENT_BUF, "skirtout"}, /* output skirt geometry, faces and edges */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, bmo_extrude_discrete_faces_exec, 0 }; @@ -618,8 +685,11 @@ static BMOpDefine bmo_extrude_discrete_faces_def = { static BMOpDefine bmo_extrude_edge_only_def = { "extrude_edge_only", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input vertices */ - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* output geometry */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* output geometry */ + {0} /* null-terminating sentinel */, + }, bmo_extrude_edge_only_exec, 0 }; @@ -632,9 +702,12 @@ static BMOpDefine bmo_extrude_edge_only_def = { static BMOpDefine bmo_extrude_vert_indiv_def = { "extrude_vert_indiv", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output wire edges */ + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output wire edges */ {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, bmo_extrude_vert_indiv_exec, 0 }; @@ -642,8 +715,11 @@ static BMOpDefine bmo_extrude_vert_indiv_def = { static BMOpDefine bmo_connect_verts_def = { "connect_verts", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, + {0} /* null-terminating sentinel */, + }, bmo_connect_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -653,8 +729,11 @@ static BMOpDefine bmo_extrude_face_region_def = { {{BMO_OP_SLOT_ELEMENT_BUF, "edgefacein"}, {BMO_OP_SLOT_MAPPING, "exclude"}, {BMO_OP_SLOT_BOOL, "alwayskeeporig"}, - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, + {0} /* null-terminating sentinel */, + }, bmo_extrude_face_region_exec, 0 }; @@ -662,7 +741,9 @@ static BMOpDefine bmo_extrude_face_region_def = { static BMOpDefine bmo_dissolve_verts_def = { "dissolve_verts", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_dissolve_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -670,9 +751,12 @@ static BMOpDefine bmo_dissolve_verts_def = { static BMOpDefine bmo_dissolve_edges_def = { "dissolve_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, - {BMO_OP_SLOT_ELEMENT_BUF, "regionout"}, {BMO_OP_SLOT_BOOL, "use_verts"}, /* dissolve verts left between only 2 edges. */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "regionout"}, + {0} /* null-terminating sentinel */, + }, bmo_dissolve_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -680,8 +764,11 @@ static BMOpDefine bmo_dissolve_edges_def = { static BMOpDefine bmo_dissolve_edge_loop_def = { "dissolve_edge_loop", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, - {BMO_OP_SLOT_ELEMENT_BUF, "regionout"}, - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "regionout"}, + {0} /* null-terminating sentinel */, + }, bmo_dissolve_edgeloop_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -689,9 +776,12 @@ static BMOpDefine bmo_dissolve_edge_loop_def = { static BMOpDefine bmo_dissolve_faces_def = { "dissolve_faces", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, - {BMO_OP_SLOT_ELEMENT_BUF, "regionout"}, {BMO_OP_SLOT_BOOL, "use_verts"}, /* dissolve verts left between only 2 edges. */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "regionout"}, + {0} /* null-terminating sentinel */, + }, bmo_dissolve_faces_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -702,7 +792,9 @@ static BMOpDefine bmo_dissolve_limit_def = { {BMO_OP_SLOT_BOOL, "use_dissolve_boundaries"}, {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, {BMO_OP_SLOT_ELEMENT_BUF, "edges"}, - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_dissolve_limit_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -710,11 +802,14 @@ static BMOpDefine bmo_dissolve_limit_def = { static BMOpDefine bmo_triangulate_def = { "triangulate", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, - {BMO_OP_SLOT_MAPPING, "facemap"}, {BMO_OP_SLOT_BOOL, "use_beauty"}, - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, + {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, + {BMO_OP_SLOT_MAPPING, "facemap_out"}, + {0} /* null-terminating sentinel */, + }, bmo_triangulate_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -723,7 +818,9 @@ static BMOpDefine bmo_unsubdivide_def = { "unsubdivide", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {BMO_OP_SLOT_INT, "iterations"}, - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_unsubdivide_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -739,16 +836,16 @@ static BMOpDefine bmo_subdivide_edges_def = { {BMO_OP_SLOT_MAPPING, "custompatterns"}, {BMO_OP_SLOT_MAPPING, "edgepercents"}, - /* these next three can have multiple types of elements in them */ - {BMO_OP_SLOT_ELEMENT_BUF, "outinner"}, - {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* contains all output geometr */ - {BMO_OP_SLOT_INT, "quadcornertype"}, /* quad corner type, see bmesh_operators.h */ {BMO_OP_SLOT_BOOL, "use_gridfill"}, /* fill in fully-selected faces with a grid */ {BMO_OP_SLOT_BOOL, "use_singleedge"}, /* tessellate the case of one edge selected in a quad or triangle */ {BMO_OP_SLOT_BOOL, "use_sphere"}, /* for making new primitives only */ - + {0} /* null-terminating sentinel */, + }, + {/* these next three can have multiple types of elements in them */ + {BMO_OP_SLOT_ELEMENT_BUF, "innerout"}, + {BMO_OP_SLOT_ELEMENT_BUF, "splitout"}, + {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* contains all output geometr */ {0} /* null-terminating sentinel */, }, bmo_subdivide_edges_exec, @@ -759,7 +856,9 @@ static BMOpDefine bmo_delete_def = { "delete", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, {BMO_OP_SLOT_INT, "context"}, - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_delete_exec, 0 }; @@ -767,15 +866,18 @@ static BMOpDefine bmo_delete_def = { static BMOpDefine bmo_duplicate_def = { "duplicate", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, - {BMO_OP_SLOT_ELEMENT_BUF, "origout"}, + {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */ + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "origout"}, {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, /* facemap maps from source faces to dupe * faces, and from dupe faces to source faces */ - {BMO_OP_SLOT_MAPPING, "facemap"}, - {BMO_OP_SLOT_MAPPING, "boundarymap"}, - {BMO_OP_SLOT_MAPPING, "isovertmap"}, - {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */ - {0} /* null-terminating sentinel */}, + {BMO_OP_SLOT_MAPPING, "facemap_out"}, + {BMO_OP_SLOT_MAPPING, "boundarymap_out"}, + {BMO_OP_SLOT_MAPPING, "isovertmap_out"}, + {0} /* null-terminating sentinel */, + }, bmo_duplicate_exec, 0 }; @@ -783,12 +885,15 @@ static BMOpDefine bmo_duplicate_def = { static BMOpDefine bmo_split_def = { "split", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, - {BMO_OP_SLOT_MAPPING, "boundarymap"}, - {BMO_OP_SLOT_MAPPING, "isovertmap"}, {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 */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, + {BMO_OP_SLOT_MAPPING, "boundarymap_out"}, + {BMO_OP_SLOT_MAPPING, "isovertmap_out"}, + {0} /* null-terminating sentinel */, + }, bmo_split_exec, 0 }; @@ -802,14 +907,17 @@ static BMOpDefine bmo_split_def = { static BMOpDefine bmo_spin_def = { "spin", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, - {BMO_OP_SLOT_ELEMENT_BUF, "lastout"}, /* result of last step */ {BMO_OP_SLOT_VEC, "cent"}, /* rotation center */ {BMO_OP_SLOT_VEC, "axis"}, /* rotation axis */ {BMO_OP_SLOT_VEC, "dvec"}, /* translation delta per step */ {BMO_OP_SLOT_FLT, "ang"}, /* total rotation angle (degrees) */ {BMO_OP_SLOT_INT, "steps"}, /* number of steps */ {BMO_OP_SLOT_BOOL, "do_dupli"}, /* duplicate or extrude? */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "lastout"}, /* result of last step */ + {0} /* null-terminating sentinel */, + }, bmo_spin_exec, 0 }; @@ -823,11 +931,14 @@ static BMOpDefine bmo_spin_def = { 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 */ {BMO_OP_SLOT_INT, "compare"}, /* comparison method */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ + {0} /* null-terminating sentinel */, + }, bmo_similar_faces_exec, 0 }; @@ -840,11 +951,14 @@ static BMOpDefine bmo_similar_faces_def = { 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 */ {BMO_OP_SLOT_INT, "compare"}, /* comparison method */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output edges */ + {0} /* null-terminating sentinel */, + }, bmo_similar_edges_exec, 0 }; @@ -857,11 +971,14 @@ static BMOpDefine bmo_similar_edges_def = { 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 */ {BMO_OP_SLOT_INT, "compare"}, /* comparison method */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ + {0} /* null-terminating sentinel */, + }, bmo_similar_verts_exec, 0 }; @@ -874,7 +991,9 @@ 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 */}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_rotate_uvs_exec, 0 }; @@ -886,7 +1005,9 @@ static BMOpDefine bmo_rotate_uvs_def = { static BMOpDefine bmo_reverse_uvs_def = { "reverse_uvs", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_reverse_uvs_exec, 0 }; @@ -898,8 +1019,10 @@ static BMOpDefine bmo_reverse_uvs_def = { 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_OP_SLOT_INT, "dir"}, /* direction */ + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_rotate_colors_exec, 0 }; @@ -911,7 +1034,9 @@ static BMOpDefine bmo_rotate_colors_def = { static BMOpDefine bmo_reverse_colors_def = { "reverse_colors", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{0}}, /* no output */ bmo_reverse_colors_exec, 0 }; @@ -925,9 +1050,12 @@ 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 */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ + {0} /* null-terminating sentinel */, + }, bmo_shortest_path_exec, 0 }; @@ -940,11 +1068,14 @@ static BMOpDefine bmo_shortest_path_def = { 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 */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* old output disconnected edges */ + {0} /* null-terminating sentinel */, + }, bmo_split_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -956,12 +1087,15 @@ static BMOpDefine bmo_split_edges_def = { */ static BMOpDefine bmo_create_grid_def = { "create_grid", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_INT, "xsegments"}, /* number of x segments */ + {{BMO_OP_SLOT_INT, "xsegments"}, /* number of x segments */ {BMO_OP_SLOT_INT, "ysegments"}, /* number of y segments */ {BMO_OP_SLOT_FLT, "size"}, /* size of the grid */ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {0} /* null-terminating sentinel */, + }, bmo_create_grid_exec, 0, }; @@ -973,12 +1107,15 @@ static BMOpDefine bmo_create_grid_def = { */ static BMOpDefine bmo_create_uvsphere_def = { "create_uvsphere", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_INT, "segments"}, /* number of u segments */ + {{BMO_OP_SLOT_INT, "segments"}, /* number of u segments */ {BMO_OP_SLOT_INT, "revolutions"}, /* number of v segment */ {BMO_OP_SLOT_FLT, "diameter"}, /* diameter */ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {0} /* null-terminating sentinel */, + }, bmo_create_uvsphere_exec, 0, }; @@ -990,11 +1127,14 @@ static BMOpDefine bmo_create_uvsphere_def = { */ static BMOpDefine bmo_create_icosphere_def = { "create_icosphere", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_INT, "subdivisions"}, /* how many times to recursively subdivide the sphere */ + {{BMO_OP_SLOT_INT, "subdivisions"}, /* how many times to recursively subdivide the sphere */ {BMO_OP_SLOT_FLT, "diameter"}, /* diameter */ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {0} /* null-terminating sentinel */, + }, bmo_create_icosphere_exec, 0, }; @@ -1006,9 +1146,12 @@ static BMOpDefine bmo_create_icosphere_def = { */ static BMOpDefine bmo_create_monkey_def = { "create_monkey", + {{BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ + {0} /* null-terminating sentinel */, + }, {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, bmo_create_monkey_exec, 0, }; @@ -1020,15 +1163,18 @@ static BMOpDefine bmo_create_monkey_def = { */ static BMOpDefine bmo_create_cone_def = { "create_cone", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ + {{BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */ {BMO_OP_SLOT_INT, "segments"}, {BMO_OP_SLOT_FLT, "diameter1"}, /* diameter of one end */ {BMO_OP_SLOT_FLT, "diameter2"}, /* diameter of the opposite */ {BMO_OP_SLOT_FLT, "depth"}, /* distance between ends */ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {0} /* null-terminating sentinel */, + }, bmo_create_cone_exec, 0, }; @@ -1038,13 +1184,16 @@ static BMOpDefine bmo_create_cone_def = { */ static BMOpDefine bmo_create_circle_def = { "create_circle", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ + {{BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */ {BMO_OP_SLOT_INT, "segments"}, {BMO_OP_SLOT_FLT, "diameter"}, /* diameter of one end */ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {0} /* null-terminating sentinel */, + }, bmo_create_circle_exec, 0, }; @@ -1056,15 +1205,17 @@ static BMOpDefine bmo_create_circle_def = { */ static BMOpDefine bmo_create_cube_def = { "create_cube", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_FLT, "size"}, /* size of the cube */ + {{BMO_OP_SLOT_FLT, "size"}, /* size of the cube */ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ - {0, /* null-terminating sentinel */}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {0} /* null-terminating sentinel */, + }, bmo_create_cube_exec, 0, }; -#define NEW_BEVEL 1 /* * Bevel * @@ -1072,13 +1223,15 @@ static BMOpDefine bmo_create_cube_def = { */ static BMOpDefine bmo_bevel_def = { "bevel", -#ifdef NEW_BEVEL {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */ {BMO_OP_SLOT_FLT, "offset"}, /* amount to offset beveled edge */ {BMO_OP_SLOT_INT, "segments"}, /* number of segments in bevel */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ - {0} /* null-terminating sentinel */}, -#else + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ + {0} /* null-terminating sentinel */, + }, +#if 0 /* old bevel*/ {{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 */ @@ -1088,7 +1241,8 @@ static BMOpDefine bmo_bevel_def = { * modifier uses this. We could do this as another float setting */ {BMO_OP_SLOT_INT, "lengthlayer"}, /* which PROP_FLT layer to us */ {BMO_OP_SLOT_FLT, "percent"}, /* percentage to expand beveled edge */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, #endif bmo_bevel_exec, BMO_OP_FLAG_UNTAN_MULTIRES @@ -1103,8 +1257,11 @@ static BMOpDefine bmo_beautify_fill_def = { "beautify_fill", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_ELEMENT_BUF, "constrain_edges"}, /* edges that can't be flipped */ - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* new flipped faces and edges */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* new flipped faces and edges */ + {0} /* null-terminating sentinel */, + }, bmo_beautify_fill_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1117,8 +1274,11 @@ static BMOpDefine bmo_beautify_fill_def = { static BMOpDefine bmo_triangle_fill_def = { "triangle_fill", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* new faces and edges */ - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* new faces and edges */ + {0} /* null-terminating sentinel */, + }, bmo_triangle_fill_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1132,8 +1292,11 @@ static BMOpDefine bmo_solidify_def = { "solidify", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, {BMO_OP_SLOT_FLT, "thickness"}, - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, - {0}}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, + {0} /* null-terminating sentinel */, + }, bmo_solidify_face_region_exec, 0 }; @@ -1146,14 +1309,17 @@ static BMOpDefine bmo_solidify_def = { static BMOpDefine bmo_inset_def = { "inset", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ {BMO_OP_SLOT_BOOL, "use_boundary"}, {BMO_OP_SLOT_BOOL, "use_even_offset"}, {BMO_OP_SLOT_BOOL, "use_relative_offset"}, {BMO_OP_SLOT_FLT, "thickness"}, {BMO_OP_SLOT_FLT, "depth"}, {BMO_OP_SLOT_BOOL, "use_outset"}, - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ + {0} /* null-terminating sentinel */, + }, bmo_inset_exec, 0 }; @@ -1166,14 +1332,17 @@ static BMOpDefine bmo_inset_def = { static BMOpDefine bmo_wireframe_def = { "wireframe", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ {BMO_OP_SLOT_BOOL, "use_boundary"}, {BMO_OP_SLOT_BOOL, "use_even_offset"}, {BMO_OP_SLOT_BOOL, "use_crease"}, {BMO_OP_SLOT_FLT, "thickness"}, {BMO_OP_SLOT_BOOL, "use_relative_offset"}, {BMO_OP_SLOT_FLT, "depth"}, - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ + {0} /* null-terminating sentinel */, + }, bmo_wireframe_exec, 0 }; @@ -1187,9 +1356,12 @@ 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 */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, + {0} /* null-terminating sentinel */, + }, bmo_slide_vert_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1214,13 +1386,14 @@ static BMOpDefine bmo_convex_hull_def = { "convex_hull", {{BMO_OP_SLOT_ELEMENT_BUF, "input"}, {BMO_OP_SLOT_BOOL, "use_existing_faces"}, - - /* Outputs */ - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, - {BMO_OP_SLOT_ELEMENT_BUF, "interior_geom"}, - {BMO_OP_SLOT_ELEMENT_BUF, "unused_geom"}, - {BMO_OP_SLOT_ELEMENT_BUF, "holes_geom"}, - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, + {BMO_OP_SLOT_ELEMENT_BUF, "interior_geom_out"}, + {BMO_OP_SLOT_ELEMENT_BUF, "unused_geom_out"}, + {BMO_OP_SLOT_ELEMENT_BUF, "holes_geom_out"}, + {0} /* null-terminating sentinel */, + }, bmo_convex_hull_exec, 0 }; @@ -1240,11 +1413,11 @@ static BMOpDefine bmo_symmetrize_def = { "symmetrize", {{BMO_OP_SLOT_ELEMENT_BUF, "input"}, {BMO_OP_SLOT_INT, "direction"}, - - /* Outputs */ - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, - - {0} /* null-terminating sentinel */}, + {0} /* null-terminating sentinel */, + }, + {{BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, + {0} /* null-terminating sentinel */, + }, bmo_symmetrize_exec, 0 }; diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index 671cfbbc55e..fbce08ed896 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -116,6 +116,7 @@ enum { * for when your defining an operator with BMOpDefine.*/ typedef struct BMOpSlot { + const char *slot_name; /* pointer to BMOpDefine.slot_args */ int slot_type; int len; int flag; @@ -130,14 +131,16 @@ typedef struct BMOpSlot { } data; } BMOpSlot; -#define BMO_OP_MAX_SLOTS 16 /* way more than probably needed */ +/* way more than probably needed, compiler complains if limit hit */ +#define BMO_OP_MAX_SLOTS 16 typedef struct BMOperator { int type; int slot_type; int type_flag; int flag; /* runtime options */ - struct BMOpSlot slot_args[BMO_OP_MAX_SLOTS]; + struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]; + struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]; void (*exec)(BMesh *bm, struct BMOperator *op); struct MemArena *arena; } BMOperator; @@ -156,8 +159,9 @@ typedef struct BMOSlotType { } BMOSlotType; typedef struct BMOpDefine { - const char *name; - BMOSlotType slot_types[BMO_OP_MAX_SLOTS]; + const char *opname; + BMOSlotType slot_types_in[BMO_OP_MAX_SLOTS]; + BMOSlotType slot_types_out[BMO_OP_MAX_SLOTS]; void (*exec)(BMesh *bm, BMOperator *op); int type_flag; } BMOpDefine; @@ -245,15 +249,22 @@ int BMO_op_initf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, ... int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, va_list vlist); /* test whether a named slot exists */ -int BMO_slot_exists(BMOperator *op, const char *slot_name); +int BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier); /* get a pointer to a slot. this may be removed layer on from the public API. */ -BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name); +BMOpSlot *BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier); /* copies the data of a slot from one operator to another. src and dst are the * source/destination slot codes, respectively. */ -void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, - const char *src, const char *dst); +#define BMO_slot_copy(op_src, slots_src, slot_name_src, \ + op_dst, slots_dst, slot_name_dst) \ + _bmo_slot_copy((op_src)->slots_src, slot_name_src, \ + (op_dst)->slots_dst, slot_name_dst, \ + (op_dst)->arena) + +void _bmo_slot_copy(BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src, + BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst, + struct MemArena *arena_dst); /* del "context" slot values, used for operator too */ enum { @@ -279,13 +290,13 @@ typedef 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 *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); -void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len); +void BMO_slot_float_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float f); +float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); +void BMO_slot_int_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i); +int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); +void BMO_slot_bool_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i); +int BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); +void *BMO_slot_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, int *len); /* don't pass in arrays that are supposed to map to elements this way. @@ -293,68 +304,80 @@ void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len); * 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 *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]); +void BMO_slot_ptr_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *p); +void *BMO_slot_ptr_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); +void BMO_slot_vec_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float vec[3]); +void BMO_slot_vec_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], 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_MatXXX function you want. */ -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_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float *mat, int size); +void BMO_slot_mat4_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[4][4]); +void BMO_slot_mat3_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], 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); /* copies the values from another slot to the end of the output slot */ -void BMO_slot_buffer_append(BMOperator *output_op, const char *output_op_slot, - BMOperator *other_op, const char *other_op_slot); +#define BMO_slot_buffer_append(op_src, slots_src, slot_name_src, \ + op_dst, slots_dst, slot_name_dst) \ + _bmo_slot_buffer_append((op_src)->slots_src, slot_name_src, \ + (op_dst)->slots_dst, slot_name_dst, \ + (op_dst)->arena) +void _bmo_slot_buffer_append(BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst, + BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src, + struct MemArena *arena_dst); /* 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 *slot_name, +void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], 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 *slot_name, +void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], 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 *slot_name, +void BMO_slot_buffer_flag_enable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], 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 *slot_name, +void BMO_slot_buffer_flag_disable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], 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 *slot_name, +void BMO_slot_buffer_hflag_enable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], 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 *slot_name, +void BMO_slot_buffer_hflag_disable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], 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 *slot_name, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], 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 *slot_name, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], 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 *slot_name); -int BMO_slot_map_count(BMesh *bm, BMOperator *op, const char *slot_name); +int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); +int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); -void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, +void BMO_slot_map_insert(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *element, void *data, int len); /* Counts the number of edges with tool flag toolflag around @@ -363,13 +386,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 *slot_name, - const char hflag, const short oflag); +void BMO_slot_map_to_flag(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], + 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_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], + const char *slot_name, const int len); -void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, - const char htype); +void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], + const char *slot_name, const char htype); /* this part of the API is used to iterate over element buffer or * mapping slots. @@ -412,10 +436,11 @@ typedef struct BMOIter { char restrictmask; /* bitwise '&' with BMHeader.htype */ } BMOIter; -void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name); +void *BMO_slot_buffer_elem_first(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); -void *BMO_iter_new(BMOIter *iter, BMesh *bm, BMOperator *op, - const char *slot_name, const char restrictmask); +void *BMO_iter_new(BMOIter *iter, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, + const char restrictmask); void *BMO_iter_step(BMOIter *iter); /* returns a pointer to the key value when iterating over mappings. @@ -428,8 +453,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, slot_name, restrict) \ - for (ele = BMO_iter_new(iter, bm, op, slot_name, restrict); ele; ele = BMO_iter_step(iter)) +#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag) \ + for (ele = BMO_iter_new(iter, slot_args, slot_name, restrict_flag); 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 16c2b8b0505..7f7b27c693a 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h +++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h @@ -69,16 +69,18 @@ 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 *slot_name, +BLI_INLINE void BMO_slot_map_int_insert(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], + const char *slot_name, void *element, int val) { - BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(int)); + BMO_slot_map_insert(op, slot_args, slot_name, element, &val, sizeof(int)); } -BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slot_name, +BLI_INLINE void BMO_slot_map_float_insert(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], + const char *slot_name, void *element, float val) { - BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(float)); + BMO_slot_map_insert(op, slot_args, slot_name, element, &val, sizeof(float)); } @@ -87,15 +89,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 *slot_name, +BLI_INLINE void BMO_slot_map_ptr_insert(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], + const char *slot_name, void *element, void *val) { - BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(void *)); + BMO_slot_map_insert(op, slot_args, slot_name, element, &val, sizeof(void *)); } -BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element) +BLI_INLINE int BMO_slot_map_contains(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *element) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ @@ -104,11 +107,11 @@ 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 *slot_name, +BLI_INLINE void *BMO_slot_map_data_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *element) { BMOElemMapping *mapping; - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ @@ -121,28 +124,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 *slot_name, +BLI_INLINE float BMO_slot_map_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *element) { - float *val = (float *) BMO_slot_map_data_get(bm, op, slot_name, element); + float *val = (float *) BMO_slot_map_data_get(slot_args, slot_name, element); if (val) return *val; return 0.0f; } -BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slot_name, +BLI_INLINE int BMO_slot_map_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *element) { - int *val = (int *) BMO_slot_map_data_get(bm, op, slot_name, element); + int *val = (int *) BMO_slot_map_data_get(slot_args, slot_name, element); if (val) return *val; return 0; } -BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slot_name, +BLI_INLINE void *BMO_slot_map_ptr_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *element) { - void **val = (void **) BMO_slot_map_data_get(bm, op, slot_name, element); + void **val = (void **) BMO_slot_map_data_get(slot_args, 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 8f38e1c9ba2..967574464cf 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -45,8 +45,8 @@ static void bmo_flag_layer_alloc(BMesh *bm); static void bmo_flag_layer_free(BMesh *bm); static void bmo_flag_layer_clear(BMesh *bm); -static int bmo_name_to_slotcode(BMOpDefine *def, const char *name); -static int bmo_name_to_slotcode_check(BMOpDefine *def, const char *name); +static int bmo_name_to_slotcode(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier); +static int bmo_name_to_slotcode_check(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier); static int bmo_opname_to_opcode(const char *opname); static const char *bmo_error_messages[] = { @@ -125,6 +125,18 @@ void BMO_pop(BMesh *bm) bm->stackdepth--; } + +/* use for both slot_types_in and slot_types_out */ +static void bmo_op_slots_init(BMOSlotType *slot_types, BMOpSlot *slot_args) +{ + unsigned int i; + for (i = 0; slot_types[i].type; i++) { + slot_args[i].slot_name = slot_types[i].name; + slot_args[i].slot_type = slot_types[i].type; + slot_args[i].index = i; + } +} + /** * \brief BMESH OPSTACK INIT OP * @@ -132,7 +144,7 @@ void BMO_pop(BMesh *bm) */ void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname) { - int i, opcode = bmo_opname_to_opcode(opname); + int opcode = bmo_opname_to_opcode(opname); #ifdef DEBUG BM_ELEM_INDEX_VALIDATE(bm, "pre bmo", opname); @@ -150,10 +162,8 @@ void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname) op->flag = flag; /* initialize the operator slot types */ - 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; - } + bmo_op_slots_init(opdefines[opcode]->slot_types_in, op->slots_in); + bmo_op_slots_init(opdefines[opcode]->slot_types_out, op->slots_out); /* callback */ op->exec = opdefines[opcode]->exec; @@ -189,6 +199,20 @@ void BMO_op_exec(BMesh *bm, BMOperator *op) BMO_pop(bm); } +static void bmo_op_slots_free(BMOSlotType *slot_types, BMOpSlot *slot_args) +{ + BMOpSlot *slot; + unsigned int i; + for (i = 0; slot_types[i].type; i++) { + slot = &slot_args[i]; + if (slot->slot_type == BMO_OP_SLOT_MAPPING) { + if (slot->data.ghash) { + BLI_ghash_free(slot->data.ghash, NULL, NULL); + } + } + } +} + /** * \brief BMESH OPSTACK FINISH OP * @@ -196,21 +220,13 @@ void BMO_op_exec(BMesh *bm, BMOperator *op) */ void BMO_op_finish(BMesh *bm, BMOperator *op) { - BMOpSlot *slot; - int i; - - 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); - } - } + bmo_op_slots_free(opdefines[op->type]->slot_types_in, op->slots_in); + bmo_op_slots_free(opdefines[op->type]->slot_types_out, op->slots_out); BLI_memarena_free(op->arena); #ifdef DEBUG - BM_ELEM_INDEX_VALIDATE(bm, "post bmo", opdefines[op->type]->name); + BM_ELEM_INDEX_VALIDATE(bm, "post bmo", opdefines[op->type]->opname); #else (void)bm; #endif @@ -221,9 +237,9 @@ void BMO_op_finish(BMesh *bm, BMOperator *op) * * \return Success if the slot if found. */ -int BMO_slot_exists(BMOperator *op, const char *slot_name) +int BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier) { - int slot_code = bmo_name_to_slotcode(opdefines[op->type], slot_name); + int slot_code = bmo_name_to_slotcode(slot_args, identifier); return (slot_code >= 0); } @@ -232,73 +248,76 @@ int BMO_slot_exists(BMOperator *op, const char *slot_name) * * Returns a pointer to the slot of type 'slot_code' */ -BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name) +BMOpSlot *BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier) { - int slot_code = bmo_name_to_slotcode_check(opdefines[op->type], slot_name); + int slot_code = bmo_name_to_slotcode_check(slot_args, identifier); if (slot_code < 0) { return &BMOpEmptySlot; } - return &(op->slot_args[slot_code]); + return &slot_args[slot_code]; } /** * \brief BMESH OPSTACK COPY SLOT * + * define used. * Copies data from one slot to another. */ -void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src, const char *dst) +void _bmo_slot_copy(BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src, + BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst, + struct MemArena *arena_dst) { - BMOpSlot *source_slot = BMO_slot_get(source_op, src); - BMOpSlot *dest_slot = BMO_slot_get(dest_op, dst); + BMOpSlot *slot_src = BMO_slot_get(slot_args_src, slot_name_src); + BMOpSlot *slot_dst = BMO_slot_get(slot_args_dst, slot_name_dst); - if (source_slot == dest_slot) + if (slot_src == slot_dst) return; - if (source_slot->slot_type != dest_slot->slot_type) { - /* possibly assert here? */ + BLI_assert(slot_src->slot_type == slot_dst->slot_type); + if (slot_src->slot_type != slot_dst->slot_type) { return; } - if (dest_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF) { + if (slot_dst->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->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); + slot_dst->data.buf = NULL; + slot_dst->len = slot_src->len; + if (slot_dst->len) { + const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[slot_dst->slot_type] * slot_dst->len; + slot_dst->data.buf = BLI_memarena_alloc(arena_dst, slot_alloc_size); + memcpy(slot_dst->data.buf, slot_src->data.buf, slot_alloc_size); } } - else if (dest_slot->slot_type == BMO_OP_SLOT_MAPPING) { + else if (slot_dst->slot_type == BMO_OP_SLOT_MAPPING) { GHashIterator it; BMOElemMapping *srcmap, *dstmap; /* sanity check */ - if (!source_slot->data.ghash) { + if (!slot_src->data.ghash) { return; } - if (!dest_slot->data.ghash) { - dest_slot->data.ghash = BLI_ghash_ptr_new("bmesh operator 2"); + if (!slot_dst->data.ghash) { + slot_dst->data.ghash = BLI_ghash_ptr_new("bmesh operator 2"); } - BLI_ghashIterator_init(&it, source_slot->data.ghash); - for ( ; (srcmap = BLI_ghashIterator_getValue(&it)); - BLI_ghashIterator_step(&it)) + for (BLI_ghashIterator_init(&it, slot_src->data.ghash); + (srcmap = BLI_ghashIterator_getValue(&it)); + BLI_ghashIterator_step(&it)) { - dstmap = BLI_memarena_alloc(dest_op->arena, sizeof(*dstmap) + srcmap->len); + dstmap = BLI_memarena_alloc(arena_dst, sizeof(*dstmap) + srcmap->len); dstmap->element = srcmap->element; dstmap->len = srcmap->len; memcpy(dstmap + 1, srcmap + 1, srcmap->len); - BLI_ghash_insert(dest_slot->data.ghash, dstmap->element, dstmap); + BLI_ghash_insert(slot_dst->data.ghash, dstmap->element, dstmap); } } else { - dest_slot->data = source_slot->data; + slot_dst->data = slot_src->data; } } @@ -308,9 +327,9 @@ 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 *slot_name, const float f) +void BMO_slot_float_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float f) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); if (!(slot->slot_type == BMO_OP_SLOT_FLT)) return; @@ -318,9 +337,9 @@ void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f) slot->data.f = f; } -void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i) +void BMO_slot_int_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); if (!(slot->slot_type == BMO_OP_SLOT_INT)) return; @@ -328,9 +347,9 @@ void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i) slot->data.i = i; } -void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i) +void BMO_slot_bool_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) return; @@ -339,9 +358,9 @@ void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i) } /* only supports square mats */ -void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size) +void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float *mat, int size) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; @@ -362,9 +381,9 @@ void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, i } } -void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]) +void BMO_slot_mat4_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[4][4]) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; @@ -377,9 +396,9 @@ 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_slot_mat3_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[3][3]) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; @@ -392,9 +411,9 @@ void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]) } } -void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p) +void BMO_slot_ptr_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *p) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); if (!(slot->slot_type == BMO_OP_SLOT_PTR)) return; @@ -402,9 +421,9 @@ void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p) slot->data.p = p; } -void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]) +void BMO_slot_vec_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float vec[3]) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); if (!(slot->slot_type == BMO_OP_SLOT_VEC)) return; @@ -413,9 +432,9 @@ void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]) } -float BMO_slot_float_get(BMOperator *op, const char *slot_name) +float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); if (!(slot->slot_type == BMO_OP_SLOT_FLT)) return 0.0f; @@ -423,9 +442,9 @@ float BMO_slot_float_get(BMOperator *op, const char *slot_name) return slot->data.f; } -int BMO_slot_int_get(BMOperator *op, const char *slot_name) +int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); if (!(slot->slot_type == BMO_OP_SLOT_INT)) return 0; @@ -433,9 +452,9 @@ int BMO_slot_int_get(BMOperator *op, const char *slot_name) return slot->data.i; } -int BMO_slot_bool_get(BMOperator *op, const char *slot_name) +int BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) return 0; @@ -444,9 +463,9 @@ int BMO_slot_bool_get(BMOperator *op, const char *slot_name) } /* if you want a copy of the elem buffer */ -void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len) +void *BMO_slot_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, int *len) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); void *ret; /* could add support for mapping type */ @@ -458,9 +477,9 @@ void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len) return ret; } -void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name) +void *BMO_slot_ptr_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); if (!(slot->slot_type == BMO_OP_SLOT_PTR)) return NULL; @@ -468,9 +487,9 @@ void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name) return slot->data.p; } -void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]) +void BMO_slot_vec_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_vec[3]) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); if (!(slot->slot_type == BMO_OP_SLOT_VEC)) return; @@ -546,9 +565,9 @@ 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 *slot_name) +int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); /* check if its actually a buffer */ @@ -558,9 +577,9 @@ int BMO_slot_buffer_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_na return slot->len; } -int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name) +int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* check if its actually a buffer */ @@ -573,12 +592,13 @@ int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name) /* 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 *slot_name, +void BMO_slot_map_insert(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *element, void *data, int len) { BMOElemMapping *mapping; - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); + BLI_assert(op->slots_in == slot_args || op->slots_out == slot_args); mapping = (BMOElemMapping *) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len); @@ -636,11 +656,11 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slot_code, int totadd) } #endif -void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_map_to_flag(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { GHashIterator it; - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BMElemF *ele_f; BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); @@ -656,10 +676,9 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, } } -void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len) +void *BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int len) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); - BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); /* check if its actually a buffer */ if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) @@ -676,9 +695,10 @@ void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len * * Copies all elements of a certain type into an operator slot. */ -void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, const char htype) +void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], + const char *slot_name, const char htype) { - BMOpSlot *output = BMO_slot_get(op, slot_name); + BMOpSlot *output = BMO_slot_get(slot_args, slot_name); int totelement = 0, i = 0; if (htype & BM_VERT) totelement += bm->totvert; @@ -689,7 +709,7 @@ void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, BMIter iter; BMHeader *ele; - BMO_slot_buffer_alloc(op, slot_name, totelement); + BMO_slot_buffer_alloc(op, slot_args, slot_name, totelement); /* TODO - collapse these loops into one */ @@ -722,11 +742,11 @@ void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, * 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 *slot_name, +static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag, const short test_for_enabled) { - BMOpSlot *output = BMO_slot_get(op, slot_name); + BMOpSlot *output = BMO_slot_get(slot_args, slot_name); int totelement = 0, i = 0; const int respecthide = (op->flag & BMO_FLAG_RESPECT_HIDE) != 0; @@ -741,7 +761,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl BMIter iter; BMElem *ele; - BMO_slot_buffer_alloc(op, slot_name, totelement); + BMO_slot_buffer_alloc(op, slot_args, slot_name, totelement); /* TODO - collapse these loops into one */ @@ -783,46 +803,51 @@ 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 *slot_name, +void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, TRUE); + bmo_slot_buffer_from_hflag(bm, op, slot_args, slot_name, htype, hflag, TRUE); } -void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, FALSE); + bmo_slot_buffer_from_hflag(bm, op, slot_args, slot_name, htype, hflag, FALSE); } /** * Copies the values from another slot to the end of the output slot. */ -void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, - BMOperator *other_op, const char *other_slot_name) +void _bmo_slot_buffer_append(BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst, + BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src, + struct MemArena *arena_dst) { - BMOpSlot *output_slot = BMO_slot_get(output_op, output_slot_name); - BMOpSlot *other_slot = BMO_slot_get(other_op, other_slot_name); + BMOpSlot *slot_dst = BMO_slot_get(slot_args_dst, slot_name_dst); + BMOpSlot *slot_src = BMO_slot_get(slot_args_src, slot_name_src); - BLI_assert(output_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF && - other_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot_dst->slot_type == BMO_OP_SLOT_ELEMENT_BUF && + slot_src->slot_type == BMO_OP_SLOT_ELEMENT_BUF); - if (output_slot->len == 0) { + if (slot_dst->len == 0) { /* output slot is empty, copy rather than append */ - BMO_slot_copy(other_op, output_op, other_slot_name, output_slot_name); + _bmo_slot_copy(slot_args_src, slot_name_src, + slot_args_dst, slot_name_dst, + arena_dst); } - else if (other_slot->len != 0) { - int elem_size = BMO_OPSLOT_TYPEINFO[output_slot->slot_type]; - int alloc_size = elem_size * (output_slot->len + other_slot->len); + else if (slot_src->len != 0) { + int elem_size = BMO_OPSLOT_TYPEINFO[slot_dst->slot_type]; + int alloc_size = elem_size * (slot_dst->len + slot_src->len); /* allocate new buffer */ - void *buf = BLI_memarena_alloc(output_op->arena, alloc_size); + void *buf = BLI_memarena_alloc(arena_dst, alloc_size); /* copy slot data */ - memcpy(buf, output_slot->data.buf, elem_size * output_slot->len); - memcpy(((char *)buf) + elem_size * output_slot->len, other_slot->data.buf, elem_size * other_slot->len); + memcpy(buf, slot_dst->data.buf, elem_size * slot_dst->len); + memcpy(((char *)buf) + elem_size * slot_dst->len, slot_src->data.buf, elem_size * slot_src->len); - output_slot->data.buf = buf; - output_slot->len += other_slot->len; + slot_dst->data.buf = buf; + slot_dst->len += slot_src->len; } } @@ -832,13 +857,15 @@ 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 *slot_name, +static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag, const short test_for_enabled) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); int totelement, i = 0; + BLI_assert(op->slots_in == slot_args || op->slots_out == slot_args); BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); if (test_for_enabled) @@ -853,7 +880,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo BMHeader *ele; BMHeader **ele_array; - BMO_slot_buffer_alloc(op, slot_name, totelement); + BMO_slot_buffer_alloc(op, slot_args, slot_name, totelement); ele_array = (BMHeader **)slot->data.p; @@ -891,16 +918,18 @@ 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 *slot_name, +void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, TRUE); + bmo_slot_buffer_from_flag(bm, op, slot_args, slot_name, htype, oflag, TRUE); } -void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, FALSE); + bmo_slot_buffer_from_flag(bm, op, slot_args, slot_name, htype, oflag, FALSE); } /** @@ -909,10 +938,11 @@ 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 *slot_name, +void BMO_slot_buffer_hflag_enable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag, const char do_flush) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BMElem **data = slot->data.p; int i; const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); @@ -942,10 +972,11 @@ void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_na * 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 *slot_name, +void BMO_slot_buffer_hflag_disable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag, const char do_flush) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BMElem **data = slot->data.p; int i; const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); @@ -993,10 +1024,11 @@ 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 *slot_name, +void BMO_slot_buffer_flag_enable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BMHeader **data = slot->data.p; int i; @@ -1015,10 +1047,11 @@ void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_nam * * Removes flags from elements in a slots buffer */ -void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_flag_disable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BMHeader **data = slot->data.p; int i; @@ -1171,9 +1204,9 @@ 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 *slot_name) +void *BMO_slot_buffer_elem_first(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return NULL; @@ -1187,10 +1220,11 @@ void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name) * \param restrictmask restricts the iteration to certain element types * (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 *slot_name, const char restrictmask) +void *BMO_iter_new(BMOIter *iter, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, + const char restrictmask) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); memset(iter, 0, sizeof(BMOIter)); @@ -1324,24 +1358,26 @@ int BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op) #define NEXT_CHAR(fmt) ((fmt)[0] != 0 ? (fmt)[1] : 0) -static int bmo_name_to_slotcode(BMOpDefine *def, const char *name) +static int bmo_name_to_slotcode(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier) { - int i; + int i = 0; - for (i = 0; def->slot_types[i].type; i++) { - if (!strncmp(name, def->slot_types[i].name, MAX_SLOTNAME)) { + while (slot_args->slot_name) { + if (strncmp(identifier, slot_args->slot_name, MAX_SLOTNAME) == 0) { return i; } + slot_args++; + i++; } return -1; } -static int bmo_name_to_slotcode_check(BMOpDefine *def, const char *name) +static int bmo_name_to_slotcode_check(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier) { - int i = bmo_name_to_slotcode(def, name); + int i = bmo_name_to_slotcode(slot_args, identifier); if (i < 0) { - fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, name); + fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, identifier); } return i; @@ -1352,12 +1388,12 @@ static int bmo_opname_to_opcode(const char *opname) int i; for (i = 0; i < bmesh_total_ops; i++) { - if (!strcmp(opname, opdefines[i]->name)) { + if (!strcmp(opname, opdefines[i]->opname)) { return i; } } - fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, opname); + fprintf(stderr, "%s: could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, opname); return -1; } @@ -1367,6 +1403,8 @@ static int bmo_opname_to_opcode(const char *opname) * i - int * b - boolean (same as int but 1/0 only) * f - float + * s - slot_in + * S - slot_out * hv - header flagged verts (hflag) * he - header flagged edges (hflag) * hf - header flagged faces (hflag) @@ -1380,7 +1418,7 @@ static int bmo_opname_to_opcode(const char *opname) int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, va_list vlist) { - BMOpDefine *def; +// BMOpDefine *def; char *opname, *ofmt, *fmt; char slot_name[64] = {0}; int i /*, n = strlen(fmt) */, stop /*, slot_code = -1 */, type, state; @@ -1419,7 +1457,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v } BMO_op_init(bm, op, flag, opname); - def = opdefines[i]; +// def = opdefines[i]; i = 0; state = 1; /* 0: not inside slot_code name, 1: inside slot_code name */ @@ -1442,7 +1480,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v fmt[i] = 0; - if (bmo_name_to_slotcode_check(def, fmt) < 0) { + if (bmo_name_to_slotcode_check(op->slots_in, fmt) < 0) { GOTO_ERROR("name to slot code check failed"); } @@ -1468,20 +1506,20 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v else if (c == '4') size = 4; else GOTO_ERROR("matrix size was not 3 or 4"); - BMO_slot_mat_set(op, slot_name, va_arg(vlist, void *), size); + BMO_slot_mat_set(op, op->slots_in, slot_name, va_arg(vlist, void *), size); state = 1; break; } case 'v': { - BMO_slot_vec_set(op, slot_name, va_arg(vlist, float *)); + BMO_slot_vec_set(op->slots_in, slot_name, va_arg(vlist, float *)); state = 1; break; } case 'e': { BMHeader *ele = va_arg(vlist, void *); - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(op->slots_in, slot_name); slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(void *) * 4); slot->len = 1; @@ -1491,24 +1529,34 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v break; } case 's': + case 'S': { - BMOperator *op2 = va_arg(vlist, void *); - const char *slot_name2 = va_arg(vlist, char *); + BMOperator *op_other = va_arg(vlist, void *); + const char *slot_name_other = va_arg(vlist, char *); - BMO_slot_copy(op2, op, slot_name2, slot_name); + if (*fmt == 's') { + BLI_assert(bmo_name_to_slotcode_check(op_other->slots_in, slot_name_other) != -1); + BMO_slot_copy(op_other, slots_in, slot_name_other, + op, slots_in, slot_name); + } + else { + BLI_assert(bmo_name_to_slotcode_check(op_other->slots_out, slot_name_other) != -1); + BMO_slot_copy(op_other, slots_out, slot_name_other, + op, slots_in, slot_name); + } state = 1; break; } case 'i': - BMO_slot_int_set(op, slot_name, va_arg(vlist, int)); + BMO_slot_int_set(op->slots_in, slot_name, va_arg(vlist, int)); state = 1; break; case 'b': - BMO_slot_bool_set(op, slot_name, va_arg(vlist, int)); + BMO_slot_bool_set(op->slots_in, slot_name, va_arg(vlist, int)); state = 1; break; case 'p': - BMO_slot_ptr_set(op, slot_name, va_arg(vlist, void *)); + BMO_slot_ptr_set(op->slots_in, slot_name, va_arg(vlist, void *)); state = 1; break; case 'f': @@ -1519,7 +1567,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v type = *fmt; if (NEXT_CHAR(fmt) == ' ' || NEXT_CHAR(fmt) == '\0') { - BMO_slot_float_set(op, slot_name, va_arg(vlist, double)); + BMO_slot_float_set(op->slots_in, slot_name, va_arg(vlist, double)); } else { htype = 0; @@ -1541,19 +1589,19 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v } if (type == 'h') { - BMO_slot_buffer_from_enabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int)); } else if (type == 'H') { - BMO_slot_buffer_from_disabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_disabled_hflag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int)); } else if (type == 'a') { - BMO_slot_buffer_from_all(bm, op, slot_name, htype); + BMO_slot_buffer_from_all(bm, op, op->slots_in, slot_name, htype); } else if (type == 'f') { - BMO_slot_buffer_from_enabled_flag(bm, op, slot_name, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int)); } else if (type == 'F') { - BMO_slot_buffer_from_disabled_flag(bm, op, slot_name, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_disabled_flag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int)); } } |