@@ -122,7 +122,7 @@ public MeshCollisionShape(ByteBuffer indices, ByteBuffer vertices, boolean memor
122122 this .vertexStride = 12 ;
123123 this .triangleIndexStride = 12 ;
124124 this .memoryOptimized = memoryOptimized ;
125- this .createShape (true );
125+ this .createShape (null );
126126 }
127127
128128 private void createCollisionMesh (Mesh mesh ) {
@@ -150,7 +150,7 @@ private void createCollisionMesh(Mesh mesh) {
150150 vertices .rewind ();
151151 vertices .clear ();
152152
153- this .createShape (true );
153+ this .createShape (null );
154154 }
155155
156156 @ Override
@@ -191,25 +191,19 @@ public void read(final JmeImporter im) throws IOException {
191191 this .vertexBase = BufferUtils .createByteBuffer (capsule .readByteArray (MeshCollisionShape .VERTEX_BASE , null ));
192192
193193 byte [] nativeBvh = capsule .readByteArray (MeshCollisionShape .NATIVE_BVH , null );
194- if (nativeBvh == null ) {
195- // Either using non memory optimized BVH or old J3O file
196- memoryOptimized = false ;
197- createShape (true );
198- } else {
199- // Using memory optimized BVH, load from J3O, then assign it.
200- memoryOptimized = true ;
201- createShape (false );
202- nativeBVHBuffer = setBVH (nativeBvh , this .objectId );
203- }
194+ memoryOptimized =nativeBvh != null ;
195+ createShape (nativeBvh );
204196 }
205197
206- private void createShape (boolean buildBvt ) {
198+ private void createShape (byte bvh []) {
199+ boolean buildBvh =bvh ==null ||bvh .length ==0 ;
207200 this .meshId = NativeMeshUtil .createTriangleIndexVertexArray (this .triangleIndexBase , this .vertexBase , this .numTriangles , this .numVertices , this .vertexStride , this .triangleIndexStride );
208201 Logger .getLogger (this .getClass ().getName ()).log (Level .FINE , "Created Mesh {0}" , Long .toHexString (this .meshId ));
209- this .objectId = createShape (memoryOptimized , buildBvt , this .meshId );
202+ this .objectId = createShape (memoryOptimized , buildBvh , this .meshId );
210203 Logger .getLogger (this .getClass ().getName ()).log (Level .FINE , "Created Shape {0}" , Long .toHexString (this .objectId ));
204+ if (!buildBvh ) nativeBVHBuffer = setBVH (bvh , this .objectId );
211205 this .setScale (this .scale );
212- this .setMargin (this .margin );
206+ this .setMargin (this .margin );
213207 }
214208
215209 /**
0 commit comments