Skip to content
Snippets Groups Projects
Commit e28ba6b9 authored by mano-wii's avatar mano-wii
Browse files

mesh_snap_utilities_line: Fix point size drawing.

parent 03d5de4e
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@
bl_info = {
"name": "Snap_Utilities_Line",
"author": "Germano Cavalcante",
"version": (5, 9, 12),
"version": (5, 9, 14),
"blender": (2, 80, 0),
"location": "View3D > TOOLS > Line Tool",
"description": "Extends Blender Snap controls",
......
......@@ -33,6 +33,7 @@ class SnapDrawn():
'axis_z_color',
'_format_pos',
'_format_pos_and_color',
'_is_point_size_enabled',
'_program_unif_col',
'_program_smooth_col',
'_batch_point',
......@@ -69,7 +70,6 @@ class SnapDrawn():
self._batch_point = None
def batch_line_strip_create(self, coords):
from gpu.types import (
GPUVertBuf,
......@@ -118,8 +118,7 @@ class SnapDrawn():
def draw(self, type, location, list_verts_co, vector_constrain, prevloc):
import gpu
# draw 3d point OpenGL in the 3D View
bgl.glEnable(bgl.GL_BLEND)
self._gl_state_push()
gpu.matrix.push()
self._program_unif_col.bind()
......@@ -139,7 +138,7 @@ class SnapDrawn():
point_batch = self.batch_point_get()
if vector_constrain:
if prevloc:
bgl.glPointSize(5)
bgl.glPointSize(5.0)
gpu.matrix.translate(prevloc)
self._program_unif_col.uniform_float("color", (1.0, 1.0, 1.0, 0.5))
point_batch.draw(self._program_unif_col)
......@@ -169,7 +168,7 @@ class SnapDrawn():
else: # type == None
Color4f = self.out_color
bgl.glPointSize(10)
bgl.glPointSize(10.0)
gpu.matrix.translate(location)
self._program_unif_col.uniform_float("color", Color4f)
......@@ -180,9 +179,9 @@ class SnapDrawn():
bgl.glPointSize(1.0)
bgl.glLineWidth(1.0)
bgl.glEnable(bgl.GL_DEPTH_TEST)
bgl.glDisable(bgl.GL_BLEND)
gpu.matrix.pop()
self._gl_state_restore()
def draw_elem(self, snap_obj, bm, elem):
#TODO: Cache coords (because antialiasing)
......@@ -192,11 +191,11 @@ class SnapDrawn():
BMEdge,
BMFace,
)
# draw 3d point OpenGL in the 3D View
bgl.glEnable(bgl.GL_BLEND)
bgl.glDisable(bgl.GL_DEPTH_TEST)
with gpu.matrix.push_pop():
self._gl_state_push()
bgl.glDisable(bgl.GL_DEPTH_TEST)
gpu.matrix.multiply_matrix(snap_obj.mat)
if isinstance(elem, BMVert):
......@@ -239,4 +238,5 @@ class SnapDrawn():
# restore opengl defaults
bgl.glEnable(bgl.GL_DEPTH_TEST)
bgl.glDisable(bgl.GL_BLEND)
self._gl_state_restore()
......@@ -507,6 +507,12 @@ class SnapContext():
#bgl.glDisable(bgl.GL_MULTISAMPLE)
bgl.glEnable(bgl.GL_DEPTH_TEST)
is_point_size_enabled = bgl.glIsEnabled(bgl.GL_PROGRAM_POINT_SIZE)
if is_point_size_enabled:
bgl.glDisable(bgl.GL_PROGRAM_POINT_SIZE)
bgl.glPointSize(4.0)
proj_mat = self.rv3d.perspective_matrix.copy()
if self.proj_mat != proj_mat:
self.proj_mat = proj_mat
......@@ -570,10 +576,12 @@ class SnapContext():
if snap_obj:
ret = self._get_loc(snap_obj, index)
bgl.glDisable(bgl.GL_DEPTH_TEST)
if is_point_size_enabled:
bgl.glEnable(bgl.GL_PROGRAM_POINT_SIZE)
self._offscreen.unbind()
bgl.glDisable(bgl.GL_DEPTH_TEST)
_Internal.gpu_Indices_restore_state()
self._offscreen.unbind()
return (snap_obj, *ret)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment