v3.1 Tasks
- [ ] sample character mover
- [ ] smooth manifold merger
- [ ] world serialization
- [x] floating point determinism
- [ ] rolling resistance
- [ ] infinite planes
- [x] 64 bit category and mask bits
- [ ] clang-cl support in VS
https://box2d.org/posts/2024/08/determinism/
I investigated using realloc, but alignment is not well supported.
Character movement reference: https://x.com/MaddyThorson/status/1238338574220546049
world serialization in 3.2
Removed infinite planes. Only one user asked for it so it is not widely useful or worth the effort.
Removed smooth manifold merger because I took a different approach with the character mover
Here are some of the technical problems with infinite planes:
- it is a new shape type
- it cannot be added to the broad-phase because it is too big, this means it needs special logic in many places
- contact points can be very far from the plane body's origin, leading to precision problems
I already recommend people don't create bodies bigger than ~20meters for precision reasons.
If someone makes a fork and shows how all these problems can be addressed without much complexity then I will reconsider.
if most worlds only need one plane (the ground), wouldn't the performance hit of special-casing collision checks for a single, unique shape type be an acceptable trade-off?
even with precision limitations far from the origin, it might still be a good enough and super convenient solution for ground and other boundaries instead of needing huge finite boxes
It would be an interesting to test a huge box and see how the stability looks far from the origin compared to a smaller ground box with an origin closer to the active bodies.
This would be somewhat similar to an infinite plane for stability.
A single infinite plane per world would be easier. It would be in the b2WorldDef.
I tested the card house with sleeping disabled. It is a bit less stable with a huge ground box offset from the origin by 20km.
#if 1
{
b2BodyDef bodyDef = b2DefaultBodyDef();
bodyDef.position = { 20000.0f, -5000.0f };
b2BodyId groundId = b2CreateBody( m_worldId, &bodyDef );
b2ShapeDef shapeDef = b2DefaultShapeDef();
shapeDef.material.friction = 0.7f;
b2Polygon groundBox = b2MakeBox( 30000.0f, 5000.0f );
b2CreatePolygonShape( groundId, &shapeDef, &groundBox );
}
#else
{
b2BodyDef bodyDef = b2DefaultBodyDef();
bodyDef.position = { 0.0f, -2.0f };
b2BodyId groundId = b2CreateBody( m_worldId, &bodyDef );
b2ShapeDef shapeDef = b2DefaultShapeDef();
shapeDef.material.friction = 0.7f;
b2Polygon groundBox = b2MakeBox( 40.0f, 2.0f );
b2CreatePolygonShape( groundId, &shapeDef, &groundBox );
}
#endif