0002-fpermissive-fix.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. diff --git a/thirdparty/vhacd/inc/btScalar.h b/thirdparty/vhacd/inc/btScalar.h
  2. index 487205062..52297cd78 100644
  3. --- a/thirdparty/vhacd/inc/btScalar.h
  4. +++ b/thirdparty/vhacd/inc/btScalar.h
  5. @@ -535,6 +535,29 @@ struct btTypedObject {
  6. }
  7. };
  8. +// -- GODOT start --
  9. +// Cherry-picked from Bullet 2.88 to fix GH-27926
  10. +///align a pointer to the provided alignment, upwards
  11. +template <typename T>
  12. +T *btAlignPointer(T *unalignedPtr, size_t alignment)
  13. +{
  14. + struct btConvertPointerSizeT
  15. + {
  16. + union {
  17. + T *ptr;
  18. + size_t integer;
  19. + };
  20. + };
  21. + btConvertPointerSizeT converter;
  22. +
  23. + const size_t bit_mask = ~(alignment - 1);
  24. + converter.ptr = unalignedPtr;
  25. + converter.integer += alignment - 1;
  26. + converter.integer &= bit_mask;
  27. + return converter.ptr;
  28. +}
  29. +// -- GODOT end --
  30. +
  31. // -- GODOT start --
  32. }; // namespace VHACD
  33. // -- GODOT end --
  34. diff --git a/thirdparty/vhacd/src/btAlignedAllocator.cpp b/thirdparty/vhacd/src/btAlignedAllocator.cpp
  35. index ce0e7f26f..8dee31e7e 100644
  36. --- a/thirdparty/vhacd/src/btAlignedAllocator.cpp
  37. +++ b/thirdparty/vhacd/src/btAlignedAllocator.cpp
  38. @@ -72,8 +72,12 @@ static inline void* btAlignedAllocDefault(size_t size, int32_t alignment)
  39. real = (char*)sAllocFunc(size + sizeof(void*) + (alignment - 1));
  40. if (real) {
  41. - offset = (alignment - (unsigned long)(real + sizeof(void*))) & (alignment - 1);
  42. - ret = (void*)((real + sizeof(void*)) + offset);
  43. + // -- GODOT start --
  44. + // Synced with Bullet 2.88 to fix GH-27926
  45. + //offset = (alignment - (unsigned long)(real + sizeof(void*))) & (alignment - 1);
  46. + //ret = (void*)((real + sizeof(void*)) + offset);
  47. + ret = btAlignPointer(real + sizeof(void *), alignment);
  48. + // -- GODOT end --
  49. *((void**)(ret)-1) = (void*)(real);
  50. }
  51. else {