Skip to content

Commit 2bc58e9

Browse files
authored
Removed GLM Library (#471)
* another one * normalize test
1 parent 39ebde2 commit 2bc58e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+759
-493
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ bld/
3636

3737
# Submodules folder
3838
__externals/fmt
39-
__externals/glm
4039
__externals/imgui/src
4140
__externals/imgui/src/examples/example_glfw_vulkan/out/
4241
__externals/SDL2

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@
5252
[submodule "__externals/Vulkan-Loader"]
5353
path = __externals/Vulkan-Loader
5454
url = https://github.com/KhronosGroup/Vulkan-Loader
55-
[submodule "__externals/glm"]
56-
path = __externals/glm
57-
url = https://github.com/g-truc/glm
5855
[submodule "__externals/Vulkan-Headers"]
5956
path = __externals/Vulkan-Headers
6057
url = https://github.com/KhronosGroup/Vulkan-Headers

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ if (NOT LAUNCHER_ONLY)
4646
add_subdirectory (${EXTERNAL_DIR}/imgui)
4747
add_subdirectory (${EXTERNAL_DIR}/glfw)
4848
add_subdirectory (${EXTERNAL_DIR}/spdlog)
49-
add_subdirectory (${EXTERNAL_DIR}/glm)
5049
add_subdirectory (${EXTERNAL_DIR}/entt)
5150
add_subdirectory (${EXTERNAL_DIR}/assimp)
5251
add_subdirectory (${EXTERNAL_DIR}/stduuid)

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ See our roadmap here [Roadmap](Roadmap.md)
8787

8888
The project uses the following dependencies as submodules :
8989
- [GLFW](https://github.com/glfw/glfw) for window creation and user input management for Windows, Linux, and MacOS,
90-
- [GLM](https://glm.g-truc.net/0.9.9/index.html) for functions and mathematical calculations,
9190
- [STB](https://github.com/nothings/stb) for loading and manipulating image files for textures.
9291
- [ImGUI](https://github.com/ocornut/imgui) for GUI components and interaction.
9392
- [SPDLOG](https://github.com/gabime/spdlog) for logging

Scripts/BuildEngine.ps1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
137137
}
138138

139139
# Define CMake Generator arguments
140-
$cMakeOptions = " -DCMAKE_SYSTEM_NAME=$systemName", " -DCMAKE_BUILD_TYPE=$configuration"
140+
$cMakeOptions = " -DCMAKE_SYSTEM_NAME=$systemName", " -DCMAKE_BUILD_TYPE=$configuration", "-DCMAKE_POLICY_VERSION_MINIMUM=3.5"
141141
$submoduleCMakeOptions = @{
142142
'ENTT' = @("-DENTT_INCLUDE_HEADERS=ON")
143143
'SPDLOG' = @("-DSPDLOG_BUILD_SHARED=OFF", "-DBUILD_STATIC_LIBS=ON", "-DSPDLOG_FMT_EXTERNAL=ON", "-DSPDLOG_FMT_EXTERNAL_HO=OFF");
@@ -150,7 +150,6 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
150150
'SPIRV_TOOLS' = @("-DSPIRV_SKIP_EXECUTABLES=ON", "-DSPIRV_SKIP_TESTS=ON")
151151
'SPIRV_CROSS' = @("-DSPIRV_CROSS_ENABLE_TESTS=OFF")
152152
'LAUNCHER_ONLY' = @("-DLAUNCHER_ONLY=ON")
153-
'GLM' = @("-DCMAKE_POLICY_VERSION_MINIMUM=3.5")
154153
}
155154

156155
$cMakeCacheVariableOverride = $cMakeOptions -join ' '
@@ -192,7 +191,6 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
192191
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.SPIRV_CROSS -join ' '
193192
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.SPIRV_TOOLS -join ' '
194193
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.GLFW -join ' '
195-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.GLM -join ' '
196194
}
197195

198196
$cMakeArguments = " -S $repositoryRootPath -B $buildDirectoryPath $cMakeGenerator $cMakeCacheVariableOverride"

Tetragrama/Components/HierarchyViewUIComponent.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
#include <Editor.h>
33
#include <HierarchyViewUIComponent.h>
44
#include <ImGuizmo/ImGuizmo.h>
5+
#include <ZEngine/Core/Maths/Matrix.h>
56
#include <ZEngine/Managers/AssetManager.h>
67
#include <ZEngine/Rendering/Scenes/GraphicScene.h>
78
#include <ZEngine/Windows/Inputs/KeyCodeDefinition.h>
89
#include <ZEngine/Windows/Inputs/Keyboard.h>
910
#include <ZEngine/Windows/Inputs/Mouse.h>
10-
#include <glm/glm.hpp>
11-
#include <glm/gtc/type_ptr.hpp>
1211

1312
using namespace ZEngine;
1413
using namespace ZEngine::Helpers;
1514
using namespace ZEngine::Windows::Inputs;
1615
using namespace ZEngine::Rendering::Scenes;
16+
using namespace ZEngine::Core::Maths;
1717

1818
namespace Tetragrama::Components
1919
{
@@ -233,7 +233,7 @@ namespace Tetragrama::Components
233233
if (camera && IDevice::As<Keyboard>()->IsKeyPressed(ZENGINE_KEY_F, app->CurrentWindow))
234234
{
235235
auto active_editor_camera = reinterpret_cast<Controllers::EditorCameraControllerPtr>(app->CameraController);
236-
active_editor_camera->SetTarget(glm::vec3(global_transform[0][3], global_transform[1][3], global_transform[2][3]));
236+
active_editor_camera->SetTarget(Vec3f(global_transform[0][3], global_transform[1][3], global_transform[2][3]));
237237
}
238238

239239
// snapping
@@ -247,10 +247,10 @@ namespace Tetragrama::Components
247247

248248
if (m_gizmo_operation > 0)
249249
{
250-
ImGuizmo::Manipulate(glm::value_ptr(camera_view_matrix), glm::value_ptr(camera_projection), (ImGuizmo::OPERATION) m_gizmo_operation, ImGuizmo::MODE::WORLD, glm::value_ptr(global_transform), nullptr, is_snap_operation ? snap_array : nullptr);
250+
ImGuizmo::Manipulate(value_ptr(camera_view_matrix), value_ptr(camera_projection), (ImGuizmo::OPERATION) m_gizmo_operation, ImGuizmo::MODE::WORLD, value_ptr(global_transform), nullptr, is_snap_operation ? snap_array : nullptr);
251251
}
252252

253-
auto delta_transform = glm::inverse(initial_transform) * global_transform;
253+
auto delta_transform = initial_transform.Inverse() * global_transform;
254254
local_transform = local_transform * delta_transform;
255255
// current_scene->MarkSceneNodeAsChanged(m_selected_node_identifier);
256256

Tetragrama/Components/InspectorViewUIComponent.cpp

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
#include <InspectorViewUIComponent.h>
33
#include <UIComponentDrawerHelper.h>
44
#include <ZEngine/Core/Coroutine.h>
5+
#include <ZEngine/Core/Maths/Matrix.h>
56
#include <ZEngine/Helpers/MeshHelper.h>
67
#include <ZEngine/Rendering/Textures/Texture.h>
78

8-
#define GLM_ENABLE_EXPERIMENTAL
9-
#include <glm/gtx/matrix_decompose.hpp>
10-
119
using namespace ZEngine::Rendering::Textures;
1210
using namespace ZEngine::Helpers;
11+
using namespace ZEngine::Core::Maths;
1312

1413
namespace Tetragrama::Components
1514
{
@@ -56,20 +55,20 @@ namespace Tetragrama::Components
5655
// Helpers::DrawEntityControl("Transform", m_scene_entity, m_node_flag, [this] {
5756
// auto transform = m_scene_entity.GetTransform();
5857

59-
// glm::vec3 translation, scale, skew;
60-
// glm::qua<float> rot_quat;
61-
// glm::vec4 perspective;
62-
// glm::decompose(transform, scale, rot_quat, translation, skew, perspective);
58+
// Vec3f translation, scale, skew;
59+
// Quaternion<float> rot_quat;
60+
// Vec4f perspective;
61+
// decompose(transform, scale, rot_quat, translation, skew, perspective);
6362

6463
// ImGui::Dummy(ImVec2(0, 3));
65-
// Helpers::DrawVec3Control("Position", translation, [&translation](glm::vec3& value) { translation = value; });
64+
// Helpers::DrawVec3Control("Position", translation, [&translation](Vec3f& value) { translation = value; });
6665

67-
// glm::vec3 rotation = glm::eulerAngles(rot_quat);
66+
// Vec3f rotation = eulerAngles(rot_quat);
6867
// ImGui::Dummy(ImVec2(0, 0.5));
69-
// Helpers::DrawVec3Control("Rotation", rotation, [&rotation](glm::vec3& value) { rotation = value; });
68+
// Helpers::DrawVec3Control("Rotation", rotation, [&rotation](Vec3f& value) { rotation = value; });
7069

7170
// ImGui::Dummy(ImVec2(0, 0.5));
72-
// Helpers::DrawVec3Control("Scale", scale, [&scale](glm::vec3& value) { scale = value; }, 1.0f);
71+
// Helpers::DrawVec3Control("Scale", scale, [&scale](Vec3f& value) { scale = value; }, 1.0f);
7372
//});
7473

7574
// Mesh Renderer
@@ -143,24 +142,24 @@ namespace Tetragrama::Components
143142
if (light_type == LightType::DIRECTIONAL)
144143
{
145144
auto light_ptr = reinterpret_cast<DirectionalLight*>(light.get());
146-
auto direction = light_ptr->Direction.As<glm::vec3>();
147-
auto ambient = light_ptr->Ambient.As<glm::vec3>();
148-
auto diffuse = light_ptr->Diffuse.As<glm::vec3>();
149-
auto specular = light_ptr->Specular.As<glm::vec3>();
145+
auto direction = light_ptr->Direction.As<Vec3f>();
146+
auto ambient = light_ptr->Ambient.As<Vec3f>();
147+
auto diffuse = light_ptr->Diffuse.As<Vec3f>();
148+
auto specular = light_ptr->Specular.As<Vec3f>();
150149
151150
ImGui::Dummy(ImVec2(0, 0.5f));
152151
{
153-
Helpers::DrawVec3Control("Direction", direction, [light_ptr](glm::vec3& value) {
154-
light_ptr->Direction = glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
152+
Helpers::DrawVec3Control("Direction", direction, [light_ptr](Vec3f& value) {
153+
light_ptr->Direction = Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
155154
156-
Helpers::DrawColorEdit3Control("Ambient", ambient, [light_ptr](glm::vec3& value) {
157-
light_ptr->Ambient = glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
155+
Helpers::DrawColorEdit3Control("Ambient", ambient, [light_ptr](Vec3f& value) {
156+
light_ptr->Ambient = Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
158157
159-
Helpers::DrawColorEdit3Control("Diffuse", diffuse, [light_ptr](glm::vec3& value) {
160-
light_ptr->Diffuse = glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
158+
Helpers::DrawColorEdit3Control("Diffuse", diffuse, [light_ptr](Vec3f& value) {
159+
light_ptr->Diffuse = Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
161160
162-
Helpers::DrawColorEdit3Control("Specular", specular, [light_ptr](glm::vec3& value) {
163-
light_ptr->Specular = glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
161+
Helpers::DrawColorEdit3Control("Specular", specular, [light_ptr](Vec3f& value) {
162+
light_ptr->Specular = Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
164163
}
165164
}
166165
@@ -169,24 +168,24 @@ namespace Tetragrama::Components
169168
auto transform = m_scene_entity.GetTransform();
170169
auto light_ptr = reinterpret_cast<PointLight*>(light.get());
171170
172-
auto position = glm::vec3(transform[3]);
173-
auto ambient = light_ptr->Ambient.As<glm::vec3>();
174-
auto diffuse = light_ptr->Diffuse.As<glm::vec3>();
175-
auto specular = light_ptr->Specular.As<glm::vec3>();
171+
auto position = Vec3f(transform[3]);
172+
auto ambient = light_ptr->Ambient.As<Vec3f>();
173+
auto diffuse = light_ptr->Diffuse.As<Vec3f>();
174+
auto specular = light_ptr->Specular.As<Vec3f>();
176175
177176
ImGui::Dummy(ImVec2(0, 0.5f));
178177
{
179-
Helpers::DrawVec3Control("Position", position, [light_ptr](glm::vec3& value) { light_ptr->Position =
180-
glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
178+
Helpers::DrawVec3Control("Position", position, [light_ptr](Vec3f& value) { light_ptr->Position =
179+
Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
181180
182-
Helpers::DrawColorEdit3Control("Ambient", ambient, [light_ptr](glm::vec3& value) {
183-
light_ptr->Ambient = glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
181+
Helpers::DrawColorEdit3Control("Ambient", ambient, [light_ptr](Vec3f& value) {
182+
light_ptr->Ambient = Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
184183
185-
Helpers::DrawColorEdit3Control("Diffuse", diffuse, [light_ptr](glm::vec3& value) {
186-
light_ptr->Diffuse = glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
184+
Helpers::DrawColorEdit3Control("Diffuse", diffuse, [light_ptr](Vec3f& value) {
185+
light_ptr->Diffuse = Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
187186
188-
Helpers::DrawColorEdit3Control("Specular", specular, [light_ptr](glm::vec3& value) {
189-
light_ptr->Specular = glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
187+
Helpers::DrawColorEdit3Control("Specular", specular, [light_ptr](Vec3f& value) {
188+
light_ptr->Specular = Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
190189
191190
Helpers::DrawDragFloatControl("Constant", light_ptr->Constant, 0.2f, 0.0f, 0.0f, "%.2f",
192191
[light_ptr](float value) { light_ptr->Constant = value; }); ImGui::Dummy(ImVec2(0, 0.5f));
@@ -204,32 +203,32 @@ namespace Tetragrama::Components
204203
auto transform = m_scene_entity.GetTransform();
205204
auto light_ptr = reinterpret_cast<Spotlight*>(light.get());
206205
207-
auto direction = light_ptr->Direction.As<glm::vec3>();
208-
auto position = glm::vec3(transform[3]);
209-
auto ambient = light_ptr->Ambient.As<glm::vec3>();
210-
auto diffuse = light_ptr->Diffuse.As<glm::vec3>();
211-
auto specular = light_ptr->Specular.As<glm::vec3>();
206+
auto direction = light_ptr->Direction.As<Vec3f>();
207+
auto position = Vec3f(transform[3]);
208+
auto ambient = light_ptr->Ambient.As<Vec3f>();
209+
auto diffuse = light_ptr->Diffuse.As<Vec3f>();
210+
auto specular = light_ptr->Specular.As<Vec3f>();
212211
static float phi_angle = 12.5f;
213212
214213
ImGui::Dummy(ImVec2(0, 0.5f));
215214
{
216-
Helpers::DrawVec3Control("Position", position, [light_ptr](glm::vec3& value) { light_ptr->Position =
217-
glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
215+
Helpers::DrawVec3Control("Position", position, [light_ptr](Vec3f& value) { light_ptr->Position =
216+
Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
218217
219-
Helpers::DrawVec3Control("Direction", direction, [light_ptr](glm::vec3& value) {
220-
light_ptr->Direction = glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
218+
Helpers::DrawVec3Control("Direction", direction, [light_ptr](Vec3f& value) {
219+
light_ptr->Direction = Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
221220
222-
Helpers::DrawColorEdit3Control("Ambient", ambient, [light_ptr](glm::vec3& value) {
223-
light_ptr->Ambient = glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
221+
Helpers::DrawColorEdit3Control("Ambient", ambient, [light_ptr](Vec3f& value) {
222+
light_ptr->Ambient = Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
224223
225-
Helpers::DrawColorEdit3Control("Diffuse", diffuse, [light_ptr](glm::vec3& value) {
226-
light_ptr->Diffuse = glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
224+
Helpers::DrawColorEdit3Control("Diffuse", diffuse, [light_ptr](Vec3f& value) {
225+
light_ptr->Diffuse = Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
227226
228-
Helpers::DrawColorEdit3Control("Specular", specular, [light_ptr](glm::vec3& value) {
229-
light_ptr->Specular = glm::vec4(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
227+
Helpers::DrawColorEdit3Control("Specular", specular, [light_ptr](Vec3f& value) {
228+
light_ptr->Specular = Vec4f(value, 1.0f); }); ImGui::Dummy(ImVec2(0, 0.5f));
230229
231230
Helpers::DrawDragFloatControl("CutOff", phi_angle, 0.1f, 0.0f, 360.0f, "%.2f", [light_ptr](float
232-
value) { phi_angle = value; light_ptr->CutOff = glm::cos(glm::radians(value));
231+
value) { phi_angle = value; light_ptr->CutOff = cos(radians(value));
233232
});
234233
ImGui::Dummy(ImVec2(0, 0.5f));
235234

Tetragrama/Controllers/EditorCameraController.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include <EditorCameraController.h>
2+
#include <ZEngine/Core/Maths/MathUtils.h>
23

34
using namespace ZEngine::Rendering::Cameras;
45
using namespace ZEngine::Helpers;
6+
using namespace ZEngine::Core::Maths;
57

68
namespace Tetragrama::Controllers
79
{
@@ -13,7 +15,7 @@ namespace Tetragrama::Controllers
1315
m_window = window;
1416

1517
m_perspective_camera = ZPushStructCtor(arena, PerspectiveCamera);
16-
m_perspective_camera->Initialize(m_camera_fov, m_aspect_ratio, m_camera_near, m_camera_far, glm::radians(yaw_degree), glm::radians(pitch_degree));
18+
m_perspective_camera->Initialize(m_camera_fov, m_aspect_ratio, m_camera_near, m_camera_far, radians(yaw_degree), radians(pitch_degree));
1719
m_perspective_camera->SetDistance(distance);
1820

1921
m_window = window;

Tetragrama/EditorScene.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using namespace ZEngine::Rendering::Meshes;
66
using namespace ZEngine::Core::Containers;
7+
using namespace ZEngine::Core::Maths;
78
using namespace ZEngine::Managers;
89
using namespace ZEngine::Helpers;
910

@@ -63,8 +64,8 @@ namespace Tetragrama
6364

6465
Hierarchies.push(new_node);
6566
HierarchiesNodeRef.push({});
66-
LocalTransforms.push(glm::mat4(1.0f));
67-
GlobalTransforms.push(glm::mat4(1.0f));
67+
LocalTransforms.push(Identity<Mat4f>());
68+
GlobalTransforms.push(Identity<Mat4f>());
6869

6970
if (parent >= 0)
7071
{
@@ -329,8 +330,8 @@ namespace Tetragrama
329330
auto& root_name = Names.push_use({});
330331
root_name.init(&LocalArena, Name);
331332

332-
LocalTransforms.push(glm::mat4(1.0f));
333-
GlobalTransforms.push(glm::mat4(1.0f));
333+
LocalTransforms.push(Identity<Mat4f>());
334+
GlobalTransforms.push(Identity<Mat4f>());
334335

335336
auto& node = Hierarchies.push_use({});
336337
HierarchiesNodeRef.push({});

0 commit comments

Comments
 (0)