mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-26 12:41:40 +00:00
reduce bounces when high speed, still not a perfect fix
This commit is contained in:
parent
f917210f8c
commit
8a677fd2c3
1 changed files with 29 additions and 29 deletions
|
|
@ -700,7 +700,7 @@ class Marble extends GameObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!done);
|
} while (!done);
|
||||||
if (this.velocity.lengthSq() < 625) {
|
// if (this.velocity.lengthSq() < 625) {
|
||||||
var gotOne = false;
|
var gotOne = false;
|
||||||
var dir = new Vector(0, 0, 0);
|
var dir = new Vector(0, 0, 0);
|
||||||
for (j in 0...contacts.length) {
|
for (j in 0...contacts.length) {
|
||||||
|
|
@ -717,20 +717,20 @@ class Marble extends GameObject {
|
||||||
var soFar = 0.0;
|
var soFar = 0.0;
|
||||||
for (k in 0...contacts.length) {
|
for (k in 0...contacts.length) {
|
||||||
var dist = this._radius - contacts[k].contactDistance;
|
var dist = this._radius - contacts[k].contactDistance;
|
||||||
var timeToSeparate = 0.1;
|
var timeToSeparate = 0.016;
|
||||||
var vel = this.velocity.sub(contacts[k].velocity);
|
var vel = this.velocity.sub(contacts[k].velocity);
|
||||||
var outVel = vel.add(dir.multiply(soFar)).dot(contacts[k].normal);
|
var outVel = vel.add(dir.multiply(soFar)).dot(contacts[k].normal);
|
||||||
if (dist > timeToSeparate * outVel) {
|
if (dist > timeToSeparate * outVel) {
|
||||||
soFar += (dist - outVel * timeToSeparate) / timeToSeparate / contacts[k].normal.dot(dir);
|
soFar += (dist - outVel * timeToSeparate) / timeToSeparate / contacts[k].normal.dot(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (soFar < -25)
|
// if (soFar < -25)
|
||||||
soFar = -25;
|
// soFar = -25;
|
||||||
if (soFar > 25)
|
// if (soFar > 25)
|
||||||
soFar = 25;
|
// soFar = 25;
|
||||||
this.velocity = this.velocity.add(dir.multiply(soFar));
|
this.velocity = this.velocity.add(dir.multiply(soFar));
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
|
|
||||||
return stoppedPaths;
|
return stoppedPaths;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue