Skip to content

Commit 71b802f

Browse files
Enable Dependency management with fetchcontent
- Renamed the cmake imported targets for the ZEngine and Tetragrama dependencies. - Change output location for the vulkan-loader to use FetchContent locations
1 parent c90975b commit 71b802f

8 files changed

Lines changed: 78 additions & 16 deletions

File tree

.github/workflows/Engine-CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
on:
22
push:
3-
branches: [ master, develop, arena-integration ]
3+
branches: [ master, develop, arena-integration, compile_on_linux_fetchcontent ]
44
pull_request:
55
branches: [ master, develop, arena-integration ]
66

Obelisk/EntryPoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int applicationEntryPoint(int argc, char* argv[])
1818
MemoryManager manager = {};
1919
MemoryConfiguration config = {.DefaultSize = ZGiga(3u)};
2020
manager.Initialize(config);
21-
auto arena = &(manager.Allocator);
21+
auto arena = &(manager.ArenaAllocatorValue);
2222

2323
LoggerConfiguration logger_cfg = {};
2424
Logger::Initialize(arena, logger_cfg);

Scripts/RunTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ function RunTests {
7777
}
7878
# Run tests for each configuration
7979
foreach ($config in $Configurations) {
80-
RunTests -Configuration $config
80+
RunTests -Configuration $config
8181
}

ZEngine/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@ project (ZEngine
66
LANGUAGES CXX C
77
)
88

9-
set (CMAKE_CXX_STANDARD_REQUIRED ON)
10-
set (CMAKE_CXX_STANDARD 20)
11-
129
add_subdirectory (ZEngine)
1310
add_subdirectory (tests)

ZEngine/ZEngine/Core/Memory/MemoryManager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ namespace ZEngine::Core::Memory
1212
{
1313
void Initialize(const MemoryConfiguration& config)
1414
{
15-
this->Allocator.Initialize(config.DefaultSize);
15+
this->ArenaAllocatorValue.Initialize(config.DefaultSize);
1616
}
1717

1818
void Shutdowm()
1919
{
20-
Allocator.Shutdown();
20+
ArenaAllocatorValue.Shutdown();
2121
}
2222

23-
ArenaAllocator Allocator = {};
23+
ArenaAllocator ArenaAllocatorValue = {};
2424
};
2525
} // namespace ZEngine::Core::Memory

ZEngine/ZEngine/Maths/Math.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include <Maths/Math.h>
2+
3+
#include <glm/gtx/matrix_decompose.hpp>
4+
5+
namespace glm
6+
{
7+
8+
bool DecomposeTransformComponent(const Matrix4& transform, Vector3& translation, Vector3& rotation, Vector3& scale)
9+
{
10+
// From glm::decompose in matrix_decompose.inl
11+
12+
using T = float;
13+
14+
mat4 LocalMatrix(transform);
15+
16+
// Normalize the matrix.
17+
if (epsilonEqual(LocalMatrix[3][3], static_cast<float>(0), epsilon<T>()))
18+
return false;
19+
20+
// First, isolate perspective. This is the messiest.
21+
if (epsilonNotEqual(LocalMatrix[0][3], static_cast<T>(0), epsilon<T>()) || epsilonNotEqual(LocalMatrix[1][3], static_cast<T>(0), epsilon<T>()) || epsilonNotEqual(LocalMatrix[2][3], static_cast<T>(0), epsilon<T>()))
22+
{
23+
// Clear the perspective partition
24+
LocalMatrix[0][3] = LocalMatrix[1][3] = LocalMatrix[2][3] = static_cast<T>(0);
25+
LocalMatrix[3][3] = static_cast<T>(1);
26+
}
27+
28+
// Next take care of translation (easy).
29+
translation = vec3(LocalMatrix[3]);
30+
LocalMatrix[3] = vec4(0, 0, 0, LocalMatrix[3].w);
31+
32+
vec3 Row[3], Pdum3;
33+
34+
// Now get scale and shear.
35+
for (length_t i = 0; i < 3; ++i)
36+
for (length_t j = 0; j < 3; ++j)
37+
Row[i][j] = LocalMatrix[i][j];
38+
39+
// Compute X scale factor and normalize first row.
40+
scale.x = length(Row[0]);
41+
Row[0] = detail::scale(Row[0], static_cast<T>(1));
42+
scale.y = length(Row[1]);
43+
Row[1] = detail::scale(Row[1], static_cast<T>(1));
44+
scale.z = length(Row[2]);
45+
Row[2] = detail::scale(Row[2], static_cast<T>(1));
46+
47+
// At this point, the matrix (in rows[]) is orthonormal.
48+
// Check for a coordinate system flip. If the determinant
49+
// is -1, then negate the matrix and the scaling factors.
50+
51+
rotation.y = asin(-Row[0][2]);
52+
if (cos(rotation.y) != 0)
53+
{
54+
rotation.x = atan2(Row[1][2], Row[2][2]);
55+
rotation.z = atan2(Row[0][1], Row[0][0]);
56+
}
57+
else
58+
{
59+
rotation.x = atan2(-Row[2][0], Row[1][1]);
60+
rotation.z = 0;
61+
}
62+
63+
return true;
64+
}
65+
} // namespace glm

