From 0fd176e03d0f6b0c6e4211c0a29eafa8309c4b8b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Feb 2012 20:27:30 +0000 Subject: moved select interior faces into a C function (was python) --- release/scripts/startup/bl_operators/mesh.py | 44 ---------------------- .../startup/bl_ui/properties_data_modifier.py | 4 +- release/scripts/startup/bl_ui/space_view3d.py | 6 +-- source/blender/editors/include/ED_mesh.h | 2 + source/blender/editors/mesh/bmesh_select.c | 32 ++++++++++++++++ source/blender/editors/mesh/bmesh_tools.c | 31 +++++++++++++++ source/blender/editors/mesh/mesh_intern.h | 1 + source/blender/editors/mesh/mesh_ops.c | 1 + source/blender/makesdna/DNA_modifier_types.h | 2 - source/blender/makesrna/intern/rna_modifier.c | 2 +- 10 files changed, 73 insertions(+), 52 deletions(-) diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py index 3e206017238..1904ee5598e 100644 --- a/release/scripts/startup/bl_operators/mesh.py +++ b/release/scripts/startup/bl_operators/mesh.py @@ -24,50 +24,6 @@ from bpy.types import Operator from bpy.props import EnumProperty -class MeshSelectInteriorFaces(Operator): - '''Select faces where all edges have more than 2 face users''' - - bl_idname = "mesh.faces_select_interior" - bl_label = "Select Interior Faces" - bl_options = {'REGISTER', 'UNDO'} - - @classmethod - def poll(cls, context): - ob = context.active_object - return (ob and ob.type == 'MESH') - - def execute(self, context): - from bpy_extras import mesh_utils - ob = context.active_object - context.tool_settings.mesh_select_mode = False, False, True - is_editmode = (ob.mode == 'EDIT') - if is_editmode: - bpy.ops.object.mode_set(mode='OBJECT', toggle=False) - - mesh = ob.data - - face_list = mesh.faces[:] - face_edge_keys = [face.edge_keys for face in face_list] - - edge_face_count = mesh_utils.edge_face_count_dict(mesh) - - def test_interior(index): - for key in face_edge_keys[index]: - if edge_face_count[key] < 3: - return False - return True - - for index, face in enumerate(face_list): - if(test_interior(index)): - face.select = True - else: - face.select = False - - if is_editmode: - bpy.ops.object.mode_set(mode='EDIT', toggle=False) - return {'FINISHED'} - - class MeshMirrorUV(Operator): '''Copy mirror UV coordinates on the X axis based on a mirrored mesh''' bl_idname = "mesh.faces_mirror_uv" diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 9cbb9b92463..f4e5c27b90a 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -126,11 +126,11 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): split.prop(md, "width") split.prop(md, "use_only_vertices") - # BMESH_BRANCH ONLY + # -- new modifier only, this may be reverted in favor of 2.62 mod. split = layout.split() split.prop(md, "use_even_offset") split.prop(md, "use_distance_offset") - # END BMESH_BRANCH ONLY + # -- end layout.label(text="Limit Method:") layout.row().prop(md, "limit_method", expand=True) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index c12a94e6637..be5aa91db3c 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -522,7 +522,7 @@ class VIEW3D_MT_select_edit_mesh(Menu): layout.operator("mesh.select_nth", text="Every N Number of Verts") layout.operator("mesh.edges_select_sharp", text="Sharp Edges") layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces") - layout.operator("mesh.faces_select_interior", text="Interior Faces") + layout.operator("mesh.select_interior_faces", text="Interior Faces") layout.operator("mesh.select_axis", text="Side of Active") layout.separator() @@ -1501,7 +1501,7 @@ class VIEW3D_MT_edit_mesh(Menu): layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region") layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual") - layout.operator("mesh.dissolve_limited") # BMESH ONLY + layout.operator("mesh.dissolve_limited") layout.operator("mesh.duplicate_move") layout.operator("mesh.delete", text="Delete...") @@ -1537,7 +1537,7 @@ class VIEW3D_MT_edit_mesh_specials(Menu): """ layout.operator("mesh.merge", text="Merge...") layout.operator("mesh.remove_doubles") - layout.operator("mesh.dissolve_limited") # BMESH ONLY + layout.operator("mesh.dissolve_limited") layout.operator("mesh.hide", text="Hide") layout.operator("mesh.reveal", text="Reveal") layout.operator("mesh.select_all").action = 'INVERT' diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index dc9011b5d46..12524a9fd2e 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -180,6 +180,8 @@ int EDBM_init_backbuf_circle(struct ViewContext *vc, short xs, short ys, short void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const short select); +int EDBM_select_interior_faces(struct BMEditMesh *em); + struct UvElementMap *EDBM_make_uv_element_map(struct BMEditMesh *em, int selected, int doIslands); void EDBM_free_uv_element_map(struct UvElementMap *vmap); diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index b0440eeb14f..38daf3c0d22 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -1694,6 +1694,38 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */ // if (EM_texFaceCheck()) } +int EDBM_select_interior_faces(struct BMEditMesh *em) +{ + BMesh *bm = em->bm; + BMIter iter; + BMIter eiter; + BMFace *efa; + BMEdge *eed; + int ok; + int change = FALSE; + + BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { + if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) + continue; + + + ok = TRUE; + BM_ITER(eed, &eiter, bm, BM_EDGES_OF_FACE, efa) { + if (BM_edge_face_count(eed) < 3) { + ok = FALSE; + break; + } + } + + if (ok) { + BM_elem_select_set(bm, efa, TRUE); + change = TRUE; + } + } + + return change; +} + static void linked_limit_default(bContext *C, wmOperator *op) { if (!RNA_struct_property_is_set(op->ptr, "limit")) { diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 63834815f42..cffc001b8d2 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -680,6 +680,37 @@ void MESH_OT_select_all(wmOperatorType *ot) WM_operator_properties_select_all(ot); } +static int mesh_faces_select_interior_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *obedit = CTX_data_edit_object(C); + BMEditMesh *em = ((Mesh *)obedit->data)->edit_btmesh; + + if (EDBM_select_interior_faces(em)) { + WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } + +} + +void MESH_OT_select_interior_faces(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Interior Faces"; + ot->idname = "MESH_OT_select_interior_faces"; + ot->description = "Select faces where all edges have more than 2 face users"; + + /* api callbacks */ + ot->exec = mesh_faces_select_interior_exec; + ot->poll = ED_operator_editmesh; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + /* *************** add-click-mesh (extrude) operator ************** */ /* in trunk see: 'editmesh_add.c' */ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index ec92b78c2c4..58ad32fad4d 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -200,6 +200,7 @@ void MESH_OT_knife_cut(struct wmOperatorType *ot); /* ******************* bmesh_select.c */ void MESH_OT_loop_select(struct wmOperatorType *ot); void MESH_OT_select_all(struct wmOperatorType *ot); +void MESH_OT_select_interior_faces(struct wmOperatorType *ot); void MESH_OT_bmesh_test(struct wmOperatorType *ot); void MESH_OT_select_more(struct wmOperatorType *ot); void MESH_OT_select_less(struct wmOperatorType *ot); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index d26fc5c6492..4bc500fcdab 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -60,6 +60,7 @@ void ED_operatortypes_mesh(void) { WM_operatortype_append(MESH_OT_select_all); + WM_operatortype_append(MESH_OT_select_interior_faces); WM_operatortype_append(MESH_OT_select_more); WM_operatortype_append(MESH_OT_select_less); WM_operatortype_append(MESH_OT_select_non_manifold); diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 98b4a0bd4f6..93e8c2973f2 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -77,8 +77,6 @@ typedef enum ModifierType { eModifierType_Ocean, eModifierType_DynamicPaint, eModifierType_Remesh, - - /* BMESH ONLY - keeps getting bumped by new modifiers in trunk */ eModifierType_NgonInterp, NUM_MODIFIER_TYPES } ModifierType; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index a4bc99174be..6bcd8c0a5bc 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -73,6 +73,7 @@ EnumPropertyItem modifier_type_items[] ={ {eModifierType_Screw, "SCREW", ICON_MOD_SCREW, "Screw", ""}, {eModifierType_Solidify, "SOLIDIFY", ICON_MOD_SOLIDIFY, "Solidify", ""}, {eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""}, + {eModifierType_NgonInterp, "NGONINTERP", ICON_MOD_LATTICE, "Precision UV Interpolation", ""}, {0, "", 0, "Deform", ""}, {eModifierType_Armature, "ARMATURE", ICON_MOD_ARMATURE, "Armature", ""}, {eModifierType_Cast, "CAST", ICON_MOD_CAST, "Cast", ""}, @@ -98,7 +99,6 @@ EnumPropertyItem modifier_type_items[] ={ {eModifierType_Smoke, "SMOKE", ICON_MOD_SMOKE, "Smoke", ""}, {eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""}, {eModifierType_Surface, "SURFACE", ICON_MOD_PHYSICS, "Surface", ""}, - {eModifierType_NgonInterp, "NGONINTERP", ICON_MOD_LATTICE, "Precision UV Interpolation", ""}, {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME -- cgit v1.2.3