From 89a21ebb5cbc8162f3709f516f896bb837ee44ae Mon Sep 17 00:00:00 2001 From: Redacted Date: Wed, 3 Jan 2024 09:26:21 -0500 Subject: [PATCH] Remove glm ;) --- CMakeLists.txt | 9 ------ cmake/glm.cmake | 64 ------------------------------------------ include/types/camera.h | 12 ++++---- include/types/entity.h | 13 +++++---- include/types/moby.h | 6 ++-- include/types/vector.h | 15 +++++----- src/types/entity.cpp | 14 ++++----- src/types/moby.cpp | 12 ++++---- 8 files changed, 36 insertions(+), 109 deletions(-) delete mode 100644 cmake/glm.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fe30079..0b2ae62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") # Enable Package Managers include(cmake/CPM.cmake) -include(cmake/glm.cmake) file(GLOB_RECURSE HEADERS "include/*") file(GLOB_RECURSE SOURCES "src/*") @@ -25,13 +24,6 @@ file(GLOB_RECURSE ASSETS "assets/*") include_directories("include") -CPMAddPackage( - NAME glm - GITHUB_REPOSITORY g-truc/glm - OPTIONS "GLM_STATIC_LIBRARY_ENABLE" - GIT_TAG 0.9.9.8 -) - #Move all libraries to lib after building. SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") @@ -70,7 +62,6 @@ set_target_properties(Re3D_Demo PROPERTIES LINK_FLAGS "-Wl,-rpath,./lib") include_directories( ${PROJECT_SOURCE_DIR}/include - #${glm_SOURCE_DIR} ${ReWindow_SOURCE_DIR}/include ${ReHardwareID_SOURCE_DIR}/include ${J3ML_SOURCE_DIR}/include diff --git a/cmake/glm.cmake b/cmake/glm.cmake deleted file mode 100644 index fac156c..0000000 --- a/cmake/glm.cmake +++ /dev/null @@ -1,64 +0,0 @@ - -#----------------------------------------------------------------------- -# CPM configuration -#----------------------------------------------------------------------- -set(CPM_MODULE_NAME iauns_cpm_glm) -set(CPM_LIB_TARGET_NAME ${CPM_MODULE_NAME}) - -if ((DEFINED CPM_DIR) AND (DEFINED CPM_UNIQUE_ID) AND (DEFINED CPM_TARGET_NAME)) - set(CPM_LIB_TARGET_NAME ${CPM_TARGET_NAME}) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CPM_DIR}) - include(CPM) -else() - set(CPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/cpm-packages" CACHE TYPE STRING) - find_package(Git) - if(NOT GIT_FOUND) - message(FATAL_ERROR "CPM requires Git.") - endif() - if (NOT EXISTS ${CPM_DIR}/CPM.cmake) - execute_process( - COMMAND "${GIT_EXECUTABLE}" clone https://github.com/iauns/cpm ${CPM_DIR} - RESULT_VARIABLE error_code - OUTPUT_VARIABLE head_sha) - if(error_code) - message(FATAL_ERROR "CPM failed to get the hash for HEAD") - endif() - endif() - include(${CPM_DIR}/CPM.cmake) -endif() - -# All externals *must* define this. -CPM_ForceOnlyOneModuleVersion() - -CPM_InitModule(${CPM_MODULE_NAME}) - -#------------------------------------------------------------------------------ -# GLM -#------------------------------------------------------------------------------ - -# We manually download GLM into our source directory so the user can access -# glm through 'glm/...'. There is no build step since this is a header only -# library. -set(REPO_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/glm") -CPM_EnsureRepoIsCurrent( - TARGET_DIR ${REPO_SOURCE_DIR} - GIT_REPOSITORY "https://github.com/g-truc/glm.git" - GIT_TAG "0.9.4.6" - USE_CACHING TRUE -) -CPM_ExportAdditionalIncludeDir("${REPO_SOURCE_DIR}") - -# Enable a number of useful GLM options. -if (NOT DEFINED CPM_GLM_NO_SWIZZLE) - CPM_ExportAdditionalDefinition("-DGLM_SWIZZLE") -endif() - -if (NOT DEFINED CPM_GLM_CPP11) - CPM_ExportAdditionalDefinition("-DGLM_FORCE_CXX03") -endif() - -if (NOT DEFINED CPM_GLM_DEGREES) - CPM_ExportAdditionalDefinition("-DGLM_FORCE_RADIANS") -endif() - - diff --git a/include/types/camera.h b/include/types/camera.h index 3ee4ba4..6a26bcb 100644 --- a/include/types/camera.h +++ b/include/types/camera.h @@ -2,10 +2,8 @@ #include "moby.h" #include "player.h" #include "../engine/engine.h" -#include #include "entityList.h" #include -#include "glm/ext/matrix_transform.hpp" enum class CameraMode: uint8_t { THIRD_PERSON = 0, @@ -13,13 +11,13 @@ enum class CameraMode: uint8_t { SCRIPTED_MOVE = 2 }; -const glm::vec3 UP = {0, 1, 0}; +const LinearAlgebra::Vector3 UP = {0, 1, 0}; class Camera : public Moby { protected: public: - glm::mat4x4 GetViewMatrix() + LinearAlgebra::Matrix4x4 GetViewMatrix() { //return glm::lookAt(position, position + angle, UP); } @@ -30,9 +28,9 @@ public: void TurnLeft(float deg = 90); void TurnRight(float deg = 90); - void LookAt(glm::vec3 pos, glm::vec3 target, glm::vec3 upaxis = UP) {} - void Rotate(float amt, glm::vec3 axis) { } - void Translate(glm::vec3 dir) { } + void LookAt(LinearAlgebra::Vector3 pos, LinearAlgebra::Vector3 target, LinearAlgebra::Vector3 upaxis = UP) {} + void Rotate(float amt, LinearAlgebra::Vector3 axis) { } + void Translate(LinearAlgebra::Vector3 dir) { } float fov; Camera() : Moby(), fov(60) diff --git a/include/types/entity.h b/include/types/entity.h index cdd6d83..95448ad 100644 --- a/include/types/entity.h +++ b/include/types/entity.h @@ -1,20 +1,21 @@ #pragma once #include -#include #include +#include +#include class Entity { protected: - glm::mat4x4 coordinates; + LinearAlgebra::Matrix4x4 coordinates; public: Position position; //X Y Z uint32_t ticksAlive; //At 64tps it'd take 776 days to overflow. - glm::vec3 GetPos() const; - void SetPos(const glm::vec3& rhs); - glm::mat4 GetMatrix() const; - void SetMatrix(const glm::mat4& rhs); + LinearAlgebra::Vector3 GetPos() const; + void SetPos(const LinearAlgebra::Vector3& rhs); + LinearAlgebra::Matrix4x4 GetMatrix() const; + void SetMatrix(const LinearAlgebra::Matrix4x4& rhs); //Angle GetRotation() const { return glm::eulerAngles(); } //void SetRotation(Angle&const rhs); bool draw = true; diff --git a/include/types/moby.h b/include/types/moby.h index 8806bf5..2bb11e6 100644 --- a/include/types/moby.h +++ b/include/types/moby.h @@ -2,7 +2,7 @@ #include #include "animation/scriptedMove.h" - +#include "J3ML/LinearAlgebra/Vector3.h" //Movable Object. @@ -14,8 +14,8 @@ public: } Angle angle = {0,0,0}; //Pitch Yaw Roll, The orientation of the entity in the world, Angle velAngle = {0,0,0}; //The angle of an entities velocity. - glm::vec3 Velocity; - vector3 upVector = {0.0f,1.0f,0.0f}; + LinearAlgebra::Vector3 Velocity; + LinearAlgebra::Vector3 upVector = {0.0f,1.0f,0.0f}; ScriptedMove scriptedMove; void move(Angle a, float speed); Angle fAngle(); // forward angle diff --git a/include/types/vector.h b/include/types/vector.h index 6d00b95..9564f74 100644 --- a/include/types/vector.h +++ b/include/types/vector.h @@ -4,8 +4,9 @@ #include #include #include -#include -#include +#include +#include +#include inline float lerp(float a, float b, float t) { @@ -138,9 +139,9 @@ public: Angle movementAngle() { Angle a; - a.pitch = (cos(glm::radians(yaw)) * cos(glm::radians(pitch))); - a.yaw = -sin(glm::radians(pitch)); - a.roll = (sin(glm::radians(yaw)) * cos(glm::radians(pitch))); + a.pitch = (cos(Math::Radians(yaw)) * cos(Math::Radians(pitch))); + a.yaw = -sin(Math::Radians(pitch)); + a.roll = (sin(Math::Radians(yaw)) * cos(Math::Radians(pitch))); return a; } }; @@ -198,7 +199,7 @@ public: // The CFrame is fundamentally 4 vectors (position, forward, right, up vector) class CoordinateFrame { - glm::mat4x4 matrix; + LinearAlgebra::Matrix4x4 matrix; vector3 getPosition(); vector3 getLookVector(); vector3 getRightVector(); @@ -219,7 +220,7 @@ inline namespace VectorMath { //Basically an aimbot. inline Angle calcAngle(Position sP, Position eP) { - const auto pi = glm::pi(); + const auto pi = Math::Pi; //returned.x = -(asinf((eP.y - sP.y) / distance(sP, eP)) * 180.0f / M_PI); //returned.y = (atan2f(eP.x - sP.x,eP.z - sP.z) / M_PI * 180.0f); return {static_cast((-(asinf((eP.y - sP.y) / distance(sP, eP)) * 180.0f / pi ))),static_cast((atan2f(eP.x - sP.x,eP.z - sP.z) / pi * 180.0f)),0}; diff --git a/src/types/entity.cpp b/src/types/entity.cpp index d115633..554d533 100644 --- a/src/types/entity.cpp +++ b/src/types/entity.cpp @@ -1,13 +1,13 @@ #include -inline glm::vec3 Entity::GetPos() const -{ return glm::vec3(coordinates[1]); } +//inline LinearAlgebra::Vector3 Entity::GetPos() const +//{ return LinearAlgebra::Vector3(coordinates[1]); } -void Entity::SetPos(const glm::vec3& rhs) -{ coordinates[1] = glm::vec4(rhs.x, rhs.y, rhs.z, 0); } +//void Entity::SetPos(const LinearAlgebra::Vector3& rhs) +//{ coordinates[1] = LinearAlgebra::Vector4(rhs.x, rhs.y, rhs.z, 0); } -glm::mat4 Entity::GetMatrix() const -{ return coordinates;} +//glm::mat4 Entity::GetMatrix() const +//{ return coordinates;} -void Entity::SetMatrix(const glm::mat4& rhs) +void Entity::SetMatrix(const LinearAlgebra::Matrix4x4& rhs) { coordinates = rhs; } diff --git a/src/types/moby.cpp b/src/types/moby.cpp index 49d8f50..d95f060 100644 --- a/src/types/moby.cpp +++ b/src/types/moby.cpp @@ -19,18 +19,18 @@ Position Moby::simulateMove(Angle a, float speed) { inline Angle Moby::fAngle() { Angle a; - a.pitch = (cos(glm::radians(this->angle.yaw)) * cos(glm::radians(this->angle.pitch))); - a.yaw = -sin(glm::radians(this->angle.pitch)); - a.roll = (sin(glm::radians(this->angle.yaw)) * cos(glm::radians(this->angle.pitch))); + a.pitch = (cos(Math::Radians(this->angle.yaw)) * cos(Math::Radians(this->angle.pitch))); + a.yaw = -sin(Math::Radians(this->angle.pitch)); + a.roll = (sin(Math::Radians(this->angle.yaw)) * cos(Math::Radians(this->angle.pitch))); return a; } Angle Moby::bAngle() { Angle a; - a.pitch = -(cos(glm::radians(this->angle.yaw)) * cos(glm::radians(this->angle.pitch))); - a.yaw = sin(glm::radians(this->angle.pitch)); - a.roll = -(sin(glm::radians(this->angle.yaw)) * cos(glm::radians(this->angle.pitch))); + a.pitch = -(cos(Math::Radians(this->angle.yaw)) * cos(Math::Radians(this->angle.pitch))); + a.yaw = sin(Math::Radians(this->angle.pitch)); + a.roll = -(sin(Math::Radians(this->angle.yaw)) * cos(Math::Radians(this->angle.pitch))); return a; }