Error fixes

This commit is contained in:
2025-06-06 21:49:20 -04:00
parent 2f74e45cc1
commit e3103457bc
9 changed files with 9 additions and 214 deletions

View File

@@ -9,6 +9,7 @@
#include <vector>
#include "engine/memory/buffers/BufferHandle.hpp"
#include <variant>
namespace vk
{

View File

@@ -10,6 +10,7 @@
#include "engine/primitives/points/Coordinate.hpp"
#include "rotation/QuatRotation.hpp"
#include "rotation/UniversalRotation.hpp"
#include <variant>
namespace fgl::engine
{

View File

@@ -6,6 +6,7 @@
#include <cassert>
#include <fstream>
#include <variant>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
@@ -107,11 +108,11 @@ namespace fgl::engine
{ .name = CompilerOptionName::Optimization,
.value = { .kind = CompilerOptionValueKind::Int,
.intValue0 = static_cast< int32_t >( SLANG_OPTIMIZATION_LEVEL_NONE ) } },
// .intValue0 = static_cast< int32_t >( SLANG_OPTIMIZATION_LEVEL_HIGH ) } },
// .intValue0 = static_cast< int32_t >( SLANG_OPTIMIZATION_LEVEL_HIGH ) } },
{ .name = CompilerOptionName::DebugInformation,
.value = { .kind = CompilerOptionValueKind::Int,
.intValue0 = static_cast< int32_t >( SLANG_DEBUG_INFO_LEVEL_MAXIMAL ) } },
// .intValue0 = static_cast< int32_t >( SLANG_DEBUG_INFO_LEVEL_MINIMAL ) } },
// .intValue0 = static_cast< int32_t >( SLANG_DEBUG_INFO_LEVEL_MINIMAL ) } },
{ .name = CompilerOptionName::EmitSpirvDirectly,
.value = { .kind = CompilerOptionValueKind::Int, .intValue0 = static_cast< int32_t >( true ) } },
} };

View File

