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.
This commit is contained in:
@@ -644,6 +644,11 @@ class Manipulator(StructRNA, metaclass=OrderedMeta):
|
|||||||
if matrix is None:
|
if matrix is None:
|
||||||
matrix = self.matrix_world
|
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:
|
if select_id is not None:
|
||||||
gpu.select.load_id(select_id)
|
gpu.select.load_id(select_id)
|
||||||
else:
|
else:
|
||||||
@@ -651,11 +656,11 @@ class Manipulator(StructRNA, metaclass=OrderedMeta):
|
|||||||
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)
|
||||||
shape.uniform_f32("color", *color)
|
batch.uniform_f32("color", *color)
|
||||||
|
|
||||||
with gpu.matrix.push_pop():
|
with gpu.matrix.push_pop():
|
||||||
gpu.matrix.multiply_matrix(matrix)
|
gpu.matrix.multiply_matrix(matrix)
|
||||||
shape.draw()
|
batch.draw()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def new_custom_shape(type, verts):
|
def new_custom_shape(type, verts):
|
||||||
@@ -684,8 +689,7 @@ class Manipulator(StructRNA, metaclass=OrderedMeta):
|
|||||||
vbo = Gwn_VertBuf(len=len(verts), format=fmt)
|
vbo = Gwn_VertBuf(len=len(verts), format=fmt)
|
||||||
vbo.fill(id=pos_id, data=verts)
|
vbo.fill(id=pos_id, data=verts)
|
||||||
batch = Gwn_Batch(type=type, buf=vbo)
|
batch = Gwn_Batch(type=type, buf=vbo)
|
||||||
batch.program_set_builtin('3D_UNIFORM_COLOR' if dims == 3 else '2D_UNIFORM_COLOR')
|
return (batch, dims)
|
||||||
return batch
|
|
||||||
|
|
||||||
|
|
||||||
# Only defined so operators members can be used by accessing self.order
|
# Only defined so operators members can be used by accessing self.order
|
||||||
|
@@ -134,7 +134,7 @@ class MyCustomShapeWidgetGroup(ManipulatorGroup):
|
|||||||
mpr.color = 1.0, 0.5, 1.0
|
mpr.color = 1.0, 0.5, 1.0
|
||||||
mpr.alpha = 0.5
|
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
|
mpr.alpha_highlight = 0.5
|
||||||
|
|
||||||
# units are large, so shrink to something more reasonable.
|
# units are large, so shrink to something more reasonable.
|
||||||
|
@@ -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 PyObject *bpygwn_VertBatch_uniform_f32(BPyGwn_Batch *self, PyObject *args)
|
||||||
{
|
{
|
||||||
static struct {
|
struct {
|
||||||
const char *id;
|
const char *id;
|
||||||
float values[4];
|
float values[4];
|
||||||
} params;
|
} params;
|
||||||
@@ -648,10 +648,10 @@ static PyObject *bpygwn_VertBatch_uniform_f32(BPyGwn_Batch *self, PyObject *args
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (PyTuple_GET_SIZE(args)) {
|
switch (PyTuple_GET_SIZE(args)) {
|
||||||
case 2: GWN_batch_uniform_1f(self->batch, params.id, params.values[0]); break;
|
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 3: GWN_batch_uniform_2f(self->batch, params.id, UNPACK2(params.values)); break;
|
||||||
case 4: GWN_batch_uniform_3fv(self->batch, params.id, params.values); break;
|
case 4: GWN_batch_uniform_3f(self->batch, params.id, UNPACK3(params.values)); break;
|
||||||
case 5: GWN_batch_uniform_4fv(self->batch, params.id, params.values); break;
|
case 5: GWN_batch_uniform_4f(self->batch, params.id, UNPACK4(params.values)); break;
|
||||||
default:
|
default:
|
||||||
BLI_assert(0);
|
BLI_assert(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user