Renamed some glm::vec3 to Vector3

This commit is contained in:
Antoine Pilote
2023-07-19 00:31:22 -04:00
parent 3800587c07
commit 4e4d203666
24 changed files with 59 additions and 96 deletions

View File

@@ -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();
{

View File

@@ -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);
}

View File

@@ -29,8 +29,8 @@ namespace Nuake
float m_bottomYOffset;
float m_bottomRoundedRegionYOffset;
glm::vec3 m_manualVelocity;
std::vector<glm::vec3> m_surfaceHitNormals;
Vector3 m_manualVelocity;
std::vector<Vector3> m_surfaceHitNormals;
CharacterController(const Ref<PhysicShape>& shape, float friction, float maxSlopeAngle);

View File

@@ -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
};

View File

@@ -52,7 +52,7 @@ namespace Nuake
void DrawDebug();
void SetGravity(glm::vec3 g);
void SetGravity(const Vector3& g);
void AddRigidbody(Ref<RigidBody> rb);
void AddGhostbody(Ref<GhostObject> 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();

View File

@@ -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;
}

View File

@@ -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<Physics::RigidBody> rb);
void RegisterGhostBody(Ref<GhostObject> rb);

View File

@@ -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;

View File

@@ -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; }

View File

@@ -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;
};
}

View File

@@ -26,7 +26,7 @@ namespace Nuake
RigidBody();
RigidBody(Vector3 position, Entity handle);
RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref<PhysicShape> shape, Entity entity, glm::vec3 initialVel = glm::vec3(0, 0, 0));
RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref<PhysicShape> shape, Entity entity, Vector3 initialVel = Vector3(0, 0, 0));
void UpdateTransform();

View File

@@ -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<PhysicShape> shape, Entity entity, glm::vec3 initialVel) :
RigidBody::RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref<PhysicShape> shape, Entity entity, Vector3 initialVel) :
_position(position),
_collisionShape(shape),
_mass(mass),

View File

@@ -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)

View File

@@ -124,7 +124,7 @@ namespace Nuake {
template<Frustum::Planes a, Frustum::Planes b, Frustum::Planes c>
inline Vector3 Frustum::intersection(const Vector3* crosses) const
{
float D = glm::dot(glm::vec3(m_planes[a]), crosses[ij2k<b, c>::k]);
float D = glm::dot(Vector3(m_planes[a]), crosses[ij2k<b, c>::k]);
Vector3 res = glm::mat3(crosses[ij2k<b, c>::k], -crosses[ij2k<a, c>::k], crosses[ij2k<a, b>::k]) *
Vector3(m_planes[a].w, m_planes[b].w, m_planes[c].w);
return res * (-1.0f / D);

View File

@@ -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)

View File

@@ -44,10 +44,10 @@ namespace Nuake
{
std::uniform_real_distribution<float> randomFloats(0.0, 1.0); // random floats between [0.0, 1.0]
std::default_random_engine generator;
std::vector<glm::vec3> ssaoKernel;
std::vector<Vector3> 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);

View File

@@ -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);

View File

@@ -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> 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());

View File

@@ -4,7 +4,8 @@
#include <src/Scene/Components/BSPBrushComponent.h>
#include <GL\glew.h>
namespace Nuake {
namespace Nuake
{
void SceneRenderer::Init()
{
const auto defaultResolution = Vector2(1920, 1080);

View File

@@ -56,7 +56,7 @@ namespace Nuake
InitDefaultTextures();
}
Material::Material(const glm::vec3 albedoColor)
Material::Material(const Vector3 albedoColor)
{
InitDefaultTextures();
InitUniformBuffer();

View File

@@ -73,7 +73,7 @@ namespace Nuake
Material();
Material(const std::string albedo);
Material(Ref<Texture> texture) { m_Albedo = texture; }
Material(const glm::vec3 albedoColor);
Material(const Vector3 albedoColor);
~Material();
void InitDefaultTextures();

View File

@@ -7,7 +7,7 @@ namespace Nuake {
{
public:
Ref<Physics::PhysicShape> 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();

View File

@@ -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);
}

View File

@@ -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<FrameBuffer> m_Framebuffer;
bool SyncDirectionWithSky = false;
bool CastShadows = false;
Ref<FrameBuffer> 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<Camera> 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)
{