@@ -9,10 +9,11 @@
#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>
#include "../../engine/primitives/rotation/QuatRotation.hpp"
#include "engine/primitives/Scale.hpp"
#include "engine/primitives/matricies/Matrix.hpp"
#include "engine/primitives/points/Coordinate.hpp"
#include "engine/primitives/rotation/EulerRotation.hpp"
#include "engine/primitives/rotation/QuatRotation.hpp"
#include "engine/primitives/vectors/Vector.hpp"
namespace Catch
@@ -63,7 +64,7 @@ namespace Catch
template <>
struct StringMaker< fgl::engine::EulerRotation >
{
static std::string convert( const fgl::engine::QuatRotation& rot )
static std::string convert( const fgl::engine::EulerRotation& rot )
{
return StringMaker< glm::vec3 >::convert( glm::vec3( rot.x, rot.y, rot.z ) );
}

View File

@@ -1,45 +0,0 @@
//
// Created by kj16609 on 2/15/25.
//
#include "primitives/boxes/OrientedBoundingBox.hpp"
#include <catch2/catch_all.hpp>
#include "tests/src/gtest_printers.hpp"
#include <engine/math/intersections/obb/intersections.hpp>
TEST_CASE( "Oriented Bounding Box", "[intersection][obb][coordinate]" )
{
using namespace fgl::engine;
SECTION( "Coordinate" )
{
constexpr Coordinate< CoordinateSpace::World > start_pos { 1.0, 1.0, 1.0 };
OrientedBoundingBox< CoordinateSpace::World > box { start_pos, glm::vec3( 1.0f ) };
box.getTransform().rotation.addX( 2.0 );
box.getTransform().rotation.addY( 2.0 );
box.getTransform().rotation.addZ( 2.0 );
WHEN( "Coordinate is outside the bounds of the box" )
{
Coordinate< CoordinateSpace::World > coord { 5.0, 5.0, 5.0 };
THEN( "The intersection should fail" )
{
REQUIRE( !intersections::contains( box, coord ) );
}
}
WHEN("Coordinate is inside of the bounds of the box")
{
Coordinate< CoordinateSpace::World > coord { 1.0, 1.0, 1.0 };
THEN( "The intersection should pass" )
{
REQUIRE( intersections::contains( box, coord ) );
}
}
}
}

View File

@@ -1,108 +0,0 @@
//
// Created by kj16609 on 1/30/25.
//
#include <catch2/catch_all.hpp>
#include "tests/src/gtest_printers.hpp"
using namespace Catch::literals;
TEST_CASE( "Quaternions", "[math][rotation]" )
{
SECTION( "Default" )
{
fgl::engine::QuatRotation rot {};
SECTION( "Raw" )
{
const glm::quat raw_quat { rot.internal_quat() };
REQUIRE( raw_quat.x == 0.0f );
REQUIRE( raw_quat.y == 0.0f );
REQUIRE( raw_quat.z == 0.0f );
REQUIRE( raw_quat.w == 1.0f );
}
}
SECTION( "Predefined" )
{
SECTION( "-1.126, 1.012, -0.548" )
{
fgl::engine::QuatRotation rot { -1.256f, 1.012f, -0.548 };
REQUIRE_THAT( rot.internal_quat().w, Catch::Matchers::WithinAbs( 0.604f, 0.1f ) );
REQUIRE_THAT( rot.internal_quat().x, Catch::Matchers::WithinAbs( -0.601f, 0.1f ) );
REQUIRE_THAT( rot.internal_quat().y, Catch::Matchers::WithinAbs( -0.239f, 0.1f ) );
REQUIRE_THAT( rot.internal_quat().z, Catch::Matchers::WithinAbs( -0.466f, 0.1f ) );
}
}
SECTION( "Test xRange" )
{
for ( std::size_t i = 0; i < 360; ++i )
{
DYNAMIC_SECTION( "X Angle" << i )
{
constexpr float offset { std::numbers::pi_v< float > / 360.0f };
fgl::engine::QuatRotation rot1 { static_cast< float >( i ) * offset, 0.0f, 0.0f };
fgl::engine::QuatRotation rot2 { 0.0f, 0.0f, 0.0f };
for ( std::size_t x = 0; x < i; ++x ) rot2.addX( offset );
// compare both quaternions
using namespace Catch::Matchers;
REQUIRE_THAT( rot1.internal_quat().x, WithinAbs( rot2.internal_quat().x, 0.01f ) );
REQUIRE_THAT( rot1.internal_quat().y, WithinAbs( rot2.internal_quat().y, 0.01f ) );
REQUIRE_THAT( rot1.internal_quat().z, WithinAbs( rot2.internal_quat().z, 0.01f ) );
REQUIRE_THAT( rot1.internal_quat().w, WithinAbs( rot2.internal_quat().w, 0.01f ) );
}
}
SECTION( "Test yRange" )
{
for ( std::size_t i = 0; i < 360; ++i )
{
DYNAMIC_SECTION( "Y Angle: " << i )
{
constexpr float offset { std::numbers::pi_v< float > / 360.0f };
fgl::engine::QuatRotation rot1 { 0.0f, static_cast< float >( i ) * offset, 0.0f };
fgl::engine::QuatRotation rot2 { 0.0f, 0.0f, 0.0f };
for ( std::size_t x = 0; x < i; ++x ) rot2.addY( offset );
// compare both quaternions
using namespace Catch::Matchers;
REQUIRE_THAT( rot1.internal_quat().x, WithinAbs( rot2.internal_quat().x, 0.01f ) );
REQUIRE_THAT( rot1.internal_quat().y, WithinAbs( rot2.internal_quat().y, 0.01f ) );
REQUIRE_THAT( rot1.internal_quat().z, WithinAbs( rot2.internal_quat().z, 0.01f ) );
REQUIRE_THAT( rot1.internal_quat().w, WithinAbs( rot2.internal_quat().w, 0.01f ) );
}
}
}
SECTION( "Test zRange" )
{
for ( std::size_t i = 0; i < 360; ++i )
{
DYNAMIC_SECTION( "Z Angle" << i )
{
constexpr float offset { std::numbers::pi_v< float > / 360.0f };
fgl::engine::QuatRotation rot1 { 0.0f, 0.0f, static_cast< float >( i ) * offset };
fgl::engine::QuatRotation rot2 { 0.0f, 0.0f, 0.0f };
for ( std::size_t x = 0; x < i; ++x ) rot2.addZ( offset );
// compare both quaternions
using namespace Catch::Matchers;
REQUIRE_THAT( rot1.internal_quat().x, WithinAbs( rot2.internal_quat().x, 0.01f ) );
REQUIRE_THAT( rot1.internal_quat().y, WithinAbs( rot2.internal_quat().y, 0.01f ) );
REQUIRE_THAT( rot1.internal_quat().z, WithinAbs( rot2.internal_quat().z, 0.01f ) );
REQUIRE_THAT( rot1.internal_quat().w, WithinAbs( rot2.internal_quat().w, 0.01f ) );
}
}
}
}
}

View File

@@ -1,24 +0,0 @@
//
// Created by kj16609 on 2/18/25.
//
#include "primitives/Transform.hpp"
#include <catch2/catch_test_macros.hpp>
TEST_CASE( "Transform", "[transform]" )
{
using namespace fgl::engine::v2;
SECTION( "Default" )
{
TransformComponent transform {};
}
}

View File

@@ -1,32 +0,0 @@
//
// Created by kj16609 on 8/4/24.
//
#pragma once
namespace fgl::engine
{
inline bool operator==( const NormalVector& left, const NormalVector& right )
{
const glm::vec3 high_range { left.vec() + glm::vec3( std::numeric_limits< float >::epsilon() ) };
const glm::vec3 low_range { left.vec() - glm::vec3( std::numeric_limits< float >::epsilon() ) };
const auto within_high { glm::lessThanEqual( right.vec(), high_range ) };
const auto within_low { glm::greaterThanEqual( right.vec(), low_range ) };
return glm::all( within_high ) && glm::all( within_low );
}
inline bool operator==( const Vector& left, const Vector& right )
{
const glm::vec3 high_range { left.vec() + glm::vec3( std::numeric_limits< float >::epsilon() ) };
const glm::vec3 low_range { left.vec() - glm::vec3( std::numeric_limits< float >::epsilon() ) };
const auto within_high { glm::lessThanEqual( right.vec(), high_range ) };
const auto within_low { glm::greaterThanEqual( right.vec(), low_range ) };
return glm::all( within_high ) && glm::all( within_low );
}
} // namespace fgl::engine