Conversation
clean up double stuff
fix ground grid far from origin
disable validation for now
Pull request overview
Adds an optional “large world” mode that keeps absolute body positions in double precision (BOX3D_DOUBLE_PRECISION) while preserving mostly-float internal math, plus associated API, debug-draw, and test updates. This also adjusts mass/inertia computations to be origin-independent when shapes are far from the body origin.
Changes:
- Introduces
b3Pos/b3WorldTransformand related boundary helpers (b3SubPos,b3OffsetPos, etc.), updating APIs that consume/return world positions. - Improves robustness/precision for far-from-origin operations (AABB construction, sweeps/TOI, collision manifolds, queries, debug draw origin shifting).
- Expands unit/samples coverage for large-world invariants and updates docs/CI to test double-precision builds.
Reviewed changes
Copilot reviewed 113 out of 115 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/test_world.c | Updates tests to b3Pos; adds explosion regression test. |
| test/test_shape.c | Updates inertia expectations (center-of-mass basis). |
| test/test_math.c | Adds large-world boundary helper tests. |
| test/test_height_field.c | Updates shape-cast input API usage. |
| test/test_distance.c | Updates distance/shape-cast input API usage. |
| test/test_determinism.c | Splits expected determinism constants by precision mode. |
| test/test_collision.c | Adds large-world manifold/AABB regression tests. |
| test/test_body.c | New tests for far-offset mass/inertia correctness. |
| test/main.c | Registers new tests (body/query/large-world). |
| test/CMakeLists.txt | Adds new test sources. |
| src/wheel_joint.c | Migrates joint drawing/center deltas to world types. |
| src/weld_joint.c | Migrates center delta and debug draw to world types. |
| src/types.c | Updates default debug-draw no-op signatures to world types. |
| src/triangle_manifold.c | Updates distance input API usage. |
| src/spherical_joint.c | Migrates transforms/draw calls to world types. |
| src/sphere.c | Switches inertia to COM basis; updates query inputs. |
| src/solver.c | Recenters CCD sweeps; uses conservative fat AABBs. |
| src/shape.h | Updates proxy creation signature; adds fat-AABB helper decl. |
| src/shape.c | Adds b3ComputeFatShapeAABB; updates ray/closest-point paths. |
| src/sensor.c | Uses relative transforms for float-frame sensor overlap. |
| src/revolute_joint.c | Migrates transforms/draw calls to world types. |
| src/prismatic_joint.c | Migrates transforms/draw calls to world types. |
| src/physics_world.h | Updates debug point/line storage to b3Pos. |
| src/parallel_joint.c | Migrates draw calls to world transform + b3Pos. |
| src/motor_joint.c | Updates delta-center computation for b3Pos. |
| src/mesh.c | Updates overlap/shape-cast distance input API usage. |
| src/mesh_contact.c | Uses world transforms + relative conversion where needed. |
| src/math_internal.h | Removes Steiner helper declaration (COM inertia basis). |
| src/math_functions.c | Adds b3IsBoundedAABB, b3IsValidPosition, etc. |
| src/joint.h | Updates debug draw function signatures to world transforms. |
| src/joint.c | Migrates joint reactions/separation/draw to world types. |
| src/hull.c | Adds b3CreateRock; switches inertia to COM basis. |
| src/height_field.c | Updates shape-cast and overlap distance input API usage. |
| src/dynamic_tree.c | Replaces shape-cast traversal with box-cast traversal. |
| src/distance_joint.c | Migrates anchor/length/draw to b3Pos/world transforms. |
| src/core.c | Adds b3IsDoublePrecision() runtime query. |
| src/convex_manifold.c | Updates distance input API usage. |
| src/contact.h | Refactors contact recycling cache; updates transform types. |
| src/contact.c | Migrates contact update/manifold building to world transforms. |
| src/compound.c | Reworks compound cast to use box-cast traversal. |
| src/CMakeLists.txt | Adds CMake option propagation for BOX3D_DOUBLE_PRECISION. |
| src/capsule.c | Switches inertia to COM basis; updates query inputs. |
| src/broad_phase.c | Uses demoted relative transforms for float-frame AABB queries. |
| src/box3d.natvis | Adds natvis visualizers for new world types. |
| src/body.h | Updates body sim storage to world types; adds relative sweep helper. |
| shared/utils.h | Adds RandomPos helper for world positions. |
| shared/stability.h | Updates CreateMeshDrop signature to include origin. |
| shared/stability.c | Applies mesh-drop origin in b3Pos and offsets. |
| shared/overflow_color.c | Updates body positions to b3Pos. |
| shared/human.h | Updates CreateHuman signature to accept b3Pos. |
| shared/determinism.c | Hashes b3WorldTransform and uses b3Pos positions. |
| samples/shaders/shapes/geom.glsl | Adds grid offset uniform usage for large-world rendering. |
| samples/shaders/post/gtao_prefilter_depth.glsl | Renames doc text from render3d to Box3D. |
| samples/shaders/post/gtao_denoise.glsl | Renames doc text from render3d to Box3D. |
| samples/shaders/common/xe_gtao_common.glsl | Renames doc text from render3d to Box3D. |
| samples/shaders/common/pbr.glsl | Updates procedural grid API for wrapped origin offsets. |
| samples/sample.h | Migrates sample interfaces/state to b3Pos/world transforms. |
| samples/sample_tree.cpp | Updates debug draw calls and distance math for b3Pos. |
| samples/sample_stacking.cpp | Updates camera pivots and positions to b3Pos. |
| samples/sample_shapes.cpp | Updates camera pivots and positions to b3Pos. |
| samples/sample_robustness.cpp | Updates camera pivots to b3Pos. |
| samples/sample_ragdoll.cpp | Updates camera pivots and positions to b3Pos. |
| samples/sample_issues.cpp | Updates debug draw transforms/points to world types. |
| samples/sample_geometry.cpp | Updates debug draw transforms to world types. |
| samples/sample_events.cpp | Migrates event rendering to b3Pos/world transforms. |
| samples/sample_determinism.cpp | Updates camera pivot to b3Pos. |
| samples/sample_continuous.cpp | Updates camera pivots and query usage for new APIs. |
| samples/sample_compound.cpp | Header include cleanup + debug draw transform updates. |
| samples/sample_benchmark.cpp | Updates camera pivots and debug axes to world types. |
| samples/main.cpp | Sets draw origin; shows precision mode in title; grid wrapping. |
| samples/host/camera.h | Adds b3Pos pick origin; eye-relative camera representation. |
| samples/host/camera.cpp | Implements eye-relative view + world-eye lifting for picking. |
| samples/gfx/renderer.h | Adds draw origin + grid wrap to frame input. |
| samples/gfx/renderer.c | Passes grid offset uniform to shaders. |
| samples/gfx/picking.h | Removes obsolete pick helper (camera owns it now). |
| samples/gfx/keycodes.h | Simplifies comment to TODO placeholder. |
| samples/gfx/geometry_registry.c | Increases registry entry cap. |
| samples/gfx/draw.h | Converts draw API to world-space (b3Pos/world transforms). |
| samples/gfx/debug_adapter.h | Exposes grid cell size for host-side wrapping. |
| samples/gfx/debug_adapter.c | Shifts debug draw into camera-relative frame via draw origin. |
| samples/gfx/CMakeLists.txt | Removes picking header; comment cleanup. |
| samples/CMakeLists.txt | Reorders/clarifies sample source listing/comments. |
| include/box3d/math_functions.h | Adds b3Pos/b3WorldTransform + boundary helpers/inlines. |
| include/box3d/constants.h | Widens B3_HUGE when double precision is enabled. |
| include/box3d/collision.h | Adds box-cast API; adds b3CreateRock; clarifies frames. |
| include/box3d/base.h | Adds b3IsDoublePrecision() declaration. |
| extern/sokol/README.md | Removes vendored sokol notes (file deleted). |
| docs/simulation.md | Updates examples for b3Pos/b3WorldTransform query signatures. |
| docs/large_worlds.md | New documentation for large-world (double-precision) mode. |
| docs/collision.md | Updates docs for relative transforms + box-cast API. |
| docs/CMakeLists.txt | Adds large_worlds.md to Doxygen build. |
| docs/character.md | Updates mover query signatures and guidance for origin usage. |
| CMakeLists.txt | Adds top-level BOX3D_DOUBLE_PRECISION option. |
| .gitignore | Ignores build-dp/. |
| .github/workflows/build.yml | Adds double-precision CI jobs (Ubuntu/Windows + samples). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
644
to
+648
| for ( int j = 0; j < manifold->pointCount; ++j ) | ||
| { | ||
| const b3ManifoldPoint* manifoldPoint = manifold->points + i; | ||
| b3Vec3 p1 = manifoldPoint->anchorA + centerOfMass; | ||
| b3Vec3 p2 = p1 + manifoldPoint->totalNormalImpulse * normal; | ||
| b3Pos p1 = b3OffsetPos( centerOfMass, manifoldPoint->anchorA ); | ||
| b3Pos p2 = b3OffsetPos( p1, manifoldPoint->totalNormalImpulse * normal ); |
Copilot commented on Jun 19, 2026
CopilotAI
- High
Copilot uses AI. Check for mistakes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added a compile time option to use double precision body positions. Most math remains single precision with minimal performance loss.
BOX3D_DOUBLE_PRECISIONImproved accuracy of body inertia computation when shapes are far from the body origin.
WARNING: several APIs changed but migration should be straight forward if doubles are not enabled.