Loops: try to position player so hitbox edge touches loop radius

Large enough momentum will still position the player
beyond the loop radius initially. This is intentional so
that there is no jerk when entering the loop. Without
a more sophisticated algorithm to revolve asymmetrically,
this is the best I can do. The player is guaranteed to
exit at the correct position, though.
This commit is contained in:
James R 2023-10-13 21:20:52 -07:00
parent 2c1cce17b2
commit c87ffeba29
2 changed files with 16 additions and 3 deletions

View file

@ -7847,6 +7847,15 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
player->mo->sprzoff += player->cameraOffset;
}
if (player->loop.radius)
{
// Offset sprite Z position so wheels touch top of
// hitbox when rotated 180 degrees.
// TODO: this should be generalized for pitch/roll
angle_t pitch = FixedAngle(player->loop.revolution * 360) / 2;
player->mo->sprzoff += FixedMul(player->mo->height, FSIN(pitch));
}
K_UpdateOffroad(player);
K_UpdateDraft(player);
K_UpdateEngineSounds(player); // Thanks, VAda!

View file

@ -96,7 +96,7 @@ boolean P_PlayerOrbit(player_t *player)
angle_t pitch;
angle_t pitch_normal;
fixed_t xy, z;
fixed_t r, xy, z;
fixed_t xs, ys;
fixed_t step, th, left;
@ -124,9 +124,13 @@ boolean P_PlayerOrbit(player_t *player)
pitch = get_pitch(s->revolution);
pitch_normal = get_pitch(normal_revolution(s) / 2);
r = abs(s->radius) -
FixedMul(player->mo->radius, abs(FSIN(pitch)));
xy = FixedMul(abs(s->radius), FSIN(pitch));
z = FixedMul(abs(s->radius), -(FCOS(pitch)));
xy = FixedMul(r, FSIN(pitch));
z = FixedMul(abs(s->radius), -(FCOS(pitch))) -
FixedMul(player->mo->height, FSIN(pitch / 2));
// XY shift is transformed on wave scale; less movement
// at start and end of rotation, more halfway.