// Path: src/com/htssoft/sploosh/ThreadVars.java
// public class ThreadVars {
// 	public Vector3f temp0 = new Vector3f();
// 	public Vector3f temp1 = new Vector3f();
// 	public Vector3f temp2 = new Vector3f();
// 	
// 	public Vector3f[] vec = new Vector3f[6];
// 	{
// 		for (int i = 0; i < vec.length; i++){
// 			vec[i] = new Vector3f();
// 		}
// 	}
// 	
// 	public Matrix3f mat = new Matrix3f();
// }


import com.htssoft.sploosh.ThreadVars;
import com.jme3.bounding.BoundingBox;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
		bounds.setMinMax(min, max);
		extent.set(max).subtractLocal(min);
		this.defaultValue = defaultValue;
		
		nCells[0] = (int) (FastMath.ceil(extent.x * cellsPerUnit));
		nCells[1] = (int) (FastMath.ceil(extent.y * cellsPerUnit));
		nCells[2] = (int) (FastMath.ceil(extent.z * cellsPerUnit));
		
		values = (T[]) new Object[nCells[0] * nCells[1] * nCells[2]];
	}
	
	public void insert(T value, Vector3f position, ThreadVars vars){
		if (!bounds.contains(position)){
			throw new IllegalArgumentException("Tried to add " + position + " to grid with bounds " + bounds);
		}

		values[indexOfPosition(position, vars)] = value;
	}
	
	public T get(Vector3f position, ThreadVars vars){
		int index = indexOfPosition(position, vars);
		
		T retval = values[index];
		if (retval == null){
			return defaultValue;
		}
		
		return retval;
	}
	
// Path: src/com/htssoft/sploosh/ThreadVars.java
// public class ThreadVars {
// 	public Vector3f temp0 = new Vector3f();
// 	public Vector3f temp1 = new Vector3f();
// 	public Vector3f temp2 = new Vector3f();
// 	
// 	public Vector3f[] vec = new Vector3f[6];
// 	{
// 		for (int i = 0; i < vec.length; i++){
// 			vec[i] = new Vector3f();
// 		}
// 	}
// 	
// 	public Matrix3f mat = new Matrix3f();
// }


// Path: src/com/htssoft/sploosh/space/UniformGrid.java
import com.htssoft.sploosh.ThreadVars;
import com.jme3.bounding.BoundingBox;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;

		bounds.setMinMax(min, max);
		extent.set(max).subtractLocal(min);
		this.defaultValue = defaultValue;
		
		nCells[0] = (int) (FastMath.ceil(extent.x * cellsPerUnit));
		nCells[1] = (int) (FastMath.ceil(extent.y * cellsPerUnit));
		nCells[2] = (int) (FastMath.ceil(extent.z * cellsPerUnit));
		
		values = (T[]) new Object[nCells[0] * nCells[1] * nCells[2]];
	}
	
	public void insert(T value, Vector3f position, ThreadVars vars){
		if (!bounds.contains(position)){
			throw new IllegalArgumentException("Tried to add " + position + " to grid with bounds " + bounds);
		}

		values[indexOfPosition(position, vars)] = value;
	}
	
	public T get(Vector3f position, ThreadVars vars){
		int index = indexOfPosition(position, vars);
		
		T retval = values[index];
		if (retval == null){
			return defaultValue;
		}
		
		return retval;
	}
	
	protected int indexOfPosition(Vector3f position, ThreadVars vars){