DanielChappuis / reactphysics3d

Open source C++ physics engine library in 3D
http://www.reactphysics3d.com
zlib License
1.54k stars 224 forks source link

HeapAllocator alignment #314

Closed ZeunO8 closed 8 months ago

ZeunO8 commented 1 year ago

In DynamicAABBTree.cpp on Line 59 the HeapAllocator is used to allocate some memory.

On android memory must be aligned to 4/8 bytes to prevent SIGBUS: Illegal Alignment. Currently I'm getting a memory address like 0xd0309f4a which is clearly not aligned to 4/8 bytes.

Can you make changes to the HeapAllocator such that it returns aligned pointers? That way I can get my Android port running.

ZeunO8 commented 1 year ago

That or how do I override the HeapAllocator with my own Allocator which provides pointer alignment?

ZeunO8 commented 1 year ago

I forked the respository and made quite a few edits to the code ro make sure mBaseAllocator is the only allocator used. It's probably not worthy of a PR. It would still be good to get HeapAllocator, PoolAllocator and SingleFrameAllocator returning aligned pointers so that your engine works on Android

DanielChappuis commented 1 year ago

Duplicate of #239

DanielChappuis commented 1 year ago

This is already fixed in the "develop" branch. This will be part of the next release of the library. All memory allocations will be 16 bytes aligned.

DanielChappuis commented 8 months ago

This is now fixed in version v0.10.0 of the library. Thanks a lot for reporting the issue.