Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_armature.c
| Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void OVERLAY_armature_cache_init(OVERLAY_Data *vedata) | void OVERLAY_armature_cache_init(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const bool is_select_mode = DRW_state_is_select(); | |||||
| pd->armature.transparent = (draw_ctx->v3d->shading.type == OB_WIRE) || | pd->armature.transparent = (draw_ctx->v3d->shading.type == OB_WIRE) || | ||||
| XRAY_FLAG_ENABLED(draw_ctx->v3d); | XRAY_FLAG_ENABLED(draw_ctx->v3d); | ||||
| pd->armature.show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0); | pd->armature.show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0) && | ||||
| !is_select_mode; | |||||
| pd->armature.do_pose_fade_geom = (pd->overlay.flag & V3D_OVERLAY_BONE_SELECT) && | pd->armature.do_pose_fade_geom = (pd->overlay.flag & V3D_OVERLAY_BONE_SELECT) && | ||||
| ((draw_ctx->object_mode & OB_MODE_WEIGHT_PAINT) == 0) && | ((draw_ctx->object_mode & OB_MODE_WEIGHT_PAINT) == 0) && | ||||
| draw_ctx->object_pose != NULL; | draw_ctx->object_pose != NULL; | ||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ADD; | DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ADD; | ||||
| DRW_PASS_CREATE(psl->armature_transp_ps, state | pd->clipping_state); | DRW_PASS_CREATE(psl->armature_transp_ps, state | pd->clipping_state); | ||||
| if (pd->armature.do_pose_fade_geom) { | if (pd->armature.do_pose_fade_geom) { | ||||
| ▲ Show 20 Lines • Show All 1,834 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; | ||||
| } | } | ||||
| if (ctx->show_relations) { | |||||
| 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); | ||||
| draw_bone_line(ctx, eBone, NULL, arm, boneflag, constflag, select_id); | draw_bone_line(ctx, eBone, NULL, arm, boneflag, constflag, select_id); | ||||
| ▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 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 (ctx->show_relations) { | |||||
| 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); | ||||
| draw_bone_envelope(ctx, NULL, pchan, arm, boneflag, constflag, select_id); | draw_bone_envelope(ctx, NULL, pchan, arm, boneflag, constflag, select_id); | ||||
| Show All 32 Lines | static void draw_armature_pose(ArmatureDrawContext *ctx) | ||||
| arm->flag &= ~ARM_POSEMODE; | arm->flag &= ~ARM_POSEMODE; | ||||
| } | } | ||||
| static void armature_context_setup(ArmatureDrawContext *ctx, | static void armature_context_setup(ArmatureDrawContext *ctx, | ||||
| OVERLAY_PrivateData *pd, | OVERLAY_PrivateData *pd, | ||||
| Object *ob, | Object *ob, | ||||
| const bool do_envelope_dist, | const bool do_envelope_dist, | ||||
| const bool is_edit_mode, | |||||
| const bool is_pose_mode, | const bool is_pose_mode, | ||||
| float *const_color) | float *const_color) | ||||
| { | { | ||||
| const bool is_xray = (ob->dtx & OB_DRAWXRAY) != 0 || | const bool is_xray = (ob->dtx & OB_DRAWXRAY) != 0 || | ||||
| (pd->armature.do_pose_fade_geom && is_pose_mode); | (pd->armature.do_pose_fade_geom && is_pose_mode); | ||||
| const bool is_filled = !pd->armature.transparent || do_envelope_dist; | const bool is_filled = !pd->armature.transparent || do_envelope_dist; | ||||
| bArmature *arm = ob->data; | bArmature *arm = ob->data; | ||||
| OVERLAY_ArmatureCallBuffers *cb = &pd->armature_call_buffers[is_xray]; | OVERLAY_ArmatureCallBuffers *cb = &pd->armature_call_buffers[is_xray]; | ||||
| Show All 27 Lines | static void armature_context_setup(ArmatureDrawContext *ctx, | ||||
| ctx->dof_sphere = cb->dof_sphere; | ctx->dof_sphere = cb->dof_sphere; | ||||
| ctx->point_solid = (is_filled) ? cb->point_solid : NULL; | ctx->point_solid = (is_filled) ? cb->point_solid : NULL; | ||||
| ctx->point_outline = cb->point_outline; | ctx->point_outline = cb->point_outline; | ||||
| ctx->custom_solid = (is_filled) ? cb->custom_solid : NULL; | ctx->custom_solid = (is_filled) ? cb->custom_solid : NULL; | ||||
| ctx->custom_outline = cb->custom_outline; | ctx->custom_outline = cb->custom_outline; | ||||
| ctx->custom_wire = cb->custom_solid; /* Use same shader. */ | ctx->custom_wire = cb->custom_solid; /* Use same shader. */ | ||||
| ctx->custom_shapes_ghash = cb->custom_shapes_ghash; | ctx->custom_shapes_ghash = cb->custom_shapes_ghash; | ||||
| ctx->transparent = pd->armature.transparent; | ctx->transparent = pd->armature.transparent; | ||||
| ctx->show_relations = pd->armature.show_relations; | ctx->show_relations = pd->armature.show_relations && (is_edit_mode | is_pose_mode); | ||||
| ctx->const_color = DRW_state_is_select() ? select_const_color : const_color; | ctx->const_color = DRW_state_is_select() ? select_const_color : const_color; | ||||
| ctx->const_wire = (((ob->base_flag & BASE_SELECTED) || (arm->drawtype == ARM_WIRE)) ? | ctx->const_wire = (((ob->base_flag & BASE_SELECTED) || (arm->drawtype == ARM_WIRE)) ? | ||||
| 1.5f : | 1.5f : | ||||
| ((ctx->transparent) ? 1.0f : 0.0f)); | ((ctx->transparent) ? 1.0f : 0.0f)); | ||||
| /** See: 'set_pchan_color'*/ | /** See: 'set_pchan_color'*/ | ||||
| #define NO_ALPHA(c) (((c)[3] = 1.0f), (c)) | #define NO_ALPHA(c) (((c)[3] = 1.0f), (c)) | ||||
| Show All 16 Lines | |||||
| #undef NO_ALPHA | #undef NO_ALPHA | ||||
| } | } | ||||
| void OVERLAY_edit_armature_cache_populate(OVERLAY_Data *vedata, Object *ob) | void OVERLAY_edit_armature_cache_populate(OVERLAY_Data *vedata, Object *ob) | ||||
| { | { | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| ArmatureDrawContext arm_ctx; | ArmatureDrawContext arm_ctx; | ||||
| armature_context_setup(&arm_ctx, pd, ob, true, false, NULL); | armature_context_setup(&arm_ctx, pd, ob, true, true, false, NULL); | ||||
| draw_armature_edit(&arm_ctx); | draw_armature_edit(&arm_ctx); | ||||
| } | } | ||||
| void OVERLAY_pose_armature_cache_populate(OVERLAY_Data *vedata, Object *ob) | void OVERLAY_pose_armature_cache_populate(OVERLAY_Data *vedata, Object *ob) | ||||
| { | { | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| ArmatureDrawContext arm_ctx; | ArmatureDrawContext arm_ctx; | ||||
| armature_context_setup(&arm_ctx, pd, ob, true, true, NULL); | armature_context_setup(&arm_ctx, pd, ob, true, false, true, NULL); | ||||
| draw_armature_pose(&arm_ctx); | draw_armature_pose(&arm_ctx); | ||||
| } | } | ||||
| void OVERLAY_armature_cache_populate(OVERLAY_Data *vedata, Object *ob) | void OVERLAY_armature_cache_populate(OVERLAY_Data *vedata, Object *ob) | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| ArmatureDrawContext arm_ctx; | ArmatureDrawContext arm_ctx; | ||||
| float *color; | float *color; | ||||
| DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); | DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); | ||||
| armature_context_setup(&arm_ctx, pd, ob, false, false, color); | armature_context_setup(&arm_ctx, pd, ob, false, false, false, color); | ||||
| draw_armature_pose(&arm_ctx); | draw_armature_pose(&arm_ctx); | ||||
| } | } | ||||
| static bool POSE_is_driven_by_active_armature(Object *ob) | static bool POSE_is_driven_by_active_armature(Object *ob) | ||||
| { | { | ||||
| Object *ob_arm = modifiers_isDeformedByArmature(ob); | Object *ob_arm = modifiers_isDeformedByArmature(ob); | ||||
| if (ob_arm) { | if (ob_arm) { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | if (psl->armature_bone_select_ps != NULL) { | ||||
| if (DRW_state_is_fbo()) { | if (DRW_state_is_fbo()) { | ||||
| GPU_framebuffer_clear_depth(dfbl->default_fb, 1.0f); | GPU_framebuffer_clear_depth(dfbl->default_fb, 1.0f); | ||||
| } | } | ||||
| /* Selection still works because we are drawing only the pose bones in this case. */ | /* Selection still works because we are drawing only the pose bones in this case. */ | ||||
| DRW_draw_pass(psl->armature_ps[1]); | DRW_draw_pass(psl->armature_ps[1]); | ||||
| } | } | ||||
| } | } | ||||
| No newline at end of file | No newline at end of file | ||||