Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mesh_snap_utilities_line/snap_context_l/mesh_drawing.py')
-rw-r--r--mesh_snap_utilities_line/snap_context_l/mesh_drawing.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/mesh_snap_utilities_line/snap_context_l/mesh_drawing.py b/mesh_snap_utilities_line/snap_context_l/mesh_drawing.py
index 0b0b099c..76b9a1d4 100644
--- a/mesh_snap_utilities_line/snap_context_l/mesh_drawing.py
+++ b/mesh_snap_utilities_line/snap_context_l/mesh_drawing.py
@@ -18,9 +18,7 @@
import bgl
import bmesh
-import numpy as np
from mathutils import Matrix
-import gpu
def load_shader(shadername):
from os import path
@@ -30,6 +28,8 @@ def load_shader(shadername):
def get_mesh_vert_co_array(me):
tot_vco = len(me.vertices)
if tot_vco:
+ import numpy as np
+
verts_co = np.empty(len(me.vertices) * 3, 'f4')
me.vertices.foreach_get("co", verts_co)
verts_co.shape = (-1, 3)
@@ -40,6 +40,8 @@ def get_mesh_vert_co_array(me):
def get_bmesh_vert_co_array(bm):
tot_vco = len(bm.verts)
if tot_vco:
+ import numpy as np
+
return np.array([v.co for v in bm.verts], 'f4')
return None
@@ -48,6 +50,8 @@ def get_mesh_tri_verts_array(me):
me.calc_loop_triangles()
len_triangles = len(me.loop_triangles)
if len_triangles:
+ import numpy as np
+
tris = np.empty(len_triangles * 3, 'i4')
me.loop_triangles.foreach_get("vertices", tris)
tris.shape = (-1, 3)
@@ -56,6 +60,8 @@ def get_mesh_tri_verts_array(me):
def get_bmesh_tri_verts_array(bm):
+ import numpy as np
+
l_tri_layer = bm.faces.layers.int.get("l_tri")
if l_tri_layer is None:
l_tri_layer = bm.faces.layers.int.new("l_tri")
@@ -81,6 +87,8 @@ def get_bmesh_tri_verts_array(bm):
def get_mesh_edge_verts_array(me):
tot_edges = len(me.edges)
if tot_edges:
+ import numpy as np
+
edge_verts = np.empty(tot_edges * 2, 'i4')
me.edges.foreach_get("vertices", edge_verts)
edge_verts.shape = tot_edges, 2
@@ -92,11 +100,14 @@ def get_bmesh_edge_verts_array(bm):
bm.edges.ensure_lookup_table()
edges = [[e.verts[0].index, e.verts[1].index] for e in bm.edges if not e.hide]
if edges:
+ import numpy as np
return np.array(edges, 'i4')
return None
def get_mesh_loosevert_array(me, edges):
+ import numpy as np
+
verts = np.arange(len(me.vertices))
mask = np.in1d(verts, edges, invert=True)
@@ -110,6 +121,7 @@ def get_mesh_loosevert_array(me, edges):
def get_bmesh_loosevert_array(bm):
looseverts = [v.index for v in bm.verts if not (v.link_edges or v.hide)]
if looseverts:
+ import numpy as np
return np.array(looseverts, 'i4')
return None
@@ -150,6 +162,8 @@ class _Mesh_Arrays():
else: #TODO
+ import numpy as np
+
self.verts_co = np.zeros((1,3), 'f4')
self.looseverts = np.zeros(1, 'i4')
@@ -193,6 +207,7 @@ class GPU_Indices_Mesh():
return
import atexit
+ import gpu
# Make sure we only registered the callback once.
atexit.unregister(cls.end_opengl)
@@ -211,6 +226,7 @@ class GPU_Indices_Mesh():
@staticmethod
def set_ModelViewMatrix(MV):
+ import gpu
gpu.matrix.load_matrix(MV)
@@ -242,6 +258,8 @@ class GPU_Indices_Mesh():
update = True;
if update:
+ import gpu
+
self.draw_tris = draw_tris
self.draw_edges = draw_edges
self.draw_verts = draw_verts
@@ -378,6 +396,8 @@ class GPU_Indices_Mesh():
def gpu_Indices_enable_state():
+ import gpu
+
GPU_Indices_Mesh.init_opengl()
gpu.matrix.push()
gpu.matrix.push_projection()
@@ -386,6 +406,8 @@ def gpu_Indices_enable_state():
def gpu_Indices_restore_state():
+ import gpu
+
gpu.matrix.pop()
gpu.matrix.pop_projection()
@@ -406,6 +428,8 @@ def gpu_Indices_use_clip_planes(rv3d, value):
def gpu_Indices_set_ProjectionMatrix(P):
+ import gpu
+
gpu.matrix.load_projection_matrix(P)
GPU_Indices_Mesh.P[:] = P