Skip to content

added AABB check#179

Merged
orange-cpp merged 1 commit intomainfrom
feature/aabb_check
Mar 24, 2026
Merged

added AABB check#179
orange-cpp merged 1 commit intomainfrom
feature/aabb_check

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 adds an axis-aligned bounding box (AABB) primitive and introduces frustum-culling support for AABBs on the generic projection camera, with unit tests covering several culling scenarios across engine camera variants.

Changes:

  • Add omath::primitives::Aabb type.
  • Add Camera::is_aabb_culled_by_frustum(...) using view-projection plane extraction.
  • Add unit tests validating AABB frustum culling for Source/Unity/OpenGL camera conventions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/general/unit_test_projection.cpp Adds a suite of AABB/frustum culling unit tests across multiple engine camera types.
include/omath/projection/camera.hpp Adds AABB frustum culling API to the core templated camera.
include/omath/3d_primitives/aabb.hpp Introduces a new AABB struct (min/max corners).
Comments suppressed due to low confidence (1)

include/omath/projection/camera.hpp:11

  • camera.hpp uses std::array (including in the newly added frustum/AABB code) but does not include <array> directly, relying on transitive includes via other headers. This makes the header fragile if includes change; add #include <array> here.
#include "omath/3d_primitives/aabb.hpp"
#include "omath/linear_algebra/mat.hpp"
#include "omath/linear_algebra/triangle.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include "omath/projection/error_codes.hpp"

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

Comment on lines +312 to +313
[[nodiscard]] bool is_aabb_culled_by_frustum(const primitives::Aabb<float>& aabb) const noexcept
{
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The API naming is inconsistent: this introduces is_aabb_culled_by_frustum(...) while an existing overload uses is_culled_by_frustum(...) for triangles. Consider making this an overload named is_culled_by_frustum(const primitives::Aabb<float>&) (or otherwise aligning the naming) to improve discoverability and consistency.

Copilot uses AI. Check for mistakes.
Comment on lines +322 to +330
TEST(UnitTestProjection, AabbCulledUnityEngine)
{
constexpr auto fov = omath::projection::FieldOfView::from_degrees(60.f);
const auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1280.f, 720.f}, fov, 0.03f, 1000.f);

// Box in front — not culled
const omath::primitives::Aabb<float> inside{{-1.f, -1.f, 50.f}, {1.f, 1.f, 100.f}};
EXPECT_FALSE(cam.is_aabb_culled_by_frustum(inside));

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This test name is misleading: AabbCulledUnityEngine contains both an "inside" (not culled) assertion and a "behind" (culled) assertion. Consider renaming it to reflect both behaviors or splitting into two focused tests so failures are easier to interpret.

Copilot uses AI. Check for mistakes.
Comment on lines +495 to +501
TEST(UnitTestProjection, AabbUnityEngineSideCulled)
{
constexpr auto fov = omath::projection::FieldOfView::from_degrees(60.f);
const auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1280.f, 720.f}, fov, 0.03f, 1000.f);

// Box far above (Unity: +Y up)
const omath::primitives::Aabb<float> aabb{{-1.f, 5000.f, 50.f}, {1.f, 6000.f, 100.f}};
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

AabbUnityEngineSideCulled appears to be testing an AABB far above the frustum (per the comment and Y values), not a generic "side" cull. Renaming the test to match what it checks (e.g., above/top culling) would reduce confusion when reading failures.

Copilot uses AI. Check for mistakes.
@orange-cpp orange-cpp merged commit 0b52b28 into main Mar 24, 2026
24 checks passed
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