Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong Z check in OgreWideAngleCamera::Project3d #746

Merged

Conversation

darksylinc
Copy link
Contributor

🦟 Bug fix

There is no ticket assigned to this bug

Summary

The matrix returned by Ogre::Camera::getProjectionMatrix has Z in range [-1; 1], not range [0; 1]

This means we can't do pos.z > 0. We must do pos.z / pos.w > -1 Additionally, we must check against against z < 1; otherwise the point may get picked by the wrong face (and fail tests).

I found this bug while porting OgreWideAngleCamera to ogre2

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

The matrix returned by Ogre::Camera::getProjectionMatrix has Z in range
[-1; 1], not range [0; 1]

This means we can't do pos.z > 0. We must do pos.z / pos.w > -1
Additionally, we must check against against z < 1; otherwise the point
may get picked by the wrong face (and fail tests).

Signed-off-by: Matias N. Goldberg <[email protected]>
@darksylinc darksylinc requested a review from iche033 as a code owner October 22, 2022 16:23
@codecov
Copy link

codecov bot commented Oct 22, 2022

Codecov Report

Merging #746 (39f67c4) into main (b197260) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #746   +/-   ##
=======================================
  Coverage   74.07%   74.07%           
=======================================
  Files         159      159           
  Lines       14408    14408           
=======================================
  Hits        10673    10673           
  Misses       3735     3735           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@darksylinc darksylinc marked this pull request as draft October 24, 2022 14:13
@darksylinc
Copy link
Contributor Author

I turned this PR into a draft because I discovered a better solution, as the current one has an undesired behavior I discovered while dealing with lens flare.

This plays better with the far plane, while still playing fair with the
near plane.

Signed-off-by: Matias N. Goldberg <[email protected]>
@darksylinc darksylinc marked this pull request as ready for review October 29, 2022 16:17
@darksylinc
Copy link
Contributor Author

OK I fixed the issue. It's ready now for review and merge

@mjcarroll
Copy link
Contributor

New failure in Windows is unrelated to this changeset.

@mjcarroll mjcarroll merged commit fcd52be into gazebosim:main Oct 30, 2022
@iche033
Copy link
Contributor

iche033 commented Nov 7, 2022

@sanjuksha @scpeters, you may be interested in this change for gazebo-classic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎵 harmonic Gazebo Harmonic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants