feat: convert simulation to native float32 math - #7
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR migrates movement, collision, liquid, and simulator math from float64 to float32, introduces float32 cube and math dependencies, updates public state and provider contracts, and adjusts regression tests and coordinate conversions. ChangesFloat32 physics migration
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@simulation.go`:
- Line 1024: Update the cobweb collision check around IntersectsWith to use the
already world-space collision box directly, removing the additional
Translate(posVec3(pos)) call. Preserve the existing intersection behavior while
ensuring BlockCollisions results are not offset twice.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6dec3eee-c345-4427-9c91-fbef994f2012
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (17)
bbox.goblock.gocollision.goconstants.gogo.modinput.gointerfaces.goliquid.goliquid_hardening_test.goliquid_test.gomath.gomovement.gonative_float32_test.goresult.gosimulation.gosimulator.gosimulator_test.go
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@liquid_test.go`:
- Around line 57-76: Update liquidWorld.BlockCollisions to return the collision
box in block-local coordinates without translating by pos. In
liquidWorld.GetNearbyBBoxes, translate each returned local box by the
corresponding block position before intersecting with aabb and appending it,
ensuring consumers receive world-space boxes while avoiding double translation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f2665d84-3c7e-4fd3-8c30-5b17140d68b4
📒 Files selected for processing (12)
bbox.goblock.gocollision.gointerfaces.goliquid.goliquid_hardening_test.goliquid_test.gomath.gomovement.gonative_float32_test.gosimulation.gosimulator_test.go
🚧 Files skipped from review as they are similar to previous changes (5)
- native_float32_test.go
- bbox.go
- math.go
- collision.go
- simulator_test.go
Summary
cube.BBox32for all simulation-side geometry through the maintained forkWhy
The Bedrock client performs movement arithmetic in 32-bit floats and the protocol carries float32 positions and velocities. Running the simulator in float64 changes rounding before epsilon-sensitive collision, on-ground, penetration, and stepping branches, which can produce discrete client-parity failures.
Breaking changes
Provider collision APIs now exchange Dragonfly
cube.BBox32values, movement vectors usemgl32, and simulation scalars—including block friction and correction thresholds—usefloat32.BBoxFromDragonflyis provided for conversion at Dragonfly model/provider boundaries.Validation
go build ./...go vet ./...go test ./... -count=1git diff --checkrg 'mgl64|float64' --glob '*.go'returns no matchesSummary by CodeRabbit
float32.