Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-01-10 12:50:14 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-01-10 12:50:14 +0300
commitf59303bead2ae4a25132edadf217a64cdd581dc5 (patch)
tree1d64b157ee7c0ddac1f5c91c239d12a104e3c87e
parent2b56faebe5f2a8e2b37004485206007d22cdac1d (diff)
Fix color for manipulator drawing
Was drawing black after the first draw call. For now set the shader before each draw call, noted as TODO to investigate a nicer way to handle.
-rw-r--r--release/scripts/modules/bpy_types.py12
-rw-r--r--release/scripts/templates_py/manipulator_custom_geometry.py2
-rw-r--r--source/blender/python/gawain/gwn_py_types.c10
3 files changed, 14 insertions, 10 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 78c70225a04..6b06ff77ecd 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -644,6 +644,11 @@ class Manipulator(StructRNA, metaclass=OrderedMeta):
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')
+
if select_id is not None:
gpu.select.load_id(select_id)
else:
@@ -651,11 +656,11 @@ class Manipulator(StructRNA, metaclass=OrderedMeta):
color = (*self.color_highlight, self.alpha_highlight)
else:
color = (*self.color, self.alpha)
- shape.uniform_f32("color", *color)
+ batch.uniform_f32("color", *color)
with gpu.matrix.push_pop():
gpu.matrix.multiply_matrix(matrix)
- shape.draw()
+ batch.draw()
@staticmethod
def new_custom_shape(type, verts):
@@ -684,8 +689,7 @@ class Manipulator(StructRNA, metaclass=OrderedMeta):
vbo = Gwn_VertBuf(len=len(verts), format=fmt)
vbo.fill(id=pos_id, data=verts)
batch = Gwn_Batch(type=type, buf=vbo)
- batch.program_set_builtin('3D_UNIFORM_COLOR' if dims == 3 else '2D_UNIFORM_COLOR')
- return batch
+ return (batch, dims)
# Only defined so operators members can be used by accessing self.order
diff --git a/release/scripts/templates_py/manipulator_custom_geometry.py b/release/scripts/templates_py/manipulator_custom_geometry.py
index 0f1ab72f9ef..48bb6956f85 100644
--- a/release/scripts/templates_py/manipulator_custom_geometry.py
+++ b/release/scripts/templates_py/manipulator_custom_geometry.py
@@ -134,7 +134,7 @@ class MyCustomShapeWidgetGroup(ManipulatorGroup):
mpr.color = 1.0, 0.5, 1.0
mpr.alpha = 0.5
- mpr.color_highlight = 1.0, 0.5, 1.0
+ mpr.color_highlight = 1.0, 1.0, 1.0
mpr.alpha_highlight = 0.5
# units are large, so shrink to something more reasonable.
diff --git a/source/blender/python/gawain/gwn_py_types.c b/source/blender/python/gawain/gwn_py_types.c
index 5b602e85a12..4f6b354b7be 100644
--- a/source/blender/python/gawain/gwn_py_types.c
+++ b/source/blender/python/gawain/gwn_py_types.c
@@ -634,7 +634,7 @@ static PyObject *bpygwn_VertBatch_uniform_i32(BPyGwn_Batch *self, PyObject *args
static PyObject *bpygwn_VertBatch_uniform_f32(BPyGwn_Batch *self, PyObject *args)
{
- static struct {
+ struct {
const char *id;
float values[4];
} params;
@@ -648,10 +648,10 @@ static PyObject *bpygwn_VertBatch_uniform_f32(BPyGwn_Batch *self, PyObject *args
}
switch (PyTuple_GET_SIZE(args)) {
- case 2: GWN_batch_uniform_1f(self->batch, params.id, params.values[0]); break;
- case 3: GWN_batch_uniform_2fv(self->batch, params.id, params.values); break;
- case 4: GWN_batch_uniform_3fv(self->batch, params.id, params.values); break;
- case 5: GWN_batch_uniform_4fv(self->batch, params.id, params.values); break;
+ case 2: GWN_batch_uniform_1f(self->batch, params.id, params.values[0]); break;
+ case 3: GWN_batch_uniform_2f(self->batch, params.id, UNPACK2(params.values)); break;
+ case 4: GWN_batch_uniform_3f(self->batch, params.id, UNPACK3(params.values)); break;
+ case 5: GWN_batch_uniform_4f(self->batch, params.id, UNPACK4(params.values)); break;
default:
BLI_assert(0);
}