Handle multiple edge collision in a buggy way
This commit is contained in:
@@ -790,7 +790,7 @@ const Move = (() => {
|
|||||||
let posP;
|
let posP;
|
||||||
const contact = contacts[0];
|
const contact = contacts[0];
|
||||||
|
|
||||||
if (contact.corner) {
|
if (contacts.length == 1 && contact.corner) {
|
||||||
contact.position = cornerContactPosition(p.x, p.y, px, py, contact.corner, s.radius);
|
contact.position = cornerContactPosition(p.x, p.y, px, py, contact.corner, s.radius);
|
||||||
contact.position.x = +contact.position.x.toPrecision(13);
|
contact.position.x = +contact.position.x.toPrecision(13);
|
||||||
contact.position.y = +contact.position.y.toPrecision(13);
|
contact.position.y = +contact.position.y.toPrecision(13);
|
||||||
@@ -804,14 +804,12 @@ const Move = (() => {
|
|||||||
const tangentVect = { x: normalVect.y, y: -normalVect.x };
|
const tangentVect = { x: normalVect.y, y: -normalVect.x };
|
||||||
// drawLine(contact.position.x, contact.position.y, contact.position.x + tangentVect.x, contact.position.y + tangentVect.y, "green");
|
// drawLine(contact.position.x, contact.position.y, contact.position.x + tangentVect.x, contact.position.y + tangentVect.y, "green");
|
||||||
contact.velocity = bounceVector(v, tangentVect.x, tangentVect.y);
|
contact.velocity = bounceVector(v, tangentVect.x, tangentVect.y);
|
||||||
|
|
||||||
|
|
||||||
// drawLine(contact.position.x, contact.position.y, contact.position.x + contact.velocity.x, contact.position.y + contact.velocity.y, "blue");
|
// drawLine(contact.position.x, contact.position.y, contact.position.x + contact.velocity.x, contact.position.y + contact.velocity.y, "blue");
|
||||||
|
|
||||||
// Velocity[entity_id] = { x: 0, y: 0 };
|
// Velocity[entity_id] = { x: 0, y: 0 };
|
||||||
Velocity[entity_id] = contact.velocity;
|
Velocity[entity_id] = contact.velocity;
|
||||||
Position[entity_id] = cornerContactPosition(p.x, p.y, px, py, contact.corner, s.radius);
|
Position[entity_id] = cornerContactPosition(p.x, p.y, px, py, contact.corner, s.radius);
|
||||||
} else if (contact.edge) {
|
} else if (contacts.length == 1 && contact.edge) {
|
||||||
// if (isLandable(contact.edge) && s.gearDown) s.isLanded = true;
|
// if (isLandable(contact.edge) && s.gearDown) s.isLanded = true;
|
||||||
const rise = contact.edge.yb-contact.edge.ya;
|
const rise = contact.edge.yb-contact.edge.ya;
|
||||||
const run = contact.edge.xb-contact.edge.xa;
|
const run = contact.edge.xb-contact.edge.xa;
|
||||||
@@ -906,6 +904,10 @@ const Move = (() => {
|
|||||||
// drawCircle(newP.x, newP.y, "black");
|
// drawCircle(newP.x, newP.y, "black");
|
||||||
|
|
||||||
Position[entity_id] = newP;
|
Position[entity_id] = newP;
|
||||||
|
} else if (contacts.every(c => c.edge)) {
|
||||||
|
// all edges
|
||||||
|
// doing nothing seems to kind of work (but it's buggy), ideally we
|
||||||
|
// should add the vectors of all the contacts together
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Velocity[entity_id] = { x: v.x, y: v.y };
|
Velocity[entity_id] = { x: v.x, y: v.y };
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
Reference in New Issue
Block a user