diff --git a/Editor/src/ComponentsPanel/BoxColliderPanel.h b/Editor/src/ComponentsPanel/BoxColliderPanel.h index 05ba27e5..1e3d56f5 100644 --- a/Editor/src/ComponentsPanel/BoxColliderPanel.h +++ b/Editor/src/ComponentsPanel/BoxColliderPanel.h @@ -28,7 +28,7 @@ public: component.Size.z = std::max(component.Size.z, 0.0001f); ImGui::TableNextColumn(); - ComponentTableReset(component.Size, glm::vec3(0.5f, 0.5f, 0.5f)); + ComponentTableReset(component.Size, Vector3(0.5f, 0.5f, 0.5f)); } ImGui::TableNextColumn(); { diff --git a/Nuake/src/Core/Maths.cpp b/Nuake/src/Core/Maths.cpp index 884f4339..0b66c7a8 100644 --- a/Nuake/src/Core/Maths.cpp +++ b/Nuake/src/Core/Maths.cpp @@ -37,29 +37,12 @@ Quat Nuake::CreateFromAxisAngle(Vector3 axis, float angle) Quat Nuake::QuatFromEuler(float x, float y, float z) { - glm::quat pitchQuat = glm::angleAxis(Rad(x), glm::vec3(1.0f, 0.0f, 0.0f)); - glm::quat yawQuat = glm::angleAxis(Rad(y), glm::vec3(0.0f, 1.0f, 0.0f)); - glm::quat rollQuat = glm::angleAxis(Rad(z), glm::vec3(0.0f, 0.0f, -1.0f)); - glm::quat orientation = yawQuat * pitchQuat * rollQuat; + Quat pitchQuat = glm::angleAxis(Rad(x), Vector3(1.0f, 0.0f, 0.0f)); + Quat yawQuat = glm::angleAxis(Rad(y), Vector3(0.0f, 1.0f, 0.0f)); + Quat rollQuat = glm::angleAxis(Rad(z), Vector3(0.0f, 0.0f, -1.0f)); + Quat orientation = yawQuat * pitchQuat * rollQuat; return glm::normalize(orientation); - - return Quat(Vector3(Rad(x), Rad(y), Rad(z))); - - Quat q; - - float cr = cos(x * 0.5); - float sr = sin(x * 0.5); - float cp = cos(y * 0.5); - float sp = sin(y * 0.5); - float cy = cos(z * 0.5); - float sy = sin(z * 0.5); - - q.w = cr * cp * cy + sr * sp * sy; - q.x = sr * cp * cy - cr * sp * sy; - q.y = cr * sp * cy + sr * cp * sy; - q.z = cr * cp * sy - sr * sp * cy; - return q; } Vector3 Nuake::QuatToDirection(const Quat& quat) @@ -72,9 +55,9 @@ void Nuake::Decompose(const Matrix4& m, Vector3& pos, Quat& rot, Vector3& scale) pos = m[3]; for (int i = 0; i < 3; i++) scale[i] = glm::length(Vector3(m[i])); - const glm::mat3 rotMtx( - glm::vec3(m[0]) / scale[0], - glm::vec3(m[1]) / scale[1], - glm::vec3(m[2]) / scale[2]); + const Matrix3 rotMtx( + Vector3(m[0]) / scale[0], + Vector3(m[1]) / scale[1], + Vector3(m[2]) / scale[2]); rot = glm::quat_cast(rotMtx); } \ No newline at end of file diff --git a/Nuake/src/Core/Physics/CharacterController.h b/Nuake/src/Core/Physics/CharacterController.h index 9e20bb6b..791ee773 100644 --- a/Nuake/src/Core/Physics/CharacterController.h +++ b/Nuake/src/Core/Physics/CharacterController.h @@ -29,8 +29,8 @@ namespace Nuake float m_bottomYOffset; float m_bottomRoundedRegionYOffset; - glm::vec3 m_manualVelocity; - std::vector m_surfaceHitNormals; + Vector3 m_manualVelocity; + std::vector m_surfaceHitNormals; CharacterController(const Ref& shape, float friction, float maxSlopeAngle); diff --git a/Nuake/src/Core/Physics/DynamicWorld.cpp b/Nuake/src/Core/Physics/DynamicWorld.cpp index 1d674c8a..0ffbcf16 100644 --- a/Nuake/src/Core/Physics/DynamicWorld.cpp +++ b/Nuake/src/Core/Physics/DynamicWorld.cpp @@ -241,7 +241,7 @@ namespace Nuake } - void DynamicWorld::SetGravity(glm::vec3 g) + void DynamicWorld::SetGravity(const Vector3& gravity) { } @@ -323,16 +323,16 @@ namespace Nuake return false; } - RaycastResult DynamicWorld::Raycast(glm::vec3 from, glm::vec3 to) + RaycastResult DynamicWorld::Raycast(const Vector3& from, const Vector3& to) { - Vector3 localNorm = glm::vec3(0,0,0); + Vector3 localNorm = Vector3(0,0,0); //Logger::Log("normal: x:" + std::to_string(localNorm.x) + " y:" + std::to_string(localNorm.y )+ "z: " + std::to_string(localNorm.z)); // Map bullet result to dto. RaycastResult result{ - glm::vec3(0,0,0), - glm::vec3(0,0,0), + Vector3(0,0,0), + Vector3(0,0,0), localNorm }; diff --git a/Nuake/src/Core/Physics/DynamicWorld.h b/Nuake/src/Core/Physics/DynamicWorld.h index cfa25a48..0bc45ecd 100644 --- a/Nuake/src/Core/Physics/DynamicWorld.h +++ b/Nuake/src/Core/Physics/DynamicWorld.h @@ -52,7 +52,7 @@ namespace Nuake void DrawDebug(); - void SetGravity(glm::vec3 g); + void SetGravity(const Vector3& g); void AddRigidbody(Ref rb); void AddGhostbody(Ref gb); @@ -62,7 +62,7 @@ namespace Nuake void MoveAndSlideCharacterController(const Entity& entity, const Vector3 velocity); - RaycastResult Raycast(glm::vec3 from, glm::vec3 to); + RaycastResult Raycast(const Vector3& from, const Vector3& to); void StepSimulation(Timestep ts); void Clear(); diff --git a/Nuake/src/Core/Physics/PhysicsManager.cpp b/Nuake/src/Core/Physics/PhysicsManager.cpp index 7d5ebaf1..26aa6bac 100644 --- a/Nuake/src/Core/Physics/PhysicsManager.cpp +++ b/Nuake/src/Core/Physics/PhysicsManager.cpp @@ -37,7 +37,7 @@ namespace Nuake m_World->Clear(); } - RaycastResult PhysicsManager::Raycast(glm::vec3 from, glm::vec3 to) + RaycastResult PhysicsManager::Raycast(const Vector3& from, const Vector3& to) { return m_World->Raycast(from, to); } @@ -58,7 +58,7 @@ namespace Nuake JPH::RegisterTypes(); m_World = new Physics::DynamicWorld(); - m_World->SetGravity(glm::vec3(0, -3, 0)); + m_World->SetGravity(Vector3(0, -3, 0)); m_IsRunning = false; } diff --git a/Nuake/src/Core/Physics/PhysicsManager.h b/Nuake/src/Core/Physics/PhysicsManager.h index 4a854340..3934a07c 100644 --- a/Nuake/src/Core/Physics/PhysicsManager.h +++ b/Nuake/src/Core/Physics/PhysicsManager.h @@ -45,7 +45,7 @@ namespace Nuake void Reset(); - RaycastResult Raycast(glm::vec3 from, glm::vec3 to); + RaycastResult Raycast(const Vector3& from, const Vector3& to); void RegisterBody(Ref rb); void RegisterGhostBody(Ref rb); diff --git a/Nuake/src/Core/Physics/PhysicsShapes.cpp b/Nuake/src/Core/Physics/PhysicsShapes.cpp index 5009e910..00ce6da5 100644 --- a/Nuake/src/Core/Physics/PhysicsShapes.cpp +++ b/Nuake/src/Core/Physics/PhysicsShapes.cpp @@ -1,5 +1,4 @@ #include "PhysicsShapes.h" -#include "src/Rendering/Vertex.h" namespace Nuake { @@ -7,12 +6,11 @@ namespace Nuake { Box::Box() { - Size = glm::vec3(1); + Size = Vector3(1); m_Type = BOX; } - // Sphere - Box::Box(glm::vec3 size) + Box::Box(Vector3 size) { Size = size; m_Type = BOX; @@ -20,11 +18,10 @@ namespace Nuake Box::Box(float x, float y, float z) { - Size = glm::vec3(x, y, z); + Size = Vector3(x, y, z); m_Type = BOX; } - // Sphere Sphere::Sphere(float radius) { Radius = radius; diff --git a/Nuake/src/Core/Physics/PhysicsShapes.h b/Nuake/src/Core/Physics/PhysicsShapes.h index 49e3b167..859768dc 100644 --- a/Nuake/src/Core/Physics/PhysicsShapes.h +++ b/Nuake/src/Core/Physics/PhysicsShapes.h @@ -26,7 +26,7 @@ namespace Nuake Vector3 Size; public: Box(); - Box(glm::vec3 size); + Box(Vector3 size); Box(float x, float y, float z); Vector3 GetSize() const { return Size; } diff --git a/Nuake/src/Core/Physics/RaycastResult.h b/Nuake/src/Core/Physics/RaycastResult.h index 2da51a59..be12f90c 100644 --- a/Nuake/src/Core/Physics/RaycastResult.h +++ b/Nuake/src/Core/Physics/RaycastResult.h @@ -13,8 +13,8 @@ namespace Nuake // result object from raycast. struct RaycastResult { - glm::vec3 WorldPoint; - glm::vec3 LocalPoint; - glm::vec3 Normal; + Vector3 WorldPoint; + Vector3 LocalPoint; + Vector3 Normal; }; } diff --git a/Nuake/src/Core/Physics/Rigibody.h b/Nuake/src/Core/Physics/Rigibody.h index 14b99b76..c579400a 100644 --- a/Nuake/src/Core/Physics/Rigibody.h +++ b/Nuake/src/Core/Physics/Rigibody.h @@ -26,7 +26,7 @@ namespace Nuake RigidBody(); RigidBody(Vector3 position, Entity handle); - RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref shape, Entity entity, glm::vec3 initialVel = glm::vec3(0, 0, 0)); + RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref shape, Entity entity, Vector3 initialVel = Vector3(0, 0, 0)); void UpdateTransform(); diff --git a/Nuake/src/Core/Physics/Rigidbody.cpp b/Nuake/src/Core/Physics/Rigidbody.cpp index aaa93938..0a4da02e 100644 --- a/Nuake/src/Core/Physics/Rigidbody.cpp +++ b/Nuake/src/Core/Physics/Rigidbody.cpp @@ -13,12 +13,12 @@ namespace Nuake } - RigidBody::RigidBody(glm::vec3 position, Entity handle) : _position(position) + RigidBody::RigidBody(Vector3 position, Entity handle) : _position(position) { } - RigidBody::RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref shape, Entity entity, glm::vec3 initialVel) : + RigidBody::RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref shape, Entity entity, Vector3 initialVel) : _position(position), _collisionShape(shape), _mass(mass), diff --git a/Nuake/src/Rendering/Camera.cpp b/Nuake/src/Rendering/Camera.cpp index f44b340c..7b60d972 100644 --- a/Nuake/src/Rendering/Camera.cpp +++ b/Nuake/src/Rendering/Camera.cpp @@ -10,7 +10,7 @@ namespace Nuake { - Camera::Camera(CAMERA_TYPE type, glm::vec3 position) + Camera::Camera(CAMERA_TYPE type, Vector3 position) { m_Type = PERSPECTIVE; Translation = position; @@ -25,7 +25,7 @@ namespace Nuake Camera::Camera() { m_Type = PERSPECTIVE; - Translation = glm::vec3(0, 0, 0); + Translation = Vector3(0, 0, 0); Direction = Vector3(0, 0, 1); Right = glm::normalize(glm::cross(Vector3(0, 1, 0), Direction)); Up = glm::cross(Direction, Right); @@ -83,7 +83,7 @@ namespace Nuake Matrix4 Camera::GetTransformRotation() { - return lookAt(glm::vec3(), Direction, Up); + return lookAt(Vector3(), Direction, Up); } bool Camera::BoxFrustumCheck(const AABB& aabb) diff --git a/Nuake/src/Rendering/Frustum.h b/Nuake/src/Rendering/Frustum.h index 01febbb9..22479bce 100644 --- a/Nuake/src/Rendering/Frustum.h +++ b/Nuake/src/Rendering/Frustum.h @@ -124,7 +124,7 @@ namespace Nuake { template inline Vector3 Frustum::intersection(const Vector3* crosses) const { - float D = glm::dot(glm::vec3(m_planes[a]), crosses[ij2k::k]); + float D = glm::dot(Vector3(m_planes[a]), crosses[ij2k::k]); Vector3 res = glm::mat3(crosses[ij2k::k], -crosses[ij2k::k], crosses[ij2k::k]) * Vector3(m_planes[a].w, m_planes[b].w, m_planes[c].w); return res * (-1.0f / D); diff --git a/Nuake/src/Rendering/Light.cpp b/Nuake/src/Rendering/Light.cpp index 84643404..b2091acc 100644 --- a/Nuake/src/Rendering/Light.cpp +++ b/Nuake/src/Rendering/Light.cpp @@ -87,17 +87,17 @@ namespace Nuake float radius = 0.0f; for (int i = 0; i < 8; i++) { - float distance = glm::length(glm::vec3(frustumCorners[i]) - frustumCenter); + float distance = glm::length(Vector3(frustumCorners[i]) - frustumCenter); radius = glm::max(radius, distance); } radius = std::ceil(radius * 16.0f) / 16.0f; - Vector3 maxExtents = glm::vec3(radius); + Vector3 maxExtents = Vector3(radius); Vector3 minExtents = -maxExtents; // Calculate the view and projection matrix Vector3 lightDir = -this->Direction; - Matrix4 lightViewMatrix = glm::lookAt(frustumCenter - lightDir * -minExtents.z, frustumCenter, glm::vec3(0.0f, 0.0f, 1.0f)); + Matrix4 lightViewMatrix = glm::lookAt(frustumCenter - lightDir * -minExtents.z, frustumCenter, Vector3(0.0f, 0.0f, 1.0f)); Matrix4 lightProjectionMatrix = glm::ortho(minExtents.x, maxExtents.x, minExtents.y, maxExtents.y, 0.0f + mCascadeNearPlaneOffset, maxExtents.z - minExtents.z + mCascadeFarPlaneOffset); // Offset to texel space to avoid shimmering ->(https://stackoverflow.com/questions/33499053/cascaded-shadow-map-shimmering) diff --git a/Nuake/src/Rendering/PostFX/SSAO.cpp b/Nuake/src/Rendering/PostFX/SSAO.cpp index 16624513..02a75aaf 100644 --- a/Nuake/src/Rendering/PostFX/SSAO.cpp +++ b/Nuake/src/Rendering/PostFX/SSAO.cpp @@ -44,10 +44,10 @@ namespace Nuake { std::uniform_real_distribution randomFloats(0.0, 1.0); // random floats between [0.0, 1.0] std::default_random_engine generator; - std::vector ssaoKernel; + std::vector ssaoKernel; for (unsigned int i = 0; i < 64; ++i) { - glm::vec3 sample( + Vector3 sample( randomFloats(generator) * 2.0 - 1.0, randomFloats(generator) * 2.0 - 1.0, randomFloats(generator) @@ -70,7 +70,7 @@ namespace Nuake for (unsigned int i = 0; i < 16; i++) { - glm::vec3 noise( + Vector3 noise( randomFloats(generator) * 2.0 - 1.0, randomFloats(generator) * 2.0 - 1.0, 0.0f); diff --git a/Nuake/src/Rendering/Renderer.cpp b/Nuake/src/Rendering/Renderer.cpp index bcd2d449..25f86f4f 100644 --- a/Nuake/src/Rendering/Renderer.cpp +++ b/Nuake/src/Rendering/Renderer.cpp @@ -209,7 +209,7 @@ namespace Nuake RenderCommand::DrawLines(0, 2); } - void Renderer::DrawDebugLine(glm::vec3 start, glm::vec3 end, glm::vec4 color) + void Renderer::DrawDebugLine(Vector3 start, Vector3 end, Vector3 color) { //m_DebugShader->Bind(); //m_DebugShader->SetUniform4f("u_Color", color.r, color.g, color.b, color.a); diff --git a/Nuake/src/Rendering/Renderer.h b/Nuake/src/Rendering/Renderer.h index 0b5de6ae..847e3b86 100644 --- a/Nuake/src/Rendering/Renderer.h +++ b/Nuake/src/Rendering/Renderer.h @@ -16,10 +16,6 @@ namespace Nuake }; const int MAX_LIGHT = 64; - //struct LightDataArray - //{ - // LightData Lights[MAX_LIGHT]; - //}; struct LightData { @@ -59,7 +55,6 @@ namespace Nuake static void Init(); static void LoadShaders(); - static void BeginScene(); static void SubmitMesh(Ref mesh, Matrix4 transform, const int32_t entityId = -1); static void SubmitCube(Matrix4 transform); static void Flush(Shader* shader, bool depthOnly = false); @@ -75,7 +70,7 @@ namespace Nuake // Debug static void DrawLine(Vector3 start, Vector3 end, Color color, Matrix4 transform = Matrix4()); - static void DrawDebugLine(glm::vec3 start, glm::vec3 end, glm::vec4 color); + static void DrawDebugLine(Vector3 start, Vector3 end, Vector3 color); static void DrawCube(TransformComponent transform, glm::vec4 color); static void DrawSphere(TransformComponent transform, glm::vec4 color); static void DrawQuad(Matrix4 transform = Matrix4()); diff --git a/Nuake/src/Rendering/SceneRenderer.cpp b/Nuake/src/Rendering/SceneRenderer.cpp index 6bd30a64..7d4b2512 100644 --- a/Nuake/src/Rendering/SceneRenderer.cpp +++ b/Nuake/src/Rendering/SceneRenderer.cpp @@ -4,7 +4,8 @@ #include #include -namespace Nuake { +namespace Nuake +{ void SceneRenderer::Init() { const auto defaultResolution = Vector2(1920, 1080); diff --git a/Nuake/src/Rendering/Textures/Material.cpp b/Nuake/src/Rendering/Textures/Material.cpp index f68785cd..65c14827 100644 --- a/Nuake/src/Rendering/Textures/Material.cpp +++ b/Nuake/src/Rendering/Textures/Material.cpp @@ -56,7 +56,7 @@ namespace Nuake InitDefaultTextures(); } - Material::Material(const glm::vec3 albedoColor) + Material::Material(const Vector3 albedoColor) { InitDefaultTextures(); InitUniformBuffer(); diff --git a/Nuake/src/Rendering/Textures/Material.h b/Nuake/src/Rendering/Textures/Material.h index 9dd2e269..2d9986fc 100644 --- a/Nuake/src/Rendering/Textures/Material.h +++ b/Nuake/src/Rendering/Textures/Material.h @@ -73,7 +73,7 @@ namespace Nuake Material(); Material(const std::string albedo); Material(Ref texture) { m_Albedo = texture; } - Material(const glm::vec3 albedoColor); + Material(const Vector3 albedoColor); ~Material(); void InitDefaultTextures(); diff --git a/Nuake/src/Scene/Components/BoxCollider.h b/Nuake/src/Scene/Components/BoxCollider.h index 125452b3..4cc88f8e 100644 --- a/Nuake/src/Scene/Components/BoxCollider.h +++ b/Nuake/src/Scene/Components/BoxCollider.h @@ -7,7 +7,7 @@ namespace Nuake { { public: Ref Box; - glm::vec3 Size = glm::vec3(0.5f, 0.5f, 0.5f); + Vector3 Size = Vector3(0.5f, 0.5f, 0.5f); bool IsTrigger = false; json Serialize(); diff --git a/Nuake/src/Scene/Components/LightComponent.cpp b/Nuake/src/Scene/Components/LightComponent.cpp index 9cd8a776..bbc00d16 100644 --- a/Nuake/src/Scene/Components/LightComponent.cpp +++ b/Nuake/src/Scene/Components/LightComponent.cpp @@ -50,7 +50,7 @@ namespace Nuake { } } - glm::mat4 LightComponent::GetProjection() + Matrix4 LightComponent::GetProjection() { return glm::ortho(-25.0f, 25.0f, -25.0f, 25.0f, -25.0f, 25.0f); } diff --git a/Nuake/src/Scene/Components/LightComponent.h b/Nuake/src/Scene/Components/LightComponent.h index 32c4a110..321fb07e 100644 --- a/Nuake/src/Scene/Components/LightComponent.h +++ b/Nuake/src/Scene/Components/LightComponent.h @@ -21,41 +21,28 @@ namespace Nuake { public: LightType Type = Point; - glm::vec3 Direction = glm::vec3(0, -1, 0); - glm::vec3 Color; + Vector3 Direction; + Vector3 Color; + bool IsVolumetric = false; float Strength; - bool SyncDirectionWithSky = false; - Ref m_Framebuffer; + bool SyncDirectionWithSky = false; bool CastShadows = false; Ref m_Framebuffers[CSM_AMOUNT]; - glm::mat4 mViewProjections[CSM_AMOUNT]; + Matrix4 mViewProjections[CSM_AMOUNT]; float mCascadeSplitDepth[CSM_AMOUNT]; + float mCascadeSplits[CSM_AMOUNT]; + public: LightComponent(); + ~LightComponent() = default; void SetCastShadows(bool toggle); - glm::mat4 GetProjection(); - - glm::mat4 GetLightTransform(); - void SetDirection(glm::vec3 dir); - glm::vec3 GetDirection(); - - void BeginDrawShadow(); - - void EndDrawShadow(); - void DrawShadow(); - - void Draw(TransformComponent transformComponent, Ref cam); - void DrawDeferred(TransformComponent transformComponent, Camera* cam); - void DrawEditor(); - - void SetType(LightType type); - - float mCascadeSplits[CSM_AMOUNT]; + Matrix4 GetProjection(); + Vector3 GetDirection(); void CalculateViewProjection(glm::mat4& view, const glm::mat4& projection) {