don't trust your bundler cache

This commit is contained in:
Schluffe
2026-04-16 22:48:41 +02:00
parent 82bb948328
commit 52e4aca941
2 changed files with 11 additions and 11 deletions
+11 -8
View File
@@ -511,13 +511,18 @@ export function moveAndSlide(
let timeLeft = 1;
const position = $<Vector>("position").get(id)!.value;
for (let i = 0; i < 4; i++) {
let i = 0;
while (i++ < 4 && timeLeft > 0) {
const deltaLeft = delta * timeLeft;
const collisions = moveAndCollide(id, velocity, delta);
if (collisions.length < 1) {
position.x += velocity.x * deltaLeft;
position.y += velocity.y * deltaLeft;
break;
}
let closest = collisions[0];
let closest = collisions.pop()!;
for (const collision of collisions) {
if (collision.time < closest.time) {
closest = collision;
@@ -530,16 +535,14 @@ export function moveAndSlide(
break;
}
const scalar = Math.max(0, time - EPSILON) * delta * timeLeft;
position.x += velocity.x * scalar;
position.y += velocity.y * scalar;
const dot = getDotProduct(velocity, closest.normal);
velocity.x -= closest.normal.x * dot;
velocity.y -= closest.normal.y * dot;
const scalar = Math.max(0, time - EPSILON) * deltaLeft;
position.x += velocity.x * scalar;
position.y += velocity.y * scalar;
timeLeft *= 1 - time;
}
scale(velocity, timeLeft);
}