Skip to content

Releases

box3d-rust 0.5.0

Choose a tag to compare

@larsbrubaker larsbrubaker released this 22 Oct 00:27

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:

  • 51f056e SAT benchmark (#177)
  • e77352c Add support for AVX2 and runtime feature detection (#174)
  • 16f7f4c Tree perf (#179)
  • f8c4fe8 Shape cast support for box movers (#180)
  • 003a3f7 Fix recording crash on compounds (#181)
  • 3d9db79 Various recording fixes (#182)
  • 5d83df8 Improve compound serialization (#183)
  • a2e4816 Fixes for #175 (#187)
  • 8128d74 Discussion template (#185) (GitHub discussion template only, nothing to port)
  • 0cfc475 Solver stuff (#189)
  • efca0c1 Gyro tolerance (#191)

Breaking

  • Hulls store the dot product of the two adjacent face normals for each full
    edge (upstream 51f056e). HullData gains edge_cosine_offset,
    edge_cosines, and an explicit padding field; BoxHull gains
    edge_cosines: [f32; 12] (left zero, as upstream never fills them for
    boxes). The serialized layout grows: the HullData header is 152 bytes
    (was 144), HULL_BYTE_COUNT_OFFSET is 144, BoxHull is 696 bytes (was
    640), and HULL_VERSION changes to 0x9D3E61B7C2A4F085. 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 (upstream e77352c,
    B3_HULL_SOA_PADDING). New HULL_SOA_PADDING and get_hull_soa_stride;
    hull_soa_vertex_count / hull_soa_normal_count now return the 8-padded
    stride. Hulls whose vertex or face count is not a multiple of 8 grow, and
    HULL_VERSION changes again to 0x6B1E39D4A87C25F3. 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_threshold are removed, as
    upstream removed b3SetStallThreshold / b3GetStallThreshold and the CCD
    stall logging (upstream 16f7f4c). The demo's Continuous / Stall readout
    goes with them.
  • The wide contact solver types change shape (upstream 16f7f4c).
    contact_solver::wide::ContactConstraintWide keeps the per-lane body data
    and gains manifold_count; the per-manifold data moves to the new
    ContactManifoldWide (with rolling_mask), and a color's constraints live
    in WideContactConstraints (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_w is removed.
  • Baked compounds no longer carry a dynamic tree or tree proxies (upstream
    5d83df8). CompoundData loses proxy_offset and tree and gains
    bounds, tree_height, node_count, and nodes (the live tree nodes;
    leaves hold the child index). The blob header is 96 bytes (was 184; the
    embedded b3DynamicTree and COMPOUND_TREE_OFFSET are gone), the proxy
    array is dropped, and COMPOUND_VERSION no longer depends on the tree
    version: it is now 0x9E4B17D3A25C68F1 ^ MESH_VERSION ^ HULL_VERSION
    (0x5FFEB407FB88E7F5). Compound blobs and hashes change, and compound
    blobs and recordings from earlier versions no longer load.
  • convert_compound_to_bytes and convert_bytes_to_compound are replaced by
    CompoundData::to_bytes and validate_compound (upstream
    b3ValidateCompound, replacing b3ConvertCompoundToBytes /
    b3ConvertBytesToCompound). In C the compound is now a pointer-free blob
    used in place; the port still parses it into an owned CompoundData.
  • RegistrySlot::live_compound and RegistrySlot::get_live_compound are
    replaced by RegistrySlot::compound, filled when the registry loads
    (upstream removed b3RegistrySlot::live and b3RecGetLiveCompound).
  • The local rotational inertia moves from Body::inertia to
    BodySim::inertia (upstream efca0c1), so the solver reads it directly.
    body_flags::BODY_ENABLE_CONTACT_RECYCLING is renamed
    body_flags::ENABLE_CONTACT_RECYCLING, and math_functions::skew is
    removed (upstream removed b3Skew). 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 RecPlayer keyframe ring fields keyframe_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_policy and read the first four with the get_keyframe_*
    getters; last_keyframe_frame has no public replacement.

Added

  • get_hull_edge_cosines (upstream b3GetHullEdgeCosines).
  • core::is_avx2_available (upstream b3IsAVX2Available). It returns false:
    the port implements the scalar path, matching a BOX3D_DISABLE_SIMD build.
  • world_enable_sse2_fallback (upstream b3World_EnableSSE2Fallback). The
    world's SIMD width (crate-internal, like upstream's world->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 (upstream b3ComputeShapeMinExtent):
    the radius for spheres and capsules, the inner radius for hulls, and the
    compute_shape_extent minimum otherwise.
  • shape_get_compound (upstream b3Shape_GetCompound). The port's shape
    owns a copy of the compound, so it returns that copy.
  • dynamic_tree::TreeView and make_tree_view (upstream b3TreeView,
    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
    DynamicTree queries wrap it and are unchanged.
  • WorldDef::isotropic_inertia_tolerance (default 0.2, clamped to [0, 1])
    with world_set_isotropic_inertia_tolerance /
    world_get_isotropic_inertia_tolerance (upstream efca0c1,
    b3World_SetIsotropicInertiaTolerance / _GetIsotropicInertiaTolerance),
    recorded as the new WorldSetIsotropicInertiaTolerance op (0x70). A
    change only reaches bodies whose mass is computed afterwards. New body
    flag body_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_frame and validate_replay), within a byte budget: when a
    capture would exceed it, the interval doubles and keyframes off the new
    grid are evicted. seek_frame restores 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_budget used to report
    0); set_keyframe_policy keeps the current value for a zero budget or a
    non-positive interval and drops the ring, and restart keeps 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_bytes charges 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 of efca0c1 in both precision modes; two budgets sized
    relative to the first keyframe also keep C's ring in float.
    RecBuffer gains capacity, the allocation size C's b3RecBufAppend
    growth rule would reach, which the keyframe budget charges.

Changed

  • GeometryRegistry::intern matches an existing entry by bytes only, as
    upstream's b3InternGeometry does; it used to also require the same
    kind.
  • The separating axis test culls edge candidates with upstream's inscribed
    sphere test b3TestEdgeCandidateSorted (replacing b3TestEdgeCandidate),
    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 of 51f056e on 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 (upstream e77352c). 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...
Read more

box3d-rust 0.4.1

Choose a tag to compare

@larsbrubaker larsbrubaker released this 20 Oct 22:02

Bug-fix release. No public API changes; C reference pin unchanged (9f998c8).

Fixed

  • body_set_awake(world, id, false) passed a stale island id to try_sleep_island after split_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 C b3Body_SetAwake. Reported by @KennethWerner in #2.

box3d-rust 0.4.0

Choose a tag to compare

@larsbrubaker larsbrubaker released this 29 Sep 19:02

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:

  • 47d7f7c clockwise option, joint is awake (#130)
  • 954cf87 Fixes (#157)
  • f555ee4 Optimize Broad-Phase (#159)
  • 9e5a4cd Optimizations (#161)
  • 79fc559 Optimizations (#168)
  • 8fda30e (samples only, nothing to port)
  • adec25b SAT optimizations (#170)
  • 5643cd8 Remove compound mesh child material limit (#172)
  • 9f998c8 SAT samples (#173)

Breaking

  • Sensor visitors must now be convex (upstream b3IsConvex check); mesh,
    height-field, and compound shapes no longer generate sensor overlaps as
    visitors.
  • MAX_SHAPE_CAST_POINTS now equals MAX_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, and HeightFieldData hash fields are u64, struct byte
    layouts and version constants changed (BoxHull 648 -> 640 bytes), and
    serialized geometry from older versions no longer loads.
  • core::non_zero_hash and recording::hash64_blob are removed;
    hash_hull_data returns 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_recording take the Recording by value, and
    world_stop_recording(world) / recording::stop_recording return the
    finalized Option<Recording>. The world previously held a raw pointer to
    a caller-owned Recording, which was unsound if the caller moved or dropped
    it mid-session. World::recording is now
    Option<Box<RefCell<Recording>>>.
  • Shared hull geometry is now Arc<HullData> instead of Rc<HullData>
    (ShapeGeometry::Hull, the world hull database).
  • Recording format major version advances to 5 (upstream 47d7f7c): recorded
    mover planes carry the new PlaneResult triangle, child, and material
    indices. Recordings from major version 4 no longer replay.
  • PlaneResult gains triangle_index, child_index, and material_index,
    and MeshDef gains stride, vertex_bytes, and clock_wise_winding
    (upstream 47d7f7c). Struct literals without ..Default::default() must
    add the new fields.
  • get_length_and_normalize now treats vectors with squared length at or
    below 1000 * f32::MIN_POSITIVE as zero (was length below f32::EPSILON)
    and writes a zero length on failure, matching upstream.
  • Recording format major version advances to 6 (upstream 954cf87): the
    recorded body def carries safety_factor, and the new op 0x3B
    BodySetSafetyFactor is 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.
  • BodyDef gains safety_factor (default 0.5) and Body gains
    safety_factor (upstream 954cf87). Struct literals without
    ..Default::default() must add the field.
  • The shared human ragdoll (human module) is rewritten to match upstream
    954cf87: the Spine02 and Head bones are gone (the neck bone carries the
    head capsule), BoneId values are renumbered, BONE_COUNT is 12,
    FILTER_JOINT_COUNT is 9, and create_human now 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: TreeNode is
    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 new TreeProxy array. DYNAMIC_TREE_VERSION is now
    0x1D6F4C2A73B80E91, which also changes COMPOUND_VERSION; baked compounds
    and saved trees from earlier versions no longer load. The b3TreeNodeFlags
    constants (ALLOCATED_NODE, ENLARGED_NODE, the old LEAF_NODE) are
    replaced by the MOVED_NODE / LEAF_NODE / EMPTY_NODE flag-index bits.
  • DynamicTree::validate_no_enlarged is renamed validate_no_moved
    (b3DynamicTree_ValidateNoMoved), and BroadPhase::validate_no_enlarged is
    renamed validate_no_moved. DynamicTree::node_count and root_index are
    removed (use node_end and ROOT_NODE). user_data / aabb now resolve
    the proxy id through the proxy array, so proxy ids are no longer node
    indices.
  • TreeNodeView (from DynamicTree::node_views) now describes the sibling
    pair layout: left_child, proxy_id, user_data, is_leaf, is_empty,
    is_moved, and covers only nodes below node_end.
  • BroadPhase drops moved_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_set is replaced
    by TaskContext::pair_keys, the shape flag ENLARGED_AABB is removed, and
    World gains compound_shape_count.
  • The baked compound blob gains proxy_offset and 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 (upstream f555ee4): 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, and World::compound_shape_count; the move
    buffer is gone. Older snapshots are rejected.
  • Shape fat AABBs move out of Shape into the parallel World::fat_aabbs
    array (upstream 9e5a4cd); Shape::fat_aabb is removed and
    create_shape_proxy now takes the world and a shape id.
  • Contact::body_sim_index_a/b are replaced by the persistent
    encoded_body_sim_a/b locators (awake: local index, static:
    -(local index + 2), otherwise NULL_INDEX), maintained by the new
    refresh_body_contact_indices and the wake, sleep, transfer, destroy, and
    graph paths. New helpers encode_body_sim_index, is_static_sim_index,
    decode_awake_index, and sleep_body_sim_index.
  • body_flags::ENLARGE_BOUNDS is renamed ENLARGE_BULLET_BOUNDS and is only
    set for bullets; IS_FAST is no longer a transient body flag and only lives
    on BodySim.
  • The restitution solver stage is gone: RESTITUTION_ITERATIONS,
    Profile::apply_restitution, apply_restitution, and
    apply_restitution_convex are removed, and ContactConstraint::restitution
    is removed. ManifoldConstraintPoint::relative_velocity becomes
    restitution_velocity. The contact kernels split into push_contacts /
    push_contacts_convex (biased) and solve_contacts /
    solve_contacts_convex (relax with deferred restitution); none take a
    use_bias flag. prepare_color_contacts takes the contacts mutably.
  • Counters::byte_count is i64 and is now the first field (upstream
    b3Counters layout). The port has no allocator hooks, so upstream's
    b3AllocFcn / b3FreeFcn / b3GetByteCount signature changes have no Rust
    counterpart.
  • Recording format minor version advances to 7 and the world snapshot version
    to 7 (upstream 9e5a4cd): snapshots store World::fat_aabbs after the
    shapes and keep the contact body sim locators. Older snapshots are rejected.
  • The same-step restitution from 9e5a4cd is replaced by a post-solve
    restitution stage again (upstream 79fc559): ManifoldConstraintPoint
    carries relative_velocity and restitution_impulse (instead of
    restitution_velocity) and ContactConstraint regains restitution.
    apply_restitution (Mesh/overflow) returns with a new signature taking the
    restitution threshold and the propagation flag, and StepContext loses
    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
    b3FloatW path, replacing the per-lane solve_contacts_convex /
    push_contacts_convex / warm_start_contacts_convex on ContactConstraint.
    prepare_color_contacts is replaced by prepare_mesh_contacts and
    wide::prepare_contacts_convex. The b3FloatW helpers move from
    manifold to the crate-level simd_scalar module.
  • world_rebuild_static_tree is now crate-internal (upstream removed
    b3World_RebuildStaticTree from the public API); the recording op still
    replays it.
  • Recording format minor version advances to 8 (upstream 79fc559) with the
    new ops 0x0E WorldSetRestitutionIterations and 0x0F
    WorldEnableRestitutionPropagation. The world snapshot version advances to
    10: the world config stores restitution_iterations and the restitution
    propagation flag (bit 0x10). Older snapshots are rejected.
  • Compound mesh children no longer have a material limit (upstream
    5643cd8). MAX_COMPOUND_MESH_MATERIALS is removed. CompoundCapsule,
    CompoundHull, and CompoundSphere carry a u16 material_index plus a
    u16 padding field (was i32). CompoundMesh::material_indices and
    ChildShape::material_indices are now &[u16] slices into the compound
    with a material_count field (was a fixed [i32; 4]), and
    compute_mesh_manifolds takes its material map as Option<&[u16]>.
  • The baked compound blob layout changes (upstream 5643cd8): the convex
    child and hull instance material indices are u16 + padding, mesh
    instances store a material_offset / material_count pair (60 -> 52
    bytes) into a packed u16 mesh material map stored after th...
Read more