snap_context module: Use clip planes exposed by RNA

This commit is contained in:
Germano Cavalcante 2017-09-15 14:14:01 -03:00
parent b119529556
commit 7c2d2fb096
2 changed files with 4 additions and 13 deletions

View File

@ -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)

View File

@ -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)