Refactor: anim, rename flag PCHAN_HAS_TARGET to PCHAN_HAS_NO_TARGET

Rename the `bPoseChannel::flag` `PCHAN_HAS_TARGET` to `PCHAN_HAS_NO_TARGET`
as that is actually the meaning of the flag (in the majority of the code).

Since the flag was so confusingly named, there were some mixups in the
armature overlay drawing code as well, which have been fixed now too.
This commit is contained in:
Sybren A. Stüvel
2023-09-25 12:03:30 +02:00
parent 0ddd0460f0
commit caf46c9fbb
9 changed files with 21 additions and 24 deletions

View File

@@ -1184,7 +1184,7 @@ void BKE_pose_update_constraint_flags(bPose *pose)
if (data->tar == nullptr || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0))
{
pchan->constflag |= PCHAN_HAS_TARGET;
pchan->constflag |= PCHAN_HAS_NO_TARGET;
}
/* negative rootbone = recalc rootbone index. used in do_versions */

View File

@@ -1211,8 +1211,8 @@ static void get_pchan_color_constraint(const ThemeWireColor *bcolor,
get_pchan_color_solid(bcolor, solid_color);
float4 constraint_color;
if (constflag & PCHAN_HAS_TARGET) {
constraint_color = G_draw.block.color_bone_pose_target;
if (constflag & PCHAN_HAS_NO_TARGET) {
constraint_color = G_draw.block.color_bone_pose_no_target;
}
else if (constflag & PCHAN_HAS_IK) {
constraint_color = G_draw.block.color_bone_pose_ik;
@@ -1823,11 +1823,11 @@ static void pchan_draw_ik_lines(const ArmatureDrawContext *ctx,
if (parchan) {
line_end = parchan->pose_head;
if (constflag & PCHAN_HAS_TARGET) {
drw_shgroup_bone_ik_lines(ctx, line_start, line_end);
if (constflag & PCHAN_HAS_NO_TARGET) {
drw_shgroup_bone_ik_no_target_lines(ctx, line_start, line_end);
}
else {
drw_shgroup_bone_ik_no_target_lines(ctx, line_start, line_end);
drw_shgroup_bone_ik_lines(ctx, line_start, line_end);
}
}
break;

View File

@@ -159,7 +159,7 @@ struct ThemeColorData {
float4 color_bone_pose_constraint;
float4 color_bone_pose_ik;
float4 color_bone_pose_spline_ik;
float4 color_bone_pose_target;
float4 color_bone_pose_no_target;
float4 color_bone_solid;
float4 color_bone_locked;
float4 color_bone_active;

View File

@@ -112,14 +112,14 @@ void DRW_globals_update()
UI_GetThemeColorBlendShade4fv(TH_WIRE, TH_BONE_POSE, 0.15f, 0, gb->color_bone_pose_active_unsel);
UI_GetThemeColorBlendShade3fv(
TH_WIRE_EDIT, TH_EDGE_SELECT, 0.15f, 0, gb->color_bone_active_unsel);
UI_COLOR_RGBA_FROM_U8(255, 150, 0, 80, gb->color_bone_pose_target);
UI_COLOR_RGBA_FROM_U8(255, 150, 0, 80, gb->color_bone_pose_no_target);
UI_COLOR_RGBA_FROM_U8(255, 255, 0, 80, gb->color_bone_pose_ik);
UI_COLOR_RGBA_FROM_U8(200, 255, 0, 80, gb->color_bone_pose_spline_ik);
UI_COLOR_RGBA_FROM_U8(0, 255, 120, 80, gb->color_bone_pose_constraint);
UI_GetThemeColor4fv(TH_BONE_SOLID, gb->color_bone_solid);
UI_GetThemeColor4fv(TH_BONE_LOCKED_WEIGHT, gb->color_bone_locked);
copy_v4_fl4(gb->color_bone_ik_line, 0.8f, 0.5f, 0.0f, 1.0f);
copy_v4_fl4(gb->color_bone_ik_line_no_target, 0.8f, 0.8f, 0.2f, 1.0f);
copy_v4_fl4(gb->color_bone_ik_line, 0.8f, 0.8f, 0.0f, 1.0f);
copy_v4_fl4(gb->color_bone_ik_line_no_target, 0.8f, 0.5f, 0.2f, 1.0f);
copy_v4_fl4(gb->color_bone_ik_line_spline, 0.8f, 0.8f, 0.2f, 1.0f);
/* Curve */

View File

@@ -92,7 +92,7 @@ struct GlobalsUboStorage {
float4 color_bone_pose_constraint;
float4 color_bone_pose_ik;
float4 color_bone_pose_spline_ik;
float4 color_bone_pose_target;
float4 color_bone_pose_no_target;
float4 color_bone_solid;
float4 color_bone_locked;
float4 color_bone_active;
@@ -207,7 +207,7 @@ BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
# define colorBonePoseConstraint globalsBlock.color_bone_pose_constraint
# define colorBonePoseIK globalsBlock.color_bone_pose_ik
# define colorBonePoseSplineIK globalsBlock.color_bone_pose_spline_ik
# define colorBonePoseTarget globalsBlock.color_bone_pose_target
# define colorBonePoseTarget globalsBlock.color_bone_pose_no_target
# define colorBoneSolid globalsBlock.color_bone_solid
# define colorBoneLocked globalsBlock.color_bone_locked
# define colorBoneActive globalsBlock.color_bone_active

View File

@@ -2751,7 +2751,7 @@ static int pose_ik_clear_exec(bContext *C, wmOperator * /*op*/)
BKE_constraint_remove(&pchan->constraints, con);
}
}
pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET);
pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_NO_TARGET);
if (prev_ob != ob) {
prev_ob = ob;

View File

@@ -324,7 +324,7 @@ static bool pchan_autoik_adjust(bPoseChannel *pchan, short chainlen)
bool changed = false;
/* don't bother to search if no valid constraints */
if ((pchan->constflag & (PCHAN_HAS_IK | PCHAN_HAS_TARGET)) == 0) {
if ((pchan->constflag & (PCHAN_HAS_IK | PCHAN_HAS_NO_TARGET)) == 0) {
return changed;
}

View File

@@ -232,7 +232,7 @@ static bConstraint *add_temporary_ik_constraint(bPoseChannel *pchan,
nullptr, pchan, "TempConstraint", CONSTRAINT_TYPE_KINEMATIC);
/* for draw, but also for detecting while pose solving */
pchan->constflag |= (PCHAN_HAS_IK | PCHAN_HAS_TARGET);
pchan->constflag |= (PCHAN_HAS_IK | PCHAN_HAS_NO_TARGET);
bKinematicConstraint *temp_con_data = static_cast<bKinematicConstraint *>(con->data);
@@ -1655,7 +1655,7 @@ static void pose_grab_with_ik_clear(Main *bmain, Object *ob)
/* clear all temporary lock flags */
pchan->ikflag &= ~(BONE_IK_NO_XDOF_TEMP | BONE_IK_NO_YDOF_TEMP | BONE_IK_NO_ZDOF_TEMP);
pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET);
pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_NO_TARGET);
/* remove all temporary IK-constraints added */
for (con = static_cast<bConstraint *>(pchan->constraints.first); con; con = next) {
@@ -1675,7 +1675,7 @@ static void pose_grab_with_ik_clear(Main *bmain, Object *ob)
}
pchan->constflag |= PCHAN_HAS_IK;
if (data->tar == nullptr || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)) {
pchan->constflag |= PCHAN_HAS_TARGET;
pchan->constflag |= PCHAN_HAS_NO_TARGET;
}
}
}

View File

@@ -389,15 +389,12 @@ typedef enum ePchan_Flag {
/* PoseChannel constflag (constraint detection) */
typedef enum ePchan_ConstFlag {
PCHAN_HAS_IK = (1 << 0),
PCHAN_HAS_CONST = (1 << 1),
/* Only used for drawing pose-mode, not stored in channel. */
PCHAN_HAS_IK = (1 << 0), /* Has IK constraint. */
PCHAN_HAS_CONST = (1 << 1), /* Has any constraint. */
/* PCHAN_HAS_ACTION = (1 << 2), */ /* UNUSED */
PCHAN_HAS_TARGET = (1 << 3),
/* Only for drawing pose-mode too. */
PCHAN_HAS_NO_TARGET = (1 << 3), /* Has (spline) IK constraint but no target is set. */
/* PCHAN_HAS_STRIDE = (1 << 4), */ /* UNUSED */
/* spline IK */
PCHAN_HAS_SPLINEIK = (1 << 5),
PCHAN_HAS_SPLINEIK = (1 << 5), /* Has Spline IK constraint. */
} ePchan_ConstFlag;
/* PoseChannel->ikflag */