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