int casterCount = 0, receiverCount = 0;
for (int i = 0; i < receivers.size(); i++) {
// convert bounding box to light's viewproj space
Geometry receiver = receivers.get(i);
BoundingVolume bv = receiver.getWorldBound();
BoundingVolume recvBox = bv.transform(viewProjMatrix, vars.bbox);
if (splitBB.intersects(recvBox)) {
//Nehon : prevent NaN and infinity values to screw the final bounding box
if (!Float.isNaN(recvBox.getCenter().x) && !Float.isInfinite(recvBox.getCenter().x)) {
receiverBB.mergeLocal(recvBox);
receiverCount++;
}
}
}
for (int i = 0; i < occluders.size(); i++) {
// convert bounding box to light's viewproj space
Geometry occluder = occluders.get(i);
BoundingVolume bv = occluder.getWorldBound();
BoundingVolume occBox = bv.transform(viewProjMatrix, vars.bbox);
boolean intersects = splitBB.intersects(occBox);
if (!intersects && occBox instanceof BoundingBox) {
BoundingBox occBB = (BoundingBox) occBox;
//Kirill 01/10/2011
// Extend the occluder further into the frustum
// This fixes shadow dissapearing issues when
// the caster itself is not in the view camera
// but its shadow is in the camera
// The number is in world units
occBB.setZExtent(occBB.getZExtent() + 50);
occBB.setCenter(occBB.getCenter().addLocal(0, 0, 25));
if (splitBB.intersects(occBB)) {
//Nehon : prevent NaN and infinity values to screw the final bounding box
if (!Float.isNaN(occBox.getCenter().x) && !Float.isInfinite(occBox.getCenter().x)) {
// To prevent extending the depth range too much
// We return the bound to its former shape
// Before adding it
occBB.setZExtent(occBB.getZExtent() - 50);
occBB.setCenter(occBB.getCenter().subtractLocal(0, 0, 25));