[Bf-blender-cvs] [f59303bead2] blender2.8: Fix color for manipulator drawing

Campbell Barton noreply at git.blender.org
Wed Jan 10 10:43:18 CET 2018


Commit: f59303bead2ae4a25132edadf217a64cdd581dc5
Author: Campbell Barton
Date:   Wed Jan 10 20:50:14 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBf59303bead2ae4a25132edadf217a64cdd581dc5

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.

===================================================================

M	release/scripts/modules/bpy_types.py
M	release/scripts/templates_py/manipulator_custom_geometry.py
M	source/blender/python/gawain/gwn_py_types.c

===================================================================

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);
 	}



More information about the Bf-blender-cvs mailing list