|
|
|
@ -851,8 +851,12 @@ public class BoundingSphere extends BoundingVolume { |
|
|
|
|
Vector3f p = center.add(a.add(part1.mult(u)).addLocal(part2.mult(v))); |
|
|
|
|
|
|
|
|
|
CollisionResult r = new CollisionResult(); |
|
|
|
|
r.setDistance((float)Math.sqrt(d) - radius); |
|
|
|
|
r.setContactNormal(n.normalize()); |
|
|
|
|
Vector3f normal = n.normalize(); |
|
|
|
|
float dist = -normal.dot(a); // a is center relative, so -a points to center
|
|
|
|
|
dist = dist - radius; |
|
|
|
|
|
|
|
|
|
r.setDistance(dist); |
|
|
|
|
r.setContactNormal(normal); |
|
|
|
|
r.setContactPoint(p); |
|
|
|
|
results.addCollision(r); |
|
|
|
|
return 1; |
|
|
|
@ -920,7 +924,7 @@ public class BoundingSphere extends BoundingVolume { |
|
|
|
|
Vector3f cn = nearestPt.divide(-dist); |
|
|
|
|
|
|
|
|
|
CollisionResult r = new CollisionResult(); |
|
|
|
|
r.setDistance(dist); |
|
|
|
|
r.setDistance(dist - radius); |
|
|
|
|
r.setContactNormal(cn); |
|
|
|
|
r.setContactPoint(nearestPt.add(center)); |
|
|
|
|
results.addCollision(r); |
|
|
|
@ -960,7 +964,7 @@ public class BoundingSphere extends BoundingVolume { |
|
|
|
|
Vector3f cn = nearestPt.divide(-dist); |
|
|
|
|
|
|
|
|
|
CollisionResult r = new CollisionResult(); |
|
|
|
|
r.setDistance(dist); |
|
|
|
|
r.setDistance(dist - radius); |
|
|
|
|
r.setContactNormal(cn); |
|
|
|
|
r.setContactPoint(nearestPt.add(center)); |
|
|
|
|
results.addCollision(r); |
|
|
|
|