Skip to content

Commit

Permalink
Merge pull request #1105 from katharostech/issue_get-contacts-node-fix
Browse files Browse the repository at this point in the history
Get Contacts Node Returns Each Contact Once
  • Loading branch information
luboslenco committed Jan 22, 2019
2 parents a7cb62f + 1838b30 commit 64bc7da
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 64bc7da

Please sign in to comment.