public void separation(Pair<Geometry> pair) {
}
};
//create the detector with handler
BroadphaseCollisionDetection sweep = new SAP2();
sweep.addHandler(handler);
//add both boxes
sweep.add(box1);
sweep.add(box2);
// expect an overlap
sweep.run();
assertTrue( sweep.getOverlappingPairs().contains(new Pair<Geometry>(box1,box2)));
// remove box2
sweep.remove(box2);
// expect no overlaps
sweep.run();
assertTrue( sweep.getOverlappingPairs().size() == 0);
// add box2 again
sweep.add(box2);
// expect an overlap
sweep.run();
assertTrue( sweep.getOverlappingPairs().contains(new Pair<Geometry>(box1,box2)));
//move box2 1.0 along z axis
b2.setPosition(0,0,1.0);
// expect an overlap
sweep.run();
assertTrue( sweep.getOverlappingPairs().contains(new Pair<Geometry>(box1,box2)));
// move box2 by 1.0 + twice the envelope + epsilon
// this will make bounding boxes only just separated
b2.setPosition(0,0,1.0+2*env+epsilon);
// expect no overlap
sweep.run();
assertTrue( !sweep.getOverlappingPairs().contains(new Pair<Geometry>(box1,box2)) );
// move box2 by 1 + 2 env - epsilon
// such that boxes will only just overlap by epsilon
b2.setPosition(new Vector3(0,0,1.0+2*env-epsilon));
// expect an overlap
sweep.run();
assertTrue( sweep.getOverlappingPairs().contains(new Pair<Geometry>(box1,box2)));
}