From c7606ccff2527acc1b6495a87bc742646c030e07 Mon Sep 17 00:00:00 2001 From: Nehon Date: Sun, 12 Jul 2015 20:43:54 +0200 Subject: [PATCH] Fixed issue https://github.com/jMonkeyEngine/jmonkeyengine/issues/291 --- .../src/main/java/com/jme3/collision/bih/BIHTree.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/collision/bih/BIHTree.java b/jme3-core/src/main/java/com/jme3/collision/bih/BIHTree.java index 38a633e96..5db94b409 100644 --- a/jme3-core/src/main/java/com/jme3/collision/bih/BIHTree.java +++ b/jme3-core/src/main/java/com/jme3/collision/bih/BIHTree.java @@ -48,6 +48,7 @@ import com.jme3.math.Vector3f; import com.jme3.scene.CollisionData; import com.jme3.scene.Mesh; import com.jme3.scene.Mesh.Mode; +import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.mesh.IndexBuffer; import com.jme3.scene.mesh.VirtualIndexBuffer; @@ -114,8 +115,13 @@ public class BIHTree implements CollisionData { bihSwapTmp = new float[9]; - FloatBuffer vb = (FloatBuffer) mesh.getBuffer(Type.Position).getData(); + VertexBuffer vBuffer = mesh.getBuffer(Type.Position); + if(vBuffer == null){ + throw new IllegalArgumentException("A mesh should at least contain a Position buffer"); + } IndexBuffer ib = mesh.getIndexBuffer(); + FloatBuffer vb = (FloatBuffer) vBuffer.getData(); + if (ib == null) { ib = new VirtualIndexBuffer(mesh.getVertexCount(), mesh.getMode()); } else if (mesh.getMode() != Mode.Triangles) {