Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
interpolation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dankmeme01 committed Sep 21, 2023
1 parent 469b35b commit 052f091
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# v0.1.3

* Improved interpolation for greater smoothness
* Blocked connecting to the server with no account
* Made it harder for data corruption to cause a crash
* Fixed some grammatical errors
Expand Down
8 changes: 6 additions & 2 deletions src/ppa/ppa_interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void InterpolationPPAEngine::updateSpecificPlayer(
rotDelta.y = 0;
}

bool hasDashDelta = false;
if (data.isDashing && (data.gameMode == IconGameMode::CUBE || data.gameMode == IconGameMode::BALL)) {
// dash = 720 degrees per second
float dashDelta = DASH_DEGREES_PER_SECOND * targetUpdateDelay;
Expand All @@ -75,6 +76,7 @@ void InterpolationPPAEngine::updateSpecificPlayer(
}
rotDelta.x = dashDelta;
rotDelta.y = dashDelta;
hasDashDelta = true;
}

// disable Y interpolation for spider, so it doesn't appear mid-air
Expand All @@ -92,11 +94,13 @@ void InterpolationPPAEngine::updateSpecificPlayer(
auto wholeRotDeltaX = iRotX - lastRot.x;
auto wholeRotDeltaY = iRotY - lastRot.y;

if (wholePosDelta.x <= posDelta.x) {
// packet loss can cause extrapolation, remove it.
// this isn't exactly bad normally, but when you die, you go through blocks without these conditions.
if (abs(wholePosDelta.x) <= abs(posDelta.x)) {
player->setPosition(iPos);
}

if (wholeRotDeltaX <= rotDelta.x || wholeRotDeltaY <= rotDelta.y) {
if (hasDashDelta || abs(wholeRotDeltaX) <= abs(rotDelta.x) || abs(wholeRotDeltaY) <= abs(rotDelta.y)) {
player->setRotationX(iRotX);
player->setRotationY(iRotY);
}
Expand Down

0 comments on commit 052f091

Please sign in to comment.