Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_armature.cc
- This file was moved from source/blender/draw/engines/overlay/overlay_armature.c.
| Show All 31 Lines | |||||
| #include "ED_armature.h" | #include "ED_armature.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "draw_common.h" | #include "draw_common.h" | ||||
| #include "draw_manager_text.h" | #include "draw_manager_text.h" | ||||
| #include "overlay_private.h" | #include "overlay_private.hh" | ||||
| #include "draw_cache_impl.h" | #include "draw_cache_impl.h" | ||||
| #define BONE_VAR(eBone, pchan, var) ((eBone) ? (eBone->var) : (pchan->var)) | #define BONE_VAR(eBone, pchan, var) ((eBone) ? (eBone->var) : (pchan->var)) | ||||
| #define BONE_FLAG(eBone, pchan) ((eBone) ? (eBone->flag) : (pchan->bone->flag)) | #define BONE_FLAG(eBone, pchan) ((eBone) ? (eBone->flag) : (pchan->bone->flag)) | ||||
| #define PT_DEFAULT_RAD 0.05f /* radius of the point batch. */ | #define PT_DEFAULT_RAD 0.05f /* radius of the point batch. */ | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | bool OVERLAY_armature_is_pose_mode(Object *ob, const DRWContextState *draw_ctx) | ||||
| /* Pose armature is handled by pose mode engine. */ | /* Pose armature is handled by pose mode engine. */ | ||||
| if (((ob == active_ob) || (ob->mode & OB_MODE_POSE)) && | if (((ob == active_ob) || (ob->mode & OB_MODE_POSE)) && | ||||
| ((draw_ctx->object_mode & OB_MODE_POSE) != 0)) { | ((draw_ctx->object_mode & OB_MODE_POSE) != 0)) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* Armature parent is also handled by pose mode engine. */ | /* Armature parent is also handled by pose mode engine. */ | ||||
| if ((active_ob != NULL) && (draw_ctx->object_mode & OB_MODE_ALL_WEIGHT_PAINT)) { | if ((active_ob != nullptr) && (draw_ctx->object_mode & OB_MODE_ALL_WEIGHT_PAINT)) { | ||||
| if (ob == draw_ctx->object_pose) { | if (ob == draw_ctx->object_pose) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| 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(); | 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; | !is_select_mode; | ||||
| pd->armature.do_pose_xray = (pd->overlay.flag & V3D_OVERLAY_BONE_SELECT) != 0; | pd->armature.do_pose_xray = (pd->overlay.flag & V3D_OVERLAY_BONE_SELECT) != 0; | ||||
| pd->armature.do_pose_fade_geom = pd->armature.do_pose_xray && | pd->armature.do_pose_fade_geom = pd->armature.do_pose_xray && | ||||
| ((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 != nullptr; | ||||
| const float wire_alpha = pd->overlay.bone_wire_alpha; | const float wire_alpha = pd->overlay.bone_wire_alpha; | ||||
| const bool use_wire_alpha = (wire_alpha < 1.0f); | const bool use_wire_alpha = (wire_alpha < 1.0f); | ||||
| DRWState state; | DRWState state; | ||||
| if (pd->armature.do_pose_fade_geom) { | if (pd->armature.do_pose_fade_geom) { | ||||
| state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA; | state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA; | ||||
| DRW_PASS_CREATE(psl->armature_bone_select_ps, state | pd->clipping_state); | DRW_PASS_CREATE(psl->armature_bone_select_ps, state | pd->clipping_state); | ||||
| float alpha = pd->overlay.xray_alpha_bone; | float alpha = pd->overlay.xray_alpha_bone; | ||||
| struct GPUShader *sh = OVERLAY_shader_uniform_color(); | struct GPUShader *sh = OVERLAY_shader_uniform_color(); | ||||
| DRWShadingGroup *grp; | DRWShadingGroup *grp; | ||||
| pd->armature_bone_select_act_grp = grp = DRW_shgroup_create(sh, psl->armature_bone_select_ps); | pd->armature_bone_select_act_grp = grp = DRW_shgroup_create(sh, psl->armature_bone_select_ps); | ||||
| DRW_shgroup_uniform_vec4_copy(grp, "color", (float[4]){0.0f, 0.0f, 0.0f, alpha}); | float4 color = {0.0f, 0.0f, 0.0f, alpha}; | ||||
| DRW_shgroup_uniform_vec4_copy(grp, "color", color); | |||||
| pd->armature_bone_select_grp = grp = DRW_shgroup_create(sh, psl->armature_bone_select_ps); | pd->armature_bone_select_grp = grp = DRW_shgroup_create(sh, psl->armature_bone_select_ps); | ||||
| DRW_shgroup_uniform_vec4_copy(grp, "color", (float[4]){0.0f, 0.0f, 0.0f, pow(alpha, 4)}); | color = {0.0f, 0.0f, 0.0f, powf(alpha, 4)}; | ||||
| DRW_shgroup_uniform_vec4_copy(grp, "color", color); | |||||
| } | } | ||||
| for (int i = 0; i < 2; i++) { | for (int i = 0; i < 2; i++) { | ||||
| struct GPUShader *sh; | struct GPUShader *sh; | ||||
| struct GPUVertFormat *format; | struct GPUVertFormat *format; | ||||
| DRWShadingGroup *grp = NULL; | DRWShadingGroup *grp = nullptr; | ||||
| OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); | OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); | ||||
| OVERLAY_ArmatureCallBuffers *cb = &pd->armature_call_buffers[i]; | OVERLAY_ArmatureCallBuffers *cb = &pd->armature_call_buffers[i]; | ||||
| cb->solid.custom_shapes_ghash = BLI_ghash_ptr_new(__func__); | cb->solid.custom_shapes_ghash = BLI_ghash_ptr_new(__func__); | ||||
| cb->transp.custom_shapes_ghash = BLI_ghash_ptr_new(__func__); | cb->transp.custom_shapes_ghash = BLI_ghash_ptr_new(__func__); | ||||
| DRWPass **p_armature_ps = &psl->armature_ps[i]; | DRWPass **p_armature_ps = &psl->armature_ps[i]; | ||||
| DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : 0; | DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : | ||||
| DRWState(0); | |||||
| state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH; | state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH; | ||||
| DRW_PASS_CREATE(*p_armature_ps, state | pd->clipping_state | infront_state); | DRW_PASS_CREATE(*p_armature_ps, state | pd->clipping_state | infront_state); | ||||
| DRWPass *armature_ps = *p_armature_ps; | DRWPass *armature_ps = *p_armature_ps; | ||||
| DRWPass **p_armature_trans_ps = &psl->armature_transp_ps[i]; | DRWPass **p_armature_trans_ps = &psl->armature_transp_ps[i]; | ||||
| state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ADD; | state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ADD; | ||||
| DRW_PASS_CREATE(*p_armature_trans_ps, state | pd->clipping_state); | DRW_PASS_CREATE(*p_armature_trans_ps, state | pd->clipping_state); | ||||
| DRWPass *armature_transp_ps = *p_armature_trans_ps; | DRWPass *armature_transp_ps = *p_armature_trans_ps; | ||||
| ▲ Show 20 Lines • Show All 438 Lines • ▼ Show 20 Lines | else { | ||||
| DRW_buffer_add_entry_struct(ctx->point_outline, &inst_data); | DRW_buffer_add_entry_struct(ctx->point_outline, &inst_data); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Custom (geometry) */ | /* Custom (geometry) */ | ||||
| extern void drw_batch_cache_validate(Object *custom); | extern "C" void drw_batch_cache_validate(Object *custom); | ||||
| extern void drw_batch_cache_generate_requested_delayed(Object *custom); | extern "C" void drw_batch_cache_generate_requested_delayed(Object *custom); | ||||
| BLI_INLINE DRWCallBuffer *custom_bone_instance_shgroup(ArmatureDrawContext *ctx, | BLI_INLINE DRWCallBuffer *custom_bone_instance_shgroup(ArmatureDrawContext *ctx, | ||||
| DRWShadingGroup *grp, | DRWShadingGroup *grp, | ||||
| struct GPUBatch *custom_geom) | struct GPUBatch *custom_geom) | ||||
| { | { | ||||
| DRWCallBuffer *buf = BLI_ghash_lookup(ctx->custom_shapes_ghash, custom_geom); | DRWCallBuffer *buf = static_cast<DRWCallBuffer *>( | ||||
| if (buf == NULL) { | BLI_ghash_lookup(ctx->custom_shapes_ghash, custom_geom)); | ||||
| if (buf == nullptr) { | |||||
| OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); | OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); | ||||
| buf = DRW_shgroup_call_buffer_instance(grp, formats->instance_bone, custom_geom); | buf = DRW_shgroup_call_buffer_instance(grp, formats->instance_bone, custom_geom); | ||||
| BLI_ghash_insert(ctx->custom_shapes_ghash, custom_geom, buf); | BLI_ghash_insert(ctx->custom_shapes_ghash, custom_geom, buf); | ||||
| } | } | ||||
| return buf; | return buf; | ||||
| } | } | ||||
| static void drw_shgroup_bone_custom_solid_mesh(ArmatureDrawContext *ctx, | static void drw_shgroup_bone_custom_solid_mesh(ArmatureDrawContext *ctx, | ||||
| Mesh *mesh, | Mesh *mesh, | ||||
| const float (*bone_mat)[4], | const float (*bone_mat)[4], | ||||
| const float bone_color[4], | const float bone_color[4], | ||||
| const float hint_color[4], | const float hint_color[4], | ||||
| const float outline_color[4], | const float outline_color[4], | ||||
| Object *custom) | Object *custom) | ||||
| { | { | ||||
| /* TODO(fclem): arg... less than ideal but we never iter on this object | /* TODO(fclem): arg... less than ideal but we never iter on this object | ||||
| * to assure batch cache is valid. */ | * to assure batch cache is valid. */ | ||||
| DRW_mesh_batch_cache_validate(custom, mesh); | DRW_mesh_batch_cache_validate(custom, mesh); | ||||
| struct GPUBatch *surf = DRW_mesh_batch_cache_get_surface(mesh); | struct GPUBatch *surf = DRW_mesh_batch_cache_get_surface(mesh); | ||||
| struct GPUBatch *edges = DRW_mesh_batch_cache_get_edge_detection(mesh, NULL); | struct GPUBatch *edges = DRW_mesh_batch_cache_get_edge_detection(mesh, nullptr); | ||||
| struct GPUBatch *ledges = DRW_mesh_batch_cache_get_loose_edges(mesh); | struct GPUBatch *ledges = DRW_mesh_batch_cache_get_loose_edges(mesh); | ||||
| BoneInstanceData inst_data; | BoneInstanceData inst_data; | ||||
| DRWCallBuffer *buf; | DRWCallBuffer *buf; | ||||
| if (surf || edges || ledges) { | if (surf || edges || ledges) { | ||||
| mul_m4_m4m4(inst_data.mat, ctx->ob->obmat, bone_mat); | mul_m4_m4m4(inst_data.mat, ctx->ob->obmat, bone_mat); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | static void drw_shgroup_custom_bone_curve(ArmatureDrawContext *ctx, | ||||
| Object *custom) | Object *custom) | ||||
| { | { | ||||
| /* TODO(fclem): arg... less than ideal but we never iter on this object | /* TODO(fclem): arg... less than ideal but we never iter on this object | ||||
| * to assure batch cache is valid. */ | * to assure batch cache is valid. */ | ||||
| DRW_curve_batch_cache_validate(curve); | DRW_curve_batch_cache_validate(curve); | ||||
| /* This only handles curves without any surface. The other curve types should have been converted | /* This only handles curves without any surface. The other curve types should have been converted | ||||
| * to meshes and rendered in the mesh drawing function. */ | * to meshes and rendered in the mesh drawing function. */ | ||||
| struct GPUBatch *ledges = NULL; | struct GPUBatch *ledges = nullptr; | ||||
| if (custom->type == OB_FONT) { | if (custom->type == OB_FONT) { | ||||
| ledges = DRW_cache_text_edge_wire_get(custom); | ledges = DRW_cache_text_edge_wire_get(custom); | ||||
| } | } | ||||
| else { | else { | ||||
| ledges = DRW_cache_curve_edge_wire_get(custom); | ledges = DRW_cache_curve_edge_wire_get(custom); | ||||
| } | } | ||||
| if (ledges) { | if (ledges) { | ||||
| Show All 17 Lines | static void drw_shgroup_bone_custom_solid(ArmatureDrawContext *ctx, | ||||
| const float outline_color[4], | const float outline_color[4], | ||||
| Object *custom) | Object *custom) | ||||
| { | { | ||||
| /* The custom object is not an evaluated object, so its object->data field hasn't been replaced | /* The custom object is not an evaluated object, so its object->data field hasn't been replaced | ||||
| * by #data_eval. This is bad since it gives preference to an object's evaluated mesh over any | * by #data_eval. This is bad since it gives preference to an object's evaluated mesh over any | ||||
| * other data type, but supporting all evaluated geometry components would require a much | * other data type, but supporting all evaluated geometry components would require a much | ||||
| * larger refactor of this area. */ | * larger refactor of this area. */ | ||||
| Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom); | Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom); | ||||
| if (mesh != NULL) { | if (mesh != nullptr) { | ||||
| drw_shgroup_bone_custom_solid_mesh( | drw_shgroup_bone_custom_solid_mesh( | ||||
| ctx, mesh, bone_mat, bone_color, hint_color, outline_color, custom); | ctx, mesh, bone_mat, bone_color, hint_color, outline_color, custom); | ||||
| return; | return; | ||||
| } | } | ||||
| if (ELEM(custom->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) { | if (ELEM(custom->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) { | ||||
| drw_shgroup_custom_bone_curve(ctx, custom->data, bone_mat, outline_color, custom); | drw_shgroup_custom_bone_curve( | ||||
| ctx, static_cast<Curve *>(custom->data), bone_mat, outline_color, custom); | |||||
| } | } | ||||
| } | } | ||||
| static void drw_shgroup_bone_custom_wire(ArmatureDrawContext *ctx, | static void drw_shgroup_bone_custom_wire(ArmatureDrawContext *ctx, | ||||
| const float (*bone_mat)[4], | const float (*bone_mat)[4], | ||||
| const float color[4], | const float color[4], | ||||
| Object *custom) | Object *custom) | ||||
| { | { | ||||
| /* See comments in #drw_shgroup_bone_custom_solid. */ | /* See comments in #drw_shgroup_bone_custom_solid. */ | ||||
| Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom); | Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom); | ||||
| if (mesh != NULL) { | if (mesh != nullptr) { | ||||
| drw_shgroup_bone_custom_mesh_wire(ctx, mesh, bone_mat, color, custom); | drw_shgroup_bone_custom_mesh_wire(ctx, mesh, bone_mat, color, custom); | ||||
| return; | return; | ||||
| } | } | ||||
| if (ELEM(custom->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) { | if (ELEM(custom->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) { | ||||
| drw_shgroup_custom_bone_curve(ctx, custom->data, bone_mat, color, custom); | drw_shgroup_custom_bone_curve( | ||||
| ctx, static_cast<Curve *>(custom->data), bone_mat, color, custom); | |||||
| } | } | ||||
| } | } | ||||
| static void drw_shgroup_bone_custom_empty(ArmatureDrawContext *ctx, | static void drw_shgroup_bone_custom_empty(ArmatureDrawContext *ctx, | ||||
| const float (*bone_mat)[4], | const float (*bone_mat)[4], | ||||
| const float color[4], | const float color[4], | ||||
| Object *custom) | Object *custom) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | enum { | ||||
| PCHAN_COLOR_NORMAL = 0, /* normal drawing */ | PCHAN_COLOR_NORMAL = 0, /* normal drawing */ | ||||
| PCHAN_COLOR_SOLID, /* specific case where "solid" color is needed */ | PCHAN_COLOR_SOLID, /* specific case where "solid" color is needed */ | ||||
| PCHAN_COLOR_CONSTS, /* "constraint" colors (which may/may-not be suppressed) */ | PCHAN_COLOR_CONSTS, /* "constraint" colors (which may/may-not be suppressed) */ | ||||
| }; | }; | ||||
| /* This function sets the color-set for coloring a certain bone */ | /* This function sets the color-set for coloring a certain bone */ | ||||
| static void set_pchan_colorset(ArmatureDrawContext *ctx, Object *ob, bPoseChannel *pchan) | static void set_pchan_colorset(ArmatureDrawContext *ctx, Object *ob, bPoseChannel *pchan) | ||||
| { | { | ||||
| bPose *pose = (ob) ? ob->pose : NULL; | bPose *pose = (ob) ? ob->pose : nullptr; | ||||
| bArmature *arm = (ob) ? ob->data : NULL; | bArmature *arm = (ob) ? static_cast<bArmature *>(ob->data) : nullptr; | ||||
| bActionGroup *grp = NULL; | bActionGroup *grp = nullptr; | ||||
| short color_index = 0; | short color_index = 0; | ||||
| /* sanity check */ | /* sanity check */ | ||||
| if (ELEM(NULL, ob, arm, pose, pchan)) { | if (ELEM(nullptr, ob, arm, pose, pchan)) { | ||||
| ctx->bcolor = NULL; | ctx->bcolor = nullptr; | ||||
| return; | return; | ||||
| } | } | ||||
| /* only try to set custom color if enabled for armature */ | /* only try to set custom color if enabled for armature */ | ||||
| if (arm->flag & ARM_COL_CUSTOM) { | if (arm->flag & ARM_COL_CUSTOM) { | ||||
| /* currently, a bone can only use a custom color set if its group (if it has one), | /* currently, a bone can only use a custom color set if its group (if it has one), | ||||
| * has been set to use one | * has been set to use one | ||||
| */ | */ | ||||
| if (pchan->agrp_index) { | if (pchan->agrp_index) { | ||||
| grp = (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1)); | grp = (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1)); | ||||
| if (grp) { | if (grp) { | ||||
| color_index = grp->customCol; | color_index = grp->customCol; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* bcolor is a pointer to the color set to use. If NULL, then the default | /* bcolor is a pointer to the color set to use. If nullptr, then the default | ||||
| * color set (based on the theme colors for 3d-view) is used. | * color set (based on the theme colors for 3d-view) is used. | ||||
| */ | */ | ||||
| if (color_index > 0) { | if (color_index > 0) { | ||||
| bTheme *btheme = UI_GetTheme(); | bTheme *btheme = UI_GetTheme(); | ||||
| ctx->bcolor = &btheme->tarm[(color_index - 1)]; | ctx->bcolor = &btheme->tarm[(color_index - 1)]; | ||||
| } | } | ||||
| else if (color_index == -1) { | else if (color_index == -1) { | ||||
| /* use the group's own custom color set (grp is always != NULL here) */ | /* use the group's own custom color set (grp is always != nullptr here) */ | ||||
| ctx->bcolor = &grp->cs; | ctx->bcolor = &grp->cs; | ||||
| } | } | ||||
| else { | else { | ||||
| ctx->bcolor = NULL; | ctx->bcolor = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| /* This function is for brightening/darkening a given color (like UI_GetThemeColorShade3ubv()) */ | /* This function is for brightening/darkening a given color (like UI_GetThemeColorShade3ubv()) */ | ||||
| static void cp_shade_color3ub(uchar cp[3], const int offset) | static void cp_shade_color3ub(uchar cp[3], const int offset) | ||||
| { | { | ||||
| int r, g, b; | int r, g, b; | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | case PCHAN_COLOR_SOLID: { | ||||
| srgb_to_linearrgb_v4(fcolor, fcolor); | srgb_to_linearrgb_v4(fcolor, fcolor); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v4_v4(fcolor, G_draw.block.color_bone_solid); | copy_v4_v4(fcolor, G_draw.block.color_bone_solid); | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| case PCHAN_COLOR_CONSTS: { | case PCHAN_COLOR_CONSTS: { | ||||
| if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) { | if ((bcolor == nullptr) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) { | ||||
| if (constflag & PCHAN_HAS_TARGET) { | if (constflag & PCHAN_HAS_TARGET) { | ||||
| copy_v4_v4(fcolor, G_draw.block.color_bone_pose_target); | copy_v4_v4(fcolor, G_draw.block.color_bone_pose_target); | ||||
| } | } | ||||
| else if (constflag & PCHAN_HAS_IK) { | else if (constflag & PCHAN_HAS_IK) { | ||||
| copy_v4_v4(fcolor, G_draw.block.color_bone_pose_ik); | copy_v4_v4(fcolor, G_draw.block.color_bone_pose_ik); | ||||
| } | } | ||||
| else if (constflag & PCHAN_HAS_SPLINEIK) { | else if (constflag & PCHAN_HAS_SPLINEIK) { | ||||
| copy_v4_v4(fcolor, G_draw.block.color_bone_pose_spline_ik); | copy_v4_v4(fcolor, G_draw.block.color_bone_pose_spline_ik); | ||||
| ▲ Show 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Helper Utils | /** \name Helper Utils | ||||
| * \{ */ | * \{ */ | ||||
| static void pchan_draw_data_init(bPoseChannel *pchan) | static void pchan_draw_data_init(bPoseChannel *pchan) | ||||
| { | { | ||||
| if (pchan->draw_data != NULL) { | if (pchan->draw_data != nullptr) { | ||||
| if (pchan->draw_data->bbone_matrix_len != pchan->bone->segments) { | if (pchan->draw_data->bbone_matrix_len != pchan->bone->segments) { | ||||
| MEM_SAFE_FREE(pchan->draw_data); | MEM_SAFE_FREE(pchan->draw_data); | ||||
| } | } | ||||
| } | } | ||||
| if (pchan->draw_data == NULL) { | if (pchan->draw_data == nullptr) { | ||||
| pchan->draw_data = MEM_mallocN( | pchan->draw_data = static_cast<bPoseChannelDrawData *>( | ||||
| sizeof(*pchan->draw_data) + sizeof(Mat4) * pchan->bone->segments, __func__); | MEM_mallocN(sizeof(*pchan->draw_data) + sizeof(Mat4) * pchan->bone->segments, __func__)); | ||||
| pchan->draw_data->bbone_matrix_len = pchan->bone->segments; | pchan->draw_data->bbone_matrix_len = pchan->bone->segments; | ||||
| } | } | ||||
| } | } | ||||
| static void draw_bone_update_disp_matrix_default(EditBone *eBone, bPoseChannel *pchan) | static void draw_bone_update_disp_matrix_default(EditBone *eBone, bPoseChannel *pchan) | ||||
| { | { | ||||
| float ebmat[4][4]; | float ebmat[4][4]; | ||||
| float bone_scale[3]; | float bone_scale[3]; | ||||
| Show All 26 Lines | static void draw_bone_update_disp_matrix_default(EditBone *eBone, bPoseChannel *pchan) | ||||
| translate_m4(disp_tail_mat, 0.0f, 1.0f, 0.0f); | translate_m4(disp_tail_mat, 0.0f, 1.0f, 0.0f); | ||||
| } | } | ||||
| /* compute connected child pointer for B-Bone drawing */ | /* compute connected child pointer for B-Bone drawing */ | ||||
| static void edbo_compute_bbone_child(bArmature *arm) | static void edbo_compute_bbone_child(bArmature *arm) | ||||
| { | { | ||||
| EditBone *eBone; | EditBone *eBone; | ||||
| for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { | for (eBone = static_cast<EditBone *>(arm->edbo->first); eBone; eBone = eBone->next) { | ||||
| eBone->bbone_child = NULL; | eBone->bbone_child = nullptr; | ||||
| } | } | ||||
| for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { | for (eBone = static_cast<EditBone *>(arm->edbo->first); eBone; eBone = eBone->next) { | ||||
| if (eBone->parent && (eBone->flag & BONE_CONNECTED)) { | if (eBone->parent && (eBone->flag & BONE_CONNECTED)) { | ||||
| eBone->parent->bbone_child = eBone; | eBone->parent->bbone_child = eBone; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* A version of BKE_pchan_bbone_spline_setup() for previewing editmode curve settings. */ | /* A version of BKE_pchan_bbone_spline_setup() for previewing editmode curve settings. */ | ||||
| static void ebone_spline_preview(EditBone *ebone, const float result_array[MAX_BBONE_SUBDIV][4][4]) | static void ebone_spline_preview(EditBone *ebone, const float result_array[MAX_BBONE_SUBDIV][4][4]) | ||||
| Show All 10 Lines | static void ebone_spline_preview(EditBone *ebone, const float result_array[MAX_BBONE_SUBDIV][4][4]) | ||||
| /* Get "next" and "prev" bones - these are used for handle calculations. */ | /* Get "next" and "prev" bones - these are used for handle calculations. */ | ||||
| if (ebone->bbone_prev_type == BBONE_HANDLE_AUTO) { | if (ebone->bbone_prev_type == BBONE_HANDLE_AUTO) { | ||||
| /* Use connected parent. */ | /* Use connected parent. */ | ||||
| if (ebone->flag & BONE_CONNECTED) { | if (ebone->flag & BONE_CONNECTED) { | ||||
| prev = ebone->parent; | prev = ebone->parent; | ||||
| } | } | ||||
| else { | else { | ||||
| prev = NULL; | prev = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| prev = ebone->bbone_prev; | prev = ebone->bbone_prev; | ||||
| } | } | ||||
| if (ebone->bbone_next_type == BBONE_HANDLE_AUTO) { | if (ebone->bbone_next_type == BBONE_HANDLE_AUTO) { | ||||
| /* Use connected child. */ | /* Use connected child. */ | ||||
| ▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | else { | ||||
| length = eBone->length; | length = eBone->length; | ||||
| xwidth = eBone->xwidth; | xwidth = eBone->xwidth; | ||||
| zwidth = eBone->zwidth; | zwidth = eBone->zwidth; | ||||
| bone_mat = ebmat; | bone_mat = ebmat; | ||||
| bbone_segments = eBone->segments; | bbone_segments = eBone->segments; | ||||
| } | } | ||||
| size_to_mat4(s, (const float[3]){xwidth, length / bbone_segments, zwidth}); | const float3 size_vec = {xwidth, length / bbone_segments, zwidth}; | ||||
| size_to_mat4(s, size_vec); | |||||
| /* Compute BBones segment matrices... */ | /* Compute BBones segment matrices... */ | ||||
| /* Note that we need this even for one-segment bones, because box drawing need specific weirdo | /* Note that we need this even for one-segment bones, because box drawing need specific weirdo | ||||
| * matrix for the box, that we cannot use to draw end points & co. */ | * matrix for the box, that we cannot use to draw end points & co. */ | ||||
| if (pchan) { | if (pchan) { | ||||
| Mat4 *bbones_mat = (Mat4 *)pchan->draw_data->bbone_matrix; | Mat4 *bbones_mat = (Mat4 *)pchan->draw_data->bbone_matrix; | ||||
| if (bbone_segments > 1) { | if (bbone_segments > 1) { | ||||
| BKE_pchan_bbone_spline_setup(pchan, false, false, bbones_mat); | BKE_pchan_bbone_spline_setup(pchan, false, false, bbones_mat); | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
| static void draw_axes(ArmatureDrawContext *ctx, | static void draw_axes(ArmatureDrawContext *ctx, | ||||
| const EditBone *eBone, | const EditBone *eBone, | ||||
| const bPoseChannel *pchan, | const bPoseChannel *pchan, | ||||
| const bArmature *arm) | const bArmature *arm) | ||||
| { | { | ||||
| float final_col[4]; | float final_col[4]; | ||||
| const float *col = (ctx->const_color) ? ctx->const_color : | const float *col = (ctx->const_color) ? ctx->const_color : | ||||
| (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? G_draw.block.color_text_hi : | (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? &G_draw.block.color_text_hi.x : | ||||
| G_draw.block.color_text; | &G_draw.block.color_text.x; | ||||
| copy_v4_v4(final_col, col); | copy_v4_v4(final_col, col); | ||||
| /* Mix with axes color. */ | /* Mix with axes color. */ | ||||
| final_col[3] = (ctx->const_color) ? 1.0 : (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? 0.1 : 0.65; | final_col[3] = (ctx->const_color) ? 1.0 : (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? 0.1 : 0.65; | ||||
| if (pchan && pchan->custom && !(arm->flag & ARM_NO_CUSTOM)) { | if (pchan && pchan->custom && !(arm->flag & ARM_NO_CUSTOM)) { | ||||
| /* Special case: Custom bones can have different scale than the bone. | /* Special case: Custom bones can have different scale than the bone. | ||||
| * Recompute display matrix without the custom scaling applied. (T65640). */ | * Recompute display matrix without the custom scaling applied. (T65640). */ | ||||
| float axis_mat[4][4]; | float axis_mat[4][4]; | ||||
| float length = pchan->bone->length; | float length = pchan->bone->length; | ||||
| copy_m4_m4(axis_mat, pchan->custom_tx ? pchan->custom_tx->pose_mat : pchan->pose_mat); | copy_m4_m4(axis_mat, pchan->custom_tx ? pchan->custom_tx->pose_mat : pchan->pose_mat); | ||||
| rescale_m4(axis_mat, (float[3]){length, length, length}); | const float3 length_vec = {length, length, length}; | ||||
| rescale_m4(axis_mat, length_vec); | |||||
| translate_m4(axis_mat, 0.0, arm->axes_position - 1.0, 0.0); | translate_m4(axis_mat, 0.0, arm->axes_position - 1.0, 0.0); | ||||
| drw_shgroup_bone_axes(ctx, axis_mat, final_col); | drw_shgroup_bone_axes(ctx, axis_mat, final_col); | ||||
| } | } | ||||
| else { | else { | ||||
| float disp_mat[4][4]; | float disp_mat[4][4]; | ||||
| copy_m4_m4(disp_mat, BONE_VAR(eBone, pchan, disp_mat)); | copy_m4_m4(disp_mat, BONE_VAR(eBone, pchan, disp_mat)); | ||||
| translate_m4(disp_mat, 0.0, arm->axes_position - 1.0, 0.0); | translate_m4(disp_mat, 0.0, arm->axes_position - 1.0, 0.0); | ||||
| Show All 9 Lines | static void draw_points(ArmatureDrawContext *ctx, | ||||
| const short constflag, | const short constflag, | ||||
| const int select_id) | const int select_id) | ||||
| { | { | ||||
| float col_solid_root[4], col_solid_tail[4], col_wire_root[4], col_wire_tail[4]; | float col_solid_root[4], col_solid_tail[4], col_wire_root[4], col_wire_tail[4]; | ||||
| float col_hint_root[4], col_hint_tail[4]; | float col_hint_root[4], col_hint_tail[4]; | ||||
| copy_v4_v4(col_solid_root, G_draw.block.color_bone_solid); | copy_v4_v4(col_solid_root, G_draw.block.color_bone_solid); | ||||
| copy_v4_v4(col_solid_tail, G_draw.block.color_bone_solid); | copy_v4_v4(col_solid_tail, G_draw.block.color_bone_solid); | ||||
| copy_v4_v4(col_wire_root, (ctx->const_color) ? ctx->const_color : G_draw.block.color_vertex); | copy_v4_v4(col_wire_root, (ctx->const_color) ? ctx->const_color : &G_draw.block.color_vertex.x); | ||||
| copy_v4_v4(col_wire_tail, (ctx->const_color) ? ctx->const_color : G_draw.block.color_vertex); | copy_v4_v4(col_wire_tail, (ctx->const_color) ? ctx->const_color : &G_draw.block.color_vertex.x); | ||||
| const bool is_envelope_draw = (arm->drawtype == ARM_ENVELOPE); | const bool is_envelope_draw = (arm->drawtype == ARM_ENVELOPE); | ||||
| const float envelope_ignore = -1.0f; | const float envelope_ignore = -1.0f; | ||||
| col_wire_tail[3] = col_wire_root[3] = get_bone_wire_thickness(ctx, boneflag); | col_wire_tail[3] = col_wire_root[3] = get_bone_wire_thickness(ctx, boneflag); | ||||
| /* Edit bone points can be selected */ | /* Edit bone points can be selected */ | ||||
| if (eBone) { | if (eBone) { | ||||
| ▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| const float *col_bone = get_bone_solid_with_consts_color( | const float *col_bone = get_bone_solid_with_consts_color( | ||||
| ctx, eBone, pchan, arm, boneflag, constflag); | ctx, eBone, pchan, arm, boneflag, constflag); | ||||
| const float *col_wire = get_bone_wire_color(ctx, eBone, pchan, arm, boneflag, constflag); | const float *col_wire = get_bone_wire_color(ctx, eBone, pchan, arm, boneflag, constflag); | ||||
| const float no_display[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | const float no_display[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | ||||
| const float *col_head = no_display; | const float *col_head = no_display; | ||||
| const float *col_tail = col_bone; | const float *col_tail = col_bone; | ||||
| if (ctx->const_color != NULL) { | if (ctx->const_color != nullptr) { | ||||
| col_wire = no_display; /* actually shrink the display. */ | col_wire = no_display; /* actually shrink the display. */ | ||||
| col_bone = col_head = col_tail = ctx->const_color; | col_bone = col_head = col_tail = ctx->const_color; | ||||
| } | } | ||||
| else { | else { | ||||
| if (eBone) { | if (eBone) { | ||||
| if (eBone->flag & BONE_TIPSEL) { | if (eBone->flag & BONE_TIPSEL) { | ||||
| col_tail = G_draw.block.color_vertex_select; | col_tail = G_draw.block.color_vertex_select; | ||||
| } | } | ||||
| if (boneflag & BONE_SELECTED) { | if (boneflag & BONE_SELECTED) { | ||||
| col_bone = G_draw.block.color_bone_active; | col_bone = G_draw.block.color_bone_active; | ||||
| } | } | ||||
| col_wire = G_draw.block.color_wire; | col_wire = G_draw.block.color_wire; | ||||
| } | } | ||||
| /* Draw root point if we are not connected to our parent. */ | /* Draw root point if we are not connected to our parent. */ | ||||
| if (!(eBone ? (eBone->parent && (boneflag & BONE_CONNECTED)) : | if (!(eBone ? (eBone->parent && (boneflag & BONE_CONNECTED)) : | ||||
| (pchan->bone->parent && (boneflag & BONE_CONNECTED)))) { | (pchan->bone->parent && (boneflag & BONE_CONNECTED)))) { | ||||
| if (eBone) { | if (eBone) { | ||||
| col_head = (eBone->flag & BONE_ROOTSEL) ? G_draw.block.color_vertex_select : col_bone; | col_head = (eBone->flag & BONE_ROOTSEL) ? &G_draw.block.color_vertex_select.x : col_bone; | ||||
| } | } | ||||
| else { | else { | ||||
| col_head = col_bone; | col_head = col_bone; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (select_id == -1) { | if (select_id == -1) { | ||||
| Show All 32 Lines | static void draw_bone_wire(ArmatureDrawContext *ctx, | ||||
| const float *col_wire = get_bone_wire_color(ctx, eBone, pchan, arm, boneflag, constflag); | const float *col_wire = get_bone_wire_color(ctx, eBone, pchan, arm, boneflag, constflag); | ||||
| if (select_id != -1) { | if (select_id != -1) { | ||||
| DRW_select_load_id(select_id | BONESEL_BONE); | DRW_select_load_id(select_id | BONESEL_BONE); | ||||
| } | } | ||||
| if (pchan) { | if (pchan) { | ||||
| Mat4 *bbones_mat = (Mat4 *)pchan->draw_data->bbone_matrix; | Mat4 *bbones_mat = (Mat4 *)pchan->draw_data->bbone_matrix; | ||||
| BLI_assert(bbones_mat != NULL); | BLI_assert(bbones_mat != nullptr); | ||||
| for (int i = pchan->bone->segments; i--; bbones_mat++) { | for (int i = pchan->bone->segments; i--; bbones_mat++) { | ||||
| drw_shgroup_bone_wire(ctx, bbones_mat->mat, col_wire); | drw_shgroup_bone_wire(ctx, bbones_mat->mat, col_wire); | ||||
| } | } | ||||
| } | } | ||||
| else if (eBone) { | else if (eBone) { | ||||
| for (int i = 0; i < eBone->segments; i++) { | for (int i = 0; i < eBone->segments; i++) { | ||||
| drw_shgroup_bone_wire(ctx, eBone->disp_bbone_mat[i], col_wire); | drw_shgroup_bone_wire(ctx, eBone->disp_bbone_mat[i], col_wire); | ||||
| Show All 23 Lines | static void draw_bone_box(ArmatureDrawContext *ctx, | ||||
| const float *col_hint = get_bone_hint_color(ctx, eBone, pchan, arm, boneflag, constflag); | const float *col_hint = get_bone_hint_color(ctx, eBone, pchan, arm, boneflag, constflag); | ||||
| if (select_id != -1) { | if (select_id != -1) { | ||||
| DRW_select_load_id(select_id | BONESEL_BONE); | DRW_select_load_id(select_id | BONESEL_BONE); | ||||
| } | } | ||||
| if (pchan) { | if (pchan) { | ||||
| Mat4 *bbones_mat = (Mat4 *)pchan->draw_data->bbone_matrix; | Mat4 *bbones_mat = (Mat4 *)pchan->draw_data->bbone_matrix; | ||||
| BLI_assert(bbones_mat != NULL); | BLI_assert(bbones_mat != nullptr); | ||||
| for (int i = pchan->bone->segments; i--; bbones_mat++) { | for (int i = pchan->bone->segments; i--; bbones_mat++) { | ||||
| drw_shgroup_bone_box(ctx, bbones_mat->mat, col_solid, col_hint, col_wire); | drw_shgroup_bone_box(ctx, bbones_mat->mat, col_solid, col_hint, col_wire); | ||||
| } | } | ||||
| } | } | ||||
| else if (eBone) { | else if (eBone) { | ||||
| for (int i = 0; i < eBone->segments; i++) { | for (int i = 0; i < eBone->segments; i++) { | ||||
| drw_shgroup_bone_box(ctx, eBone->disp_bbone_mat[i], col_solid, col_hint, col_wire); | drw_shgroup_bone_box(ctx, eBone->disp_bbone_mat[i], col_solid, col_hint, col_wire); | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| static void draw_bone_degrees_of_freedom(ArmatureDrawContext *ctx, bPoseChannel *pchan) | static void draw_bone_degrees_of_freedom(ArmatureDrawContext *ctx, bPoseChannel *pchan) | ||||
| { | { | ||||
| BoneInstanceData inst_data; | BoneInstanceData inst_data; | ||||
| float tmp[4][4], posetrans[4][4]; | float tmp[4][4], posetrans[4][4]; | ||||
| float xminmax[2], zminmax[2]; | float xminmax[2], zminmax[2]; | ||||
| float color[4]; | float color[4]; | ||||
| if (ctx->dof_sphere == NULL) { | if (ctx->dof_sphere == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ | /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ | ||||
| xminmax[0] = sinf(pchan->limitmin[0] * 0.5f); | xminmax[0] = sinf(pchan->limitmin[0] * 0.5f); | ||||
| xminmax[1] = sinf(pchan->limitmax[0] * 0.5f); | xminmax[1] = sinf(pchan->limitmax[0] * 0.5f); | ||||
| zminmax[0] = sinf(pchan->limitmin[2] * 0.5f); | zminmax[0] = sinf(pchan->limitmin[2] * 0.5f); | ||||
| zminmax[1] = sinf(pchan->limitmax[2] * 0.5f); | zminmax[1] = sinf(pchan->limitmax[2] * 0.5f); | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
| static void pchan_draw_ik_lines(ArmatureDrawContext *ctx, | static void pchan_draw_ik_lines(ArmatureDrawContext *ctx, | ||||
| bPoseChannel *pchan, | bPoseChannel *pchan, | ||||
| const bool only_temp, | const bool only_temp, | ||||
| const int constflag) | const int constflag) | ||||
| { | { | ||||
| bConstraint *con; | bConstraint *con; | ||||
| bPoseChannel *parchan; | bPoseChannel *parchan; | ||||
| float *line_start = NULL, *line_end = NULL; | float *line_start = nullptr, *line_end = nullptr; | ||||
| for (con = pchan->constraints.first; con; con = con->next) { | for (con = static_cast<bConstraint *>(pchan->constraints.first); con; con = con->next) { | ||||
| if (con->enforce == 0.0f) { | if (con->enforce == 0.0f) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| switch (con->type) { | switch (con->type) { | ||||
| case CONSTRAINT_TYPE_KINEMATIC: { | case CONSTRAINT_TYPE_KINEMATIC: { | ||||
| bKinematicConstraint *data = (bKinematicConstraint *)con->data; | bKinematicConstraint *data = (bKinematicConstraint *)con->data; | ||||
| int segcount = 0; | int segcount = 0; | ||||
| ▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | static bool pchan_culling_test_line(const DRWView *view, | ||||
| const float scale = 1.1f; | const float scale = 1.1f; | ||||
| return pchan_culling_test_with_radius_scale(view, ob, pchan, scale); | return pchan_culling_test_with_radius_scale(view, ob, pchan, scale); | ||||
| } | } | ||||
| static bool pchan_culling_test_envelope(const DRWView *view, | static bool pchan_culling_test_envelope(const DRWView *view, | ||||
| const Object *ob, | const Object *ob, | ||||
| const bPoseChannel *pchan) | const bPoseChannel *pchan) | ||||
| { | { | ||||
| const bArmature *arm = ob->data; | const bArmature *arm = static_cast<bArmature *>(ob->data); | ||||
| BLI_assert(arm->drawtype == ARM_ENVELOPE); | BLI_assert(arm->drawtype == ARM_ENVELOPE); | ||||
| UNUSED_VARS_NDEBUG(arm); | UNUSED_VARS_NDEBUG(arm); | ||||
| BoundSphere bsphere; | BoundSphere bsphere; | ||||
| pchan_culling_calc_bsphere(ob, pchan, &bsphere); | pchan_culling_calc_bsphere(ob, pchan, &bsphere); | ||||
| bsphere.radius += max_ff(pchan->bone->rad_head, pchan->bone->rad_tail) * | bsphere.radius += max_ff(pchan->bone->rad_head, pchan->bone->rad_tail) * | ||||
| mat4_to_size_max_axis(ob->obmat) * mat4_to_size_max_axis(pchan->disp_mat); | mat4_to_size_max_axis(ob->obmat) * mat4_to_size_max_axis(pchan->disp_mat); | ||||
| return DRW_culling_sphere_test(view, &bsphere); | return DRW_culling_sphere_test(view, &bsphere); | ||||
| } | } | ||||
| static bool pchan_culling_test_bbone(const DRWView *view, | static bool pchan_culling_test_bbone(const DRWView *view, | ||||
| const Object *ob, | const Object *ob, | ||||
| const bPoseChannel *pchan) | const bPoseChannel *pchan) | ||||
| { | { | ||||
| const bArmature *arm = ob->data; | const bArmature *arm = static_cast<bArmature *>(ob->data); | ||||
| BLI_assert(arm->drawtype == ARM_B_BONE); | BLI_assert(arm->drawtype == ARM_B_BONE); | ||||
| UNUSED_VARS_NDEBUG(arm); | UNUSED_VARS_NDEBUG(arm); | ||||
| const float ob_scale = mat4_to_size_max_axis(ob->obmat); | const float ob_scale = mat4_to_size_max_axis(ob->obmat); | ||||
| const Mat4 *bbones_mat = (const Mat4 *)pchan->draw_data->bbone_matrix; | const Mat4 *bbones_mat = (const Mat4 *)pchan->draw_data->bbone_matrix; | ||||
| for (int i = pchan->bone->segments; i--; bbones_mat++) { | for (int i = pchan->bone->segments; i--; bbones_mat++) { | ||||
| BoundSphere bsphere; | BoundSphere bsphere; | ||||
| float size[3]; | float size[3]; | ||||
| mat4_to_size(size, bbones_mat->mat); | mat4_to_size(size, bbones_mat->mat); | ||||
| Show All 30 Lines | static void draw_armature_edit(ArmatureDrawContext *ctx) | ||||
| const bool is_select = DRW_state_is_select(); | const bool is_select = DRW_state_is_select(); | ||||
| const bool show_text = DRW_state_show_text(); | const bool show_text = DRW_state_show_text(); | ||||
| const Object *ob_orig = DEG_get_original_object(ob); | const Object *ob_orig = DEG_get_original_object(ob); | ||||
| /* FIXME(@campbellbarton): We should be able to use the CoW object, | /* FIXME(@campbellbarton): We should be able to use the CoW object, | ||||
| * however the active bone isn't updated. Long term solution is an 'EditArmature' struct. | * however the active bone isn't updated. Long term solution is an 'EditArmature' struct. | ||||
| * for now we can draw from the original armature. See: T66773. */ | * for now we can draw from the original armature. See: T66773. */ | ||||
| // bArmature *arm = ob->data; | // bArmature *arm = ob->data; | ||||
| bArmature *arm = ob_orig->data; | bArmature *arm = static_cast<bArmature *>(ob_orig->data); | ||||
| edbo_compute_bbone_child(arm); | edbo_compute_bbone_child(arm); | ||||
| for (eBone = arm->edbo->first, index = ob_orig->runtime.select_id; eBone; | for (eBone = static_cast<EditBone *>(arm->edbo->first), index = ob_orig->runtime.select_id; | ||||
| eBone; | |||||
| eBone = eBone->next, index += 0x10000) { | eBone = eBone->next, index += 0x10000) { | ||||
| if (eBone->layer & arm->layer) { | if (eBone->layer & arm->layer) { | ||||
| if ((eBone->flag & BONE_HIDDEN_A) == 0) { | if ((eBone->flag & BONE_HIDDEN_A) == 0) { | ||||
| const int select_id = is_select ? index : (uint)-1; | const int select_id = is_select ? index : (uint)-1; | ||||
| const short constflag = 0; | const short constflag = 0; | ||||
| /* catch exception for bone with hidden parent */ | /* catch exception for bone with hidden parent */ | ||||
| int boneflag = eBone->flag; | int boneflag = eBone->flag; | ||||
| if ((eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent)) { | if ((eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent)) { | ||||
| 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; | boneflag &= ~BONE_DRAW_LOCKED_WEIGHT; | ||||
| if (!is_select) { | if (!is_select) { | ||||
| draw_bone_relations(ctx, eBone, NULL, arm, boneflag, constflag); | draw_bone_relations(ctx, eBone, nullptr, 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, nullptr); | ||||
| draw_bone_envelope(ctx, eBone, NULL, arm, boneflag, constflag, select_id); | draw_bone_envelope(ctx, eBone, nullptr, 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, nullptr); | ||||
| draw_bone_line(ctx, eBone, NULL, arm, boneflag, constflag, select_id); | draw_bone_line(ctx, eBone, nullptr, arm, boneflag, constflag, select_id); | ||||
| } | } | ||||
| else if (arm->drawtype == ARM_WIRE) { | else if (arm->drawtype == ARM_WIRE) { | ||||
| draw_bone_update_disp_matrix_bbone(eBone, NULL); | draw_bone_update_disp_matrix_bbone(eBone, nullptr); | ||||
| draw_bone_wire(ctx, eBone, NULL, arm, boneflag, constflag, select_id); | draw_bone_wire(ctx, eBone, nullptr, arm, boneflag, constflag, select_id); | ||||
| } | } | ||||
| else if (arm->drawtype == ARM_B_BONE) { | else if (arm->drawtype == ARM_B_BONE) { | ||||
| draw_bone_update_disp_matrix_bbone(eBone, NULL); | draw_bone_update_disp_matrix_bbone(eBone, nullptr); | ||||
| draw_bone_box(ctx, eBone, NULL, arm, boneflag, constflag, select_id); | draw_bone_box(ctx, eBone, nullptr, arm, boneflag, constflag, select_id); | ||||
| } | } | ||||
| else { | else { | ||||
| draw_bone_update_disp_matrix_default(eBone, NULL); | draw_bone_update_disp_matrix_default(eBone, nullptr); | ||||
| draw_bone_octahedral(ctx, eBone, NULL, arm, boneflag, constflag, select_id); | draw_bone_octahedral(ctx, eBone, nullptr, arm, boneflag, constflag, select_id); | ||||
| } | } | ||||
| if (!is_select) { | if (!is_select) { | ||||
| if (show_text && (arm->flag & ARM_DRAWNAMES)) { | if (show_text && (arm->flag & ARM_DRAWNAMES)) { | ||||
| draw_bone_name(ctx, eBone, NULL, arm, boneflag); | draw_bone_name(ctx, eBone, nullptr, arm, boneflag); | ||||
| } | } | ||||
| if (arm->flag & ARM_DRAWAXES) { | if (arm->flag & ARM_DRAWAXES) { | ||||
| draw_axes(ctx, eBone, NULL, arm); | draw_axes(ctx, eBone, nullptr, arm); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void draw_armature_pose(ArmatureDrawContext *ctx) | static void draw_armature_pose(ArmatureDrawContext *ctx) | ||||
| { | { | ||||
| 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 = static_cast<bArmature *>(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; | 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 nullptr 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. */ | ||||
| if ((ob->base_flag & (BASE_FROM_SET | BASE_FROM_DUPLI)) == 0) { | if ((ob->base_flag & (BASE_FROM_SET | BASE_FROM_DUPLI)) == 0) { | ||||
| if ((draw_ctx->object_mode & OB_MODE_POSE) || (ob == draw_ctx->object_pose)) { | if ((draw_ctx->object_mode & OB_MODE_POSE) || (ob == draw_ctx->object_pose)) { | ||||
| arm->flag |= ARM_POSEMODE; | arm->flag |= ARM_POSEMODE; | ||||
| } | } | ||||
| is_pose_select = | is_pose_select = | ||||
| /* If we're in pose-mode or object-mode with the ability to enter pose mode. */ | /* If we're in pose-mode or object-mode with the ability to enter pose mode. */ | ||||
| ( | ( | ||||
| /* Draw as if in pose mode (when selection is possible). */ | /* Draw as if in pose mode (when selection is possible). */ | ||||
| (arm->flag & ARM_POSEMODE) || | (arm->flag & ARM_POSEMODE) || | ||||
| /* When we're in object mode, which may select bones. */ | /* When we're in object mode, which may select bones. */ | ||||
| ((ob->mode & OB_MODE_POSE) && | ((ob->mode & OB_MODE_POSE) && | ||||
| ( | ( | ||||
| /* Switch from object mode when object lock is disabled. */ | /* Switch from object mode when object lock is disabled. */ | ||||
| ((draw_ctx->object_mode == OB_MODE_OBJECT) && | ((draw_ctx->object_mode == OB_MODE_OBJECT) && | ||||
| (scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) == 0) || | (scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) == 0) || | ||||
| /* Allow selection when in weight-paint mode | /* Allow selection when in weight-paint mode | ||||
| * (selection code ensures this won't become active). */ | * (selection code ensures this won't become active). */ | ||||
| ((draw_ctx->object_mode & OB_MODE_ALL_WEIGHT_PAINT) && | ((draw_ctx->object_mode & OB_MODE_ALL_WEIGHT_PAINT) && | ||||
| (draw_ctx->object_pose != NULL))))) && | (draw_ctx->object_pose != nullptr))))) && | ||||
| 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. */ | /* In weight paint mode retrieve the vertex group lock status. */ | ||||
| if ((draw_ctx->object_mode & OB_MODE_ALL_WEIGHT_PAINT) && (draw_ctx->object_pose == ob) && | if ((draw_ctx->object_mode & OB_MODE_ALL_WEIGHT_PAINT) && (draw_ctx->object_pose == ob) && | ||||
| (draw_ctx->obact != NULL)) { | (draw_ctx->obact != nullptr)) { | ||||
| draw_locked_weights = true; | draw_locked_weights = true; | ||||
| for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { | for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; | ||||
| pchan = pchan->next) { | |||||
| pchan->bone->flag &= ~BONE_DRAW_LOCKED_WEIGHT; | pchan->bone->flag &= ~BONE_DRAW_LOCKED_WEIGHT; | ||||
| } | } | ||||
| const Object *obact_orig = DEG_get_original_object(draw_ctx->obact); | const Object *obact_orig = DEG_get_original_object(draw_ctx->obact); | ||||
| const ListBase *defbase = BKE_object_defgroup_list(obact_orig); | const ListBase *defbase = BKE_object_defgroup_list(obact_orig); | ||||
| LISTBASE_FOREACH (const bDeformGroup *, dg, defbase) { | LISTBASE_FOREACH (const bDeformGroup *, dg, defbase) { | ||||
| if (dg->flag & DG_LOCK_WEIGHT) { | if (dg->flag & DG_LOCK_WEIGHT) { | ||||
| pchan = BKE_pose_channel_find_name(ob->pose, dg->name); | pchan = BKE_pose_channel_find_name(ob->pose, dg->name); | ||||
| if (pchan) { | if (pchan) { | ||||
| pchan->bone->flag |= BONE_DRAW_LOCKED_WEIGHT; | pchan->bone->flag |= BONE_DRAW_LOCKED_WEIGHT; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| const DRWView *view = is_pose_select ? DRW_view_default_get() : NULL; | const DRWView *view = is_pose_select ? DRW_view_default_get() : nullptr; | ||||
| for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, index += 0x10000) { | for (pchan = static_cast<bPoseChannel *>(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) && | ||||
| ((ob->base_flag & BASE_FROM_DUPLI) == 0) && | ((ob->base_flag & BASE_FROM_DUPLI) == 0) && | ||||
| Show All 18 Lines | if (bone_visible) { | ||||
| boneflag |= BONE_DRAW_ACTIVE; | boneflag |= BONE_DRAW_ACTIVE; | ||||
| } | } | ||||
| if (!draw_locked_weights) { | if (!draw_locked_weights) { | ||||
| boneflag &= ~BONE_DRAW_LOCKED_WEIGHT; | boneflag &= ~BONE_DRAW_LOCKED_WEIGHT; | ||||
| } | } | ||||
| if (!is_pose_select) { | if (!is_pose_select) { | ||||
| draw_bone_relations(ctx, NULL, pchan, arm, boneflag, constflag); | draw_bone_relations(ctx, nullptr, 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); | ||||
| if (!is_pose_select || pchan_culling_test_custom(view, ob, pchan)) { | if (!is_pose_select || pchan_culling_test_custom(view, ob, pchan)) { | ||||
| draw_bone_custom_shape(ctx, NULL, pchan, arm, boneflag, constflag, select_id); | draw_bone_custom_shape(ctx, nullptr, 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(nullptr, pchan); | ||||
| if (!is_pose_select || pchan_culling_test_envelope(view, ob, pchan)) { | if (!is_pose_select || pchan_culling_test_envelope(view, ob, pchan)) { | ||||
| draw_bone_envelope(ctx, NULL, pchan, arm, boneflag, constflag, select_id); | draw_bone_envelope(ctx, nullptr, pchan, arm, boneflag, constflag, select_id); | ||||
| } | } | ||||
| } | } | ||||
| else if (arm->drawtype == ARM_LINE) { | else if (arm->drawtype == ARM_LINE) { | ||||
| draw_bone_update_disp_matrix_default(NULL, pchan); | draw_bone_update_disp_matrix_default(nullptr, pchan); | ||||
| if (!is_pose_select || pchan_culling_test_line(view, ob, pchan)) { | if (!is_pose_select || pchan_culling_test_line(view, ob, pchan)) { | ||||
| draw_bone_line(ctx, NULL, pchan, arm, boneflag, constflag, select_id); | draw_bone_line(ctx, nullptr, pchan, arm, boneflag, constflag, select_id); | ||||
| } | } | ||||
| } | } | ||||
| else if (arm->drawtype == ARM_WIRE) { | else if (arm->drawtype == ARM_WIRE) { | ||||
| draw_bone_update_disp_matrix_bbone(NULL, pchan); | draw_bone_update_disp_matrix_bbone(nullptr, pchan); | ||||
| if (!is_pose_select || pchan_culling_test_wire(view, ob, pchan)) { | if (!is_pose_select || pchan_culling_test_wire(view, ob, pchan)) { | ||||
| draw_bone_wire(ctx, NULL, pchan, arm, boneflag, constflag, select_id); | draw_bone_wire(ctx, nullptr, pchan, arm, boneflag, constflag, select_id); | ||||
| } | } | ||||
| } | } | ||||
| else if (arm->drawtype == ARM_B_BONE) { | else if (arm->drawtype == ARM_B_BONE) { | ||||
| draw_bone_update_disp_matrix_bbone(NULL, pchan); | draw_bone_update_disp_matrix_bbone(nullptr, pchan); | ||||
| if (!is_pose_select || pchan_culling_test_bbone(view, ob, pchan)) { | if (!is_pose_select || pchan_culling_test_bbone(view, ob, pchan)) { | ||||
| draw_bone_box(ctx, NULL, pchan, arm, boneflag, constflag, select_id); | draw_bone_box(ctx, nullptr, pchan, arm, boneflag, constflag, select_id); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| draw_bone_update_disp_matrix_default(NULL, pchan); | draw_bone_update_disp_matrix_default(nullptr, pchan); | ||||
| if (!is_pose_select || pchan_culling_test_octohedral(view, ob, pchan)) { | if (!is_pose_select || pchan_culling_test_octohedral(view, ob, pchan)) { | ||||
| draw_bone_octahedral(ctx, NULL, pchan, arm, boneflag, constflag, select_id); | draw_bone_octahedral(ctx, nullptr, pchan, arm, boneflag, constflag, select_id); | ||||
| } | } | ||||
| } | } | ||||
| /* These aren't included in the selection. */ | /* These aren't included in the selection. */ | ||||
| if (!is_pose_select) { | if (!is_pose_select) { | ||||
| if (draw_dofs) { | if (draw_dofs) { | ||||
| draw_bone_degrees_of_freedom(ctx, pchan); | draw_bone_degrees_of_freedom(ctx, pchan); | ||||
| } | } | ||||
| if (show_text && (arm->flag & ARM_DRAWNAMES)) { | if (show_text && (arm->flag & ARM_DRAWNAMES)) { | ||||
| draw_bone_name(ctx, NULL, pchan, arm, boneflag); | draw_bone_name(ctx, nullptr, pchan, arm, boneflag); | ||||
| } | } | ||||
| if (arm->flag & ARM_DRAWAXES) { | if (arm->flag & ARM_DRAWAXES) { | ||||
| draw_axes(ctx, NULL, pchan, arm); | draw_axes(ctx, nullptr, pchan, arm); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| 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_edit_mode, | ||||
| const bool is_pose_mode, | const bool is_pose_mode, | ||||
| const float *const_color) | const float *const_color) | ||||
| { | { | ||||
| const bool is_object_mode = !do_envelope_dist; | const bool is_object_mode = !do_envelope_dist; | ||||
| const bool is_xray = (ob->dtx & OB_DRAW_IN_FRONT) != 0 || | const bool is_xray = (ob->dtx & OB_DRAW_IN_FRONT) != 0 || | ||||
| (pd->armature.do_pose_xray && is_pose_mode); | (pd->armature.do_pose_xray && is_pose_mode); | ||||
| const bool draw_as_wire = (ob->dt < OB_SOLID); | const bool draw_as_wire = (ob->dt < OB_SOLID); | ||||
| const bool is_filled = (!pd->armature.transparent && !draw_as_wire) || !is_object_mode; | const bool is_filled = (!pd->armature.transparent && !draw_as_wire) || !is_object_mode; | ||||
| const bool is_transparent = pd->armature.transparent || (draw_as_wire && !is_object_mode); | const bool is_transparent = pd->armature.transparent || (draw_as_wire && !is_object_mode); | ||||
| bArmature *arm = ob->data; | bArmature *arm = static_cast<bArmature *>(ob->data); | ||||
| OVERLAY_ArmatureCallBuffers *cbo = &pd->armature_call_buffers[is_xray]; | OVERLAY_ArmatureCallBuffers *cbo = &pd->armature_call_buffers[is_xray]; | ||||
| OVERLAY_ArmatureCallBuffersInner *cb = is_transparent ? &cbo->transp : &cbo->solid; | OVERLAY_ArmatureCallBuffersInner *cb = is_transparent ? &cbo->transp : &cbo->solid; | ||||
| static const float select_const_color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | static const float select_const_color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | ||||
| switch (arm->drawtype) { | switch (arm->drawtype) { | ||||
| case ARM_ENVELOPE: | case ARM_ENVELOPE: | ||||
| ctx->envelope_outline = cb->envelope_outline; | ctx->envelope_outline = cb->envelope_outline; | ||||
| ctx->envelope_solid = (is_filled) ? cb->envelope_fill : NULL; | ctx->envelope_solid = (is_filled) ? cb->envelope_fill : nullptr; | ||||
| ctx->envelope_distance = (do_envelope_dist) ? cb->envelope_distance : NULL; | ctx->envelope_distance = (do_envelope_dist) ? cb->envelope_distance : nullptr; | ||||
| break; | break; | ||||
| case ARM_LINE: | case ARM_LINE: | ||||
| ctx->stick = cb->stick; | ctx->stick = cb->stick; | ||||
| break; | break; | ||||
| case ARM_WIRE: | case ARM_WIRE: | ||||
| ctx->wire = cb->wire; | ctx->wire = cb->wire; | ||||
| break; | break; | ||||
| case ARM_B_BONE: | case ARM_B_BONE: | ||||
| ctx->outline = cb->box_outline; | ctx->outline = cb->box_outline; | ||||
| ctx->solid = (is_filled) ? cb->box_fill : NULL; | ctx->solid = (is_filled) ? cb->box_fill : nullptr; | ||||
| break; | break; | ||||
| case ARM_OCTA: | case ARM_OCTA: | ||||
| ctx->outline = cb->octa_outline; | ctx->outline = cb->octa_outline; | ||||
| ctx->solid = (is_filled) ? cb->octa_fill : NULL; | ctx->solid = (is_filled) ? cb->octa_fill : nullptr; | ||||
| break; | break; | ||||
| } | } | ||||
| ctx->ob = ob; | ctx->ob = ob; | ||||
| ctx->extras = &pd->extra_call_buffers[is_xray]; | ctx->extras = &pd->extra_call_buffers[is_xray]; | ||||
| ctx->dof_lines = cb->dof_lines; | ctx->dof_lines = cb->dof_lines; | ||||
| ctx->dof_sphere = cb->dof_sphere; | ctx->dof_sphere = cb->dof_sphere; | ||||
| ctx->point_solid = (is_filled) ? cb->point_fill : NULL; | ctx->point_solid = (is_filled) ? cb->point_fill : nullptr; | ||||
| ctx->point_outline = cb->point_outline; | ctx->point_outline = cb->point_outline; | ||||
| ctx->custom_solid = (is_filled) ? cb->custom_fill : NULL; | ctx->custom_solid = (is_filled) ? cb->custom_fill : nullptr; | ||||
| ctx->custom_outline = cb->custom_outline; | ctx->custom_outline = cb->custom_outline; | ||||
| ctx->custom_wire = cb->custom_wire; | ctx->custom_wire = cb->custom_wire; | ||||
| ctx->custom_shapes_ghash = cb->custom_shapes_ghash; | ctx->custom_shapes_ghash = cb->custom_shapes_ghash; | ||||
| ctx->show_relations = pd->armature.show_relations; | ctx->show_relations = pd->armature.show_relations; | ||||
| ctx->do_relations = !DRW_state_is_select() && pd->armature.show_relations && | ctx->do_relations = !DRW_state_is_select() && pd->armature.show_relations && | ||||
| (is_edit_mode | is_pose_mode); | (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) && (pd->v3d_flag & V3D_SELECT_OUTLINE)) || | ctx->const_wire = ((((ob->base_flag & BASE_SELECTED) && (pd->v3d_flag & V3D_SELECT_OUTLINE)) || | ||||
| (arm->drawtype == ARM_WIRE)) ? | (arm->drawtype == ARM_WIRE)) ? | ||||
| 1.5f : | 1.5f : | ||||
| ((!is_filled || is_transparent) ? 1.0f : 0.0f)); | ((!is_filled || is_transparent) ? 1.0f : 0.0f)); | ||||
| } | } | ||||
| 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, true, false, NULL); | armature_context_setup(&arm_ctx, pd, ob, true, true, false, nullptr); | ||||
| 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, false, true, NULL); | armature_context_setup(&arm_ctx, pd, ob, true, false, true, nullptr); | ||||
| 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; | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
| void OVERLAY_armature_cache_finish(OVERLAY_Data *vedata) | void OVERLAY_armature_cache_finish(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| for (int i = 0; i < 2; i++) { | for (int i = 0; i < 2; i++) { | ||||
| if (pd->armature_call_buffers[i].solid.custom_shapes_ghash) { | if (pd->armature_call_buffers[i].solid.custom_shapes_ghash) { | ||||
| /* TODO(fclem): Do not free it for each frame but reuse it. Avoiding alloc cost. */ | /* TODO(fclem): Do not free it for each frame but reuse it. Avoiding alloc cost. */ | ||||
| BLI_ghash_free(pd->armature_call_buffers[i].solid.custom_shapes_ghash, NULL, NULL); | BLI_ghash_free(pd->armature_call_buffers[i].solid.custom_shapes_ghash, nullptr, nullptr); | ||||
| BLI_ghash_free(pd->armature_call_buffers[i].transp.custom_shapes_ghash, NULL, NULL); | BLI_ghash_free(pd->armature_call_buffers[i].transp.custom_shapes_ghash, nullptr, nullptr); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void OVERLAY_armature_draw(OVERLAY_Data *vedata) | void OVERLAY_armature_draw(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| DRW_draw_pass(psl->armature_transp_ps[0]); | DRW_draw_pass(psl->armature_transp_ps[0]); | ||||
| DRW_draw_pass(psl->armature_ps[0]); | DRW_draw_pass(psl->armature_ps[0]); | ||||
| } | } | ||||
| void OVERLAY_armature_in_front_draw(OVERLAY_Data *vedata) | void OVERLAY_armature_in_front_draw(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| if (psl->armature_bone_select_ps == NULL || DRW_state_is_select()) { | if (psl->armature_bone_select_ps == nullptr || DRW_state_is_select()) { | ||||
| DRW_draw_pass(psl->armature_transp_ps[1]); | DRW_draw_pass(psl->armature_transp_ps[1]); | ||||
| DRW_draw_pass(psl->armature_ps[1]); | DRW_draw_pass(psl->armature_ps[1]); | ||||
| } | } | ||||
| } | } | ||||
| void OVERLAY_pose_draw(OVERLAY_Data *vedata) | void OVERLAY_pose_draw(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_FramebufferList *fbl = vedata->fbl; | OVERLAY_FramebufferList *fbl = vedata->fbl; | ||||
| if (psl->armature_bone_select_ps != NULL) { | if (psl->armature_bone_select_ps != nullptr) { | ||||
| if (DRW_state_is_fbo()) { | if (DRW_state_is_fbo()) { | ||||
| GPU_framebuffer_bind(fbl->overlay_default_fb); | GPU_framebuffer_bind(fbl->overlay_default_fb); | ||||
| } | } | ||||
| DRW_draw_pass(psl->armature_bone_select_ps); | DRW_draw_pass(psl->armature_bone_select_ps); | ||||
| if (DRW_state_is_fbo()) { | if (DRW_state_is_fbo()) { | ||||
| GPU_framebuffer_bind(fbl->overlay_line_in_front_fb); | GPU_framebuffer_bind(fbl->overlay_line_in_front_fb); | ||||
| Show All 9 Lines | |||||