Skip to content

Conversation

atlv24
Copy link
Contributor

@atlv24 atlv24 commented Oct 11, 2025

Objective

Solution

the fix i originally made was wrong. the reason it worked was because it failed the conditional and did not clip the lines in some cases where the original bug was exhibited. the condition was correct before, it turns out, but the clipping logic is wrong: an epsilon is added, with a comment saying it is to avoid falsely culling the vertex due to floating point imprecision leaving it just barely in front of the near plane. However, i do not see why an epsilon should be needed here, or why this should be avoided: triangle primitives are regularly intersecting the clipping plane, that is standard order of business. The entire primitive is not discarded if only part of it is clipped, instead only the visible pixels are rasterized.

Testing

  • original bug test case by Antony looks right
  • both grid test cases look right
  • gizmos examples look right

@alice-i-cecile alice-i-cecile added this to the 0.17.3 milestone Oct 11, 2025
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Gizmos Visual editor and debug gizmos S-Needs-Review Needs reviewer attention (from anyone!) to move forward P-Regression Functionality that used to work but no longer does. Add a test for this! labels Oct 11, 2025
Copy link
Contributor

@janis-bhm janis-bhm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked this out and tested with 3d_gismos example.
I don't fully understand the clip space math going on here, but I believe it's mix(a, b, (distance from a to near plane over distance from a to b) and the signs are flipped for some kind of optimisation?

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 13, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 13, 2025
Merged via the queue into bevyengine:main with commit e02319f Oct 13, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Gizmos Visual editor and debug gizmos C-Bug An unexpected or incorrect behavior P-Regression Functionality that used to work but no longer does. Add a test for this! S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gizmo lines culled incorrectly in 3D with depth_bias -1

4 participants