Repository navigation
Releases
box3d-rust 0.5.0
This release syncs the port to upstream Box3D efca0c1. The C reference pin
advances from 9f998c8, and this port follows its API and behavior. The sync
ran one upstream commit at a time. Simulation results are not bit-compatible
with 0.4.x, and hull, compound, recording, and snapshot blobs from earlier
versions no longer load (see Breaking). The release also ports the replay
keyframe ring (RecPlayer::seek_frame), regenerates the demo's bundled replay
recording, and fixes the recording code generators. Ported:
51f056eSAT benchmark (#177)e77352cAdd support for AVX2 and runtime feature detection (#174)16f7f4cTree perf (#179)f8c4fe8Shape cast support for box movers (#180)003a3f7Fix recording crash on compounds (#181)3d9db79Various recording fixes (#182)5d83df8Improve compound serialization (#183)a2e4816Fixes for #175 (#187)8128d74Discussion template (#185) (GitHub discussion template only, nothing to port)0cfc475Solver stuff (#189)efca0c1Gyro tolerance (#191)
Breaking
- Hulls store the dot product of the two adjacent face normals for each full
edge (upstream51f056e).HullDatagainsedge_cosine_offset,
edge_cosines, and an explicitpaddingfield;BoxHullgains
edge_cosines: [f32; 12](left zero, as upstream never fills them for
boxes). The serialized layout grows: theHullDataheader is 152 bytes
(was 144),HULL_BYTE_COUNT_OFFSETis 144,BoxHullis 696 bytes (was
640), andHULL_VERSIONchanges to0x9D3E61B7C2A4F085. Hull hashes
change, and serialized hulls, baked compounds, and recordings that embed
hulls from earlier versions no longer load. - Hull SOA vertex and normal arrays are padded to a multiple of 8 (was 4) so
upstream's AVX2 kernels can load full lanes (upstreame77352c,
B3_HULL_SOA_PADDING). NewHULL_SOA_PADDINGandget_hull_soa_stride;
hull_soa_vertex_count/hull_soa_normal_countnow return the 8-padded
stride. Hulls whose vertex or face count is not a multiple of 8 grow, and
HULL_VERSIONchanges again to0x6B1E39D4A87C25F3. Hull hashes change
(box hulls included, through the version), and hull blobs from earlier
versions no longer load. core::set_stall_threshold/core::get_stall_thresholdare removed, as
upstream removedb3SetStallThreshold/b3GetStallThresholdand the CCD
stall logging (upstream16f7f4c). The demo's Continuous / Stall readout
goes with them.- The wide contact solver types change shape (upstream
16f7f4c).
contact_solver::wide::ContactConstraintWidekeeps the per-lane body data
and gainsmanifold_count; the per-manifold data moves to the new
ContactManifoldWide(withrolling_mask), and a color's constraints live
inWideContactConstraints(constraints, manifolds, manifold starts). The
convex kernels are replaced by kernels shared with mesh contacts:
warm_start_contacts_w,push_contacts_w,solve_contacts_w,
apply_restitution_w,store_impulses_w, plus
prepare_contacts_mesh_wide.make_matrix_from_quat_wis removed. - Baked compounds no longer carry a dynamic tree or tree proxies (upstream
5d83df8).CompoundDatalosesproxy_offsetandtreeand gains
bounds,tree_height,node_count, andnodes(the live tree nodes;
leaves hold the child index). The blob header is 96 bytes (was 184; the
embeddedb3DynamicTreeandCOMPOUND_TREE_OFFSETare gone), the proxy
array is dropped, andCOMPOUND_VERSIONno longer depends on the tree
version: it is now0x9E4B17D3A25C68F1 ^ MESH_VERSION ^ HULL_VERSION
(0x5FFEB407FB88E7F5). Compound blobs and hashes change, and compound
blobs and recordings from earlier versions no longer load. convert_compound_to_bytesandconvert_bytes_to_compoundare replaced by
CompoundData::to_bytesandvalidate_compound(upstream
b3ValidateCompound, replacingb3ConvertCompoundToBytes/
b3ConvertBytesToCompound). In C the compound is now a pointer-free blob
used in place; the port still parses it into an ownedCompoundData.RegistrySlot::live_compoundandRegistrySlot::get_live_compoundare
replaced byRegistrySlot::compound, filled when the registry loads
(upstream removedb3RegistrySlot::liveandb3RecGetLiveCompound).- The local rotational inertia moves from
Body::inertiato
BodySim::inertia(upstreamefca0c1), so the solver reads it directly.
body_flags::BODY_ENABLE_CONTACT_RECYCLINGis renamed
body_flags::ENABLE_CONTACT_RECYCLING, andmath_functions::skewis
removed (upstream removedb3Skew). The snapshot version becomes 11 (the
world config stores the isotropic inertia tolerance) and the Rust snapshot
layout version 5, so snapshots from earlier versions no longer load. The
recording minor version becomes 9. - The
RecPlayerkeyframe ring fieldskeyframe_interval,
keyframe_min_interval,keyframe_budget,keyframe_bytes, and
last_keyframe_frame(public in 0.4.1) are now crate-private, as C keeps
them private. Set the budget and minimum interval with
set_keyframe_policyand read the first four with theget_keyframe_*
getters;last_keyframe_framehas no public replacement.
Added
get_hull_edge_cosines(upstreamb3GetHullEdgeCosines).core::is_avx2_available(upstreamb3IsAVX2Available). It returns false:
the port implements the scalar path, matching aBOX3D_DISABLE_SIMDbuild.world_enable_sse2_fallback(upstreamb3World_EnableSSE2Fallback). The
world's SIMD width (crate-internal, like upstream'sworld->simdWidth) is
always 4 in the port, so the call has no effect on the simulation. Internally the port also gains upstream's
b3GetSIMDWidth/b3SetSIMDWidth,b3ComputeSeparatingAxisAtWidth, and
b3CollideHullsAtWidth; contacts collide hulls at the world's width.shape::compute_shape_min_extent(upstreamb3ComputeShapeMinExtent):
the radius for spheres and capsules, the inner radius for hulls, and the
compute_shape_extentminimum otherwise.shape_get_compound(upstreamb3Shape_GetCompound). The port's shape
owns a copy of the compound, so it returns that copy.dynamic_tree::TreeViewandmake_tree_view(upstreamb3TreeView,
b3MakeTreeView,b3TreeView_Query/_QueryClosest/_RayCast/
_BoxCast): the queries and casts run on a node array with optional
proxies. A view without proxies skips the category test and reports the
leaf's shape index as the user data; compound queries use it. The
DynamicTreequeries wrap it and are unchanged.WorldDef::isotropic_inertia_tolerance(default 0.2, clamped to [0, 1])
withworld_set_isotropic_inertia_tolerance/
world_get_isotropic_inertia_tolerance(upstreamefca0c1,
b3World_SetIsotropicInertiaTolerance/_GetIsotropicInertiaTolerance),
recorded as the newWorldSetIsotropicInertiaToleranceop (0x70). A
change only reaches bodies whose mass is computed afterwards. New body
flagbody_flags::ENABLE_GYROSCOPIC_TORQUE.- The replay keyframe ring (upstream
b3RecCaptureKeyframe,
b3RecPlayerRestoreKeyframe,b3RecSeedKeyframeRegistry).RecPlayer
now snapshots the world every keyframe interval while stepping (also in
sub_step_frameandvalidate_replay), within a byte budget: when a
capture would exceed it, the interval doubles and keyframes off the new
grid are evicted.seek_framerestores the nearest keyframe strictly
before the target (or restarts) and re-steps only the gap, and seeking to
the current frame is now a no-op, as in C. The policy defaults to a 16
frame interval and a 512 MiB budget (get_keyframe_budgetused to report
0);set_keyframe_policykeeps the current value for a zero budget or a
non-positive interval and drops the ring, andrestartkeeps the ring.
Captures serialize through a registry pre-seeded 1:1 from the player's
geometry slots, so geometry ids stay stable and the registry never grows.
get_keyframe_bytescharges each keyframe its image allocation plus its
outliner body list, as C does; the images are the port's field-by-field
snapshots, so the totals differ from C's (in float, 8744 bytes per
keyframe of the four box stack where C charges 12400 to 12496), and a
budget sized between keyframes can keep a different ring than C's.
Capture cadence, eviction, and seek targets under the default and a one
byte budget, and the world hashes after each seek, were confirmed against
a scalar C build ofefca0c1in both precision modes; two budgets sized
relative to the first keyframe also keep C's ring in float.
RecBuffergainscapacity, the allocation size C'sb3RecBufAppend
growth rule would reach, which the keyframe budget charges.
Changed
GeometryRegistry::internmatches an existing entry by bytes only, as
upstream'sb3InternGeometrydoes; it used to also require the same
kind.- The separating axis test culls edge candidates with upstream's inscribed
sphere testb3TestEdgeCandidateSorted(replacingb3TestEdgeCandidate),
using per-hull plane separations of the other hull's center and the stored
edge cosines. With early return it re-culls the candidates against the
support points of the best face axes when there are enough edge pair
tests, and it reuses the seed face separation instead of recomputing it.
Contact manifolds are unchanged on 30,000 randomized hull pairs; the
early-return query can report a different (non-winning) edge axis.
Checked bit-exact against a scalar C build of51f056eon those pairs. - The wide contact solver blends the clamped rolling resistance impulse to
+0 in lanes without rolling resistance instead of scaling it by zero, which
produced -0 for negative impulses (upstreame77352c). Stored rolling
impulses can change from -0 to +0, which can change later results bitwise
in scenes that mix rolling and non-rolling contacts. The loops ove...
box3d-rust 0.4.1
Bug-fix release. No public API changes; C reference pin unchanged (9f998c8).
Fixed
body_set_awake(world, id, false)passed a stale island id totry_sleep_islandaftersplit_island, panicking on a debug assertion (and sleeping a destroyed island in release builds). The island id is now re-read after the split, matching Cb3Body_SetAwake. Reported by @KennethWerner in #2.
box3d-rust 0.4.0
This release syncs the port to upstream Box3D 9f998c8 and makes World
Send (#1). The C reference pin advances to 9f998c8 by way of 30c67b5
(upstream v0.2.0: 64-bit rapidhash geometry hashes and triangle manifold
collision fixes), and this port follows its API and behavior. The sync ran one
upstream commit at a time. Simulation results are not bit-compatible with
0.3.0. Ported:
47d7f7cclockwise option, joint is awake (#130)954cf87Fixes (#157)f555ee4Optimize Broad-Phase (#159)9e5a4cdOptimizations (#161)79fc559Optimizations (#168)8fda30e(samples only, nothing to port)adec25bSAT optimizations (#170)5643cd8Remove compound mesh child material limit (#172)9f998c8SAT samples (#173)
Breaking
- Sensor visitors must now be convex (upstream
b3IsConvexcheck); mesh,
height-field, and compound shapes no longer generate sensor overlaps as
visitors. MAX_SHAPE_CAST_POINTSnow equalsMAX_HULL_VERTICES(128, previously 64).- Recording format minor version advances to 4. Older recordings still
replay (the loader gates on major version only), but recordings that use
the new shape-mutator ops are not readable by 0.3.0. - Geometry content hashes are now 64-bit rapidhash: the
HullData,
MeshData, andHeightFieldDatahash fields areu64, struct byte
layouts and version constants changed (BoxHull648 -> 640 bytes), and
serialized geometry from older versions no longer loads. core::non_zero_hashandrecording::hash64_blobare removed;
hash_hull_datareturns the content hash directly.- Shape creation now rejects geometry with mismatched version constants at
runtime. - The world now owns an active recording (#1).
world_start_recording(world, recording: Recording)and
recording::start_recordingtake theRecordingby value, and
world_stop_recording(world)/recording::stop_recordingreturn the
finalizedOption<Recording>. The world previously held a raw pointer to
a caller-ownedRecording, which was unsound if the caller moved or dropped
it mid-session.World::recordingis now
Option<Box<RefCell<Recording>>>. - Shared hull geometry is now
Arc<HullData>instead ofRc<HullData>
(ShapeGeometry::Hull, the world hull database). - Recording format major version advances to 5 (upstream
47d7f7c): recorded
mover planes carry the newPlaneResulttriangle, child, and material
indices. Recordings from major version 4 no longer replay. PlaneResultgainstriangle_index,child_index, andmaterial_index,
andMeshDefgainsstride,vertex_bytes, andclock_wise_winding
(upstream47d7f7c). Struct literals without..Default::default()must
add the new fields.get_length_and_normalizenow treats vectors with squared length at or
below1000 * f32::MIN_POSITIVEas zero (was length belowf32::EPSILON)
and writes a zero length on failure, matching upstream.- Recording format major version advances to 6 (upstream
954cf87): the
recorded body def carriessafety_factor, and the new op0x3B
BodySetSafetyFactoris recorded and replayed. Recordings from major
version 5 no longer replay. The world snapshot version advances to 3
(Body::safety_factor); older snapshots are rejected. BodyDefgainssafety_factor(default 0.5) andBodygains
safety_factor(upstream954cf87). Struct literals without
..Default::default()must add the field.- The shared human ragdoll (
humanmodule) is rewritten to match upstream
954cf87: theSpine02andHeadbones are gone (the neck bone carries the
head capsule),BoneIdvalues are renumbered,BONE_COUNTis 12,
FILTER_JOINT_COUNTis 9, andcreate_humannow creates three filter
joints (thighs, neck and each upper arm). Bone frames, capsules, per-bone
friction, joint limits, and foot capsules on the calves all changed. - The dynamic tree is rewritten to upstream
f555ee4's layout:TreeNodeis
the 32-byte{ aabb, flag_index, height }node (siblings paired at even
indices, root at 0, index 1 always empty), and category bits and user data
live in the newTreeProxyarray.DYNAMIC_TREE_VERSIONis now
0x1D6F4C2A73B80E91, which also changesCOMPOUND_VERSION; baked compounds
and saved trees from earlier versions no longer load. Theb3TreeNodeFlags
constants (ALLOCATED_NODE,ENLARGED_NODE, the oldLEAF_NODE) are
replaced by theMOVED_NODE/LEAF_NODE/EMPTY_NODEflag-index bits. DynamicTree::validate_no_enlargedis renamedvalidate_no_moved
(b3DynamicTree_ValidateNoMoved), andBroadPhase::validate_no_enlargedis
renamedvalidate_no_moved.DynamicTree::node_countandroot_indexare
removed (usenode_endandROOT_NODE).user_data/aabbnow resolve
the proxy id through the proxy array, so proxy ids are no longer node
indices.TreeNodeView(fromDynamicTree::node_views) now describes the sibling
pair layout:left_child,proxy_id,user_data,is_leaf,is_empty,
is_moved, and covers only nodes belownode_end.BroadPhasedropsmoved_proxies,move_array,buffer_move, and
enlarge_proxy; moves are marks in the trees (mark_proxy_moved,
mark_proxy_moved_serial).TaskContext::enlarged_sim_bit_setis replaced
byTaskContext::pair_keys, the shape flagENLARGED_AABBis removed, and
Worldgainscompound_shape_count.- The baked compound blob gains
proxy_offsetand stores only the live node
range plus the proxy array (header 144 -> 184 bytes). - Recording format minor version advances to 6 and the world snapshot version
to 5 (upstreamf555ee4): snapshots store the tree node end, pair free
list, proxy capacity and free list, DFS order flag, nodes and parents up to
the node end, the proxies, andWorld::compound_shape_count; the move
buffer is gone. Older snapshots are rejected. - Shape fat AABBs move out of
Shapeinto the parallelWorld::fat_aabbs
array (upstream9e5a4cd);Shape::fat_aabbis removed and
create_shape_proxynow takes the world and a shape id. Contact::body_sim_index_a/bare replaced by the persistent
encoded_body_sim_a/blocators (awake: local index, static:
-(local index + 2), otherwiseNULL_INDEX), maintained by the new
refresh_body_contact_indicesand the wake, sleep, transfer, destroy, and
graph paths. New helpersencode_body_sim_index,is_static_sim_index,
decode_awake_index, andsleep_body_sim_index.body_flags::ENLARGE_BOUNDSis renamedENLARGE_BULLET_BOUNDSand is only
set for bullets;IS_FASTis no longer a transient body flag and only lives
onBodySim.- The restitution solver stage is gone:
RESTITUTION_ITERATIONS,
Profile::apply_restitution,apply_restitution, and
apply_restitution_convexare removed, andContactConstraint::restitution
is removed.ManifoldConstraintPoint::relative_velocitybecomes
restitution_velocity. The contact kernels split intopush_contacts/
push_contacts_convex(biased) andsolve_contacts/
solve_contacts_convex(relax with deferred restitution); none take a
use_biasflag.prepare_color_contactstakes the contacts mutably. Counters::byte_countisi64and is now the first field (upstream
b3Counterslayout). The port has no allocator hooks, so upstream's
b3AllocFcn/b3FreeFcn/b3GetByteCountsignature changes have no Rust
counterpart.- Recording format minor version advances to 7 and the world snapshot version
to 7 (upstream9e5a4cd): snapshots storeWorld::fat_aabbsafter the
shapes and keep the contact body sim locators. Older snapshots are rejected. - The same-step restitution from
9e5a4cdis replaced by a post-solve
restitution stage again (upstream79fc559):ManifoldConstraintPoint
carriesrelative_velocityandrestitution_impulse(instead of
restitution_velocity) andContactConstraintregainsrestitution.
apply_restitution(Mesh/overflow) returns with a new signature taking the
restitution threshold and the propagation flag, andStepContextloses
restitution_threshold(the solver reads the world's value, like C). - Graph-color convex contacts are solved by a four lane wide constraint
(contact_solver::wide,ContactConstraintWide) that runs the scalar
b3FloatWpath, replacing the per-lanesolve_contacts_convex/
push_contacts_convex/warm_start_contacts_convexonContactConstraint.
prepare_color_contactsis replaced byprepare_mesh_contactsand
wide::prepare_contacts_convex. Theb3FloatWhelpers move from
manifoldto the crate-levelsimd_scalarmodule. world_rebuild_static_treeis now crate-internal (upstream removed
b3World_RebuildStaticTreefrom the public API); the recording op still
replays it.- Recording format minor version advances to 8 (upstream
79fc559) with the
new ops0x0EWorldSetRestitutionIterationsand0x0F
WorldEnableRestitutionPropagation. The world snapshot version advances to
10: the world config storesrestitution_iterationsand the restitution
propagation flag (bit0x10). Older snapshots are rejected. - Compound mesh children no longer have a material limit (upstream
5643cd8).MAX_COMPOUND_MESH_MATERIALSis removed.CompoundCapsule,
CompoundHull, andCompoundSpherecarry au16material_indexplus a
u16paddingfield (wasi32).CompoundMesh::material_indicesand
ChildShape::material_indicesare now&[u16]slices into the compound
with amaterial_countfield (was a fixed[i32; 4]), and
compute_mesh_manifoldstakes its material map asOption<&[u16]>. - The baked compound blob layout changes (upstream
5643cd8): the convex
child and hull instance material indices areu16+ padding, mesh
instances store amaterial_offset/material_countpair (60 -> 52
bytes) into a packedu16mesh material map stored after th...