Skip to content

Floating-origin: rebase cloth/vehicle/navmesh/terrain-streamer + 50 km² scale validation (#429 follow-up) #613

Closed

Description

@drsnuggles8

Follow-up to the floating-origin / origin-rebasing first slice shipped in #612 (part of umbrella #429).

The first slice (Scene::RebaseOrigin / JoltScene::ShiftOrigin, opt-in WorldOriginSettings, default off) shifts root entity transforms, Jolt rigid bodies + static terrain + character controllers, and Box2D bodies back toward the origin when the primary camera travels far, keeping stored f32 coordinates small. It composes with the already-shipped camera-relative rendering.

Deferred from the first slice

Subsystems that hold world-space state outside the rebased set and so desync on a rebase (each documented as a limitation in JoltScene::ShiftOrigin):

  • Cloth soft-bodies — JPH soft-body particle clouds are not shifted (SetPosition semantics for soft bodies are unclear; a wrong shift is worse than none).
  • Vehicle / constraint anchors to a fixed world point — two-body constraints stay consistent (both endpoints translate together), but a constraint anchored to an absolute world point would not.
  • NavMesh — baked in world space; agents would path in a shifted frame against an unshifted mesh. Needs the navmesh + crowd query frame to rebase too.
  • TerrainStreamer per-tile WorldOrigin (TerrainTile.h) — set but not applied at render; the natural place to fold the rebase offset in.

Scale validation (the umbrella's acceptance bar)

  • End-to-end 50 km² traversal: no jitter/shadow-swim, physics stable across many rebases, streaming interoperates. The first slice proves the mechanism at a smaller distance (45 km visual evidence + Functional physics); this is the full-scale sign-off.
  • Auto-trigger tuning under real traversal (thresholds, rebase frequency, cost of a rebase over N thousand entities).

Notes

Labels feature,performance for freeze-eligibility, matching #429.

Activity

  1. coderabbitai commented on Jul 10, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #468 - feat(physics): wire Jolt HeightFieldShape into terrain collision (#428) [merged]
    #562 - Perf/DOD: flat depth-sorted hierarchy world-matrix propagation pass [merged]
    #587 - Camera-relative rendering + absolute-world pattern shaders (#429) [merged]
    #601 - feat(renderer2d): camera-relative CPU-bake coordinate shift for 2D sprites (#429) [merged]
    #612 - feat(scene): floating-origin / origin-rebasing (#429) [merged]
    #663 - Floating-origin: rebase cloth/constraints/navmesh/terrain-streamer + 50 km² scale validation (#613) [open]


    🧪 Issue enrichment is currently in open beta.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. drsnuggles8 commented on Jul 18, 2026

    @drsnuggles8
    OwnerAuthor

    Landed in PR #663 (feature/floating-origin-rebase-613). Per-item evidence:

    • Cloth — JoltScene::ShiftOrigin shifts each soft body's COM (SetPosition, particles are COM-relative), and Scene::RebaseOrigin shifts the absolute m_ClothRuntime CPU render cache. Guard: WorldOriginRebaseClothTest.ClothVerticesShiftRigidlyWithRebase.
    • Vehicle / constraint anchors — new JoltScene::ShiftWorldAnchoredConstraints: NotifyShapeChanged(sFixedToWorld, -delta) shifts single-body-to-world anchors exactly in place (preserving rest state/motors/warm-start); pulleys are rebuilt from their shifted authored pivots. The defer-the-whole-rebase fallback was removed. Vehicles need nothing (the VehicleConstraint holds no absolute anchor; the chassis is a regular body already shifted). Guards: WorldOriginRebaseWorldJointTest, WorldOriginRebasePulleyTest.
    • NavMesh — Scene::RebaseNavigation regenerates the mesh at the shifted bounds (Detour has no in-place translate — m_orig is private and drives every spatial query), shifting bounds/off-mesh-links/agent-targets and rebuilding the query + crowd via a shared BakeNavMesh(). Guard: WorldOriginRebaseNavTest.AgentContinuesToTargetAcrossRebase.
    • TerrainStreamer per-tile WorldOrigin — folded into the per-tile draw (entityTransform × translate(WorldOrigin)) at every draw/shadow site and the non-tess cull frustum; made entity-relative via an entity-local camera feed so it's rebase-free. This also fixes the pre-existing streamed-tile stacking bug. Single-tile terrain is byte-identical (verified rendering correctly in the editor).
    • 50 km² traversal — WorldOriginRebaseVisualEvidenceTest at 50 km + a multi-rebase traversal: no visible pop (RMSE before/after 1.635, worst consecutive 1.545, both < 5.0). WorldOriginRebaseTraversalTest fires ~10 rebases across a 10 km flight and asserts absolute-trajectory continuity.
    • Auto-trigger tuning / rebase cost — WorldOriginRebaseBenchmark: 68.7 ms @ 10k, 308 ms @ 50k entities (Debug/unoptimized); rebase frequency validated by the traversal test (~1 rebase / grid cell at threshold 1024).

    17/17 tests pass (incl. the GL visual-evidence tests, which render rather than skip). Design notes captured in docs/agent-rules/floating-origin-rebase-subsystems.md.

    Closing — the checklist is complete. Umbrella #429 closed alongside.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestperformancePerformance / data-oriented optimization

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions