Implement BMesh Operator string enumerators and docs generation.
Partial implementation of T56496 for review. Reviewers: campbellbarton Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D3635
This commit is contained in:
parent
09e1e2b8ce
commit
1e6a5eb087
|
@ -31,6 +31,7 @@
|
|||
# - campbell
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(CURRENT_DIR, "..", ".."))))
|
||||
|
@ -75,7 +76,8 @@ def main():
|
|||
for l in fsrc:
|
||||
l = l[:-1]
|
||||
# weak but ok
|
||||
if ("BMOpDefine" in l and l.split()[1] == "BMOpDefine") and "bmo_opdefines[]" not in l:
|
||||
if ((("BMOpDefine" in l and l.split()[1] == "BMOpDefine") and "bmo_opdefines[]" not in l) or
|
||||
("static BMO_FlagSet " in l)):
|
||||
is_block = True
|
||||
block_ctx = []
|
||||
blocks.append((comment_ctx, block_ctx))
|
||||
|
@ -92,9 +94,12 @@ def main():
|
|||
if cpp_comment != -1:
|
||||
l = l[:cpp_comment]
|
||||
|
||||
# remove sentinel from enums
|
||||
l = l.replace("{0, NULL}", "")
|
||||
|
||||
block_ctx.append(l)
|
||||
|
||||
if l.strip() == "};":
|
||||
if l.strip().endswith("};"):
|
||||
is_block = False
|
||||
comment_ctx = None
|
||||
|
||||
|
@ -136,6 +141,9 @@ def main():
|
|||
"BMO_OP_SLOT_SUBTYPE_PTR_MESH",
|
||||
"BMO_OP_SLOT_SUBTYPE_PTR_BMESH",
|
||||
|
||||
"BMO_OP_SLOT_SUBTYPE_INT_ENUM",
|
||||
"BMO_OP_SLOT_SUBTYPE_INT_FLAG",
|
||||
|
||||
"BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE",
|
||||
|
||||
"BM_VERT",
|
||||
|
@ -160,6 +168,7 @@ def main():
|
|||
for comment, b in blocks:
|
||||
# magic, translate into python
|
||||
b[0] = b[0].replace("static BMOpDefine ", "")
|
||||
is_enum = False
|
||||
|
||||
for i, l in enumerate(b):
|
||||
l = l.strip()
|
||||
|
@ -178,11 +187,35 @@ def main():
|
|||
# exec func. eg: bmo_rotate_edges_exec,
|
||||
if l.startswith("bmo_") and l.endswith("_exec,"):
|
||||
l = "None,"
|
||||
|
||||
# enums
|
||||
if l.startswith("static BMO_FlagSet "):
|
||||
is_enum = True
|
||||
|
||||
b[i] = l
|
||||
|
||||
# for l in b:
|
||||
# print(l)
|
||||
|
||||
if is_enum:
|
||||
text = "".join(b)
|
||||
text = text.replace("static BMO_FlagSet ", "")
|
||||
text = text.replace("[]", "")
|
||||
text = text.strip(";")
|
||||
text = text.replace("(", "[").replace(")", "]")
|
||||
text = text.replace("\"", "'")
|
||||
|
||||
k, v = text.split("=", 1)
|
||||
|
||||
v = repr(re.findall(r"'([^']*)'", v))
|
||||
|
||||
k = k.strip()
|
||||
v = v.strip()
|
||||
|
||||
vars_dict[k] = v
|
||||
|
||||
continue
|
||||
|
||||
text = "\n".join(b)
|
||||
global_namespace = {
|
||||
"__file__": "generated",
|
||||
|
@ -225,6 +258,7 @@ def main():
|
|||
|
||||
# -- wash the comment
|
||||
comment_washed = []
|
||||
comment = [] if comment is None else comment
|
||||
for i, l in enumerate(comment):
|
||||
assert((l.strip() == "") or
|
||||
(l in {"/*", " *"}) or
|
||||
|
@ -246,7 +280,9 @@ def main():
|
|||
args_wash = []
|
||||
for i in args_index:
|
||||
arg = args[i]
|
||||
if len(arg) == 3:
|
||||
if len(arg) == 4:
|
||||
name, tp, tp_sub, enums = arg
|
||||
elif len(arg) == 3:
|
||||
name, tp, tp_sub = arg
|
||||
elif len(arg) == 2:
|
||||
name, tp = arg
|
||||
|
@ -282,7 +318,12 @@ def main():
|
|||
if tp == BMO_OP_SLOT_FLT:
|
||||
tp_str = "float"
|
||||
elif tp == BMO_OP_SLOT_INT:
|
||||
tp_str = "int"
|
||||
if tp_sub == BMO_OP_SLOT_SUBTYPE_INT_ENUM:
|
||||
tp_str = "enum in " + enums + ", default " + enums.split(",", 1)[0].strip("[")
|
||||
elif tp_sub == BMO_OP_SLOT_SUBTYPE_INT_FLAG:
|
||||
tp_str = "set of flags from " + enums + ", default {}"
|
||||
else:
|
||||
tp_str = "int"
|
||||
elif tp == BMO_OP_SLOT_BOOL:
|
||||
tp_str = "bool"
|
||||
elif tp == BMO_OP_SLOT_MAT:
|
||||
|
|
|
@ -59,6 +59,8 @@
|
|||
#include "bmesh.h"
|
||||
#include "intern/bmesh_operators_private.h"
|
||||
|
||||
#include "DNA_modifier_types.h"
|
||||
|
||||
/* The formatting of these bmesh operators is parsed by
|
||||
* 'doc/python_api/rst_from_bmesh_opdefines.py'
|
||||
* for use in python docs, so reStructuredText may be used
|
||||
|
@ -95,6 +97,32 @@
|
|||
* note that '//' comments are ignored.
|
||||
*/
|
||||
|
||||
/* enums shared between multiple operators */
|
||||
|
||||
static BMO_FlagSet bmo_enum_axis_xyz[] = {
|
||||
{0, "X"},
|
||||
{1, "Y"},
|
||||
{2, "Z"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_falloff_type[] = {
|
||||
{SUBD_FALLOFF_SMOOTH, "SMOOTH"},
|
||||
{SUBD_FALLOFF_SPHERE, "SPHERE"},
|
||||
{SUBD_FALLOFF_ROOT, "ROOT"},
|
||||
{SUBD_FALLOFF_SHARP, "SHARP"},
|
||||
{SUBD_FALLOFF_LIN, "LINEAR"},
|
||||
{SUBD_FALLOFF_INVSQUARE, "INVERSE_SQUARE"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_compare_types[] = {
|
||||
{SIM_CMP_EQ, "EQUAL"},
|
||||
{SIM_CMP_GT, "GREATER_THAN"},
|
||||
{SIM_CMP_LT, "LESS_THAN"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Vertex Smooth.
|
||||
*
|
||||
|
@ -290,7 +318,7 @@ static BMOpDefine bmo_mirror_def = {
|
|||
{{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* input geometry */
|
||||
{"matrix", BMO_OP_SLOT_MAT}, /* matrix defining the mirror transformation */
|
||||
{"merge_dist", BMO_OP_SLOT_FLT}, /* maximum distance for merging. does no merging if 0. */
|
||||
{"axis", BMO_OP_SLOT_INT}, /* the axis to use, 0, 1, or 2 for x, y, z */
|
||||
{"axis", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_axis_xyz}, /* the axis to use. */
|
||||
{"mirror_u", BMO_OP_SLOT_BOOL}, /* mirror UVs across the u axis */
|
||||
{"mirror_v", BMO_OP_SLOT_BOOL}, /* mirror UVs across the v axis */
|
||||
{{'\0'}},
|
||||
|
@ -1110,6 +1138,15 @@ static BMOpDefine bmo_dissolve_faces_def = {
|
|||
BMO_OPTYPE_FLAG_SELECT_VALIDATE),
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_dissolve_limit_flags[] = {
|
||||
{BMO_DELIM_NORMAL, "NORMAL"},
|
||||
{BMO_DELIM_MATERIAL, "MATERIAL"},
|
||||
{BMO_DELIM_SEAM, "SEAM"},
|
||||
{BMO_DELIM_SHARP, "SHARP"},
|
||||
{BMO_DELIM_UV, "UV"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
/*
|
||||
* Limited Dissolve.
|
||||
*
|
||||
|
@ -1122,7 +1159,7 @@ static BMOpDefine bmo_dissolve_limit_def = {
|
|||
{"use_dissolve_boundaries", BMO_OP_SLOT_BOOL},
|
||||
{"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}},
|
||||
{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}},
|
||||
{"delimit", BMO_OP_SLOT_INT},
|
||||
{"delimit", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_FLAG}, bmo_enum_dissolve_limit_flags},
|
||||
{{'\0'}},
|
||||
},
|
||||
/* slots_out */
|
||||
|
@ -1156,6 +1193,20 @@ static BMOpDefine bmo_dissolve_degenerate_def = {
|
|||
BMO_OPTYPE_FLAG_SELECT_VALIDATE),
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_triangulate_quad_method[] = {
|
||||
{MOD_TRIANGULATE_QUAD_BEAUTY, "BEAUTY"},
|
||||
{MOD_TRIANGULATE_QUAD_FIXED, "FIXED"},
|
||||
{MOD_TRIANGULATE_QUAD_ALTERNATE, "ALTERNATE"},
|
||||
{MOD_TRIANGULATE_QUAD_SHORTEDGE, "SHORT_EDGE"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_triangulate_ngon_method[] = {
|
||||
{MOD_TRIANGULATE_NGON_BEAUTY, "BEAUTY"},
|
||||
{MOD_TRIANGULATE_NGON_EARCLIP, "EAR_CLIP"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Triangulate.
|
||||
*/
|
||||
|
@ -1163,8 +1214,8 @@ static BMOpDefine bmo_triangulate_def = {
|
|||
"triangulate",
|
||||
/* slots_in */
|
||||
{{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},
|
||||
{"quad_method", BMO_OP_SLOT_INT},
|
||||
{"ngon_method", BMO_OP_SLOT_INT},
|
||||
{"quad_method", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_triangulate_quad_method},
|
||||
{"ngon_method", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_triangulate_ngon_method},
|
||||
{{'\0'}},
|
||||
},
|
||||
/* slots_out */
|
||||
|
@ -1200,6 +1251,14 @@ static BMOpDefine bmo_unsubdivide_def = {
|
|||
BMO_OPTYPE_FLAG_SELECT_VALIDATE),
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_subdivide_edges_quad_corner_type[] = {
|
||||
{SUBD_CORNER_STRAIGHT_CUT, "STRAIGHT_CUT"},
|
||||
{SUBD_CORNER_INNERVERT, "INNER_VERT"},
|
||||
{SUBD_CORNER_PATH, "PATH"},
|
||||
{SUBD_CORNER_FAN, "FAN"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Subdivide Edges.
|
||||
*
|
||||
|
@ -1211,15 +1270,14 @@ static BMOpDefine bmo_subdivide_edges_def = {
|
|||
/* slots_in */
|
||||
{{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}},
|
||||
{"smooth", BMO_OP_SLOT_FLT},
|
||||
{"smooth_falloff", BMO_OP_SLOT_INT}, /* SUBD_FALLOFF_ROOT and friends */
|
||||
{"smooth_falloff", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_falloff_type}, /* smooth falloff type */
|
||||
{"fractal", BMO_OP_SLOT_FLT},
|
||||
{"along_normal", BMO_OP_SLOT_FLT},
|
||||
{"cuts", BMO_OP_SLOT_INT},
|
||||
{"seed", BMO_OP_SLOT_INT},
|
||||
{"custom_patterns", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL}}, /* uses custom pointers */
|
||||
{"edge_percents", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_FLT}},
|
||||
|
||||
{"quad_corner_type", BMO_OP_SLOT_INT}, /* quad corner type, see bmesh_operators.h */
|
||||
{"quad_corner_type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_subdivide_edges_quad_corner_type}, /* quad corner type */
|
||||
{"use_grid_fill", BMO_OP_SLOT_BOOL}, /* fill in fully-selected faces with a grid */
|
||||
{"use_single_edge", BMO_OP_SLOT_BOOL}, /* tessellate the case of one edge selected in a quad or triangle */
|
||||
{"use_only_quads", BMO_OP_SLOT_BOOL}, /* only subdivide quads (for loopcut) */
|
||||
|
@ -1241,6 +1299,13 @@ static BMOpDefine bmo_subdivide_edges_def = {
|
|||
BMO_OPTYPE_FLAG_SELECT_VALIDATE),
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_subdivide_edgering_interp_mode[] = {
|
||||
{SUBD_RING_INTERP_LINEAR, "LINEAR"},
|
||||
{SUBD_RING_INTERP_PATH, "PATH"},
|
||||
{SUBD_RING_INTERP_SURF, "SURFACE"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Subdivide Edge-Ring.
|
||||
*
|
||||
|
@ -1250,10 +1315,10 @@ static BMOpDefine bmo_subdivide_edgering_def = {
|
|||
"subdivide_edgering",
|
||||
/* slots_in */
|
||||
{{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* input vertices */
|
||||
{"interp_mode", BMO_OP_SLOT_INT},
|
||||
{"interp_mode", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_subdivide_edgering_interp_mode}, /* interpolation method */
|
||||
{"smooth", BMO_OP_SLOT_FLT},
|
||||
{"cuts", BMO_OP_SLOT_INT},
|
||||
{"profile_shape", BMO_OP_SLOT_INT},
|
||||
{"profile_shape", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_falloff_type}, /* profile shape type */
|
||||
{"profile_shape_factor", BMO_OP_SLOT_FLT},
|
||||
{{'\0'}},
|
||||
},
|
||||
|
@ -1293,6 +1358,17 @@ static BMOpDefine bmo_bisect_plane_def = {
|
|||
BMO_OPTYPE_FLAG_SELECT_VALIDATE),
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_delete_context[] = {
|
||||
{DEL_VERTS, "VERTS"},
|
||||
{DEL_EDGES, "EDGES"},
|
||||
{DEL_ONLYFACES, "FACES_ONLY"},
|
||||
{DEL_EDGESFACES, "EDGES_FACES"},
|
||||
{DEL_FACES, "FACES"},
|
||||
{DEL_FACES_KEEP_BOUNDARY, "FACES_KEEP_BOUNDARY"},
|
||||
{DEL_ONLYTAGGED, "TAGGED_ONLY"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Delete Geometry.
|
||||
*
|
||||
|
@ -1302,7 +1378,7 @@ static BMOpDefine bmo_delete_def = {
|
|||
"delete",
|
||||
/* slots_in */
|
||||
{{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}},
|
||||
{"context", BMO_OP_SLOT_INT}, /* enum DEL_VERTS ... */
|
||||
{"context", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_delete_context}, /* geometry types to delete */
|
||||
{{'\0'}},
|
||||
},
|
||||
{{{'\0'}}}, /* no output */
|
||||
|
@ -1398,6 +1474,20 @@ static BMOpDefine bmo_spin_def = {
|
|||
BMO_OPTYPE_FLAG_SELECT_FLUSH),
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_similar_faces_types[] = {
|
||||
{SIMFACE_MATERIAL, "MATERIAL"},
|
||||
{SIMFACE_AREA, "AREA"},
|
||||
{SIMFACE_SIDES, "SIDES"},
|
||||
{SIMFACE_PERIMETER, "PERIMETER"},
|
||||
{SIMFACE_NORMAL, "NORMAL"},
|
||||
{SIMFACE_COPLANAR, "COPLANAR"},
|
||||
{SIMFACE_SMOOTH, "SMOOTH"},
|
||||
{SIMFACE_FACEMAP, "FACE_MAP"},
|
||||
#ifdef WITH_FREESTYLE
|
||||
{SIMFACE_FREESTYLE, "FREESTYLE"},
|
||||
#endif
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Similar Faces Search.
|
||||
|
@ -1408,9 +1498,9 @@ static BMOpDefine bmo_similar_faces_def = {
|
|||
"similar_faces",
|
||||
/* slots_in */
|
||||
{{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */
|
||||
{"type", BMO_OP_SLOT_INT}, /* type of selection */
|
||||
{"type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_similar_faces_types}, /* type of selection */
|
||||
{"thresh", BMO_OP_SLOT_FLT}, /* threshold of selection */
|
||||
{"compare", BMO_OP_SLOT_INT}, /* comparison method */
|
||||
{"compare", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_compare_types}, /* comparison method */
|
||||
{{'\0'}},
|
||||
},
|
||||
/* slots_out */
|
||||
|
@ -1421,6 +1511,21 @@ static BMOpDefine bmo_similar_faces_def = {
|
|||
(BMO_OPTYPE_FLAG_SELECT_FLUSH),
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_similar_edges_types[] = {
|
||||
{SIMEDGE_LENGTH, "LENGTH"},
|
||||
{SIMEDGE_DIR, "DIRECTION"},
|
||||
{SIMEDGE_FACE, "FACE"},
|
||||
{SIMEDGE_FACE_ANGLE, "FACE_ANGLE"},
|
||||
{SIMEDGE_CREASE, "CREASE"},
|
||||
{SIMEDGE_BEVEL, "BEVEL"},
|
||||
{SIMEDGE_SEAM, "SEAM"},
|
||||
{SIMEDGE_SHARP, "SHARP"},
|
||||
#ifdef WITH_FREESTYLE
|
||||
{SIMEDGE_FREESTYLE, "FREESTYLE"},
|
||||
#endif
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Similar Edges Search.
|
||||
*
|
||||
|
@ -1430,9 +1535,9 @@ static BMOpDefine bmo_similar_edges_def = {
|
|||
"similar_edges",
|
||||
/* slots_in */
|
||||
{{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* input edges */
|
||||
{"type", BMO_OP_SLOT_INT}, /* type of selection */
|
||||
{"type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_similar_edges_types}, /* type of selection */
|
||||
{"thresh", BMO_OP_SLOT_FLT}, /* threshold of selection */
|
||||
{"compare", BMO_OP_SLOT_INT}, /* comparison method */
|
||||
{"compare", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_compare_types}, /* comparison method */
|
||||
{{'\0'}},
|
||||
},
|
||||
/* slots_out */
|
||||
|
@ -1443,6 +1548,14 @@ static BMOpDefine bmo_similar_edges_def = {
|
|||
(BMO_OPTYPE_FLAG_SELECT_FLUSH),
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_similar_verts_types[] = {
|
||||
{SIMVERT_NORMAL, "NORMAL"},
|
||||
{SIMVERT_FACE, "FACE"},
|
||||
{SIMVERT_VGROUP, "VERTEX_GROUP"},
|
||||
{SIMVERT_EDGE, "EDGE"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Similar Verts Search.
|
||||
*
|
||||
|
@ -1452,9 +1565,9 @@ static BMOpDefine bmo_similar_verts_def = {
|
|||
"similar_verts",
|
||||
/* slots_in */
|
||||
{{"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* input vertices */
|
||||
{"type", BMO_OP_SLOT_INT}, /* type of selection */
|
||||
{"type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_similar_verts_types}, /* type of selection */
|
||||
{"thresh", BMO_OP_SLOT_FLT}, /* threshold of selection */
|
||||
{"compare", BMO_OP_SLOT_INT}, /* comparison method */
|
||||
{"compare", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_compare_types}, /* comparison method */
|
||||
{{'\0'}},
|
||||
},
|
||||
/* slots_out */
|
||||
|
@ -1719,6 +1832,22 @@ static BMOpDefine bmo_create_cube_def = {
|
|||
BMO_OPTYPE_FLAG_SELECT_FLUSH),
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_bevel_offset_type[] = {
|
||||
{BEVEL_AMT_OFFSET, "OFFSET"},
|
||||
{BEVEL_AMT_WIDTH, "WIDTH"},
|
||||
{BEVEL_AMT_DEPTH, "DEPTH"},
|
||||
{BEVEL_AMT_PERCENT, "PERCENT"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_bevel_harden_normal_type[] = {
|
||||
{BEVEL_HN_NONE, "NONE"},
|
||||
{BEVEL_HN_FACE, "FACE"},
|
||||
{BEVEL_HN_ADJ, "ADJACENT"},
|
||||
{BEVEL_HN_FIX_SHA, "FIXED_NORMAL_SHADING"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Bevel.
|
||||
*
|
||||
|
@ -1729,7 +1858,7 @@ static BMOpDefine bmo_bevel_def = {
|
|||
/* slots_in */
|
||||
{{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* input edges and vertices */
|
||||
{"offset", BMO_OP_SLOT_FLT}, /* amount to offset beveled edge */
|
||||
{"offset_type", BMO_OP_SLOT_INT}, /* how to measure offset (enum) */
|
||||
{"offset_type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_bevel_offset_type}, /* how to measure the offset */
|
||||
{"segments", BMO_OP_SLOT_INT}, /* number of segments in bevel */
|
||||
{"profile", BMO_OP_SLOT_FLT}, /* profile shape, 0->1 (.5=>round) */
|
||||
{"vertex_only", BMO_OP_SLOT_BOOL}, /* only bevel vertices, not edges */
|
||||
|
@ -1739,7 +1868,7 @@ static BMOpDefine bmo_bevel_def = {
|
|||
{"mark_seam", BMO_OP_SLOT_BOOL}, /* extend edge data to allow seams to run across bevels */
|
||||
{"mark_sharp", BMO_OP_SLOT_BOOL}, /* extend edge data to allow sharp edges to run across bevels */
|
||||
{"strength", BMO_OP_SLOT_FLT}, /* strength of calculated normal in range (0, 1) for custom clnors */
|
||||
{"hnmode", BMO_OP_SLOT_INT}, /* harden normals mode used in bevel if enabled */
|
||||
{"hnmode", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_bevel_harden_normal_type}, /* harden normals mode used in bevel, if enabled */
|
||||
{{'\0'}},
|
||||
},
|
||||
/* slots_out */
|
||||
|
@ -1757,6 +1886,13 @@ static BMOpDefine bmo_bevel_def = {
|
|||
BMO_OPTYPE_FLAG_SELECT_VALIDATE),
|
||||
};
|
||||
|
||||
/* no enum is defined for this */
|
||||
static BMO_FlagSet bmo_enum_beautify_fill_method[] = {
|
||||
{0, "AREA"},
|
||||
{1, "ANGLE"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Beautify Fill.
|
||||
*
|
||||
|
@ -1768,7 +1904,7 @@ static BMOpDefine bmo_beautify_fill_def = {
|
|||
{{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */
|
||||
{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* edges that can be flipped */
|
||||
{"use_restrict_tag", BMO_OP_SLOT_BOOL}, /* restrict edge rotation to mixed tagged vertices */
|
||||
{"method", BMO_OP_SLOT_INT}, /* method to define what is beautiful */
|
||||
{"method", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_beautify_fill_method}, /* method to define what is beautiful */
|
||||
{{'\0'}},
|
||||
},
|
||||
/* slots_out */
|
||||
|
@ -1932,6 +2068,13 @@ static BMOpDefine bmo_wireframe_def = {
|
|||
BMO_OPTYPE_FLAG_SELECT_VALIDATE),
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_poke_center_mode[] = {
|
||||
{BMOP_POKE_MEAN_WEIGHTED, "MEAN_WEIGHTED"},
|
||||
{BMOP_POKE_MEAN, "MEAN"},
|
||||
{BMOP_POKE_BOUNDS, "BOUNDS"},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Pokes a face.
|
||||
*
|
||||
|
@ -1942,7 +2085,7 @@ static BMOpDefine bmo_poke_def = {
|
|||
/* slots_in */
|
||||
{{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */
|
||||
{"offset", BMO_OP_SLOT_FLT}, /* center vertex offset along normal */
|
||||
{"center_mode", BMO_OP_SLOT_INT}, /* calculation mode for center vertex */
|
||||
{"center_mode", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_poke_center_mode}, /* calculation mode for center vertex */
|
||||
{"use_relative_offset", BMO_OP_SLOT_BOOL}, /* apply offset */
|
||||
{{'\0'}},
|
||||
},
|
||||
|
@ -2008,7 +2151,7 @@ static BMOpDefine bmo_symmetrize_def = {
|
|||
"symmetrize",
|
||||
/* slots_in */
|
||||
{{"input", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}},
|
||||
{"direction", BMO_OP_SLOT_INT},
|
||||
{"direction", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_axis_xyz}, /* axis to use */
|
||||
{"dist", BMO_OP_SLOT_FLT}, /* minimum distance */
|
||||
{{'\0'}},
|
||||
},
|
||||
|
|
|
@ -193,13 +193,23 @@ typedef enum eBMOpSlotSubType_Ptr {
|
|||
BMO_OP_SLOT_SUBTYPE_PTR_OBJECT = 102,
|
||||
BMO_OP_SLOT_SUBTYPE_PTR_MESH = 103,
|
||||
} eBMOpSlotSubType_Ptr;
|
||||
typedef enum eBMOpSlotSubType_Int {
|
||||
BMO_OP_SLOT_SUBTYPE_INT_ENUM = 200,
|
||||
BMO_OP_SLOT_SUBTYPE_INT_FLAG = 201,
|
||||
} eBMOpSlotSubType_Int;
|
||||
|
||||
typedef union eBMOpSlotSubType_Union {
|
||||
eBMOpSlotSubType_Elem elem;
|
||||
eBMOpSlotSubType_Ptr ptr;
|
||||
eBMOpSlotSubType_Map map;
|
||||
eBMOpSlotSubType_Int intg;
|
||||
} eBMOpSlotSubType_Union;
|
||||
|
||||
typedef struct BMO_FlagSet {
|
||||
int value;
|
||||
const char *identifier;
|
||||
} BMO_FlagSet;
|
||||
|
||||
/* please ignore all these structures, don't touch them in tool code, except
|
||||
* for when your defining an operator with BMOpDefine.*/
|
||||
|
||||
|
@ -218,6 +228,7 @@ typedef struct BMOpSlot {
|
|||
float vec[3];
|
||||
void **buf;
|
||||
GHash *ghash;
|
||||
BMO_FlagSet *enum_flags;
|
||||
} data;
|
||||
} BMOpSlot;
|
||||
|
||||
|
@ -269,6 +280,7 @@ typedef struct BMOSlotType {
|
|||
char name[MAX_SLOTNAME];
|
||||
eBMOpSlotType type;
|
||||
eBMOpSlotSubType_Union subtype;
|
||||
BMO_FlagSet *enum_flags;
|
||||
} BMOSlotType;
|
||||
|
||||
typedef struct BMOpDefine {
|
||||
|
|
|
@ -140,6 +140,10 @@ static void bmo_op_slots_init(const BMOSlotType *slot_types, BMOpSlot *slot_args
|
|||
case BMO_OP_SLOT_MAPPING:
|
||||
slot->data.ghash = BLI_ghash_ptr_new("bmesh slot map hash");
|
||||
break;
|
||||
case BMO_OP_SLOT_INT:
|
||||
if (ELEM(slot->slot_subtype.intg, BMO_OP_SLOT_SUBTYPE_INT_ENUM, BMO_OP_SLOT_SUBTYPE_INT_FLAG)) {
|
||||
slot->data.enum_flags = slot_types[i].enum_flags;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -75,10 +75,14 @@ static char *bmp_slots_as_args(const BMOSlotType slot_types[BMO_OP_MAX_SLOTS], c
|
|||
{
|
||||
DynStr *dyn_str = BLI_dynstr_new();
|
||||
char *ret;
|
||||
bool quoted;
|
||||
bool set;
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (*slot_types[i].name) {
|
||||
quoted = false;
|
||||
set = false;
|
||||
/* cut off '.out' by using a string size arg */
|
||||
const int name_len = is_out ?
|
||||
(strchr(slot_types[i].name, '.') - slot_types[i].name) :
|
||||
|
@ -86,7 +90,19 @@ static char *bmp_slots_as_args(const BMOSlotType slot_types[BMO_OP_MAX_SLOTS], c
|
|||
const char *value = "<Unknown>";
|
||||
switch (slot_types[i].type) {
|
||||
case BMO_OP_SLOT_BOOL: value = "False"; break;
|
||||
case BMO_OP_SLOT_INT: value = "0"; break;
|
||||
case BMO_OP_SLOT_INT:
|
||||
if (slot_types[i].subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_ENUM) {
|
||||
value = slot_types[i].enum_flags[0].identifier;
|
||||
quoted = true;
|
||||
}
|
||||
else if (slot_types[i].subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_FLAG) {
|
||||
value = "";
|
||||
set = true;
|
||||
}
|
||||
else {
|
||||
value = "0";
|
||||
}
|
||||
break;
|
||||
case BMO_OP_SLOT_FLT: value = "0.0"; break;
|
||||
case BMO_OP_SLOT_PTR: value = "None"; break;
|
||||
case BMO_OP_SLOT_MAT: value = "Matrix()"; break;
|
||||
|
@ -95,7 +111,11 @@ static char *bmp_slots_as_args(const BMOSlotType slot_types[BMO_OP_MAX_SLOTS], c
|
|||
(slot_types[i].subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) ? "None" : "[]"; break;
|
||||
case BMO_OP_SLOT_MAPPING: value = "{}"; break;
|
||||
}
|
||||
BLI_dynstr_appendf(dyn_str, i ? ", %.*s=%s" : "%.*s=%s", name_len, slot_types[i].name, value);
|
||||
BLI_dynstr_appendf(dyn_str, i ? ", %.*s=%s%s%s%s%s" : "%.*s=%s%s%s%s%s",
|
||||
name_len, slot_types[i].name,
|
||||
set ? "{" : "", quoted ? "'" : "",
|
||||
value,
|
||||
quoted ? "'" : "", set ? "}" : "");
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include "../generic/python_utildefines.h"
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
BLI_STATIC_ASSERT(sizeof(PyC_FlagSet) == sizeof(BMO_FlagSet), "size mismatch");
|
||||
|
||||
static int bpy_bm_op_as_py_error(BMesh *bm)
|
||||
{
|
||||
if (BMO_error_occurred(bm)) {
|
||||
|
@ -169,16 +171,46 @@ static int bpy_slot_from_py(
|
|||
}
|
||||
case BMO_OP_SLOT_INT:
|
||||
{
|
||||
const int param = PyC_Long_AsI32(value);
|
||||
if (slot->slot_subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_ENUM) {
|
||||
int enum_val = -1;
|
||||
PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_flags;
|
||||
const char *enum_str = _PyUnicode_AsString(value);
|
||||
|
||||
if (param == -1 && PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: keyword \"%.200s\" expected an int, not %.200s",
|
||||
opname, slot_name, Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
if (enum_str == NULL) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: keyword \"%.200s\" expected a string, not %.200s",
|
||||
opname, slot_name, Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyC_FlagSet_ValueFromID(items, enum_str, &enum_val, slot_name) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
BMO_SLOT_AS_INT(slot) = enum_val;
|
||||
}
|
||||
else if (slot->slot_subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_FLAG) {
|
||||
int flag = 0;
|
||||
PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_flags;
|
||||
|
||||
if (PyC_FlagSet_ToBitfield(items, value, &flag, slot_name) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
BMO_SLOT_AS_INT(slot) = flag;
|
||||
}
|
||||
else {
|
||||
BMO_SLOT_AS_INT(slot) = param;
|
||||
const int param = PyC_Long_AsI32(value);
|
||||
|
||||
if (param == -1 && PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: keyword \"%.200s\" expected an int, not %.200s",
|
||||
opname, slot_name, Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
BMO_SLOT_AS_INT(slot) = param;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue