Merge pull request #663 from NemesisMate/patch-18

Fixed IllegalArgumentException when removing a LodControl from a spatial
fix-456
empirephoenix 8 years ago committed by GitHub
commit 2a09771bc8
  1. 20
      jme3-core/src/main/java/com/jme3/scene/control/LodControl.java

@ -121,17 +121,23 @@ public class LodControl extends AbstractControl implements Cloneable, JmeCloneab
@Override
public void setSpatial(Spatial spatial) {
if (!(spatial instanceof Geometry)) {
if (spatial != null && !(spatial instanceof Geometry)) {
throw new IllegalArgumentException("LodControl can only be attached to Geometry!");
}
super.setSpatial(spatial);
Geometry geom = (Geometry) spatial;
Mesh mesh = geom.getMesh();
numLevels = mesh.getNumLodLevels();
numTris = new int[numLevels];
for (int i = numLevels - 1; i >= 0; i--) {
numTris[i] = mesh.getTriangleCount(i);
if(spatial != null) {
Geometry geom = (Geometry) spatial;
Mesh mesh = geom.getMesh();
numLevels = mesh.getNumLodLevels();
numTris = new int[numLevels];
for (int i = numLevels - 1; i >= 0; i--) {
numTris[i] = mesh.getTriangleCount(i);
}
} else {
numLevels = 0;
numTris = null;
}
}

Loading…
Cancel
Save