don't trust your bundler cache
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -65,9 +65,6 @@ process((id, delta) => {
|
||||
scale(velocity, speed());
|
||||
moveAndSlide(id, velocity, delta);
|
||||
|
||||
position.x += velocity.x * delta;
|
||||
position.y += velocity.y * delta;
|
||||
|
||||
velocity.x = 0;
|
||||
velocity.y = 0;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user