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>2017-04-28 15:30:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-04-28 15:31:58 +0300
commit0e94d910489e2bd4a23573c315fee26b740af3a4 (patch)
tree91f0815d538a02748cae0f3021e060b1a4e7b05c /source/blender/draw/intern/draw_armature.c
parentcc43dd054fa78daf469e89b6fa86031de8dd43bc (diff)
Draw Manager: pose-mode custom bone display
Diffstat (limited to 'source/blender/draw/intern/draw_armature.c')
-rw-r--r--source/blender/draw/intern/draw_armature.c102
1 files changed, 74 insertions, 28 deletions
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index 64568d92efc..9a4c996837f 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -107,6 +107,28 @@ static void DRW_shgroup_bone_octahedral_wire(const float (*bone_mat)[4], const f
DRW_shgroup_call_dynamic_add(g_data.bone_octahedral_wire, bone_mat, color);
}
+/* Custom (geometry) */
+
+static void DRW_shgroup_bone_custom_solid(const float (*bone_mat)[4], const float color[4], Object *custom)
+{
+ /* grr, not re-using instances! */
+ struct Batch *geom = DRW_cache_object_surface_get(custom);
+ if (geom) {
+ DRWShadingGroup *shgrp_geom_solid = shgroup_instance_objspace_solid(g_data.bone_solid, geom, g_data.ob->obmat);
+ DRW_shgroup_call_dynamic_add(shgrp_geom_solid, bone_mat, color);
+ }
+}
+
+static void DRW_shgroup_bone_custom_wire(const float (*bone_mat)[4], const float color[4], Object *custom)
+{
+ /* grr, not re-using instances! */
+ struct Batch *geom = DRW_cache_object_wire_get(custom);
+ if (geom) {
+ DRWShadingGroup *shgrp_geom_wire = shgroup_instance_objspace_wire(g_data.bone_wire, geom, g_data.ob->obmat);
+ DRW_shgroup_call_dynamic_add(shgrp_geom_wire, bone_mat, color);
+ }
+}
+
/* Head and tail sphere */
static void DRW_shgroup_bone_point_solid(const float (*bone_mat)[4], const float color[4])
{
@@ -289,7 +311,7 @@ static const float *get_bone_wire_color(const EditBone *eBone, const bPoseChanne
/** \name Helper Utils
* \{ */
-static void draw_bone_update_disp_matrix(EditBone *eBone, bPoseChannel *pchan, int drawtype)
+static void draw_bone_update_disp_matrix_default(EditBone *eBone, bPoseChannel *pchan)
{
float s[4][4], ebmat[4][4];
float length;
@@ -316,27 +338,30 @@ static void draw_bone_update_disp_matrix(EditBone *eBone, bPoseChannel *pchan, i
disp_tail_mat = eBone->disp_tail_mat;
}
- if (pchan && pchan->custom) {
- /* TODO */
- }
- else if (drawtype == ARM_ENVELOPE) {
- /* TODO */
- }
- else if (drawtype == ARM_LINE) {
- /* TODO */
- }
- else if (drawtype == ARM_WIRE) {
- /* TODO */
- }
- else if (drawtype == ARM_B_BONE) {
- /* TODO */
- }
- else {
- scale_m4_fl(s, length);
- mul_m4_m4m4(disp_mat, bone_mat, s);
- copy_m4_m4(disp_tail_mat, disp_mat);
- translate_m4(disp_tail_mat, 0.0f, 1.0f, 0.0f);
- }
+ scale_m4_fl(s, length);
+ mul_m4_m4m4(disp_mat, bone_mat, s);
+ copy_m4_m4(disp_tail_mat, disp_mat);
+ translate_m4(disp_tail_mat, 0.0f, 1.0f, 0.0f);
+}
+
+static void draw_bone_update_disp_matrix_custom(bPoseChannel *pchan)
+{
+ float s[4][4];
+ float length;
+ float (*bone_mat)[4];
+ float (*disp_mat)[4];
+ float (*disp_tail_mat)[4];
+
+ /* See TODO above */
+ length = PCHAN_CUSTOM_DRAW_SIZE(pchan);
+ bone_mat = pchan->pose_mat;
+ disp_mat = pchan->disp_mat;
+ disp_tail_mat = pchan->disp_tail_mat;
+
+ scale_m4_fl(s, length);
+ mul_m4_m4m4(disp_mat, bone_mat, s);
+ copy_m4_m4(disp_tail_mat, disp_mat);
+ translate_m4(disp_tail_mat, 0.0f, 1.0f, 0.0f);
}
static void draw_axes(EditBone *eBone, bPoseChannel *pchan)
@@ -414,10 +439,23 @@ static void draw_points(
* \{ */
static void draw_bone_custom_shape(
- EditBone *UNUSED(eBone), bPoseChannel *UNUSED(pchan), bArmature *UNUSED(arm),
- const int UNUSED(select_id))
+ EditBone *eBone, bPoseChannel *pchan, bArmature *arm,
+ const int select_id)
{
- /* work in progress -- fclem */
+ const float *col_solid = get_bone_solid_color(eBone, pchan, arm);
+ const float *col_wire = get_bone_wire_color(eBone, pchan, arm);
+ const float (*disp_mat)[4] = pchan->custom_tx ? pchan->custom_tx->disp_mat : pchan->disp_mat;
+
+ if (select_id != -1) {
+ DRW_select_load_id(select_id | BONESEL_BONE);
+ }
+
+ DRW_shgroup_bone_custom_solid(disp_mat, col_solid, pchan->custom);
+ DRW_shgroup_bone_custom_wire(disp_mat, col_wire, pchan->custom);
+
+ if (select_id != -1) {
+ DRW_select_load_id(-1);
+ }
}
static void draw_bone_envelope(
@@ -493,21 +531,24 @@ static void draw_armature_edit(Object *ob)
if ((eBone->flag & BONE_HIDDEN_A) == 0) {
const int select_id = is_select ? index : (unsigned int)-1;
- draw_bone_update_disp_matrix(eBone, NULL, arm->drawtype);
-
if (arm->drawtype == ARM_ENVELOPE) {
+ draw_bone_update_disp_matrix_default(eBone, NULL);
draw_bone_envelope(eBone, NULL, arm, select_id);
}
else if (arm->drawtype == ARM_LINE) {
+ draw_bone_update_disp_matrix_default(eBone, NULL);
draw_bone_line(eBone, NULL, arm, select_id);
}
else if (arm->drawtype == ARM_WIRE) {
+ draw_bone_update_disp_matrix_default(eBone, NULL);
draw_bone_wire(eBone, NULL, arm, select_id);
}
else if (arm->drawtype == ARM_B_BONE) {
+ draw_bone_update_disp_matrix_default(eBone, NULL);
draw_bone_box(eBone, NULL, arm, select_id);
}
else {
+ draw_bone_update_disp_matrix_default(eBone, NULL);
draw_bone_octahedral(eBone, NULL, arm, select_id);
}
@@ -576,24 +617,29 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
if (bone->layer & arm->layer) {
const int select_id = is_pose_select ? index : (unsigned int)-1;
- draw_bone_update_disp_matrix(NULL, pchan, arm->drawtype);
if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) {
+ draw_bone_update_disp_matrix_custom(pchan);
draw_bone_custom_shape(NULL, pchan, arm, select_id);
}
else if (arm->drawtype == ARM_ENVELOPE) {
+ draw_bone_update_disp_matrix_default(NULL, pchan);
draw_bone_envelope(NULL, pchan, arm, select_id);
}
else if (arm->drawtype == ARM_LINE) {
+ draw_bone_update_disp_matrix_default(NULL, pchan);
draw_bone_line(NULL, pchan, arm, select_id);
}
else if (arm->drawtype == ARM_WIRE) {
+ draw_bone_update_disp_matrix_default(NULL, pchan);
draw_bone_wire(NULL, pchan, arm, select_id);
}
else if (arm->drawtype == ARM_B_BONE) {
+ draw_bone_update_disp_matrix_default(NULL, pchan);
draw_bone_box(NULL, pchan, arm, select_id);
}
else {
+ draw_bone_update_disp_matrix_default(NULL, pchan);
draw_bone_octahedral(NULL, pchan, arm, select_id);
}