Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_armature.c
| Show All 29 Lines | |||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DRW_render.h" | #include "DRW_render.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_action.h" | |||||
| #include "BKE_armature.h" | #include "BKE_armature.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "ED_armature.h" | #include "ED_armature.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| ▲ Show 20 Lines • Show All 923 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Drawing Color Helpers | /** \name Drawing Color Helpers | ||||
| * \{ */ | * \{ */ | ||||
| static void bone_locked_color_shade(float color[4]) | |||||
| { | |||||
| float locked_color[4]; | |||||
| UI_GetThemeColor4fv(TH_BONE_LOCKED_WEIGHT, locked_color); | |||||
| interp_v3_v3v3(color, color, locked_color, locked_color[3]); | |||||
| } | |||||
| static const float *get_bone_solid_color(const ArmatureDrawContext *ctx, | static const float *get_bone_solid_color(const ArmatureDrawContext *ctx, | ||||
| const EditBone *UNUSED(eBone), | const EditBone *UNUSED(eBone), | ||||
| const bPoseChannel *pchan, | const bPoseChannel *pchan, | ||||
| const bArmature *arm, | const bArmature *arm, | ||||
| const int boneflag, | const int boneflag, | ||||
| const short constflag) | const short constflag) | ||||
| { | { | ||||
| if (ctx->const_color) { | if (ctx->const_color) { | ||||
| return ctx->color.bone_solid; | return ctx->color.bone_solid; | ||||
| } | } | ||||
| if (arm->flag & ARM_POSEMODE) { | if (arm->flag & ARM_POSEMODE) { | ||||
| static float disp_color[4]; | static float disp_color[4]; | ||||
| copy_v4_v4(disp_color, pchan->draw_data->solid_color); | copy_v4_v4(disp_color, pchan->draw_data->solid_color); | ||||
| set_pchan_color(ctx, PCHAN_COLOR_SOLID, boneflag, constflag, disp_color); | set_pchan_color(ctx, PCHAN_COLOR_SOLID, boneflag, constflag, disp_color); | ||||
| if (boneflag & BONE_DRAW_LOCKED_WEIGHT) { | |||||
| bone_locked_color_shade(disp_color); | |||||
| } | |||||
| return disp_color; | return disp_color; | ||||
| } | } | ||||
| return ctx->color.bone_solid; | return ctx->color.bone_solid; | ||||
| } | } | ||||
| static const float *get_bone_solid_with_consts_color(const ArmatureDrawContext *ctx, | static const float *get_bone_solid_with_consts_color(const ArmatureDrawContext *ctx, | ||||
| const EditBone *eBone, | const EditBone *eBone, | ||||
| const bPoseChannel *pchan, | const bPoseChannel *pchan, | ||||
| const bArmature *arm, | const bArmature *arm, | ||||
| const int boneflag, | const int boneflag, | ||||
| const short constflag) | const short constflag) | ||||
| { | { | ||||
| if (ctx->const_color) { | if (ctx->const_color) { | ||||
| return ctx->color.bone_solid; | return ctx->color.bone_solid; | ||||
| } | } | ||||
| const float *col = get_bone_solid_color(ctx, eBone, pchan, arm, boneflag, constflag); | const float *col = get_bone_solid_color(ctx, eBone, pchan, arm, boneflag, constflag); | ||||
| static float consts_color[4]; | static float consts_color[4]; | ||||
| if ((arm->flag & ARM_POSEMODE) && | if ((arm->flag & ARM_POSEMODE) && !(boneflag & BONE_DRAW_LOCKED_WEIGHT) && | ||||
| set_pchan_color(ctx, PCHAN_COLOR_CONSTS, boneflag, constflag, consts_color)) { | set_pchan_color(ctx, PCHAN_COLOR_CONSTS, boneflag, constflag, consts_color)) { | ||||
| interp_v3_v3v3(consts_color, col, consts_color, 0.5f); | interp_v3_v3v3(consts_color, col, consts_color, 0.5f); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v4_v4(consts_color, col); | copy_v4_v4(consts_color, col); | ||||
| } | } | ||||
| return consts_color; | return consts_color; | ||||
| } | } | ||||
| Show All 39 Lines | else { | ||||
| else { | else { | ||||
| copy_v3_v3(disp_color, ctx->color.wire_edit); | copy_v3_v3(disp_color, ctx->color.wire_edit); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (arm->flag & ARM_POSEMODE) { | else if (arm->flag & ARM_POSEMODE) { | ||||
| copy_v4_v4(disp_color, pchan->draw_data->wire_color); | copy_v4_v4(disp_color, pchan->draw_data->wire_color); | ||||
| set_pchan_color(ctx, PCHAN_COLOR_NORMAL, boneflag, constflag, disp_color); | set_pchan_color(ctx, PCHAN_COLOR_NORMAL, boneflag, constflag, disp_color); | ||||
| if (boneflag & BONE_DRAW_LOCKED_WEIGHT) { | |||||
| bone_locked_color_shade(disp_color); | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(disp_color, ctx->color.vertex); | copy_v3_v3(disp_color, ctx->color.vertex); | ||||
| } | } | ||||
| disp_color[3] = get_bone_wire_thickness(ctx, boneflag); | disp_color[3] = get_bone_wire_thickness(ctx, boneflag); | ||||
| return disp_color; | return disp_color; | ||||
| ▲ Show 20 Lines • Show All 437 Lines • ▼ Show 20 Lines | static void draw_bone_custom_shape(ArmatureDrawContext *ctx, | ||||
| } | } | ||||
| if (pchan->custom->type == OB_EMPTY) { | if (pchan->custom->type == OB_EMPTY) { | ||||
| Object *ob = pchan->custom; | Object *ob = pchan->custom; | ||||
| if (ob->empty_drawtype != OB_EMPTY_IMAGE) { | if (ob->empty_drawtype != OB_EMPTY_IMAGE) { | ||||
| drw_shgroup_bone_custom_empty(ctx, disp_mat, col_wire, pchan->custom); | drw_shgroup_bone_custom_empty(ctx, disp_mat, col_wire, pchan->custom); | ||||
| } | } | ||||
| } | } | ||||
| if ((boneflag & BONE_DRAWWIRE) == 0) { | if ((boneflag & BONE_DRAWWIRE) == 0 && (boneflag & BONE_DRAW_LOCKED_WEIGHT) == 0) { | ||||
| drw_shgroup_bone_custom_solid(ctx, disp_mat, col_solid, col_hint, col_wire, pchan->custom); | drw_shgroup_bone_custom_solid(ctx, disp_mat, col_solid, col_hint, col_wire, pchan->custom); | ||||
| } | } | ||||
| else { | else { | ||||
| drw_shgroup_bone_custom_wire(ctx, disp_mat, col_wire, pchan->custom); | drw_shgroup_bone_custom_wire(ctx, disp_mat, col_wire, pchan->custom); | ||||
| } | } | ||||
| if (select_id != -1) { | if (select_id != -1) { | ||||
| DRW_select_load_id(-1); | DRW_select_load_id(-1); | ||||
| ▲ Show 20 Lines • Show All 475 Lines • ▼ Show 20 Lines | if (eBone->layer & arm->layer) { | ||||
| boneflag &= ~BONE_CONNECTED; | boneflag &= ~BONE_CONNECTED; | ||||
| } | } | ||||
| /* set temporary flag for drawing bone as active, but only if selected */ | /* set temporary flag for drawing bone as active, but only if selected */ | ||||
| if (eBone == arm->act_edbone) { | if (eBone == arm->act_edbone) { | ||||
| boneflag |= BONE_DRAW_ACTIVE; | boneflag |= BONE_DRAW_ACTIVE; | ||||
| } | } | ||||
| boneflag &= ~BONE_DRAW_LOCKED_WEIGHT; | |||||
| draw_bone_relations(ctx, eBone, NULL, arm, boneflag, constflag); | draw_bone_relations(ctx, eBone, NULL, arm, boneflag, constflag); | ||||
| if (arm->drawtype == ARM_ENVELOPE) { | if (arm->drawtype == ARM_ENVELOPE) { | ||||
| draw_bone_update_disp_matrix_default(eBone, NULL); | draw_bone_update_disp_matrix_default(eBone, NULL); | ||||
| draw_bone_envelope(ctx, eBone, NULL, arm, boneflag, constflag, select_id); | draw_bone_envelope(ctx, eBone, NULL, arm, boneflag, constflag, select_id); | ||||
| } | } | ||||
| else if (arm->drawtype == ARM_LINE) { | else if (arm->drawtype == ARM_LINE) { | ||||
| draw_bone_update_disp_matrix_default(eBone, NULL); | draw_bone_update_disp_matrix_default(eBone, NULL); | ||||
| Show All 28 Lines | |||||
| { | { | ||||
| Object *ob = ctx->ob; | Object *ob = ctx->ob; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const Scene *scene = draw_ctx->scene; | const Scene *scene = draw_ctx->scene; | ||||
| bArmature *arm = ob->data; | bArmature *arm = ob->data; | ||||
| bPoseChannel *pchan; | bPoseChannel *pchan; | ||||
| int index = -1; | int index = -1; | ||||
| const bool show_text = DRW_state_show_text(); | const bool show_text = DRW_state_show_text(); | ||||
| bool draw_locked_weights = false; | |||||
| /* We can't safely draw non-updated pose, might contain NULL bone pointers... */ | /* We can't safely draw non-updated pose, might contain NULL bone pointers... */ | ||||
| if (ob->pose->flag & POSE_RECALC) { | if (ob->pose->flag & POSE_RECALC) { | ||||
| return; | return; | ||||
| } | } | ||||
| bool is_pose_select = false; | bool is_pose_select = false; | ||||
| /* Object can be edited in the scene. */ | /* Object can be edited in the scene. */ | ||||
| Show All 19 Lines | is_pose_select = | ||||
| DRW_state_is_select(); | DRW_state_is_select(); | ||||
| if (is_pose_select) { | if (is_pose_select) { | ||||
| const Object *ob_orig = DEG_get_original_object(ob); | const Object *ob_orig = DEG_get_original_object(ob); | ||||
| index = ob_orig->runtime.select_id; | index = ob_orig->runtime.select_id; | ||||
| } | } | ||||
| } | } | ||||
| /* In weight paint mode retrieve the vertex group lock status. */ | |||||
| if ((draw_ctx->object_mode == OB_MODE_WEIGHT_PAINT) && (draw_ctx->object_pose == ob) && | |||||
| (draw_ctx->obact != NULL)) { | |||||
| draw_locked_weights = true; | |||||
| for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { | |||||
| pchan->bone->flag &= ~BONE_DRAW_LOCKED_WEIGHT; | |||||
| } | |||||
| const Object *obact_orig = DEG_get_original_object(draw_ctx->obact); | |||||
| LISTBASE_FOREACH (bDeformGroup *, dg, &obact_orig->defbase) { | |||||
| if (dg->flag & DG_LOCK_WEIGHT) { | |||||
| pchan = BKE_pose_channel_find_name(ob->pose, dg->name); | |||||
| if (pchan) { | |||||
| pchan->bone->flag |= BONE_DRAW_LOCKED_WEIGHT; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, index += 0x10000) { | for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, index += 0x10000) { | ||||
| Bone *bone = pchan->bone; | Bone *bone = pchan->bone; | ||||
| const bool bone_visible = (bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0; | const bool bone_visible = (bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0; | ||||
| if (bone_visible) { | if (bone_visible) { | ||||
| if (bone->layer & arm->layer) { | if (bone->layer & arm->layer) { | ||||
| const bool draw_dofs = !is_pose_select && ctx->show_relations && | const bool draw_dofs = !is_pose_select && ctx->show_relations && | ||||
| (arm->flag & ARM_POSEMODE) && (bone->flag & BONE_SELECTED) && | (arm->flag & ARM_POSEMODE) && (bone->flag & BONE_SELECTED) && | ||||
| Show All 15 Lines | if (bone_visible) { | ||||
| boneflag &= ~BONE_CONNECTED; | boneflag &= ~BONE_CONNECTED; | ||||
| } | } | ||||
| /* set temporary flag for drawing bone as active, but only if selected */ | /* set temporary flag for drawing bone as active, but only if selected */ | ||||
| if (bone == arm->act_bone) { | if (bone == arm->act_bone) { | ||||
| boneflag |= BONE_DRAW_ACTIVE; | boneflag |= BONE_DRAW_ACTIVE; | ||||
| } | } | ||||
| if (!draw_locked_weights) { | |||||
| boneflag &= ~BONE_DRAW_LOCKED_WEIGHT; | |||||
| } | |||||
| draw_bone_relations(ctx, NULL, pchan, arm, boneflag, constflag); | draw_bone_relations(ctx, NULL, pchan, arm, boneflag, constflag); | ||||
| if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) { | if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) { | ||||
| draw_bone_update_disp_matrix_custom(pchan); | draw_bone_update_disp_matrix_custom(pchan); | ||||
| draw_bone_custom_shape(ctx, NULL, pchan, arm, boneflag, constflag, select_id); | draw_bone_custom_shape(ctx, NULL, pchan, arm, boneflag, constflag, select_id); | ||||
| } | } | ||||
| else if (arm->drawtype == ARM_ENVELOPE) { | else if (arm->drawtype == ARM_ENVELOPE) { | ||||
| draw_bone_update_disp_matrix_default(NULL, pchan); | draw_bone_update_disp_matrix_default(NULL, pchan); | ||||
| ▲ Show 20 Lines • Show All 227 Lines • Show Last 20 Lines | |||||