fix: use camera-relative coordinates to avoid float precision loss at large world coordinates - #37
Closed
Whisperlyric wants to merge 1 commit into
Closed
Whisperlyric wants to merge 1 commit into
Whisperlyric wants to merge 1 commit into
Conversation
… large world coordinates
Whisperlyric
marked this pull request as ready for review
September 22, 2026 10:03
Author
|
Tips:this problem also exists in lower versions as 2612 |
Owner
|
Why did you make a PR and close it? |
Author
|
Sorry for the confusion — I accidentally opened the same PR twice and closed the duplicate; the other one is still open. |
Owner
|
Ok I'll take a look at it then, my fault for not having a CONTRIBUTING.md but I'd rather not have AI-driven PR in the future. |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
At large world coordinates (tens of millions, e.g. near the world border):
(some edges stretched to several blocks), so the
highlighted target can no longer be identified.
Cause: all render vertices were converted to
floatin absolute worldcoordinates (
new Vector3f((float) pos.x, ...)for trajectory points,float-cast box corners in
RenderUtils). Afloatonly has a 24-bit mantissa,so at ~30,000,000 the spacing between representable values grows to 2–4 blocks:
adjacent line vertices snap onto the same coarse grid, which shatters the line,
and a box's min/max corners are rounded independently, so its edges no longer
span exactly one block.
Solution
Subtract the camera position on the CPU in
doubleand convert the resultingcamera-relative offsets to
floatinstead; relative coordinates are small, so no precision is lost. The now-redundantposeStack.translate(-cam)is removed. Applied to: - trajectory line segments and the impact cross (PtpClient.renderTrajectory) - highlight/outline boxes (RenderUtils.renderFilledBox/renderBox)