<commit_before>#include <Core/Math/Math.hpp>
#include <Engine/RadiumEngine.hpp>
#include <Engine/Scene/Camera.hpp>
#include <Engine/Scene/Entity.hpp>
#include <iostream>

#include <catch2/catch.hpp>

TEST_CASE( "Engine/Camera" ) {
    using namespace Ra::Engine::Data;
    using namespace Ra::Core;

    Camera* cam = new Camera {10, 10};

    REQUIRE( Math::areApproxEqual( cam->getZNear(), 0.1_ra ) );
    REQUIRE( Math::areApproxEqual( cam->getZFar(), 1000_ra ) );

    auto dir = Ra::Core::Vector3 {1, 1, 1};
    auto pos = Ra::Core::Vector3 {0, 0, 0};
    cam->setPosition( pos );
    cam->setDirection( dir );

    REQUIRE( dir.normalized().isApprox( cam->getDirection() ) );

    /// \todo add section when cleanup is ok, now it locks tests in case of failure ...
    //    SECTION( "aabb" ) {
    Ra::Core::Aabb aabb {Ra::Core::Vector3 {3, 3, 3}, Ra::Core::Vector3 {6, 6, 6}};
    cam->fitZRange( aabb );
    REQUIRE(
        ( Math::areApproxEqual( cam->getZNear(), ( cam->getPosition() - aabb.min() ).norm() ) ||
          cam->getZNear() == cam->m_minZNear ) );
    REQUIRE(
        Math::areApproxEqual( cam->getZFar(), ( cam->getPosition() - aabb.max() ).norm(), 16_ra ) );
    REQUIRE( ( cam->getZNear() > cam->m_minZNear ||
               Math::areApproxEqual( cam->getZNear(), cam->m_minZNear ) ) );
    REQUIRE( ( ( cam->getZFar() - cam->getZNear() ) > cam->m_minZRange ||
               Math::areApproxEqual( ( cam->getZFar() - cam->getZNear() ), cam->m_minZRange ) ) );

    aabb = {Ra::Core::Vector3 {-1, -1, -1}, Ra::Core::Vector3 {1, 1, 1}};
    cam->fitZRange( aabb );
    REQUIRE( Math::areApproxEqual( cam->getZNear(), cam->m_minZNear ) );
    REQUIRE( ( Math::areApproxEqual( cam->getZFar(), ( cam->getPosition() - aabb.max() ).norm() ) ||
               Math::areApproxEqual( cam->getZFar() - cam->getZNear(), cam->m_minZRange ) ) );
    REQUIRE( ( cam->getZNear() > cam->m_minZNear ||
               Math::areApproxEqual( cam->getZNear(), cam->m_minZNear ) ) );
    REQUIRE( ( ( cam->getZFar() - cam->getZNear() ) > cam->m_minZRange ||
               Math::areApproxEqual( ( cam->getZFar() - cam->getZNear() ), cam->m_minZRange ) ) );

    aabb = {Ra::Core::Vector3 {-2, -1, 1}, Ra::Core::Vector3 {-4, -1, 0}};
    cam->fitZRange( aabb );
    REQUIRE( Math::areApproxEqual( cam->getZNear(), cam->m_minZNear ) );
    REQUIRE( Math::areApproxEqual( cam->getZFar(), cam->getZNear() + cam->m_minZRange ) );

    aabb = {Ra::Core::Vector3 {0, -3, 0}, Ra::Core::Vector3 {1, -2, 1}};
    cam->fitZRange( aabb );
    REQUIRE( Math::areApproxEqual( cam->getZNear(), cam->m_minZNear ) );
    REQUIRE( Math::areApproxEqual( cam->getZFar(), cam->getZNear() + cam->m_minZRange ) );
    //}
}<commit_msg>[tests] add section to camera test.<commit_after>#include <Core/Math/Math.hpp>
#include <Engine/RadiumEngine.hpp>
#include <Engine/Scene/Camera.hpp>
#include <Engine/Scene/Entity.hpp>
#include <iostream>