ZEngine/tests/Memory/allocator_test.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ TEST(AllocatorTest, ArenaMemoryManager)
8282
void Func() {}
8383
};
8484

85-
int* intPtr = ZPushArray(&(manager.Allocator), int, 1);
86-
auto structPtr = ZPushStruct(&(manager.Allocator), Foo);
85+
int* intPtr = ZPushArray(&(manager.ArenaAllocatorValue), int, 1);
86+
auto structPtr = ZPushStruct(&(manager.ArenaAllocatorValue), Foo);
8787

8888
*intPtr = 12;
8989
structPtr->x = 12;
9090
structPtr->y = 798.0f;
9191

92-
char* str = ZPushString(&(manager.Allocator), 12);
92+
char* str = ZPushString(&(manager.ArenaAllocatorValue), 12);
9393
Helpers::secure_memmove(str, 12, "hello", 5);
9494

9595
EXPECT_EQ(*intPtr, 12);
@@ -121,7 +121,7 @@ TEST(AllocatorTest, ArenaMemoryTemp)
121121
{
122122
MemoryManager manager{};
123123
manager.Initialize({.DefaultSize = ZKilo(10)});
124-
auto arena = &(manager.Allocator);
124+
auto arena = &(manager.ArenaAllocatorValue);
125125
{
126126
auto fooPtr = ZPushStruct(arena, Foo);
127127
fooPtr->x = 10;
@@ -142,7 +142,7 @@ TEST(AllocatorTest, ArenaMemoryPool)
142142
{
143143
MemoryManager manager{};
144144
manager.Initialize({.DefaultSize = ZKilo(10)});
145-
auto arena = &(manager.Allocator);
145+
auto arena = &(manager.ArenaAllocatorValue);
146146
{
147147
PoolAllocator pool;
148148
pool.Initialize(arena, sizeof(Foo) * 100, sizeof(Foo));

ZEngine/tests/Memory/handleManager_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class HandleManagerTest : public ::testing::Test
1010
void SetUp() override
1111
{
1212
manager.Initialize({.DefaultSize = ZKilo(10)});
13-
auto arena = &(manager.Allocator);
13+
auto arena = &(manager.ArenaAllocatorValue);
1414
handle_manager.Initialize(arena, 10);
1515
}
1616

@@ -114,7 +114,7 @@ TEST_F(HandleManagerTest, ReuseSlot)
114114
TEST_F(HandleManagerTest, ConcurrentAccess)
115115
{
116116
ZEngine::Helpers::HandleManager<int*> h_manager;
117-
h_manager.Initialize(&(manager.Allocator), 40);
117+
h_manager.Initialize(&(manager.ArenaAllocatorValue), 40);
118118
const int numThreads = 4;
119119
const int numOperationsPerThread = 10;
120120
std::vector<std::thread> threads;

0 commit comments

Comments
 (0)