box2d: upgrade to 3.1.0

Downloaded https://github.com/erincatto/box2d/archive/refs/tags/v3.1.0.tar.gz

Change-Id: I21bf8d3e26cf2601607f586a3bc1010a32b78a06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204848
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli
2026-05-06 13:50:34 +02:00
parent f0135f60fb
commit aaf7a2286a
6 changed files with 19 additions and 51 deletions
+1 -1
View File
@@ -12194,7 +12194,7 @@ dnl Check for system box2d
dnl ===================================================================
AC_MSG_CHECKING([which box2d to use])
BOX2D_MAJOR=3
BOX2D_MINOR=0
BOX2D_MINOR=1
if test "$with_system_box2d" = "yes"; then
AC_MSG_RESULT([external])
SYSTEM_BOX2D=TRUE
+2 -2
View File
@@ -19,8 +19,8 @@ BOOST_TARBALL := boost_1_90_0.tar.xz
# three static lines
# so that git cherry-pick
# will not run into conflicts
BOX2D_SHA256SUM := 64ad759006cd2377c99367f51fb36942b57f0e9ad690ed41548dd620e6f6c8b1
BOX2D_TARBALL := box2d-3.0.0.tar.gz
BOX2D_SHA256SUM := 7fac19801485efb31ee3745b2284d9d4601f9e8138a3383a7b0df6d788ea5785
BOX2D_TARBALL := box2d-3.1.0.tar.gz
# three static lines
# so that git cherry-pick
# will not run into conflicts
+2 -3
View File
@@ -29,9 +29,8 @@ endif
$(eval $(call gb_StaticLibrary_add_generated_cobjects,box2d,\
UnpackedTarball/box2d/src/aabb \
UnpackedTarball/box2d/src/allocate \
UnpackedTarball/box2d/src/arena_allocator \
UnpackedTarball/box2d/src/body \
UnpackedTarball/box2d/src/block_array \
UnpackedTarball/box2d/src/dynamic_tree \
UnpackedTarball/box2d/src/island \
UnpackedTarball/box2d/src/motor_joint \
@@ -59,7 +58,7 @@ $(eval $(call gb_StaticLibrary_add_generated_cobjects,box2d,\
UnpackedTarball/box2d/src/id_pool \
UnpackedTarball/box2d/src/math_functions \
UnpackedTarball/box2d/src/revolute_joint \
UnpackedTarball/box2d/src/stack_allocator \
UnpackedTarball/box2d/src/sensor \
UnpackedTarball/box2d/src/solver \
UnpackedTarball/box2d/src/solver_set \
UnpackedTarball/box2d/src/weld_joint \
-4
View File
@@ -11,8 +11,4 @@ $(eval $(call gb_UnpackedTarball_UnpackedTarball,box2d))
$(eval $(call gb_UnpackedTarball_set_tarball,box2d,$(BOX2D_TARBALL)))
$(eval $(call gb_UnpackedTarball_add_patches,box2d, \
external/box2d/android.patch \
))
# vim: set noet sw=4 ts=4:
-41
View File
@@ -1,41 +0,0 @@
--- box2d/src/core.h 2026-05-05 16:51:31.330228008 +0200
+++ box2d/src/core.h 2026-05-05 16:53:35.525696798 +0200
@@ -40,14 +40,12 @@
#endif
// Define CPU
-#if defined( __x86_64__ ) || defined( _M_X64 )
- #define B2_CPU_X64
-#elif defined( __aarch64__ ) || defined( _M_ARM64 )
+#if defined( __aarch64__ ) || defined( _M_ARM64 )
#define B2_CPU_ARM
#elif defined( __EMSCRIPTEN__ )
#define B2_CPU_WASM
#else
- #error Unsupported CPU
+ #define B2_CPU_X64
#endif
// Define compiler
--- box2d/src/allocate.c 2026-05-05 17:08:39.096202016 +0200
+++ box2d/src/allocate.c 2026-05-05 17:09:17.879976210 +0200
@@ -66,9 +66,16 @@
}
#ifdef B2_PLATFORM_WINDOWS
- void* ptr = _aligned_malloc( size32, B2_ALIGNMENT );
+ void* ptr = _aligned_malloc( size32, B2_ALIGNMENT );
+#elif defined( B2_PLATFORM_ANDROID )
+ void* ptr = NULL;
+ if ( posix_memalign( &ptr, B2_ALIGNMENT, size32 ) != 0 )
+ {
+ // allocation failed, exit the application
+ exit( EXIT_FAILURE );
+ }
#else
- void* ptr = aligned_alloc( B2_ALIGNMENT, size32 );
+ void* ptr = aligned_alloc( B2_ALIGNMENT, size32 );
#endif
b2TracyCAlloc( ptr, size );
+14
View File
@@ -105,8 +105,13 @@ void addTriangleVectorToBody(const basegfx::triangulator::B2DTriangleVector& rTr
b2Hull aHull = b2ComputeHull(aTriangleVertices, 3);
b2ShapeDef aShapeDef = b2DefaultShapeDef();
aShapeDef.density = fDefaultStaticDensity;
#if BOX2D_CHECK_VERSION(3, 1)
aShapeDef.material.friction = fDefaultStaticFriction;
aShapeDef.material.restitution = fDefaultStaticBodyBounciness;
#else
aShapeDef.friction = fDefaultStaticFriction;
aShapeDef.restitution = fDefaultStaticBodyBounciness;
#endif
b2Polygon aPolygonShape = b2MakePolygon(&aHull, 0.0);
b2CreatePolygonShape(*aBody, &aShapeDef, &aPolygonShape);
#else
@@ -208,8 +213,13 @@ void addEdgeShapeToBody(const basegfx::B2DPolygon& rPolygon, b2Body* aBody,
b2Hull aHull = b2ComputeHull(aQuadrilateralVertices, 4);
b2ShapeDef aShapeDef = b2DefaultShapeDef();
aShapeDef.density = fDefaultStaticDensity;
#if BOX2D_CHECK_VERSION(3, 1)
aShapeDef.material.friction = fDefaultStaticFriction;
aShapeDef.material.restitution = fDefaultStaticBodyBounciness;
#else
aShapeDef.friction = fDefaultStaticFriction;
aShapeDef.restitution = fDefaultStaticBodyBounciness;
#endif
b2Polygon aPolygonShape = b2MakePolygon(&aHull, 0.0);
b2CreatePolygonShape(*aBody, &aShapeDef, &aPolygonShape);
#else
@@ -993,7 +1003,11 @@ void box2DBody::setDensityAndRestitution(const double fDensity, const double fRe
for (int i = 0; i < nShapeCount; ++i)
{
b2ShapeId aShapeId = aShapeIds[i];
#if BOX2D_CHECK_VERSION(3, 1)
b2Shape_SetDensity(aShapeId, static_cast<float>(fDensity), false);
#else
b2Shape_SetDensity(aShapeId, static_cast<float>(fDensity));
#endif
b2Shape_SetRestitution(aShapeId, static_cast<float>(fRestitution));
}
// without resetting the massdata of the body, density change won't take effect