related: https://github.com/jMonkeyEngine/jmonke ... issues/254
I use large MeshCollisionShapes that I save using the serialization mechanisms of bullet.
If i load it on a same OS, they work flawless.
However if I load them on a Window if generated on Linux or vice vesa, a native crash occures.
The question is, is this expected by design? Is this a mistake in my wrapping code?
Here is the code doing the actual serisialisation:
https://github.com/jMonkeyEngine/jmonke ... nShape.cpp
Code: Select all
//mesh is a btBvhTriangleMeshShape
btOptimizedBvh* bvh = mesh->getOptimizedBvh();
unsigned int ssize = bvh->calculateSerializeBufferSize();
char* buffer = (char*)btAlignedAlloc(ssize, 16);
bool success = bvh->serialize(buffer, ssize, true);
if(!success){
//error handling for java side
jclass newExc = env->FindClass("java/lang/RuntimeException");
env->ThrowNew(newExc, "Unableto Serialize, native error reported");
}
//copy data to java side
jbyteArray byteArray = env->NewByteArray(ssize);
env->SetByteArrayRegion(byteArray, 0, ssize , (jbyte*) buffer);
//free the buffer after it is copied
btAlignedFree(buffer);
Code: Select all
void* buffer = btAlignedAlloc(len, 16);
//just copy back from java side
env->GetByteArrayRegion (bytearray, 0, len, reinterpret_cast<jbyte*>(buffer));
btOptimizedBvh* bhv = btOptimizedBvh::deSerializeInPlace(buffer, len, true);
//on java side the objects are simply a long, so need to cast to actual type
btBvhTriangleMeshShape* mesh = reinterpret_cast<btBvhTriangleMeshShape*>(meshobj);
mesh->setOptimizedBvh(bhv);