diff --git a/src/k_kart.c b/src/k_kart.c index 8ea9d92ab..9635ad966 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -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! diff --git a/src/p_loop.c b/src/p_loop.c index 12ef3d714..b0aeb7a79 100644 --- a/src/p_loop.c +++ b/src/p_loop.c @@ -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.