Update Gizmo.draw_custom_shape for API changes
This commit is contained in:
@@ -594,10 +594,7 @@ class Gizmo(StructRNA):
|
|||||||
if matrix is None:
|
if matrix is None:
|
||||||
matrix = self.matrix_world
|
matrix = self.matrix_world
|
||||||
|
|
||||||
batch, dims = shape
|
batch, shader, dims = shape
|
||||||
|
|
||||||
# XXX, can we avoid setting the shader every time?
|
|
||||||
batch.program_set_builtin('3D_UNIFORM_COLOR' if dims == 3 else '2D_UNIFORM_COLOR')
|
|
||||||
|
|
||||||
if select_id is not None:
|
if select_id is not None:
|
||||||
gpu.select.load_id(select_id)
|
gpu.select.load_id(select_id)
|
||||||
@@ -606,7 +603,8 @@ class Gizmo(StructRNA):
|
|||||||
color = (*self.color_highlight, self.alpha_highlight)
|
color = (*self.color_highlight, self.alpha_highlight)
|
||||||
else:
|
else:
|
||||||
color = (*self.color, self.alpha)
|
color = (*self.color, self.alpha)
|
||||||
batch.uniform_f32("color", *color)
|
batch.program_set(shader)
|
||||||
|
shader.uniform_float("color", color)
|
||||||
|
|
||||||
with gpu.matrix.push_pop():
|
with gpu.matrix.push_pop():
|
||||||
gpu.matrix.multiply_matrix(matrix)
|
gpu.matrix.multiply_matrix(matrix)
|
||||||
@@ -626,6 +624,7 @@ class Gizmo(StructRNA):
|
|||||||
:return: The newly created shape.
|
:return: The newly created shape.
|
||||||
:rtype: Undefined (it may change).
|
:rtype: Undefined (it may change).
|
||||||
"""
|
"""
|
||||||
|
import gpu
|
||||||
from gpu.types import (
|
from gpu.types import (
|
||||||
GPUBatch,
|
GPUBatch,
|
||||||
GPUVertBuf,
|
GPUVertBuf,
|
||||||
@@ -637,9 +636,10 @@ class Gizmo(StructRNA):
|
|||||||
fmt = GPUVertFormat()
|
fmt = GPUVertFormat()
|
||||||
pos_id = fmt.attr_add(id="pos", comp_type='F32', len=dims, fetch_mode='FLOAT')
|
pos_id = fmt.attr_add(id="pos", comp_type='F32', len=dims, fetch_mode='FLOAT')
|
||||||
vbo = GPUVertBuf(len=len(verts), format=fmt)
|
vbo = GPUVertBuf(len=len(verts), format=fmt)
|
||||||
vbo.fill(id=pos_id, data=verts)
|
vbo.attr_fill(id=pos_id, data=verts)
|
||||||
batch = GPUBatch(type=type, buf=vbo)
|
batch = GPUBatch(type=type, buf=vbo)
|
||||||
return (batch, dims)
|
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR' if dims == 3 else '2D_UNIFORM_COLOR')
|
||||||
|
return (batch, shader, dims)
|
||||||
|
|
||||||
|
|
||||||
# Only defined so operators members can be used by accessing self.order
|
# Only defined so operators members can be used by accessing self.order
|
||||||
|
|||||||
Reference in New Issue
Block a user