[Bf-extensions-cvs] [ba89ec3] master: Update Mesh Edit Tools: T50680
meta-androcto
noreply at git.blender.org
Thu Mar 30 08:31:33 CEST 2017
Commit: ba89ec341ccea23d480d3c23c51ebaaf2bb88ee5
Author: meta-androcto
Date: Thu Mar 30 17:31:07 2017 +1100
Branches: master
https://developer.blender.org/rBAba89ec341ccea23d480d3c23c51ebaaf2bb88ee5
Update Mesh Edit Tools: T50680
===================================================================
M mesh_extra_tools/__init__.py
A mesh_extra_tools/icons/icons.py
A mesh_extra_tools/icons/ngon.png
A mesh_extra_tools/icons/triangle.png
A mesh_extra_tools/mesh_check.py
M mesh_extra_tools/mesh_mextrude_plus.py
M mesh_extra_tools/pkhg_faces.py
===================================================================
diff --git a/mesh_extra_tools/__init__.py b/mesh_extra_tools/__init__.py
index 90f5c67..89b9a45 100644
--- a/mesh_extra_tools/__init__.py
+++ b/mesh_extra_tools/__init__.py
@@ -63,6 +63,7 @@ if "bpy" in locals():
importlib.reload(mesh_selection_topokit)
importlib.reload(mesh_info_select)
importlib.reload(mesh_extrude_and_reshape)
+ importlib.reload(mesh_check)
else:
from . import face_inset_fillet
@@ -83,6 +84,7 @@ else:
from . import vfe_specials
from . import mesh_help
from . import mesh_extrude_and_reshape
+ from . import mesh_check
from .mesh_select_tools import mesh_select_by_direction
from .mesh_select_tools import mesh_select_by_edge_length
@@ -93,7 +95,11 @@ else:
from .mesh_select_tools import mesh_selection_topokit
from .mesh_select_tools import mesh_info_select
+ from . icons.icons import load_icons
+
import bpy
+import bmesh
+from bpy.props import EnumProperty
from bpy.types import (
Menu,
Panel,
@@ -316,6 +322,11 @@ class EditToolsPanel(Panel):
row.operator("mesh.extra_tools_help",
icon="LAYER_USED").help_ids = "split_solidify"
+ row = layout.split(0.8, align=True)
+ row.operator("mesh.add_faces_to_object", "Shape Extrude")
+ row.operator("mesh.extra_tools_help",
+ icon="LAYER_USED").help_ids = "pkhg_faces"
+
# Utils options
box1 = self.layout.box()
col = box1.column(align=True)
@@ -353,11 +364,64 @@ class EditToolsPanel(Panel):
row = layout.row(align=True)
row.operator("mesh.select_vert_edge_face_index",
- icon="VERTEXSEL", text="Vert Index").select_type = 'VERT'
- row.operator("mesh.select_vert_edge_face_index",
- icon="EDGESEL", text="Edge Index").select_type = 'EDGE'
- row.operator("mesh.select_vert_edge_face_index",
- icon="FACESEL", text="Face Index").select_type = 'FACE'
+ icon="VERTEXSEL", text="Select By Index").select_type = 'VERT'
+
+ layout = self.layout
+ icons = load_icons()
+ tris = icons.get("triangles")
+ ngons = icons.get("ngons")
+
+
+ mesh_check = context.window_manager.mesh_check
+
+ layout.prop(mesh_check, "mesh_check_use")
+
+ if mesh_check.mesh_check_use:
+ layout = self.layout
+
+ row = layout.row()
+ row.operator("object.face_type_select", text="Tris", icon_value=tris.icon_id).face_type = 'tris'
+ row.operator("object.face_type_select", text="Ngons",icon_value=ngons.icon_id).face_type = 'ngons'
+ row = layout.row()
+ row.prop(mesh_check, "display_faces", text="Display Faces")
+ if mesh_check.display_faces:
+ row = layout.row()
+ row.prop(mesh_check, "edge_width")
+ row = layout.row()
+ row.prop(mesh_check, "custom_tri_color",text="Tris color" )
+ row = layout.row()
+ row.prop(mesh_check, "custom_ngons_color")
+ row = layout.row()
+ row.prop(mesh_check, "face_opacity")
+ if bpy.context.object.mode == 'EDIT':
+ obj = bpy.context.object
+ me = obj.data
+ bm = bmesh.from_edit_mesh(me)
+
+ info_str = ""
+ tris = ngons = 0
+
+ for f in bm.faces:
+
+ v = len(f.verts)
+ if v == 3:
+ tris += 1
+ elif v > 4:
+ ngons += 1
+
+ bmesh.update_edit_mesh(me)
+ info_str = " Ngons: %i Tris: %i" % (ngons, tris)
+
+ split = layout.split(percentage=0.1)
+ split.separator()
+ split.label(info_str, icon='MESH_DATA')
+
+ if context.mode == 'EDIT_MESH' and not context.space_data.use_occlude_geometry:
+ split = layout.split(percentage=0.1)
+ split.separator()
+ split2 = split.split()
+ row = split2.row()
+ row.prop(mesh_check, "finer_lines_behind_use")
# ********** Edit Multiselect **********
@@ -719,6 +783,7 @@ def register():
mesh_pen_tool.register()
vfe_specials.register()
mesh_extrude_and_reshape.register()
+ mesh_check.register()
bpy.utils.register_module(__name__)
# Register Scene Properties
@@ -742,6 +807,7 @@ def unregister():
mesh_pen_tool.unregister()
vfe_specials.unregister()
mesh_extrude_and_reshape.unregister()
+ mesh_check.unregister()
del bpy.types.Scene.mesh_extra_tools
del bpy.types.Object.tkkey
diff --git a/mesh_extra_tools/icons/icons.py b/mesh_extra_tools/icons/icons.py
new file mode 100644
index 0000000..92b7d0d
--- /dev/null
+++ b/mesh_extra_tools/icons/icons.py
@@ -0,0 +1,31 @@
+import os
+import bpy
+import bpy.utils.previews
+
+mesh_check_icon_collections = {}
+mesh_check_icons_loaded = False
+
+def load_icons():
+ global mesh_check_icon_collections
+ global mesh_check_icons_loaded
+
+ if mesh_check_icons_loaded: return mesh_check_icon_collections["main"]
+
+ custom_icons = bpy.utils.previews.new()
+
+ icons_dir = os.path.join(os.path.dirname(__file__))
+
+ custom_icons.load("ngons", os.path.join(icons_dir, "ngon.png"), 'IMAGE')
+ custom_icons.load("triangles", os.path.join(icons_dir, "triangle.png"), 'IMAGE')
+
+ mesh_check_icon_collections["main"] = custom_icons
+ mesh_check_icons_loaded = True
+
+ return mesh_check_icon_collections["main"]
+
+def clear_icons():
+ global mesh_check_icons_loaded
+ for icon in mesh_check_icon_collections.values():
+ bpy.utils.previews.remove(icon)
+ mesh_check_icon_collections.clear()
+ mesh_check_icons_loaded = False
diff --git a/mesh_extra_tools/icons/ngon.png b/mesh_extra_tools/icons/ngon.png
new file mode 100644
index 0000000..b1a79b9
Binary files /dev/null and b/mesh_extra_tools/icons/ngon.png differ
diff --git a/mesh_extra_tools/icons/triangle.png b/mesh_extra_tools/icons/triangle.png
new file mode 100644
index 0000000..05f3a8d
Binary files /dev/null and b/mesh_extra_tools/icons/triangle.png differ
diff --git a/mesh_extra_tools/mesh_check.py b/mesh_extra_tools/mesh_check.py
new file mode 100644
index 0000000..a8f1ab6
--- /dev/null
+++ b/mesh_extra_tools/mesh_check.py
@@ -0,0 +1,448 @@
+bl_info = {"name": "Mesh Check BGL edition",
+ "description": "Display the triangles and ngons of the mesh",
+ "author": "Pistiwique",
+ "version": (1, 0, 0),
+ "blender": (2, 75, 0),
+ "location": "3D View(s) -> Properties -> Shading",
+ "category": "3D View"
+ }
+
+
+
+import bpy
+from bgl import (
+ glBegin,
+ glLineWidth,
+ glColor3f,
+ glColor4f,
+ glVertex3f,
+ glEnd,
+ GL_LINES,
+ glEnable,
+ glDisable,
+ GL_DEPTH_TEST,
+ GL_BLEND,
+ GL_POLYGON
+)
+
+from mathutils.geometry import tessellate_polygon as tessellate
+import bmesh
+from mathutils import Vector
+
+from bpy.props import EnumProperty, PointerProperty
+
+mesh_check_handle = []
+draw_enabled = [False]
+edge_width = [1.0]
+face_opacity = [0.2]
+edges_tri_color = [(1.0, 1.0, 0.0, 1)]
+faces_tri_color = [(1.0, 1.0, 0.0, face_opacity[0])]
+edges_ngons_color = [(1.0, 0.0, 0.0, 1.0)]
+faces_ngons_color = [(1.0, 0.0, 0.0, face_opacity[0])]
+bm_old = [None]
+finer_lines = [False]
+
+
+def draw_poly(points):
+ for i in range(len(points)):
+ glVertex3f(points[i][0], points[i][1], points[i][2])
+
+
+def mesh_check_draw_callback():
+ obj = bpy.context.object
+ if obj and obj.type == 'MESH':
+ if draw_enabled[0]:
+ mesh = obj.data
+ matrix_world = obj.matrix_world
+
+ glLineWidth(edge_width[0])
+
+ if bpy.context.mode == 'EDIT_MESH':
+
+ use_occlude = True
+
+ if bm_old[0] is None or not bm_old[0].is_valid:
+ bm = bm_old[0] = bmesh.from_edit_mesh(mesh)
+
+ else:
+ bm = bm_old[0]
+
+ no_depth = not bpy.context.space_data.use_occlude_geometry
+
+ if no_depth:
+ glDisable(GL_DEPTH_TEST)
+
+ use_occlude = False
+
+ if finer_lines[0]:
+ glLineWidth(edge_width[0]/4.0)
+ use_occlude = True
+
+ for face in bm.faces:
+ if len([verts for verts in face.verts]) == 3:
+ faces = [matrix_world*vert.co for vert in face.verts]
+ glColor4f(*faces_tri_color[0])
+ glEnable(GL_BLEND)
+ glBegin(GL_POLYGON)
+ draw_poly(faces)
+ glEnd()
+
+ for edge in face.edges:
+ if edge.is_valid:
+ edges = [matrix_world*vert.co for vert in edge.verts]
+ glColor4f(*edges_tri_color[0])
+ glBegin(GL_LINES)
+ draw_poly(edges)
+ glEnd()
+
+ elif len([verts for verts in face.verts]) > 4:
+ new_faces = []
+ faces = []
+ coords = [v.co for v in face.verts]
+ indices = [v.index for v in face.verts]
+ for pol in tessellate([coords]):
+ new_faces.append([i
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list