Implementing ECS SystemBase and updating slang
This commit is contained in:
@@ -2,7 +2,7 @@ target_sources(Engine
|
||||
PUBLIC
|
||||
Math.h
|
||||
Matrix.h
|
||||
Vector.h
|
||||
Vector.cpp
|
||||
Transform.h
|
||||
Transform.cpp)
|
||||
Transform.cpp
|
||||
Vector.h
|
||||
Vector.cpp)
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace Math
|
||||
{
|
||||
struct Rect
|
||||
{
|
||||
Rect()
|
||||
@@ -58,4 +60,5 @@ inline constexpr T align(const T ptr, int64_t alignment)
|
||||
{
|
||||
return (T)(((uint64_t)ptr + alignment - 1) & ~(alignment - 1));
|
||||
}
|
||||
} // namespace Math
|
||||
} // namespace Seele
|
||||
@@ -5,7 +5,10 @@
|
||||
#include <glm/mat4x4.hpp>
|
||||
namespace Seele
|
||||
{
|
||||
namespace Math
|
||||
{
|
||||
typedef glm::mat2 Matrix2;
|
||||
typedef glm::mat3 Matrix3;
|
||||
typedef glm::mat4 Matrix4;
|
||||
} // namespace Math
|
||||
} // namespace Seele
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
using namespace Seele;
|
||||
using namespace Seele::Math;
|
||||
|
||||
Transform::Transform()
|
||||
: position(Vector4(0, 0, 0, 0)), rotation(Quaternion(1, 0, 0, 0)), scale(Vector4(1, 1, 1, 0))
|
||||
@@ -44,7 +45,7 @@ Vector Transform::inverseTransformPosition(const Vector &v) const
|
||||
{
|
||||
return (unrotateVector(rotation, v - Vector(position))) * getSafeScaleReciprocal(scale);
|
||||
}
|
||||
Matrix4 Transform::toMatrix()
|
||||
Matrix4 Transform::toMatrix() const
|
||||
{
|
||||
Matrix4 mat;
|
||||
|
||||
@@ -197,20 +198,26 @@ void Transform::add(Transform *outTransform, const Transform *a, const Transform
|
||||
|
||||
Transform &Transform::operator=(const Transform &other)
|
||||
{
|
||||
position = other.position;
|
||||
rotation = other.rotation;
|
||||
scale = other.scale;
|
||||
if(&other != this)
|
||||
{
|
||||
position = other.position;
|
||||
rotation = other.rotation;
|
||||
scale = other.scale;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transform &Transform::operator=(Transform &&other)
|
||||
{
|
||||
position = other.position;
|
||||
rotation = other.rotation;
|
||||
scale = other.scale;
|
||||
other.position = Vector4(0, 0, 0, 0);
|
||||
other.rotation = Quaternion(1, 0, 0, 0);
|
||||
other.scale = Vector4(0, 0, 0, 0);
|
||||
if(&other != this)
|
||||
{
|
||||
position = other.position;
|
||||
rotation = other.rotation;
|
||||
scale = other.scale;
|
||||
other.position = Vector4(0, 0, 0, 0);
|
||||
other.rotation = Quaternion(1, 0, 0, 0);
|
||||
other.scale = Vector4(0, 0, 0, 0);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
#include "Vector.h"
|
||||
#include "Matrix.h"
|
||||
#include "Math/Vector.h"
|
||||
#include "Math/Matrix.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace Math
|
||||
{
|
||||
class Transform
|
||||
{
|
||||
public:
|
||||
@@ -16,7 +18,7 @@ public:
|
||||
Transform(Quaternion rotation, Vector scale);
|
||||
~Transform();
|
||||
Vector inverseTransformPosition(const Vector &v) const;
|
||||
Matrix4 toMatrix();
|
||||
Matrix4 toMatrix() const;
|
||||
static Vector getSafeScaleReciprocal(const Vector4 &inScale, float tolerance = 0.000000001f);
|
||||
Vector transformPosition(const Vector &v) const;
|
||||
|
||||
@@ -41,4 +43,5 @@ private:
|
||||
Quaternion rotation;
|
||||
Vector4 scale;
|
||||
};
|
||||
} // namespace Math
|
||||
} // namespace Seele
|
||||
@@ -1,25 +1,25 @@
|
||||
#include "Vector.h"
|
||||
#include <regex>
|
||||
|
||||
using namespace Seele;
|
||||
using namespace Seele::Math;
|
||||
|
||||
std::ostream& Seele::operator<<(std::ostream& stream, const Vector2& vector)
|
||||
std::ostream& operator<<(std::ostream& stream, const Vector2& vector)
|
||||
{
|
||||
stream << "(" << vector.x << ", " << vector.y << ")";
|
||||
return stream;
|
||||
}
|
||||
std::ostream& Seele::operator<<(std::ostream& stream, const Vector& vector)
|
||||
std::ostream& operator<<(std::ostream& stream, const Vector& vector)
|
||||
{
|
||||
stream << "(" << vector.x << ", " << vector.y << ", " << vector.z << ")";
|
||||
return stream;
|
||||
}
|
||||
std::ostream& Seele::operator<<(std::ostream& stream, const Vector4& vector)
|
||||
std::ostream& operator<<(std::ostream& stream, const Vector4& vector)
|
||||
{
|
||||
stream << "(" << vector.x << ", " << vector.y << ", " << vector.z << ", " << vector.w << ")";
|
||||
return stream;
|
||||
}
|
||||
|
||||
Vector Seele::parseVector(const char* str)
|
||||
Vector Seele::Math::parseVector(const char* str)
|
||||
{
|
||||
//regex pattern consisting of 'float3(xComp, yComp, zComp)', more also matches for invalid floats, but that will throw later
|
||||
std::regex pattern("float3\\(\\s*([0-9.]+f?)\\s*,\\s*([0-9.]+f?)\\s*,\\s*([0-9.]+f?)\\s*\\)");
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
#pragma once
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4201)
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#pragma warning(pop)
|
||||
namespace Seele
|
||||
{
|
||||
namespace Math
|
||||
{
|
||||
typedef glm::vec2 Vector2;
|
||||
typedef glm::vec3 Vector;
|
||||
typedef glm::vec4 Vector4;
|
||||
@@ -95,4 +100,5 @@ static inline Vector toRotator(const Quaternion &other)
|
||||
}
|
||||
return rotatorFromQuat;
|
||||
}
|
||||
} // namespace Math
|
||||
} // namespace Seele
|
||||
Reference in New Issue
Block a user