Ogre2FrustumVisual: draw wireframe at the actual frustum extents#1276
Merged
iche033 merged 1 commit intogazebosim:mainfrom Apr 22, 2026
Merged
Ogre2FrustumVisual: draw wireframe at the actual frustum extents#1276iche033 merged 1 commit intogazebosim:mainfrom
iche033 merged 1 commit intogazebosim:mainfrom
Conversation
Ogre2FrustumVisual::Update() computed nearWidth/nearHeight/farWidth/farHeight as full plane dimensions and then halved them when forming the per-corner offset vectors (upNearHeight2, rightNearWidth2, ...). Those offset vectors feed points[] / edges[] / planes[], which were therefore correct. The Ogre2DynamicRenderable used for the visible wireframe, however, was populated via AddPoint() calls that consumed the unhalved nearWidth, nearHeight, farWidth, farHeight directly as corner coordinates. Every drawn corner sat at twice its true distance from the optical axis, so the wireframe always showed roughly double the configured horizontal and vertical field of view (for example a logical_camera with horizontal_fov=1.047 rad / 60 deg was rendered as a cone of ~98 deg). Redefine the four locals as half-extents (drop the 2.0 factor) and drop the matching 0.5 factor from the offset vectors. The AddPoint() calls now consume the correct half-extents, while points[], edges[], and planes[] are geometrically unchanged. No public API change. Signed-off-by: MDEAGEWT <kmk6061602@naver.com> Generated-by: Claude Opus 4.7 <noreply@anthropic.com>
ahcorde
approved these changes
Apr 22, 2026
Contributor
|
changes look good. The test failure looks unrelated |
iche033
approved these changes
Apr 22, 2026
Contributor
iche033
left a comment
There was a problem hiding this comment.
thanks for the contribution!
Contributor
|
@Mergifyio backport gz-rendering10 gz-rendering9 gz-rendering8 |
Contributor
✅ Backports have been createdDetails
Cherry-pick of c001a37 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
This was referenced Apr 22, 2026
iche033
pushed a commit
that referenced
this pull request
Apr 22, 2026
Ogre2FrustumVisual::Update() computed nearWidth/nearHeight/farWidth/farHeight as full plane dimensions and then halved them when forming the per-corner offset vectors (upNearHeight2, rightNearWidth2, ...). Those offset vectors feed points[] / edges[] / planes[], which were therefore correct. The Ogre2DynamicRenderable used for the visible wireframe, however, was populated via AddPoint() calls that consumed the unhalved nearWidth, nearHeight, farWidth, farHeight directly as corner coordinates. Every drawn corner sat at twice its true distance from the optical axis, so the wireframe always showed roughly double the configured horizontal and vertical field of view (for example a logical_camera with horizontal_fov=1.047 rad / 60 deg was rendered as a cone of ~98 deg). Redefine the four locals as half-extents (drop the 2.0 factor) and drop the matching 0.5 factor from the offset vectors. The AddPoint() calls now consume the correct half-extents, while points[], edges[], and planes[] are geometrically unchanged. No public API change. Generated-by: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: MDEAGEWT <kmk6061602@naver.com> (cherry picked from commit c001a37)
iche033
pushed a commit
that referenced
this pull request
Apr 22, 2026
Ogre2FrustumVisual::Update() computed nearWidth/nearHeight/farWidth/farHeight as full plane dimensions and then halved them when forming the per-corner offset vectors (upNearHeight2, rightNearWidth2, ...). Those offset vectors feed points[] / edges[] / planes[], which were therefore correct. The Ogre2DynamicRenderable used for the visible wireframe, however, was populated via AddPoint() calls that consumed the unhalved nearWidth, nearHeight, farWidth, farHeight directly as corner coordinates. Every drawn corner sat at twice its true distance from the optical axis, so the wireframe always showed roughly double the configured horizontal and vertical field of view (for example a logical_camera with horizontal_fov=1.047 rad / 60 deg was rendered as a cone of ~98 deg). Redefine the four locals as half-extents (drop the 2.0 factor) and drop the matching 0.5 factor from the offset vectors. The AddPoint() calls now consume the correct half-extents, while points[], edges[], and planes[] are geometrically unchanged. No public API change. Generated-by: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: MDEAGEWT <kmk6061602@naver.com> (cherry picked from commit c001a37)
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.
🦟 Bug fix
Fixes N/A — bug was not previously filed as an issue.
Summary
Ogre2FrustumVisual::Update()renders the camera / logical_camera frustum wireframe at roughly double the configured field of view. TheLogicalCameraSensordetections and theplanes[]produced by the sameUpdate()are already correct — only the drawn wireframe is wrong.For a logical_camera with
horizontal_fov = 1.047 rad (60°)andaspect_ratio = 1.333, the current code draws a cone that measures ~98° across. This makes theVisualizeFrustumGUI plugin misleading: an object that looks "inside" the wireframe may in fact be outside the sensor's true FOV.Root cause
In
ogre2/src/Ogre2FrustumVisual.cc::Update()the four locals are defined as full plane dimensions:They are halved when building the per-corner offset vectors that feed
points[],edges[], andplanes[](so those are correct):But the
AddPoint()calls that populate theOgre2DynamicRenderable— i.e. the visible wireframe — use the un-halved values directly as the corner coordinate:Every rendered corner therefore sits at twice its true distance from the optical axis, and the drawn cone is roughly 2× wider / taller than the configured FOV.
Fix
Redefine the four locals as half-extents (drop the
2.0 *factor) and drop the matching* 0.5from the offset vectors. No other logic changes —points[],edges[], andplanes[]come out exactly the same, and there is no public API/ABI change.Diff: +11 / -11, single file (
ogre2/src/Ogre2FrustumVisual.cc).Reproduction & verification
Built the
rotarygazebodistro collection (everygz-*repo atmain) inside a container and ran a minimal world: alogical_camera+ an RGBcameraat the same pose(0, 1.5, 1.2)facing+Xwithhorizontal_fov = 1.047 rad, plus four1×1×1boxes — two of them placed at ~44° and ~49° off the optical axis, well outside the 30° half-FOV.In
gz sim, opened theVisualize Frustumplugin, subscribed to/station_dual/camera_info(the RGB CameraInfo path added in gazebosim/gz-sim#3374), and switched the scene to top-orthographic.Before (
main, unpatched) — wireframe encloses every box, including the two off-axis onesAfter (
main+ this patch) — wireframe matches the configured 60°The two off-axis boxes are now clearly outside the cone, matching what the actual sensor geometry says. The rendered RGB image on the right side of the window is unchanged, confirming that only the wireframe visualization differs.
Cross-check against the logical_camera topic on the same scene:
In the unpatched wireframe (Before),
red_boxandblue_box_1appear visually inside the cone even though the sensor correctly excludes them; after this patch, they sit outside the cone — the visualization now agrees with what the sensor has been reporting all along.The same fix was independently verified on
gz-rendering10(Jetty). TheOgre2FrustumVisual.cccontent is identical betweenmainandgz-rendering10aside from one unrelatedGZ_PROFILEmacro line.Checklist
codecheckpassed (See contributing)Generated-by: Claude Opus 4.7 noreply@anthropic.com
This PR was prepared with assistance from a generative AI tool (Claude). All code changes were manually reviewed, built, and visually verified by the contributor on both
gz-rendering10(Jetty) and themainrotary collection.