|
|
@ -820,6 +820,10 @@ public class PhysicsSpace { |
|
|
|
// return lrr.hitFraction;
|
|
|
|
// return lrr.hitFraction;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Performs a sweep collision test and returns the results as a list of |
|
|
|
* Performs a sweep collision test and returns the results as a list of |
|
|
|
* PhysicsSweepTestResults<br/> You have to use different Transforms for |
|
|
|
* PhysicsSweepTestResults<br/> You have to use different Transforms for |
|
|
@ -828,48 +832,47 @@ public class PhysicsSpace { |
|
|
|
* center. |
|
|
|
* center. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end) { |
|
|
|
public List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end) { |
|
|
|
List<PhysicsSweepTestResult> results = new LinkedList<PhysicsSweepTestResult>(); |
|
|
|
List results = new LinkedList(); |
|
|
|
// if (!(shape.getCShape() instanceof ConvexShape)) {
|
|
|
|
sweepTest(shape, start, end , results); |
|
|
|
// logger.log(Level.WARNING, "Trying to sweep test with incompatible mesh shape!");
|
|
|
|
return (List<PhysicsSweepTestResult>) results; |
|
|
|
// return results;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
// dynamicsWorld.convexSweepTest((ConvexShape) shape.getCShape(), Converter.convert(start, sweepTrans1), Converter.convert(end, sweepTrans2), new InternalSweepListener(results));
|
|
|
|
|
|
|
|
return results; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end, List<PhysicsSweepTestResult> results) { |
|
|
|
|
|
|
|
return sweepTest(shape, start, end, results, 0.0f); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public native void sweepTest_native(long shape, Transform from, Transform to, long physicsSpaceId, List<PhysicsSweepTestResult> results, float allowedCcdPenetration); |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Performs a sweep collision test and returns the results as a list of |
|
|
|
* Performs a sweep collision test and returns the results as a list of |
|
|
|
* PhysicsSweepTestResults<br/> You have to use different Transforms for |
|
|
|
* PhysicsSweepTestResults<br/> You have to use different Transforms for |
|
|
|
* start and end (at least distance > 0.4f). SweepTest will not see a |
|
|
|
* start and end (at least distance > allowedCcdPenetration). SweepTest will not see a |
|
|
|
* collision if it starts INSIDE an object and is moving AWAY from its |
|
|
|
* collision if it starts INSIDE an object and is moving AWAY from its |
|
|
|
* center. |
|
|
|
* center. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end, List<PhysicsSweepTestResult> results) { |
|
|
|
public List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end, List<PhysicsSweepTestResult> results, float allowedCcdPenetration ) { |
|
|
|
results.clear(); |
|
|
|
results.clear(); |
|
|
|
// if (!(shape.getCShape() instanceof ConvexShape)) {
|
|
|
|
sweepTest_native(shape.getObjectId(), start, end, physicsSpaceId, results, allowedCcdPenetration); |
|
|
|
// logger.log(Level.WARNING, "Trying to sweep test with incompatible mesh shape!");
|
|
|
|
|
|
|
|
// return results;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// dynamicsWorld.convexSweepTest((ConvexShape) shape.getCShape(), Converter.convert(start, sweepTrans1), Converter.convert(end, sweepTrans2), new InternalSweepListener(results));
|
|
|
|
|
|
|
|
return results; |
|
|
|
return results; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// private class InternalSweepListener extends CollisionWorld.ConvexResultCallback {
|
|
|
|
/* private class InternalSweepListener extends CollisionWorld.ConvexResultCallback { |
|
|
|
//
|
|
|
|
|
|
|
|
// private List<PhysicsSweepTestResult> results;
|
|
|
|
private List<PhysicsSweepTestResult> results; |
|
|
|
//
|
|
|
|
|
|
|
|
// public InternalSweepListener(List<PhysicsSweepTestResult> results) {
|
|
|
|
public InternalSweepListener(List<PhysicsSweepTestResult> results) { |
|
|
|
// this.results = results;
|
|
|
|
this.results = results; |
|
|
|
// }
|
|
|
|
} |
|
|
|
//
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
@Override |
|
|
|
// public float addSingleResult(LocalConvexResult lcr, boolean bln) {
|
|
|
|
public float addSingleResult(LocalConvexResult lcr, boolean bln) { |
|
|
|
// PhysicsCollisionObject obj = (PhysicsCollisionObject) lcr.hitCollisionObject.getUserPointer();
|
|
|
|
PhysicsCollisionObject obj = (PhysicsCollisionObject) lcr.hitCollisionObject.getUserPointer(); |
|
|
|
// results.add(new PhysicsSweepTestResult(obj, Converter.convert(lcr.hitNormalLocal), lcr.hitFraction, bln));
|
|
|
|
results.add(new PhysicsSweepTestResult(obj, Converter.convert(lcr.hitNormalLocal), lcr.hitFraction, bln)); |
|
|
|
// return lcr.hitFraction;
|
|
|
|
return lcr.hitFraction; |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* destroys the current PhysicsSpace so that a new one can be created |
|
|
|
* destroys the current PhysicsSpace so that a new one can be created |
|
|
|
*/ |
|
|
|
*/ |
|
|
|