[Bf-extensions-cvs] [7c2d2fb0] master: snap_context module: Use clip planes exposed by RNA

Germano noreply at git.blender.org
Fri Sep 15 19:14:11 CEST 2017


Commit: 7c2d2fb096f5899f82c16e3d81039f38335dd1be
Author: Germano
Date:   Fri Sep 15 14:14:01 2017 -0300
Branches: master
https://developer.blender.org/rBA7c2d2fb096f5899f82c16e3d81039f38335dd1be

snap_context module: Use clip planes exposed by RNA

===================================================================

M	modules/snap_context/bgl_ext.py
M	modules/snap_context/mesh_drawing.py

===================================================================

diff --git a/modules/snap_context/bgl_ext.py b/modules/snap_context/bgl_ext.py
index 46ce3186..f8dbff09 100644
--- a/modules/snap_context/bgl_ext.py
+++ b/modules/snap_context/bgl_ext.py
@@ -128,13 +128,3 @@ def bgl_Buffer_reshape(buf, shape):
     del c_buf
     del c_tmp_buf
     del tmp_buf
-
-
-def get_clip_planes(rv3d):
-    #(int)(&((struct RegionView3D *)0)->rflag) == 842
-    #(int)(&((struct RegionView3D *)0)->clip) == 464
-    rv3d_ptr = rv3d.as_pointer()
-    rflag = ctypes.c_short.from_address(rv3d_ptr + 842).value
-    if rflag & 4: # RV3D_CLIPPING
-        clip = (6 * (4 * ctypes.c_float)).from_address(rv3d_ptr + 464)
-        return bgl.Buffer(bgl.GL_FLOAT, (6, 4), clip)
diff --git a/modules/snap_context/mesh_drawing.py b/modules/snap_context/mesh_drawing.py
index dc6619a0..14e358a8 100644
--- a/modules/snap_context/mesh_drawing.py
+++ b/modules/snap_context/mesh_drawing.py
@@ -21,7 +21,7 @@ import bmesh
 import numpy as np
 from mathutils import Matrix
 
-from .bgl_ext import VoidBufValue, np_array_as_bgl_Buffer, bgl_Buffer_reshape, get_clip_planes
+from .bgl_ext import VoidBufValue, np_array_as_bgl_Buffer, bgl_Buffer_reshape
 from .utils_shader import Shader
 
 
@@ -502,8 +502,9 @@ def gpu_Indices_restore_state():
 
 
 def gpu_Indices_use_clip_planes(rv3d, value):
-    planes = get_clip_planes(rv3d)
-    if planes:
+    if rv3d.use_clip_planes:
+        planes = bgl.Buffer(bgl.GL_FLOAT, (6, 4), rv3d.clip_planes)
+
         _store_current_shader_state(PreviousGLState)
         bgl.glUseProgram(GPU_Indices_Mesh.shader.program)
         bgl.glUniform1i(GPU_Indices_Mesh.unif_use_clip_planes, value)



More information about the Bf-extensions-cvs mailing list