From 6d2897c7ed7c36ba428bb61fc3ac16eb308c283c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 26 Oct 2018 11:26:39 +1100 Subject: Update Gizmo.draw_custom_shape for API changes --- release/scripts/modules/bpy_types.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'release/scripts/modules/bpy_types.py') diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 84262e618d8..a80fe6a7c9f 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -594,10 +594,7 @@ class Gizmo(StructRNA): if matrix is None: matrix = self.matrix_world - batch, 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') + batch, shader, dims = shape if select_id is not None: gpu.select.load_id(select_id) @@ -606,7 +603,8 @@ class Gizmo(StructRNA): color = (*self.color_highlight, self.alpha_highlight) else: color = (*self.color, self.alpha) - batch.uniform_f32("color", *color) + batch.program_set(shader) + shader.uniform_float("color", color) with gpu.matrix.push_pop(): gpu.matrix.multiply_matrix(matrix) @@ -626,6 +624,7 @@ class Gizmo(StructRNA): :return: The newly created shape. :rtype: Undefined (it may change). """ + import gpu from gpu.types import ( GPUBatch, GPUVertBuf, @@ -637,9 +636,10 @@ class Gizmo(StructRNA): fmt = GPUVertFormat() pos_id = fmt.attr_add(id="pos", comp_type='F32', len=dims, fetch_mode='FLOAT') 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) - 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 -- cgit v1.2.3