29inline constexpr Vec3 UP{0.0f, 0.0f, 1.0f};
30inline constexpr float PI = std::numbers::pi_v<float>;
35 t = std::clamp(t, 0.0f, 1.0f);
36 return t * t * (3.0f - 2.0f * t);
41 return std::hypot(a.
x - b.
x, a.
y - b.
y);
61 const Vec3 toTarget = target - root;
63 const Vec3 direction =
64 distance > 1e-5f ? toTarget * (1.0f / distance) :
Vec3{0.0f, 0.0f, -1.0f};
65 const float minimum = std::abs(upper - lower) + 1e-3f;
66 const float maximum = (upper + lower) * 0.9995f;
70 (upper * upper - lower * lower + distance * distance) / (2.0f * distance);
71 const float height = std::sqrt(std::max(upper * upper - along * along, 0.0f));
77 direction, std::abs(direction.
z) < 0.9f ?
UP :
Vec3{1.0f, 0.0f, 0.0f});
82 bend = bend * (1.0f / bendLength);
84 return {root + direction * along + bend * height, root + direction * distance,
95 float toeLength,
float reach,
float maxAngle)
98 const Vec3 toe = ankle + footForward * toeLength;
99 const auto at = [&](
float angle)
101 return toe - footForward * (toeLength * std::cos(angle)) +
102 UP * (toeLength * std::sin(angle));
105 float high = maxAngle;
111 for (
int step = 0; step < 8; ++step)
113 const float middle = (low + high) * 0.5f;
195 const Vec3 initialPosition =
197 foot.
liftOff = initialPosition;
198 foot.
planted = initialPosition;
222 if (
const bool drifted =
244 const float share = std::clamp(input.
legPhase /
TWO_PI, 0.0f, 1.0f);
245 const bool stance = share < input.
duty;
248 if (
const Vec3 ideal =
261 (share - input.
duty) / std::max(1.0f - input.
duty, 1e-3f);
349 if (speed < bands.idle)
return IDLE;
350 if (speed < bands.walk)
return WALK;
351 if (speed < bands.jog)
return JOG;
352 if (speed < bands.run)
return RUN;
390 if (std::abs(input.
turnRate) >= bands.turnRate && input.
speed >= bands.idle &&
391 input.
speed < bands.turnSpeed)
400 constexpr float WALK_DUTY = 0.62f;
401 constexpr float JOG_DUTY = 0.4f;
402 constexpr float SPRINT_DUTY = 0.28f;
403 if (speed <= 1.5f)
return WALK_DUTY;
405 return WALK_DUTY + (JOG_DUTY - WALK_DUTY) * (speed - 1.5f) / 2.5f;
406 return std::max(SPRINT_DUTY,
407 JOG_DUTY + (SPRINT_DUTY - JOG_DUTY) * (speed - 4.0f) / 3.5f);
426 return {0.55f, 0.05f, 0.7f};
428 return {0.4f, 0.32f, 0.6f};
431 return {0.38f, 0.08f, 0.22f};
454 if (seconds < 0.0f || seconds >= timing.
total())
return contact;
456 const Vec3 finish = contact + direction * swing.
forward +
463 if (
const float through =
469 const float eased = 1.0f - (1.0f - through) * (1.0f - through);
Definition match_player_rig.h:26
Action
Definition match_player_rig.h:275
TwoBone solveTwoBone(Vec3 root, Vec3 target, float upper, float lower, Vec3 pole)
Definition match_player_rig.h:58
Vec3 kickAnkle(Event event, float seconds, Vec3 contact, Vec3 direction, Vec3 across, const KickTiming &timing, float &weight)
Definition match_player_rig.h:450
Action locomotionFor(float speed, const GaitBands &bands={})
Definition match_player_rig.h:346
Vec3 stanceSpot(const StrideInput &input, float share)
Definition match_player_rig.h:175
Action selectAction(const ActionInput &input, const GaitBands &bands={})
Definition match_player_rig.h:361
constexpr float TWO_PI
Definition match_player_rig.h:31
constexpr float PI
Definition match_player_rig.h:30
Event
Definition match_player_rig.h:298
float smoothStep(float t)
Definition match_player_rig.h:33
float dutyFactor(float speed)
Definition match_player_rig.h:397
float rollOntoToes(Vec3 &ankle, Vec3 hip, Vec3 footForward, float toeLength, float reach, float maxAngle)
Definition match_player_rig.h:94
Swing followThroughFor(Event event)
Definition match_player_rig.h:420
Mood
Definition match_player_rig.h:311
constexpr Vec3 UP
Definition match_player_rig.h:29
float flatDistance(Vec3 a, Vec3 b)
Definition match_player_rig.h:39
Vec3 stepFoot(FootState &foot, const StrideInput &input)
Definition match_player_rig.h:188
constexpr Vec3 lerp(Vec3 a, Vec3 b, float t)
Definition match_render_math.h:73
constexpr float dot(Vec3 a, Vec3 b)
Definition match_render_math.h:59
Vec3 normalize(Vec3 a)
Definition match_render_math.h:68
float length(Vec3 a)
Definition match_render_math.h:67
constexpr Vec3 cross(Vec3 a, Vec3 b)
Definition match_render_math.h:63
std::int64_t minimum
Definition runtime_editor_validation.cpp:46
std::int64_t maximum
Definition runtime_editor_validation.cpp:47
Definition match_player_rig.h:319
float run
Definition match_player_rig.h:323
float turnSpeed
Definition match_player_rig.h:326
float idle
Definition match_player_rig.h:320
float turnRate
Definition match_player_rig.h:325
float walk
Definition match_player_rig.h:321
float jog
Definition match_player_rig.h:322
Definition match_player_rig.h:437
float contactHold
Definition match_player_rig.h:438
float total() const
Definition match_player_rig.h:441
float followThrough
Definition match_player_rig.h:439
float recover
Definition match_player_rig.h:440
Definition match_player_rig.h:414
float up
Definition match_player_rig.h:417
float across
Definition match_player_rig.h:416
float forward
Definition match_player_rig.h:415
Definition match_player_rig.h:47
Vec3 end
Definition match_player_rig.h:49
Vec3 middle
Definition match_player_rig.h:48
bool reached
Definition match_player_rig.h:50
Definition match_render_math.h:32
float x
Definition match_render_math.h:33
float z
Definition match_render_math.h:35
float y
Definition match_render_math.h:34