Skip to content

added clip option#175

Merged
orange-cpp merged 1 commit intomainfrom
feature/w2s_no_clip
Mar 21, 2026
Merged

added clip option#175
orange-cpp merged 1 commit intomainfrom
feature/w2s_no_clip

Conversation

@orange-cpp
Copy link
Owner

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the projection Camera API to optionally disable out-of-bounds rejection during world→NDC/screen projection, and adjusts naming around NDC→world unprojection.

Changes:

  • Added an auto_clip boolean option to world_to_screen() and world_to_view_port() to control whether out-of-bounds NDC returns an error.
  • Gated the NDC bounds check in world_to_view_port() behind auto_clip.
  • Renamed view_port_to_screen() to view_port_to_world() and updated screen_to_world() accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +281 to 282
if (auto_clip && is_ndc_out_of_bounds(projected))
return std::unexpected(Error::WORLD_POSITION_IS_OUT_OF_SCREEN_BOUNDS);
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

The new auto_clip branch changes behavior by allowing out-of-bounds NDC to be returned when auto_clip == false, but there are no unit tests covering this new path. Please add tests that assert: (1) out-of-bounds world positions still error with the default, and (2) the same positions return a value when auto_clip is disabled.

Copilot uses AI. Check for mistakes.
world_to_screen(const Vector3<float>& world_position, const bool auto_clip = true) const noexcept
{
const auto normalized_cords = world_to_view_port(world_position);
const auto normalized_cords = world_to_view_port(world_position, auto_clip);
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

Typo in variable name: normalized_cords reads like "cords" rather than "coords" (coordinates). Renaming would improve readability, especially since this variable is central to the projection logic.

Copilot uses AI. Check for mistakes.
}
[[nodiscard]]
std::expected<Vector3<float>, Error> view_port_to_screen(const Vector3<float>& ndc) const noexcept
std::expected<Vector3<float>, Error> view_port_to_world(const Vector3<float>& ndc) const noexcept
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

view_port_to_screen was renamed to view_port_to_world, but this is a public method on Camera (in an exported header) and will be a breaking API change for any downstream users. Consider keeping view_port_to_screen as a deprecated forwarding wrapper (or otherwise providing a compatibility alias) and documenting the rename.

Copilot uses AI. Check for mistakes.
Comment on lines +270 to 271
world_to_view_port(const Vector3<float>& world_position, const bool auto_clip = true) const noexcept
{
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

The new auto_clip parameter name is misleading: when enabled it doesn't clip coordinates, it rejects out-of-bounds NDC by returning an error. Consider renaming it to something like reject_out_of_bounds/validate_ndc_bounds, or add documentation clarifying that it controls the bounds-check behavior rather than geometric clipping.

Copilot uses AI. Check for mistakes.
@orange-cpp orange-cpp merged commit 7567501 into main Mar 21, 2026
24 checks passed
@orange-cpp orange-cpp deleted the feature/w2s_no_clip branch March 21, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants