@@ -122,7 +122,7 @@ public MeshCollisionShape(ByteBuffer indices, ByteBuffer vertices, boolean memor
122
122
this .vertexStride = 12 ;
123
123
this .triangleIndexStride = 12 ;
124
124
this .memoryOptimized = memoryOptimized ;
125
- this .createShape (true );
125
+ this .createShape (null );
126
126
}
127
127
128
128
private void createCollisionMesh (Mesh mesh ) {
@@ -150,7 +150,7 @@ private void createCollisionMesh(Mesh mesh) {
150
150
vertices .rewind ();
151
151
vertices .clear ();
152
152
153
- this .createShape (true );
153
+ this .createShape (null );
154
154
}
155
155
156
156
@ Override
@@ -191,25 +191,19 @@ public void read(final JmeImporter im) throws IOException {
191
191
this .vertexBase = BufferUtils .createByteBuffer (capsule .readByteArray (MeshCollisionShape .VERTEX_BASE , null ));
192
192
193
193
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 );
204
196
}
205
197
206
- private void createShape (boolean buildBvt ) {
198
+ private void createShape (byte bvh []) {
199
+ boolean buildBvh =bvh ==null ||bvh .length ==0 ;
207
200
this .meshId = NativeMeshUtil .createTriangleIndexVertexArray (this .triangleIndexBase , this .vertexBase , this .numTriangles , this .numVertices , this .vertexStride , this .triangleIndexStride );
208
201
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 );
210
203
Logger .getLogger (this .getClass ().getName ()).log (Level .FINE , "Created Shape {0}" , Long .toHexString (this .objectId ));
204
+ if (!buildBvh ) nativeBVHBuffer = setBVH (bvh , this .objectId );
211
205
this .setScale (this .scale );
212
- this .setMargin (this .margin );
206
+ this .setMargin (this .margin );
213
207
}
214
208
215
209
/**
0 commit comments