mirror of
https://github.com/liabru/matter-js.git
synced 2025-03-10 00:06:42 -04:00
Add permeable objects
This commit is contained in:
parent
5ff218234a
commit
1573359354
2 changed files with 15 additions and 2 deletions
|
@ -53,6 +53,7 @@ var Axes = require('../geometry/Axes');
|
||||||
angularSpeed: 0,
|
angularSpeed: 0,
|
||||||
velocity: { x: 0, y: 0 },
|
velocity: { x: 0, y: 0 },
|
||||||
angularVelocity: 0,
|
angularVelocity: 0,
|
||||||
|
isPermeable: false,
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
isSleeping: false,
|
isSleeping: false,
|
||||||
motion: 0,
|
motion: 0,
|
||||||
|
|
|
@ -78,6 +78,9 @@ var Bounds = require('../geometry/Bounds');
|
||||||
bodyB = collision.parentB;
|
bodyB = collision.parentB;
|
||||||
normal = collision.normal;
|
normal = collision.normal;
|
||||||
|
|
||||||
|
if (bodyA.isPermeable || bodyB.isPermeable)
|
||||||
|
continue;
|
||||||
|
|
||||||
// get current separation between body edges involved in collision
|
// get current separation between body edges involved in collision
|
||||||
bodyBtoA = Vector.sub(Vector.add(bodyB.positionImpulse, bodyB.position, tempA),
|
bodyBtoA = Vector.sub(Vector.add(bodyB.positionImpulse, bodyB.position, tempA),
|
||||||
Vector.add(bodyA.positionImpulse,
|
Vector.add(bodyA.positionImpulse,
|
||||||
|
@ -98,6 +101,9 @@ var Bounds = require('../geometry/Bounds');
|
||||||
normal = collision.normal;
|
normal = collision.normal;
|
||||||
positionImpulse = (pair.separation - pair.slop) * timeScale;
|
positionImpulse = (pair.separation - pair.slop) * timeScale;
|
||||||
|
|
||||||
|
if (bodyA.isPermeable || bodyB.isPermeable)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (bodyA.isStatic || bodyB.isStatic)
|
if (bodyA.isStatic || bodyB.isStatic)
|
||||||
positionImpulse *= 2;
|
positionImpulse *= 2;
|
||||||
|
|
||||||
|
@ -190,6 +196,9 @@ var Bounds = require('../geometry/Bounds');
|
||||||
normal = collision.normal;
|
normal = collision.normal;
|
||||||
tangent = collision.tangent;
|
tangent = collision.tangent;
|
||||||
|
|
||||||
|
if (bodyA.isPermeable || bodyB.isPermeable)
|
||||||
|
continue;
|
||||||
|
|
||||||
// resolve each contact
|
// resolve each contact
|
||||||
for (j = 0; j < contacts.length; j++) {
|
for (j = 0; j < contacts.length; j++) {
|
||||||
contact = contacts[j];
|
contact = contacts[j];
|
||||||
|
@ -250,6 +259,9 @@ var Bounds = require('../geometry/Bounds');
|
||||||
contacts = pair.activeContacts,
|
contacts = pair.activeContacts,
|
||||||
contactShare = 1 / contacts.length;
|
contactShare = 1 / contacts.length;
|
||||||
|
|
||||||
|
if (bodyA.isPermeable || bodyB.isPermeable)
|
||||||
|
continue;
|
||||||
|
|
||||||
// update body velocities
|
// update body velocities
|
||||||
bodyA.velocity.x = bodyA.position.x - bodyA.positionPrev.x;
|
bodyA.velocity.x = bodyA.position.x - bodyA.positionPrev.x;
|
||||||
bodyA.velocity.y = bodyA.position.y - bodyA.positionPrev.y;
|
bodyA.velocity.y = bodyA.position.y - bodyA.positionPrev.y;
|
||||||
|
|
Loading…
Add table
Reference in a new issue