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:
authorGermano Cavalcante <germano.costa@ig.com.br>2021-08-16 19:46:11 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-08-16 20:01:05 +0300
commit8c8df3e36974c000ffb6b11c40c0e017902e98d7 (patch)
tree815ea76146b9ff1abdad68e4914ba6c7f8157f51
parent21dc384d15305a01d8f5042ae0d3bde7525fb925 (diff)
Snap_Utilities_Line: support 3d view clip planes
Elements that are not visible due to clip planes are ignored in the main operation.
-rw-r--r--mesh_snap_utilities_line/__init__.py4
-rw-r--r--mesh_snap_utilities_line/snap_context_l/mesh_drawing.py39
-rw-r--r--mesh_snap_utilities_line/snap_context_l/shaders/ID_color_vert.glsl4
3 files changed, 25 insertions, 22 deletions
diff --git a/mesh_snap_utilities_line/__init__.py b/mesh_snap_utilities_line/__init__.py
index 98f88e76..0b1b7a15 100644
--- a/mesh_snap_utilities_line/__init__.py
+++ b/mesh_snap_utilities_line/__init__.py
@@ -21,8 +21,8 @@
bl_info = {
"name": "Snap_Utilities_Line",
"author": "Germano Cavalcante",
- "version": (6, 9, 23),
- "blender": (2, 93, 0),
+ "version": (6, 9, 3),
+ "blender": (3, 0, 0),
"location": "View3D > TOOLS > Line Tool",
"description": "Extends Blender Snap controls",
"doc_url" : "https://blenderartists.org/t/cad-snap-utilities",
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 d05becec..bd324afd 100644
--- a/mesh_snap_utilities_line/snap_context_l/mesh_drawing.py
+++ b/mesh_snap_utilities_line/snap_context_l/mesh_drawing.py
@@ -211,12 +211,13 @@ class GPU_Indices_Mesh():
atexit.unregister(cls.end_opengl)
atexit.register(cls.end_opengl)
- cls.shader = gpu.types.GPUShader(load_shader("ID_color_vert.glsl"),
- load_shader("ID_color_frag.glsl"),)
- #cls.unif_use_clip_planes =
- #cls.shader.uniform_from_name('use_clip_planes')
- #cls.unif_clip_plane = cls.shader.uniform_from_name('clip_plane')
+ cls.shader = gpu.types.GPUShader(
+ load_shader("ID_color_vert.glsl"),
+ load_shader("ID_color_frag.glsl"),
+ defines="#define USE_CLIP_PLANES\n")
+
cls.unif_offset = cls.shader.uniform_from_name('offset')
+ cls.use_clip_planes = False
def __init__(self, depsgraph, obj, draw_tris, draw_edges, draw_verts):
@@ -332,8 +333,12 @@ class GPU_Indices_Mesh():
gpu.matrix.push()
gpu.matrix.push_projection()
gpu.matrix.multiply_matrix(ob_mat)
+
+ self.shader.bind()
+ if GPU_Indices_Mesh.use_clip_planes:
+ self.shader.uniform_float("ModelMatrix", ob_mat)
+
if self.draw_tris:
- self.shader.bind()
self.shader.uniform_int("offset", (index_offset,))
self.batch_tris.draw(self.shader)
index_offset += len(self.tri_verts)
@@ -359,7 +364,6 @@ class GPU_Indices_Mesh():
gpu.matrix.load_projection_matrix(winmat)
if self.draw_edges:
- self.shader.bind()
self.shader.uniform_int("offset", (index_offset,))
#bgl.glLineWidth(3.0)
self.batch_edges.draw(self.shader)
@@ -367,7 +371,6 @@ class GPU_Indices_Mesh():
index_offset += len(self.edge_verts)
if self.draw_verts:
- self.shader.bind()
self.shader.uniform_int("offset", (index_offset,))
self.batch_lverts.draw(self.shader)
@@ -427,17 +430,17 @@ def gpu_Indices_restore_state():
def gpu_Indices_use_clip_planes(rv3d, value):
- pass #TODO
- #if rv3d.use_clip_planes:
- #planes = bgl.Buffer(bgl.GL_FLOAT, (6, 4), rv3d.clip_planes)
-
- #_store_current_shader_state(PreviousGLState)
- #GPU_Indices_Mesh.init_opengl()
- #bgl.glUseProgram(GPU_Indices_Mesh.shader.program)
- #bgl.glUniform1i(GPU_Indices_Mesh.unif_use_clip_planes, value)
+ GPU_Indices_Mesh.init_opengl()
+ shader = GPU_Indices_Mesh.shader
+ shader.bind()
+ if value and rv3d.use_clip_planes:
+ GPU_Indices_Mesh.use_clip_planes = True
+ planes = gpu.types.Buffer('FLOAT', (6, 4), rv3d.clip_planes)
+ shader.uniform_vector_float(shader.uniform_from_name("clip_plane"), planes, 4, 4)
+ else:
+ GPU_Indices_Mesh.use_clip_planes = False
- #bgl.glUniform4fv(GPU_Indices_Mesh.unif_clip_plane, 4, planes)
+ shader.uniform_bool("use_clip_planes", (GPU_Indices_Mesh.use_clip_planes,))
- #_restore_shader_state(PreviousGLState)
def gpu_Indices_mesh_cache_clear():
GPU_Indices_Mesh._Hash.clear()
diff --git a/mesh_snap_utilities_line/snap_context_l/shaders/ID_color_vert.glsl b/mesh_snap_utilities_line/snap_context_l/shaders/ID_color_vert.glsl
index fa0afec6..6fb7cbb9 100644
--- a/mesh_snap_utilities_line/snap_context_l/shaders/ID_color_vert.glsl
+++ b/mesh_snap_utilities_line/snap_context_l/shaders/ID_color_vert.glsl
@@ -1,7 +1,7 @@
uniform mat4 ModelViewProjectionMatrix;
#ifdef USE_CLIP_PLANES
-uniform mat4 ModelViewMatrix;
+uniform mat4 ModelMatrix;
uniform bool use_clip_planes;
uniform vec4 clip_plane[4];
out vec4 clip_distance;
@@ -13,7 +13,7 @@ void main()
{
#ifdef USE_CLIP_PLANES
if (use_clip_planes) {
- vec4 g_pos = ModelViewMatrix * vec4(pos, 1.0);
+ vec4 g_pos = ModelMatrix * vec4(pos, 1.0);
for (int i = 0; i != 4; i++) {
clip_distance[i] = dot(clip_plane[i], g_pos);