[Bf-extensions-cvs] [b54e4c0] master: Edit Tools 2: fix register error, mesh_check cleanup
lijenstina
noreply at git.blender.org
Tue Apr 4 13:21:49 CEST 2017
Commit: b54e4c07b2246580670b82bcb2873880e3b600c8
Author: lijenstina
Date: Tue Apr 4 13:21:01 2017 +0200
Branches: master
https://developer.blender.org/rBAb54e4c07b2246580670b82bcb2873880e3b600c8
Edit Tools 2: fix register error, mesh_check cleanup
DATA_OP_facetype_select operator was included in
mesh_check but was also present in mesh_select_by_type
Pep8 cleanup
removed the panel draw code as it was already
merged in init (displayMeshCheckPanel)
===================================================================
M mesh_extra_tools/mesh_check.py
===================================================================
diff --git a/mesh_extra_tools/mesh_check.py b/mesh_extra_tools/mesh_check.py
index a8f1ab6..cc4187c 100644
--- a/mesh_extra_tools/mesh_check.py
+++ b/mesh_extra_tools/mesh_check.py
@@ -1,19 +1,19 @@
+# gpl author: Pistiwique
+
bl_info = {"name": "Mesh Check BGL edition",
"description": "Display the triangles and ngons of the mesh",
"author": "Pistiwique",
- "version": (1, 0, 0),
+ "version": (1, 0, 1),
"blender": (2, 75, 0),
"location": "3D View(s) -> Properties -> Shading",
"category": "3D View"
}
-
-
import bpy
+import bmesh
from bgl import (
glBegin,
glLineWidth,
- glColor3f,
glColor4f,
glVertex3f,
glEnd,
@@ -23,14 +23,21 @@ from bgl import (
GL_DEPTH_TEST,
GL_BLEND,
GL_POLYGON
-)
-
+ )
from mathutils.geometry import tessellate_polygon as tessellate
-import bmesh
-from mathutils import Vector
+from bpy.types import (
+ Operator,
+ PropertyGroup,
+ )
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ FloatVectorProperty,
+ PointerProperty,
+ )
-from bpy.props import EnumProperty, PointerProperty
-
+# -- Globals -- #
mesh_check_handle = []
draw_enabled = [False]
edge_width = [1.0]
@@ -41,133 +48,144 @@ 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)
+ 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]
+ 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]
+ 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]
+ indices = [v.index for v in face.verts]
for pol in tessellate([coords]):
new_faces.append([indices[i] for i in pol])
-
+
for f in new_faces:
- faces.append([((matrix_world*bm.verts[i].co)[0]+face.normal.x*0.001,
- (matrix_world*bm.verts[i].co)[1]+face.normal.y*0.001,
- (matrix_world*bm.verts[i].co)[2]+face.normal.z*0.001)
- for i in f])
-
+ faces.append(
+ [((matrix_world * bm.verts[i].co)[0] + face.normal.x * 0.001,
+ (matrix_world * bm.verts[i].co)[1] + face.normal.y * 0.001,
+ (matrix_world * bm.verts[i].co)[2] + face.normal.z * 0.001)
+ for i in f]
+ )
+
for f in faces:
glColor4f(*faces_ngons_color[0])
glEnable(GL_BLEND)
glBegin(GL_POLYGON)
draw_poly(f)
glEnd()
-
+
for edge in face.edges:
if edge.is_valid:
- edges = [matrix_world*vert.co for vert in edge.verts]
+ edges = [matrix_world * vert.co for vert in edge.verts]
glColor4f(*edges_ngons_color[0])
glBegin(GL_LINES)
draw_poly(edges)
glEnd()
-
+
glDisable(GL_BLEND)
glColor4f(0.0, 0.0, 0.0, 1.0)
glLineWidth(edge_width[0])
glEnable(GL_DEPTH_TEST)
-
+
if use_occlude:
-
+
for face in bm.faces:
if len([verts for verts in face.verts]) == 3:
faces = []
for vert in face.verts:
- vert_face = matrix_world*vert.co
- faces.append((vert_face[0]+face.normal.x*0.001, vert_face[1]+face.normal.y*0.001, vert_face[2]+face.normal.z*0.001))
-
+ vert_face = matrix_world * vert.co
+ faces.append(
+ (vert_face[0] + face.normal.x * 0.001,
+ vert_face[1] + face.normal.y * 0.001,
+ vert_face[2] + face.normal.z * 0.001)
+ )
+
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 = []
for vert in edge.verts:
- vert_edge = matrix_world*vert.co
- edges.append((vert_edge[0]+face.normal.x*0.001, vert_edge[1]+face.normal.y*0.001, vert_edge[2]+face.normal.z*0.001))
+ vert_edge = matrix_world * vert.co
+ edges.append(
+ (vert_edge[0] + face.normal.x * 0.001,
+ vert_edge[1] + face.normal.y * 0.001,
+ vert_edge[2] + face.normal.z * 0.001)
+ )
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]
+ indices = [v.index for v in face.verts]
for pol in tessellate([coords]):
new_faces.append([indices[i] for i in pol])
-
+
for f in new_faces:
- faces.append([((matrix_world*bm.verts[i].co)[0]+face.normal.x*0.001,
- (matrix_world*bm.verts[i].co)[1]+face.normal.y*0.001,
- (matrix_world*bm.verts[i].co)[2]+face.normal.z*0.001)
- for i in f])
+ faces.append([
+ (
+ (matrix_world * bm.verts[i].co)[0] + face.normal.x * 0.001,
+ (matrix_world * bm.verts[i].co)[1] + face.normal.y * 0.001,
+ (matrix_world * bm.verts[i].co)[2] + face.normal.z * 0.001)
+ for i in f]
+ )
for f in faces:
glColor4f(*faces_ngons_color[0])
@@ -175,24 +193,26 @@ def mesh_check_draw_callback():
glBegin(GL_POLYGON)
draw_poly(f)
glEnd()
-
+
for edge in face.edges:
if edge.is_valid:
edges = []
for vert in edge.verts:
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list