#include <catch2/catch.hpp>

TEST_CASE( "Engine/Camera" ) {
    using namespace Ra::Engine::Data;
    using namespace Ra::Core;

    Camera* cam = new Camera {10, 10};

    REQUIRE( Math::areApproxEqual( cam->getZNear(), 0.1_ra ) );
    REQUIRE( Math::areApproxEqual( cam->getZFar(), 1000_ra ) );

    auto dir = Ra::Core::Vector3 {1, 1, 1};
    auto pos = Ra::Core::Vector3 {0, 0, 0};
    cam->setPosition( pos );
    cam->setDirection( dir );

    REQUIRE( dir.normalized().isApprox( cam->getDirection() ) );

    SECTION( "fit aabb" ) {
        Ra::Core::Aabb aabb {Ra::Core::Vector3 {3, 3, 3}, Ra::Core::Vector3 {6, 6, 6}};
        cam->fitZRange( aabb );
        REQUIRE(
            ( Math::areApproxEqual( cam->getZNear(), ( cam->getPosition() - aabb.min() ).norm() ) ||
              cam->getZNear() == cam->m_minZNear ) );
        REQUIRE( Math::areApproxEqual(
            cam->getZFar(), ( cam->getPosition() - aabb.max() ).norm(), 16_ra ) );
        REQUIRE( ( cam->getZNear() > cam->m_minZNear ||
                   Math::areApproxEqual( cam->getZNear(), cam->m_minZNear ) ) );
        REQUIRE(
            ( ( cam->getZFar() - cam->getZNear() ) > cam->m_minZRange ||
              Math::areApproxEqual( ( cam->getZFar() - cam->getZNear() ), cam->m_minZRange ) ) );

        aabb = {Ra::Core::Vector3 {-1, -1, -1}, Ra::Core::Vector3 {1, 1, 1}};
        cam->fitZRange( aabb );
        REQUIRE( Math::areApproxEqual( cam->getZNear(), cam->m_minZNear ) );
        REQUIRE(
            ( Math::areApproxEqual( cam->getZFar(), ( cam->getPosition() - aabb.max() ).norm() ) ||
              Math::areApproxEqual( cam->getZFar() - cam->getZNear(), cam->m_minZRange ) ) );
        REQUIRE( ( cam->getZNear() > cam->m_minZNear ||
                   Math::areApproxEqual( cam->getZNear(), cam->m_minZNear ) ) );
        REQUIRE(
            ( ( cam->getZFar() - cam->getZNear() ) > cam->m_minZRange ||
              Math::areApproxEqual( ( cam->getZFar() - cam->getZNear() ), cam->m_minZRange ) ) );

        aabb = {Ra::Core::Vector3 {-2, -1, 1}, Ra::Core::Vector3 {-4, -1, 0}};
        cam->fitZRange( aabb );
        REQUIRE( Math::areApproxEqual( cam->getZNear(), cam->m_minZNear ) );
        REQUIRE( Math::areApproxEqual( cam->getZFar(), cam->getZNear() + cam->m_minZRange ) );

        aabb = {Ra::Core::Vector3 {0, -3, 0}, Ra::Core::Vector3 {1, -2, 1}};
        cam->fitZRange( aabb );
        REQUIRE( Math::areApproxEqual( cam->getZNear(), cam->m_minZNear ) );
        REQUIRE( Math::areApproxEqual( cam->getZFar(), cam->getZNear() + cam->m_minZRange ) );
    }
}
{'fraction_non_alphanumeric': 0.2067648663393344, 'fraction_numerical': 0.01927623204218949, 'mean_word_length': 3.0058266569555716, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 127, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3846518', 'n_tokens_mistral': 2204, 'n_tokens_neox': 2021, 'n_words': 371}