fix: ratio

This commit is contained in:
tresabhi committed 2024-12-12 15:19:47 -06:00
1 parent 437c5e0f57
commit 0c54905384
1 file changed
+16 -10
@@ -161,9 +161,12 @@ export function SceneProps() {
const deltaPitch = desiredPitch - lastPitch; const deltaPitch = desiredPitch - lastPitch;
const deltaYaw = desiredYaw - lastYaw; const deltaYaw = desiredYaw - lastYaw;
const deltaAngle = Math.sqrt(deltaPitch ** 2 + deltaYaw ** 2); const deltaAngle = Math.sqrt(deltaPitch ** 2 + deltaYaw ** 2);
const clampedDeltaAngle = Math.min(gunRotationSpeed * deltaT, deltaAngle); const maxPossibleRotationInTime = gunRotationSpeed * deltaT;
const clampedDeltaPitch = deltaPitch * (deltaAngle / clampedDeltaAngle); const clampedDeltaAngle = Math.min(maxPossibleRotationInTime, deltaAngle);
const clampedDeltaYaw = deltaYaw * (deltaAngle / clampedDeltaAngle); const clampedDeltaPitch =
deltaAngle === 0 ? 0 : deltaPitch * (clampedDeltaAngle / deltaAngle);
const clampedDeltaYaw =
deltaAngle === 0 ? 0 : deltaYaw * (clampedDeltaAngle / deltaAngle);
const [pitch, yaw] = applyPitchYawLimits( const [pitch, yaw] = applyPitchYawLimits(
lastPitch + clampedDeltaPitch, lastPitch + clampedDeltaPitch,
@@ -179,15 +182,18 @@ export function SceneProps() {
const turretTraversePenalty = const turretTraversePenalty =
characteristics.dispersionTurretTraversing * radToDeg(rotationSpeed); characteristics.dispersionTurretTraversing * radToDeg(rotationSpeed);
const penalty = turretTraversePenalty; const penalty = Math.sqrt(1 + turretTraversePenalty ** 2);
const dispersionMod = dispersion - characteristics.dispersion; if (penalty === 1) {
const dispersionModDischarged = const dispersionMod = dispersion - characteristics.dispersion;
dispersionMod * Math.exp(-deltaT / characteristics.aimTime) - const dispersionModDischarged =
dispersionMod; dispersionMod * Math.exp(-deltaT / characteristics.aimTime) -
dispersionMod;
dispersion += penalty - lastPenalty + dispersionModDischarged; dispersion += dispersionModDischarged;
lastPenalty = penalty; } else {
dispersion = characteristics.dispersion * penalty;
}
modelTransformEvent.emit({ pitch, yaw }); modelTransformEvent.emit({ pitch, yaw });
lastPitch = pitch; lastPitch = pitch;