Skip to content

Commit

Permalink
getContacts() Returns Each Contact Only Once
Browse files Browse the repository at this point in the history
Made sure that getContacts() doesn't return the same object multiple times.
  • Loading branch information
zicklag committed Jan 21, 2019
1 parent bc3de52 commit 1838b30
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Sources/armory/trait/physics/bullet/PhysicsWorld.hx
Expand Up @@ -188,18 +188,19 @@ class PhysicsWorld extends Trait {
var res:Array<RigidBody> = [];
for (i in 0...contacts.length) {
var c = contacts[i];
var rb = null;

#if js

if (c.a == untyped body.body.userIndex) res.push(rbMap.get(c.b));
else if (c.b == untyped body.body.userIndex) res.push(rbMap.get(c.a));

if (c.a == untyped body.body.userIndex) rb = rbMap.get(c.b);
else if (c.b == untyped body.body.userIndex) rb = rbMap.get(c.a);

#else

var ob:bullet.Bt.CollisionObject = body.body;
if (c.a == ob.getUserIndex()) res.push(rbMap.get(c.b));
else if (c.b == ob.getUserIndex()) res.push(rbMap.get(c.a));

if (c.a == ob.getUserIndex()) rb = rbMap.get(c.b);
else if (c.b == ob.getUserIndex()) rb = rbMap.get(c.a);
#end

if (rb != null && res.indexOf(rb) == -1) res.push(rb);
}
return res;
}
Expand Down

0 comments on commit 1838b30

Please sign in to comment.