Merge branch 'main' into Fix-RenderableDeleteCrash

This commit is contained in:
Kah Wei 2022-10-25 14:33:03 +08:00
commit b059385c8b
13 changed files with 642 additions and 201 deletions

View File

@ -1,17 +0,0 @@
/************************************************************************************//*!
\file Quaternion.hxx
\author Diren D Bharwani, diren.dbharwani, 390002520
\par email: diren.dbharwani\@digipen.edu
\date Oct 23, 2022
\brief Contains the definitions of Quaternion struct.
Note: This file is written in C++17/CLI.
Copyright (C) 2021 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
// TODO(Diren)

View File

@ -29,13 +29,21 @@ namespace SHADE
{ {
GetNativeComponent()->SetLocalPosition(Convert::ToNative(val)); GetNativeComponent()->SetLocalPosition(Convert::ToNative(val));
} }
Vector3 Transform::LocalRotation::get() Quaternion Transform::LocalRotation::get()
{ {
return Convert::ToCLI(GetNativeComponent()->GetLocalRotation()); return Convert::ToCLI(GetNativeComponent()->GetLocalOrientation());
} }
void Transform::LocalRotation::set(Vector3 val) void Transform::LocalRotation::set(Quaternion val)
{ {
GetNativeComponent()->SetLocalRotation(Convert::ToNative(val)); GetNativeComponent()->SetLocalOrientation(Convert::ToNative(val));
}
Vector3 Transform::LocalEulerAngles::get()
{
return Convert::ToCLI(GetNativeComponent()->GetLocalRotation());
}
void Transform::LocalEulerAngles::set(Vector3 val)
{
GetNativeComponent()->SetLocalRotation(Convert::ToNative(val));
} }
Vector3 Transform::LocalScale::get() Vector3 Transform::LocalScale::get()
{ {
@ -54,13 +62,21 @@ namespace SHADE
{ {
GetNativeComponent()->SetWorldPosition(Convert::ToNative(val)); GetNativeComponent()->SetWorldPosition(Convert::ToNative(val));
} }
Vector3 Transform::GlobalRotation::get() Quaternion Transform::GlobalRotation::get()
{ {
return Convert::ToCLI(GetNativeComponent()->GetWorldRotation()); return Convert::ToCLI(GetNativeComponent()->GetLocalOrientation());
} }
void Transform::GlobalRotation::set(Vector3 val) void Transform::GlobalRotation::set(Quaternion val)
{ {
GetNativeComponent()->SetWorldRotation(Convert::ToNative(val)); GetNativeComponent()->SetWorldOrientation(Convert::ToNative(val));
}
Vector3 Transform::GlobalEulerAngles::get()
{
return Convert::ToCLI(GetNativeComponent()->GetWorldRotation());
}
void Transform::GlobalEulerAngles::set(Vector3 val)
{
GetNativeComponent()->SetWorldRotation(Convert::ToNative(val));
} }
Vector3 Transform::GlobalScale::get() Vector3 Transform::GlobalScale::get()
{ {

View File

@ -17,14 +17,14 @@ of DigiPen Institute of Technology is prohibited.
// Project Includes // Project Includes
#include "Components/Component.hxx" #include "Components/Component.hxx"
#include "Math/Vector3.hxx" #include "Math/Vector3.hxx"
#include "Utility/Convert.hxx" #include "Math/Quaternion.hxx"
// External Dependencies // External Dependencies
#include "Math/Transform/SHTransformComponent.h" #include "Math/Transform/SHTransformComponent.h"
namespace SHADE namespace SHADE
{ {
/// <summary> /// <summary>
/// CLR version of the the SHADE Engine's TransformComponent. /// CLR version of the SHADE Engine's TransformComponent.
/// </summary> /// </summary>
public ref class Transform : public Component<SHTransformComponent> public ref class Transform : public Component<SHTransformComponent>
{ {
@ -52,9 +52,17 @@ namespace SHADE
void set(Vector3 val); void set(Vector3 val);
} }
/// <summary> /// <summary>
/// Local Z-axis rotation angle stored by this Transform in Radians. /// Local rotation quaternion stored by this Transform.
/// </summary> /// </summary>
property Vector3 LocalRotation property Quaternion LocalRotation
{
Quaternion get();
void set(Quaternion val);
}
/// <summary>
/// Local euler angle rotations stored by this Transform.
/// </summary>
property Vector3 LocalEulerAngles
{ {
Vector3 get(); Vector3 get();
void set(Vector3 val); void set(Vector3 val);
@ -76,16 +84,23 @@ namespace SHADE
void set(Vector3 val); void set(Vector3 val);
} }
/// <summary> /// <summary>
/// Global Z-axis rotation angle stored by this Transform in Radians. /// Global rotation quaternion stored by this Transform.
/// </summary> /// </summary>
property Vector3 GlobalRotation property Quaternion GlobalRotation
{
Quaternion get();
void set(Quaternion val);
}
/// <summary>
/// Global euler angle rotations stored by this Transform.
/// </summary>
property Vector3 GlobalEulerAngles
{ {
Vector3 get(); Vector3 get();
void set(Vector3 val); void set(Vector3 val);
} }
/// <summary> /// <summary>
/// Global scale stored by this Transform. /// Global scale stored by this Transform.
/// Note that this operation is expensive.
/// </summary> /// </summary>
property Vector3 GlobalScale property Vector3 GlobalScale
{ {

View File

@ -21,7 +21,7 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Utility Functions */ /* Utility Functions */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
double Math::Wrap(double value, double min, double max) float Math::Wrap(float value, float min, float max)
{ {
while (value < min) while (value < min)
{ {
@ -33,24 +33,24 @@ namespace SHADE
} }
return value; return value;
} }
double Math::DegreesToRadians(double degrees) float Math::DegreesToRadians(float degrees)
{ {
return degrees * Deg2Rad; return degrees * Deg2Rad;
} }
double Math::RadiansToDegrees(double radians) float Math::RadiansToDegrees(float radians)
{ {
return radians * Rad2Deg; return radians * Rad2Deg;
} }
double Math::Lerp(double a, double b, double t) float Math::Lerp(float a, float b, float t)
{ {
return LerpUnclamped(a, b, System::Math::Clamp(t, 0.0, 1.0)); return LerpUnclamped(a, b, System::Math::Clamp(t, 0.0f, 1.0f));
} }
double Math::LerpUnclamped(double a, double b, double t) float Math::LerpUnclamped(float a, float b, float t)
{ {
return a + t * (b - a); return a + t * (b - a);
} }
double Math::InverseLerp(double a, double b, double value) float Math::InverseLerp(float a, float b, float value)
{ {
return (value - a) / (b - a); return (value - a) / (b - a);
} }

View File

@ -27,11 +27,11 @@ namespace SHADE
/// <summary> /// <summary>
/// Degrees-to-radians conversion constant /// Degrees-to-radians conversion constant
/// </summary> /// </summary>
static constexpr double Deg2Rad = System::Math::PI / 180.0; static constexpr float Deg2Rad = System::Math::PI / 180.0f;
/// <summary> /// <summary>
/// Radians-to-degrees conversion constant /// Radians-to-degrees conversion constant
/// </summary> /// </summary>
static constexpr double Rad2Deg = 180.0 / System::Math::PI; static constexpr float Rad2Deg = 180.0f / System::Math::PI;
/// <summary> /// <summary>
/// Small value used for single precision floating point comparisons. /// Small value used for single precision floating point comparisons.
/// </summary> /// </summary>
@ -47,28 +47,28 @@ namespace SHADE
/// <param name="min">Minimum value to wrap at.</param> /// <param name="min">Minimum value to wrap at.</param>
/// <param name="max">Maximum value to wrap at.</param> /// <param name="max">Maximum value to wrap at.</param>
/// <returns>Wrapped value.</returns> /// <returns>Wrapped value.</returns>
static double Wrap(double value, double min, double max); static float Wrap(float value, float min, float max);
/// <summary> /// <summary>
/// Converts an angle from degree representation to radian representation. /// Converts an angle from degree representation to radian representation.
/// </summary> /// </summary>
/// <param name="degrees">Degree-based angle to convert.</param> /// <param name="degrees">Degree-based angle to convert.</param>
/// <returns>The specified angle in radians.</returns> /// <returns>The specified angle in radians.</returns>
static double DegreesToRadians(double degrees); static float DegreesToRadians(float degrees);
/// <summary> /// <summary>
/// Converts an angle from radian representation to degree representation. /// Converts an angle from radian representation to degree representation.
/// </summary> /// </summary>
/// <param name="radians">Radian-based angle to convert.</param> /// <param name="radians">Radian-based angle to convert.</param>
/// <returns>The specified angle in degrees.</returns> /// <returns>The specified angle in degrees.</returns>
static double RadiansToDegrees(double radians); static float RadiansToDegrees(float radians);
/// <summary> /// <summary>
/// Linearly interpolates between a and b by t. /// Linearly interpolates between a and b by t.
/// The parameter t is clamped to the range [0, 1]. /// The parameter t is clamped to the range [0, 1].
/// </summary> /// </summary>
/// <param name="a">The start value.</param> /// <param name="a">The start value.</param>
/// <param name="b">The end value.</param> /// <param name="b">The end value.</param>
/// <param name="t">The interpolation value between the two double.</param> /// <param name="t">The interpolation value between the two float.</param>
/// <returns>The interpolated double result between the two double values.</returns> /// <returns>The interpolated float result between the two float values.</returns>
static double Lerp(double a, double b, double t); static float Lerp(float a, float b, float t);
/// <summary> /// <summary>
/// Linearly interpolates between a and b by t. /// Linearly interpolates between a and b by t.
/// The parameter t is not clamped and a value based on a and b is supported. /// The parameter t is not clamped and a value based on a and b is supported.
@ -77,9 +77,9 @@ namespace SHADE
/// </summary> /// </summary>
/// <param name="a">The start value.</param> /// <param name="a">The start value.</param>
/// <param name="b">The end value.</param> /// <param name="b">The end value.</param>
/// <param name="t">The interpolation value between the two double.</param> /// <param name="t">The interpolation value between the two float.</param>
/// <returns>The interpolated double result between the two double values.</returns> /// <returns>The interpolated float result between the two float values.</returns>
static double LerpUnclamped(double a, double b, double t); static float LerpUnclamped(float a, float b, float t);
/// <summary> /// <summary>
/// Calculates the linear parameter t that produces the interpolant value within the range [a, b]. /// Calculates the linear parameter t that produces the interpolant value within the range [a, b].
/// </summary> /// </summary>
@ -87,6 +87,6 @@ namespace SHADE
/// <param name="b">End value.</param> /// <param name="b">End value.</param>
/// <param name="value">Value between start and end.</param> /// <param name="value">Value between start and end.</param>
/// <returns>Percentage of value between start and end.</returns> /// <returns>Percentage of value between start and end.</returns>
static double InverseLerp(double a, double b, double value); static float InverseLerp(float a, float b, float value);
}; };
} }

View File

@ -0,0 +1,170 @@
/************************************************************************************//*!
\file Quaternion.cxx
\author Diren D Bharwani, diren.dbharwani, 390002520
\par email: diren.dbharwani\@digipen.edu
\date Oct 23, 2022
\brief Contains the definitions of functions in the Quaternion struct.
Note: This file is written in C++17/CLI.
Copyright (C) 2021 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
// Precompiled Headers
#include "SHpch.h"
// Primary Header
#include "Quaternion.hxx"
// External Dependencies
#include "Math/SHQuaternion.h"
#include "Math/Vector/SHVec4.h"
// Project Headers
#include "Utility/Convert.hxx"
#include "Math.hxx"
namespace SHADE
{
/*---------------------------------------------------------------------------------*/
/* Constructors */
/*---------------------------------------------------------------------------------*/
Quaternion::Quaternion(float _x, float _y, float _z, float _w)
: x { _x }
, y { _y }
, z { _z }
, w { _w }
{}
/*---------------------------------------------------------------------------------*/
/* Usage Functions */
/*---------------------------------------------------------------------------------*/
void Quaternion::SetFromToRotation(Vector3 fromDirection, Vector3 toDirection)
{
const SHQuaternion R = SHQuaternion::FromToRotation(Convert::ToNative(fromDirection), Convert::ToNative(toDirection));
*this = Convert::ToCLI(R);
}
void Quaternion::SetLookRotation(Vector3 view, Vector3 up)
{
const SHQuaternion R = SHQuaternion::LookRotation(Convert::ToNative(view), Convert::ToNative(up));
*this = Convert::ToCLI(R);
}
void Quaternion::ToAngleAxis(float^% angle, Vector3^% axis)
{
const SHVec4 NATIVE_AXIS_ANGLE = Convert::ToNative(*this).GetAxisAngle();
axis = Convert::ToCLI(NATIVE_AXIS_ANGLE.ToVec3());
angle = NATIVE_AXIS_ANGLE.w;
}
System::String^ Quaternion::ToString()
{
return ValueType::ToString();
}
/*---------------------------------------------------------------------------------*/
/* IEquatable */
/*---------------------------------------------------------------------------------*/
bool Quaternion::Equals(Quaternion other)
{
const float DOT = Dot(*this, other);
return fabs(1.0f - DOT) <= Math::Epsilon;
}
/*---------------------------------------------------------------------------------*/
/* Object Overrides */
/*---------------------------------------------------------------------------------*/
bool Quaternion::Equals(Object^ o)
{
return ValueType::Equals(o);
}
int Quaternion::GetHashCode()
{
return ValueType::GetHashCode();
}
/*---------------------------------------------------------------------------------*/
/* Static Functions */
/*---------------------------------------------------------------------------------*/
float Quaternion::Angle(Quaternion a, Quaternion b)
{
return SHQuaternion::Angle(Convert::ToNative(a), Convert::ToNative(b));
}
Quaternion Quaternion::AngleAxis(float angle, Vector3 axis)
{
return Convert::ToCLI(SHQuaternion::FromAxisAngle(Convert::ToNative(axis), angle));
}
float Quaternion::Dot(Quaternion a, Quaternion b)
{
return (a.x * b.x) + (a.y * b.y) + (a.z * b.z) + (a.w * b.w);
}
Quaternion Quaternion::Euler(float _x, float _y, float _z)
{
return Convert::ToCLI(SHQuaternion::FromPitchYawRoll(_x, _y, _z));
}
Quaternion Quaternion::FromToRotation(Vector3 fromDirection, Vector3 toDirection)
{
return Convert::ToCLI(SHQuaternion::FromToRotation(Convert::ToNative(fromDirection), Convert::ToNative(toDirection)));
}
Quaternion Quaternion::Inverse(Quaternion rotation)
{
return Convert::ToCLI(SHQuaternion::Inverse(Convert::ToNative(rotation)));
}
Quaternion Quaternion::Lerp(Quaternion a, Quaternion b, float t)
{
return Convert::ToCLI(SHQuaternion::ClampedLerp(Convert::ToNative(a), Convert::ToNative(b), t));
}
Quaternion Quaternion::LerpUnclamped(Quaternion a, Quaternion b, float t)
{
return Convert::ToCLI(SHQuaternion::Lerp(Convert::ToNative(a), Convert::ToNative(b), t));
}
Quaternion Quaternion::LookRotation(Vector3 forward, Vector3 upwards)
{
return Convert::ToCLI(SHQuaternion::LookRotation(Convert::ToNative(forward), Convert::ToNative(upwards)));
}
Quaternion Quaternion::Normalize(Quaternion q)
{
return Convert::ToCLI(SHQuaternion::Normalise(Convert::ToNative(q)));
}
Quaternion Quaternion::RotateTowards(Quaternion from, Quaternion to, float maxDegreesDelta)
{
return Convert::ToCLI(SHQuaternion::RotateTowards(Convert::ToNative(from), Convert::ToNative(to), Math::DegreesToRadians(maxDegreesDelta)));
}
Quaternion Quaternion::Slerp(Quaternion a, Quaternion b, float t)
{
return Convert::ToCLI(SHQuaternion::ClampedSlerp(Convert::ToNative(a), Convert::ToNative(b), t));
}
Quaternion Quaternion::SlerpUnclamped(Quaternion a, Quaternion b, float t)
{
return Convert::ToCLI(SHQuaternion::Slerp(Convert::ToNative(a), Convert::ToNative(b), t));
}
Quaternion Quaternion::operator*(Quaternion lhs, Quaternion rhs)
{
return Convert::ToCLI(Convert::ToNative(lhs) * Convert::ToNative(rhs));
}
bool Quaternion::operator==(Quaternion lhs, Quaternion rhs)
{
return lhs.Equals(rhs);
}
}

View File

@ -0,0 +1,237 @@
/************************************************************************************//*!
\file Quaternion.hxx
\author Diren D Bharwani, diren.dbharwani, 390002520
\par email: diren.dbharwani\@digipen.edu
\date Oct 23, 2022
\brief Contains the definitions of Quaternion struct.
Note: This file is written in C++17/CLI.
Copyright (C) 2021 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
// Standard Libraries
#include <limits>
// Project Includes
#include "Vector3.hxx"
namespace SHADE
{
///<summary>
/// CLR version of SHADE's Quaternion class that represents an orientation.
/// Designed to closely match Unity's Quaternion struct.
/// </summary>
[System::Runtime::InteropServices::StructLayout(System::Runtime::InteropServices::LayoutKind::Sequential)]
public value struct Quaternion : public System::IEquatable<Quaternion>
{
public:
/*-----------------------------------------------------------------------------*/
/* Constants */
/*-----------------------------------------------------------------------------*/
#pragma region Constants
///<summary>
/// Shorthand for writing Quaternion(0, 0, 0, 1).
///</summary>
static initonly Quaternion Identity = Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
#pragma endregion
/*-----------------------------------------------------------------------------*/
/* Public Members */
/*-----------------------------------------------------------------------------*/
///<summary>
/// X-component of the Quaternion.
/// Don't modify this directly unless you know quaternions inside out.
///</summary>
float x;
///<summary>
/// Y-component of the Quaternion.
/// Don't modify this directly unless you know quaternions inside out.
///</summary>
float y;
///<summary>
/// Z-component of the Quaternion.
/// Don't modify this directly unless you know quaternions inside out.
///</summary>
float z;
///<summary>
/// W-component of the Quaternion. Do not directly modify quaternions.
///</summary>
float w;
/*-----------------------------------------------------------------------------*/
/* Constructors */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Constructor to construct a Quaternion with the specified components.
/// </summary>
/// <param name="_x">X-coordinate to set.</param>
/// <param name="_y">Y-coordinate to set.</param>
/// <param name="_z">Z-coordinate to set.</param>
/// <param name="_z">W-coordinate to set.</param>
Quaternion(float _x, float _y, float _z, float _w);
/*-----------------------------------------------------------------------------*/
/* Usage Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Creates a rotation which rotates from fromDirection to toDirection. <br/>
/// Use this to create a rotation which starts at the first Vector (fromDirection) and rotates to the second Vector (toDirection).
/// These Vectors must be set up in a script.
/// </summary>
void SetFromToRotation(Vector3 fromDirection, Vector3 toDirection);
/// <summary>
/// Creates a rotation with the specified forward and upwards directions. <br/>
/// The result is applied to this quaternion.
/// If used to orient a Transform, the Z axis will be aligned with forward and the Y axis with upwards, assuming these vectors are orthogonal.
/// Logs an error if the forward direction is zero.
/// </summary>
/// <param name="view">The direction to look in.</param>
/// <param name="up">The vector that defines in which direction up is.</param>
void SetLookRotation(Vector3 view, Vector3 up);
/// <summary>
/// Converts a rotation to angle-axis representation (angles in degrees).
/// </summary>
void ToAngleAxis(float^% angle, Vector3^% axis);
System::String^ ToString() override;
/*-----------------------------------------------------------------------------*/
/* IEquatable */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Compares equality with an object of the same type.
/// </summary>
/// <param name="other">The object to compare with.</param>
/// <returns>True if both objects are the same.</returns>
virtual bool Equals(Quaternion other);
/*-----------------------------------------------------------------------------*/
/* Object */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Compares equality with another unboxed object.
/// </summary>
/// <param name="o">The unboxed object to compare with.</param>
/// <returns>True if both objects are the same.</returns>
bool Equals(Object^ o) override;
/// <summary>
/// Gets a unique hash for this object.
/// </summary>
/// <returns>Unique hash for this object.</returns>
int GetHashCode() override;
/*-----------------------------------------------------------------------------*/
/* Static Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Returns the angle in degrees between two rotations a and b.<br/>
/// </summary>
/// <returns>The angle in degrees between the two vectors. </returns>
static float Angle(Quaternion a, Quaternion b);
/// <summary>
/// Creates a rotation which rotates angle degrees around axis.
/// </summary>
static Quaternion AngleAxis(float angle, Vector3 axis);
/// <summary>
/// The dot product between two rotations.
/// </summary>
static float Dot(Quaternion a, Quaternion b);
/// <summary>
/// Returns a rotation that rotates y degrees around the y axis, x degrees around the x axis, and z degrees around the z axis; applied in that order.
/// </summary>
static Quaternion Euler(float _x, float _y, float _z);
/// <summary>
/// Creates a rotation which rotates from fromDirection to toDirection.
/// </summary>
static Quaternion FromToRotation(Vector3 fromDirection, Vector3 toDirection);
/// <summary>
/// Returns the Inverse of rotation.
/// </summary>
static Quaternion Inverse(Quaternion rotation);
/// <summary>
/// Interpolates between a and b by t and normalizes the result afterwards. The parameter t is clamped to the range [0, 1].
/// </summary>
/// <param name="a">Start value, returned when t = 0.</param>
/// <param name="b">End value, returned when t = 1.</param>
/// <param name="t">Interpolation ratio.</param>
/// <returns> A quaternion interpolated between quaternions a and b.</returns>
static Quaternion Lerp(Quaternion a, Quaternion b, float t);
/// <summary>
/// Interpolates between a and b by t and normalizes the result afterwards. The parameter t is not clamped.
/// </summary>
static Quaternion LerpUnclamped(Quaternion a, Quaternion b, float t);
/// <summary>
/// Creates a rotation with the specified forward and upwards directions. <br/>
/// Z axis will be aligned with forward, X axis aligned with cross product between forward and upwards, and Y axis aligned with cross product between Z and X.
/// </summary>
static Quaternion LookRotation(Vector3 forward, Vector3 upwards);
/// <summary>
/// Converts this quaternion to one with the same orientation but with a magnitude of 1.
/// </summary>
static Quaternion Normalize(Quaternion q);
/// <summary>
/// Rotates a rotation from towards to. <br/>
/// The from quaternion is rotated towards to by an angular step of maxDegreesDelta (but note that the rotation will not overshoot).
/// Negative values of maxDegreesDelta will move away from to until the rotation is exactly the opposite direction.
/// </summary>
static Quaternion RotateTowards(Quaternion from, Quaternion to, float maxDegreesDelta);
/// <summary>
/// Spherically interpolates between quaternions a and b by ratio t. The parameter t is clamped to the range [0, 1].
/// </summary>
/// <param name="a">Start value, returned when t = 0.</param>
/// <param name="b">End value, returned when t = 1.</param>
/// <param name="t">Interpolation ratio.</param>
/// <returns> A quaternion spherically interpolated between quaternions a and b.</returns>
static Quaternion Slerp(Quaternion a, Quaternion b, float t);
/// <summary>
/// Spherically interpolates between a and b by t. The parameter t is not clamped.
/// </summary>
static Quaternion SlerpUnclamped(Quaternion a, Quaternion b, float t);
/*-----------------------------------------------------------------------------*/
/* Overloaded Operators */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Combines rotations lhs and rhs.
/// </summary>
/// <param name="lhs">Left-hand side quaternion.</param>
/// <param name="rhs">Right-hand side quaternion.</param>
static Quaternion operator*(Quaternion lhs, Quaternion rhs);
/// <summary>
/// Are two quaternions equal to each other?
/// </summary>
/// <param name="lhs">Left-hand side quaternion.</param>
/// <param name="rhs">Right-hand side quaternion.</param>
static bool operator==(Quaternion lhs, Quaternion rhs);
};
} // namespace SHADE

View File

@ -26,10 +26,10 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Constructors */ /* Constructors */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
Vector2::Vector2(double _x) Vector2::Vector2(float _x)
: Vector2 { _x, 0.0 } : Vector2 { _x, 0.0f }
{} {}
Vector2::Vector2(double _x, double _y) Vector2::Vector2(float _x, float _y)
: x { _x } : x { _x }
, y { _y } , y { _y }
{} {}
@ -47,22 +47,22 @@ namespace SHADE
return *this / GetMagnitude(); return *this / GetMagnitude();
} }
double Vector2::GetMagnitude() float Vector2::GetMagnitude()
{ {
return sqrt(x * x + y * y); return sqrt(x * x + y * y);
} }
double Vector2::GetSqrMagnitude() float Vector2::GetSqrMagnitude()
{ {
return x * x + y * y; return x * x + y * y;
} }
double Vector2::AngleFromRightRadians() float Vector2::AngleFromRightRadians()
{ {
return atan2(y, x); return atan2(y, x);
} }
double Vector2::AngleFromRightDegrees() float Vector2::AngleFromRightDegrees()
{ {
return Math::RadiansToDegrees(AngleFromRightRadians()); return Math::RadiansToDegrees(AngleFromRightRadians());
} }
@ -72,7 +72,7 @@ namespace SHADE
return IsNearPoint(point, Math::Epsilon); return IsNearPoint(point, Math::Epsilon);
} }
bool Vector2::IsNearPoint(Vector2 point, double tolerance) bool Vector2::IsNearPoint(Vector2 point, float tolerance)
{ {
return (*this - point).GetSqrMagnitude() < (tolerance * tolerance); return (*this - point).GetSqrMagnitude() < (tolerance * tolerance);
} }
@ -113,13 +113,13 @@ namespace SHADE
{ {
return IsNear(lhs, rhs, Math::Epsilon); return IsNear(lhs, rhs, Math::Epsilon);
} }
bool Vector2::IsNear(Vector2 lhs, Vector2 rhs, double tolerance) bool Vector2::IsNear(Vector2 lhs, Vector2 rhs, float tolerance)
{ {
return (std::abs(lhs.x) - std::abs(rhs.x)) < tolerance return (std::abs(lhs.x) - std::abs(rhs.x)) < tolerance
&& &&
(std::abs(lhs.y) - std::abs(rhs.y)) < tolerance; (std::abs(lhs.y) - std::abs(rhs.y)) < tolerance;
} }
double Vector2::Dot(Vector2 lhs, Vector2 rhs) float Vector2::Dot(Vector2 lhs, Vector2 rhs)
{ {
return lhs.x * rhs.x + lhs.y * rhs.y; return lhs.x * rhs.x + lhs.y * rhs.y;
} }
@ -153,12 +153,12 @@ namespace SHADE
} }
Vector2 Vector2::Reflect(Vector2 vec, Vector2 normal) Vector2 Vector2::Reflect(Vector2 vec, Vector2 normal)
{ {
return vec - (Project(vec, normal.GetNormalised()) * 2.0); return vec - (Project(vec, normal.GetNormalised()) * 2.0f);
} }
Vector2 Vector2::RotateRadians(Vector2 vec, double radians) Vector2 Vector2::RotateRadians(Vector2 vec, float radians)
{ {
const double SINE = sin(radians); const float SINE = sin(radians);
const double COSINE = cos(radians); const float COSINE = cos(radians);
return Vector2 return Vector2
( (
@ -166,35 +166,35 @@ namespace SHADE
vec.x * SINE + vec.y * COSINE vec.x * SINE + vec.y * COSINE
); );
} }
Vector2 Vector2::RotateDegrees(Vector2 vec, double degrees) Vector2 Vector2::RotateDegrees(Vector2 vec, float degrees)
{ {
return RotateRadians(vec, Math::DegreesToRadians(degrees)); return RotateRadians(vec, Math::DegreesToRadians(degrees));
} }
Vector2 Vector2::Min(Vector2 lhs, Vector2 rhs) Vector2 Vector2::Min(Vector2 lhs, Vector2 rhs)
{ {
double lx = lhs.x, rx = rhs.x; float lx = lhs.x, rx = rhs.x;
double ly = lhs.y, ry = rhs.y; float ly = lhs.y, ry = rhs.y;
return Vector2(std::min(lx, rx), return Vector2(std::min(lx, rx),
std::min(ly, ry)); std::min(ly, ry));
} }
Vector2 Vector2::Max(Vector2 lhs, Vector2 rhs) Vector2 Vector2::Max(Vector2 lhs, Vector2 rhs)
{ {
double lx = lhs.x, rx = rhs.x; float lx = lhs.x, rx = rhs.x;
double ly = lhs.y, ry = rhs.y; float ly = lhs.y, ry = rhs.y;
return Vector2(std::max(lx, rx), return Vector2(std::max(lx, rx),
std::max(ly, ry)); std::max(ly, ry));
} }
Vector2 Vector2::Lerp(Vector2 a, Vector2 b, double t) Vector2 Vector2::Lerp(Vector2 a, Vector2 b, float t)
{ {
return LerpUnclamped(a, b, std::clamp(t, 0.0, 1.0)); return LerpUnclamped(a, b, std::clamp(t, 0.0f, 1.0f));
} }
Vector2 Vector2::LerpUnclamped(Vector2 a, Vector2 b, double t) Vector2 Vector2::LerpUnclamped(Vector2 a, Vector2 b, float t)
{ {
return a + ((b - a) * t); return a + ((b - a) * t);
} }
Vector2 Vector2::MoveTowards(Vector2 current, Vector2 target, double maxDistanceDelta) Vector2 Vector2::MoveTowards(Vector2 current, Vector2 target, float maxDistanceDelta)
{ {
// Ignore if it is exactly on the same point // Ignore if it is exactly on the same point
if (current == target) if (current == target)
@ -206,7 +206,7 @@ namespace SHADE
// Check if check if is behind or ahead of target // Check if check if is behind or ahead of target
Vector2 DIFF = target - newPos; Vector2 DIFF = target - newPos;
if (Dot(DELTA, DIFF) < 0.0) if (Dot(DELTA, DIFF) < 0.0f)
{ {
newPos = target; newPos = target;
} }
@ -236,7 +236,7 @@ namespace SHADE
lhs.y * rhs.y lhs.y * rhs.y
); );
} }
Vector2 Vector2::operator*(Vector2 lhs, double rhs) Vector2 Vector2::operator*(Vector2 lhs, float rhs)
{ {
return Vector2 return Vector2
( (
@ -244,7 +244,7 @@ namespace SHADE
lhs.y * rhs lhs.y * rhs
); );
} }
Vector2 Vector2::operator/(Vector2 lhs, double rhs) Vector2 Vector2::operator/(Vector2 lhs, float rhs)
{ {
return Vector2 return Vector2
( (

View File

@ -19,8 +19,8 @@ of DigiPen Institute of Technology is prohibited.
namespace SHADE namespace SHADE
{ {
///<summary> ///<summary>
/// CLR version of the the SHADE Engine's Vector2 class that represents a /// CLR version of SHADE Engine's Vector2 class that represents a 2-Dimensional Vector.
/// 2-Dimensional Vector. Designed to closely match Unity's Vector2 struct. /// Designed to closely match Unity's Vector2 struct.
/// </summary> /// </summary>
[System::Runtime::InteropServices::StructLayout(System::Runtime::InteropServices::LayoutKind::Sequential)] [System::Runtime::InteropServices::StructLayout(System::Runtime::InteropServices::LayoutKind::Sequential)]
public value struct Vector2 : public System::IEquatable<Vector2> public value struct Vector2 : public System::IEquatable<Vector2>
@ -33,37 +33,37 @@ namespace SHADE
///<summary> ///<summary>
/// Shorthand for writing Vector2(0, -1). /// Shorthand for writing Vector2(0, -1).
///</summary> ///</summary>
static initonly Vector2 Down = Vector2(0.0, -1.0); static initonly Vector2 Down = Vector2(0.0f, -1.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector2(-1, 0). /// Shorthand for writing Vector2(-1, 0).
///</summary> ///</summary>
static initonly Vector2 Left = Vector2(-1.0, 0.0); static initonly Vector2 Left = Vector2(-1.0f, 0.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector2(double.NegativeInfinity, /// Shorthand for writing Vector2(float.NegativeInfinity,
/// double.NegativeInfinity). /// float.NegativeInfinity).
///</summary> ///</summary>
static initonly Vector2 NegativeInfinity = Vector2(std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest()); static initonly Vector2 NegativeInfinity = Vector2(std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest());
///<summary> ///<summary>
/// Shorthand for writing Vector2(1, 1). /// Shorthand for writing Vector2(1, 1).
///</summary> ///</summary>
static initonly Vector2 One = Vector2(1.0, 1.0); static initonly Vector2 One = Vector2(1.0f, 1.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector2(double.PositiveInfinity, /// Shorthand for writing Vector2(float.PositiveInfinity,
/// double.PositiveInfinity). /// float.PositiveInfinity).
///</summary> ///</summary>
static initonly Vector2 PositiveInfinity = Vector2(std::numeric_limits<double>::max(), std::numeric_limits<double>::max()); static initonly Vector2 PositiveInfinity = Vector2(std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
///<summary> ///<summary>
/// Shorthand for writing Vector2(1, 0). /// Shorthand for writing Vector2(1, 0).
///</summary> ///</summary>
static initonly Vector2 Right = Vector2(1.0, 0.0); static initonly Vector2 Right = Vector2(1.0f, 0.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector2(0, 1). /// Shorthand for writing Vector2(0, 1).
///</summary> ///</summary>
static initonly Vector2 Up = Vector2(0.0, 1.0); static initonly Vector2 Up = Vector2(0.0f, 1.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector2(0, 0). /// Shorthand for writing Vector2(0, 0).
///</summary> ///</summary>
static initonly Vector2 Zero = Vector2(0.0, 0.0); static initonly Vector2 Zero = Vector2(0.0f, 0.0f);
#pragma endregion #pragma endregion
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
@ -72,27 +72,27 @@ namespace SHADE
///<summary> ///<summary>
/// X-component of the Vector2. /// X-component of the Vector2.
///</summary> ///</summary>
double x; float x;
///<summary> ///<summary>
/// Y-component of the Vector2. /// Y-component of the Vector2.
///</summary> ///</summary>
double y; float y;
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Constructors */ /* Constructors */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/// <summary> /// <summary>
/// Constructor to construct a Vector2 with the specified components with the /// Constructor to construct a Vector2 with the specified components with the
/// Y-component set to 0.0. /// Y-component set to 0.0f.
/// </summary> /// </summary>
/// <param name="_x">X-coordinate to set.</param> /// <param name="_x">X-coordinate to set.</param>
Vector2(double _x); Vector2(float _x);
/// <summary> /// <summary>
/// Constructor to construct a Vector2 with the specified components.. /// Constructor to construct a Vector2 with the specified components..
/// </summary> /// </summary>
/// <param name="_x">X-coordinate to set.</param> /// <param name="_x">X-coordinate to set.</param>
/// <param name="_y">Y-coordinate to set.</param> /// <param name="_y">Y-coordinate to set.</param>
Vector2(double _x, double _y); Vector2(float _x, float _y);
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Usage Functions */ /* Usage Functions */
@ -117,24 +117,24 @@ namespace SHADE
/// need the precise magnitude, consider using GetSqrMagnitude() instead. /// need the precise magnitude, consider using GetSqrMagnitude() instead.
/// </summary> /// </summary>
/// <returns>Returns the length of this Vector2.</returns> /// <returns>Returns the length of this Vector2.</returns>
double GetMagnitude(); float GetMagnitude();
/// <summary> /// <summary>
/// Calculates and returns the squared magnitude of this Vector2. /// Calculates and returns the squared magnitude of this Vector2.
/// </summary> /// </summary>
/// <returns>Returns the squared length of this Vector2.</returns> /// <returns>Returns the squared length of this Vector2.</returns>
double GetSqrMagnitude(); float GetSqrMagnitude();
/// <summary> /// <summary>
/// Calculates and returns the angle of this vector from the right vector. This /// Calculates and returns the angle of this vector from the right vector. This
/// function returns values between -Math.PI and Math.PI. /// function returns values between -Math.PI and Math.PI.
/// </summary> /// </summary>
/// <returns>Returns the angle of this vector from the right vector in radians.</returns> /// <returns>Returns the angle of this vector from the right vector in radians.</returns>
double AngleFromRightRadians(); float AngleFromRightRadians();
/// <summary> /// <summary>
/// Calculates and returns the angle of this vector from the right vector. This /// Calculates and returns the angle of this vector from the right vector. This
/// function returns values between -180.0 and 180.0. /// function returns values between -180.0f and 180.0f.
/// </summary> /// </summary>
/// <returns>Returns the angle of this vector from the right vector in degrees.</returns> /// <returns>Returns the angle of this vector from the right vector in degrees.</returns>
double AngleFromRightDegrees(); float AngleFromRightDegrees();
/// <summary> /// <summary>
/// Checks if a specified point is near this Vector2 that represents a point with /// Checks if a specified point is near this Vector2 that represents a point with
/// a tolerance value of PLS_EPSILON. /// a tolerance value of PLS_EPSILON.
@ -156,7 +156,7 @@ namespace SHADE
/// True if this Vector2 representing a point and the specified point are within /// True if this Vector2 representing a point and the specified point are within
/// the range of the specified tolerance. False otherwise. /// the range of the specified tolerance. False otherwise.
/// </returns> /// </returns>
bool IsNearPoint(Vector2 point, double tolerance); bool IsNearPoint(Vector2 point, float tolerance);
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* IEquatable */ /* IEquatable */
@ -206,7 +206,7 @@ namespace SHADE
/// <returns> /// <returns>
/// True if the two Vector2s are within the tolerance value specified /// True if the two Vector2s are within the tolerance value specified
/// </returns> /// </returns>
static bool IsNear(Vector2 lhs, Vector2 rhs, double tolerance); static bool IsNear(Vector2 lhs, Vector2 rhs, float tolerance);
/// <summary> /// <summary>
/// Computes and returns the dot product of 2 specified Vector2s. /// Computes and returns the dot product of 2 specified Vector2s.
/// </summary> /// </summary>
@ -215,7 +215,7 @@ namespace SHADE
/// <returns> /// <returns>
/// Scalar value representing the dot product of the two Vector2s. /// Scalar value representing the dot product of the two Vector2s.
/// </returns> /// </returns>
static double Dot(Vector2 lhs, Vector2 rhs); static float Dot(Vector2 lhs, Vector2 rhs);
/// <summary> /// <summary>
/// Computes the inward perpendicular Vector2 to the specified Vector2. /// Computes the inward perpendicular Vector2 to the specified Vector2.
/// Equivalent to calling Perpendicular(lhs, true). This means, the /// Equivalent to calling Perpendicular(lhs, true). This means, the
@ -260,7 +260,7 @@ namespace SHADE
/// Angle to rotate the vector by in an anti-clockwise direction in radians. /// Angle to rotate the vector by in an anti-clockwise direction in radians.
/// </param> /// </param>
/// <returns>The Vector2 that represents the rotated vector.</returns> /// <returns>The Vector2 that represents the rotated vector.</returns>
static Vector2 RotateRadians(Vector2 vec, double radians); static Vector2 RotateRadians(Vector2 vec, float radians);
/// <summary> /// <summary>
/// Rotates a Vector2 on the Z-axis by a specified angle in an anti-clockwise /// Rotates a Vector2 on the Z-axis by a specified angle in an anti-clockwise
/// direction. /// direction.
@ -270,7 +270,7 @@ namespace SHADE
/// Angle to rotate the vector by in an anti-clockwise direction in degrees. /// Angle to rotate the vector by in an anti-clockwise direction in degrees.
/// </param> /// </param>
/// <returns>The Vector2 that represents the rotated vector.</returns> /// <returns>The Vector2 that represents the rotated vector.</returns>
static Vector2 RotateDegrees(Vector2 vec, double degrees); static Vector2 RotateDegrees(Vector2 vec, float degrees);
/// <summary> /// <summary>
/// Computes and returns a Vector2 that is made from the smallest components of /// Computes and returns a Vector2 that is made from the smallest components of
/// the two specified Vector2s. /// the two specified Vector2s.
@ -298,25 +298,25 @@ namespace SHADE
/// This is most commonly used to find a point some fraction of the way along a /// This is most commonly used to find a point some fraction of the way along a
/// line between two endpoints. /// line between two endpoints.
/// </summary> /// </summary>
/// <param name="a">The start Vector2, returned when t = 0.0.</param> /// <param name="a">The start Vector2, returned when t = 0.0f.</param>
/// <param name="b">The end Vector2, returned when t = 1.0.</param> /// <param name="b">The end Vector2, returned when t = 1.0f.</param>
/// <param name="t"> /// <param name="t">
/// Value used to interpolate between a and b which is clamped to /// Value used to interpolate between a and b which is clamped to
/// the range[0, 1]. /// the range[0, 1].
/// </param> /// </param>
/// <returns>The interpolated Vector2.</returns> /// <returns>The interpolated Vector2.</returns>
static Vector2 Lerp(Vector2 a, Vector2 b, double t); static Vector2 Lerp(Vector2 a, Vector2 b, float t);
/// <summary> /// <summary>
/// Linearly interpolates between two specified points. /// Linearly interpolates between two specified points.
/// This is most commonly used to find a point some fraction of the way along a /// This is most commonly used to find a point some fraction of the way along a
/// line between two endpoints. /// line between two endpoints.
/// Unlike Lerp(), t is not clamped to a range at all. /// Unlike Lerp(), t is not clamped to a range at all.
/// </summary> /// </summary>
/// <param name="a">The start Vector2, returned when t = 0.0.</param> /// <param name="a">The start Vector2, returned when t = 0.0f.</param>
/// <param name="b">The end Vector2, returned when t = 1.0.</param> /// <param name="b">The end Vector2, returned when t = 1.0f.</param>
/// <param name="t">Value used to interpolate between a and b.</param> /// <param name="t">Value used to interpolate between a and b.</param>
/// <returns>The interpolated Vector2.</returns> /// <returns>The interpolated Vector2.</returns>
static Vector2 LerpUnclamped(Vector2 a, Vector2 b, double t); static Vector2 LerpUnclamped(Vector2 a, Vector2 b, float t);
/// <summary> /// <summary>
/// Moves a point current towards target. /// Moves a point current towards target.
/// Similar to Lerp(), however, the function will ensure that the distance never /// Similar to Lerp(), however, the function will ensure that the distance never
@ -327,7 +327,7 @@ namespace SHADE
/// <param name="target">The target position to move to.</param> /// <param name="target">The target position to move to.</param>
/// <param name="maxDistanceDelta">Maximum distance moved per call.</param> /// <param name="maxDistanceDelta">Maximum distance moved per call.</param>
/// <returns>Vector representing the moved point.</returns> /// <returns>Vector representing the moved point.</returns>
static Vector2 MoveTowards(Vector2 current, Vector2 target, double maxDistanceDelta); static Vector2 MoveTowards(Vector2 current, Vector2 target, float maxDistanceDelta);
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Overloaded Operators */ /* Overloaded Operators */
@ -361,7 +361,7 @@ namespace SHADE
/// <param name="lhs">Vector2 to multiply with.</param> /// <param name="lhs">Vector2 to multiply with.</param>
/// <param name="rhs">Scalar to multiply with.</param> /// <param name="rhs">Scalar to multiply with.</param>
/// <returns>The result of the scalar multiplication.</returns> /// <returns>The result of the scalar multiplication.</returns>
static Vector2 operator*(Vector2 lhs, double rhs); static Vector2 operator*(Vector2 lhs, float rhs);
/// <summary> /// <summary>
/// Calculates the division of a Vector2 with a scalar value and returns /// Calculates the division of a Vector2 with a scalar value and returns
/// the result. /// the result.
@ -369,7 +369,7 @@ namespace SHADE
/// <param name="lhs">Scalar to divide with.</param> /// <param name="lhs">Scalar to divide with.</param>
/// <param name="rhs">Vector2 to divide with.</param> /// <param name="rhs">Vector2 to divide with.</param>
/// <returns>The result of the scalar division.</returns> /// <returns>The result of the scalar division.</returns>
static Vector2 operator/(Vector2 lhs, double rhs); static Vector2 operator/(Vector2 lhs, float rhs);
/// <summary> /// <summary>
/// Checks if two Vector2s are approximately equal. This is equivalent to /// Checks if two Vector2s are approximately equal. This is equivalent to
/// calling Vector2.IsNear() with default tolerance values. /// calling Vector2.IsNear() with default tolerance values.

View File

@ -11,6 +11,7 @@ Copyright (C) 2021 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited. of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/ *//*************************************************************************************/
// Precompiled Headers // Precompiled Headers
#include "SHpch.h" #include "SHpch.h"
// Primary Header // Primary Header
@ -26,13 +27,13 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Constructors */ /* Constructors */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
Vector3::Vector3(double _x) Vector3::Vector3(float _x)
: Vector3 {_x, 0.0, 0.0} : Vector3 {_x, 0.0f, 0.0f}
{} {}
Vector3::Vector3(double _x, double _y) Vector3::Vector3(float _x, float _y)
: Vector3 {_x, _y, 0.0} : Vector3 {_x, _y, 0.0f}
{} {}
Vector3::Vector3(double _x, double _y, double _z) Vector3::Vector3(float _x, float _y, float _z)
: x { _x } : x { _x }
, y { _y } , y { _y }
, z { _z } , z { _z }
@ -54,22 +55,22 @@ namespace SHADE
return *this / GetSqrMagnitude(); return *this / GetSqrMagnitude();
} }
double Vector3::GetMagnitude() float Vector3::GetMagnitude()
{ {
return sqrt(x * x + y * y + z * z); return sqrt(x * x + y * y + z * z);
} }
double Vector3::GetSqrMagnitude() float Vector3::GetSqrMagnitude()
{ {
return x * x + y * y + z * z; return x * x + y * y + z * z;
} }
double Vector3::Angle2DFromRightRadians() float Vector3::Angle2DFromRightRadians()
{ {
return atan2(y, x); return atan2(y, x);
} }
double Vector3::Angle2DFromRightDegrees() float Vector3::Angle2DFromRightDegrees()
{ {
return Math::RadiansToDegrees(Angle2DFromRightRadians()); return Math::RadiansToDegrees(Angle2DFromRightRadians());
} }
@ -79,7 +80,7 @@ namespace SHADE
return IsNearPoint(point, Math::Epsilon); return IsNearPoint(point, Math::Epsilon);
} }
bool Vector3::IsNearPoint(Vector3 point, double tolerance) bool Vector3::IsNearPoint(Vector3 point, float tolerance)
{ {
return (*this - point).GetSqrMagnitude() < (tolerance * tolerance); return (*this - point).GetSqrMagnitude() < (tolerance * tolerance);
} }
@ -121,7 +122,7 @@ namespace SHADE
{ {
return IsNear(lhs, rhs, Math::Epsilon); return IsNear(lhs, rhs, Math::Epsilon);
} }
bool Vector3::IsNear(Vector3 lhs, Vector3 rhs, double tolerance) bool Vector3::IsNear(Vector3 lhs, Vector3 rhs, float tolerance)
{ {
return (std::abs(lhs.x) - std::abs(rhs.x)) < tolerance return (std::abs(lhs.x) - std::abs(rhs.x)) < tolerance
&& &&
@ -129,7 +130,7 @@ namespace SHADE
&& &&
(std::abs(lhs.z) - std::abs(rhs.z)) < tolerance; (std::abs(lhs.z) - std::abs(rhs.z)) < tolerance;
} }
double Vector3::Dot(Vector3 lhs, Vector3 rhs) float Vector3::Dot(Vector3 lhs, Vector3 rhs)
{ {
return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z; return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z;
} }
@ -145,12 +146,12 @@ namespace SHADE
} }
Vector3 Vector3::Reflect(Vector3 vec, Vector3 normal) Vector3 Vector3::Reflect(Vector3 vec, Vector3 normal)
{ {
return vec - (Project(vec, normal.GetNormalised()) * 2.0); return vec - (Project(vec, normal.GetNormalised()) * 2.0f);
} }
Vector3 Vector3::RotateRadians(Vector3 vec, double radians) Vector3 Vector3::RotateRadians(Vector3 vec, float radians)
{ {
const double SINE = sin(radians); const float SINE = sin(radians);
const double COSINE = cos(radians); const float COSINE = cos(radians);
return Vector3 return Vector3
( (
@ -159,15 +160,15 @@ namespace SHADE
vec.z vec.z
); );
} }
Vector3 Vector3::RotateDegrees(Vector3 vec, double degrees) Vector3 Vector3::RotateDegrees(Vector3 vec, float degrees)
{ {
return RotateRadians(vec, Math::DegreesToRadians(degrees)); return RotateRadians(vec, Math::DegreesToRadians(degrees));
} }
Vector3 Vector3::Min(Vector3 lhs, Vector3 rhs) Vector3 Vector3::Min(Vector3 lhs, Vector3 rhs)
{ {
double lx = lhs.x, rx = rhs.x; float lx = lhs.x, rx = rhs.x;
double ly = lhs.y, ry = rhs.y; float ly = lhs.y, ry = rhs.y;
double lz = lhs.z, rz = rhs.z; float lz = lhs.z, rz = rhs.z;
return Vector3(std::min(lx, rx), return Vector3(std::min(lx, rx),
std::min(ly, ry), std::min(ly, ry),
@ -175,23 +176,23 @@ namespace SHADE
} }
Vector3 Vector3::Max(Vector3 lhs, Vector3 rhs) Vector3 Vector3::Max(Vector3 lhs, Vector3 rhs)
{ {
double lx = lhs.x, rx = rhs.x; float lx = lhs.x, rx = rhs.x;
double ly = lhs.y, ry = rhs.y; float ly = lhs.y, ry = rhs.y;
double lz = lhs.z, rz = rhs.z; float lz = lhs.z, rz = rhs.z;
return Vector3(std::max(lx, rx), return Vector3(std::max(lx, rx),
std::max(ly, ry), std::max(ly, ry),
std::max(lz, rz)); std::max(lz, rz));
} }
Vector3 Vector3::Lerp(Vector3 a, Vector3 b, double t) Vector3 Vector3::Lerp(Vector3 a, Vector3 b, float t)
{ {
return LerpUnclamped(a, b, std::clamp(t, 0.0, 1.0)); return LerpUnclamped(a, b, std::clamp(t, 0.0f, 1.0f));
} }
Vector3 Vector3::LerpUnclamped(Vector3 a, Vector3 b, double t) Vector3 Vector3::LerpUnclamped(Vector3 a, Vector3 b, float t)
{ {
return a + ((b - a) * t); return a + ((b - a) * t);
} }
Vector3 Vector3::MoveTowards(Vector3 current, Vector3 target, double maxDistanceDelta) Vector3 Vector3::MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta)
{ {
// Ignore if it is exactly on the same point // Ignore if it is exactly on the same point
if (current == target) if (current == target)
@ -203,7 +204,7 @@ namespace SHADE
// Check if check if is behind or ahead of target // Check if check if is behind or ahead of target
Vector3 DIFF = target - newPos; Vector3 DIFF = target - newPos;
if (Dot(DELTA, DIFF) < 0.0) if (Dot(DELTA, DIFF) < 0.0f)
{ {
newPos = target; newPos = target;
} }
@ -236,7 +237,7 @@ namespace SHADE
lhs.z * rhs.z lhs.z * rhs.z
); );
} }
Vector3 Vector3::operator*(Vector3 lhs, double rhs) Vector3 Vector3::operator*(Vector3 lhs, float rhs)
{ {
return Vector3 return Vector3
( (
@ -245,7 +246,7 @@ namespace SHADE
lhs.z * rhs lhs.z * rhs
); );
} }
Vector3 Vector3::operator/(Vector3 lhs, double rhs) Vector3 Vector3::operator/(Vector3 lhs, float rhs)
{ {
return Vector3 return Vector3
( (

View File

@ -22,8 +22,8 @@ of DigiPen Institute of Technology is prohibited.
namespace SHADE namespace SHADE
{ {
///<summary> ///<summary>
/// CLR version of the the PlushieEngine's Vector3 class that represents a /// CLR version of SHADE Engine's Vector3 class that represents a 3-Dimensional Vector.
/// 3-Dimensional Vector. Designed to closely match Unity's Vector3 struct. /// Designed to closely match Unity's Vector3 struct.
/// </summary> /// </summary>
[System::Runtime::InteropServices::StructLayout(System::Runtime::InteropServices::LayoutKind::Sequential)] [System::Runtime::InteropServices::StructLayout(System::Runtime::InteropServices::LayoutKind::Sequential)]
public value struct Vector3 : public System::IEquatable<Vector3> public value struct Vector3 : public System::IEquatable<Vector3>
@ -36,49 +36,49 @@ namespace SHADE
///<summary> ///<summary>
/// Shorthand for writing Vector3(0, 0, -1). /// Shorthand for writing Vector3(0, 0, -1).
///</summary> ///</summary>
static initonly Vector3 Back = Vector3(0.0, 0.0, -1.0); static initonly Vector3 Back = Vector3(0.0f, 0.0f, -1.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector3(0, -1, 0). /// Shorthand for writing Vector3(0, -1, 0).
///</summary> ///</summary>
static initonly Vector3 Down = Vector3(0.0, -1.0, 0.0); static initonly Vector3 Down = Vector3(0.0f, -1.0f, 0.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector3(0, 0, 1). /// Shorthand for writing Vector3(0, 0, 1).
///</summary> ///</summary>
static initonly Vector3 Forward = Vector3(0.0, 0.0, 1.0); static initonly Vector3 Forward = Vector3(0.0f, 0.0f, 1.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector3(-1, 0, 0). /// Shorthand for writing Vector3(-1, 0, 0).
///</summary> ///</summary>
static initonly Vector3 Left = Vector3(-1.0, 0.0, 0.0); static initonly Vector3 Left = Vector3(-1.0f, 0.0f, 0.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector3(double.NegativeInfinity, /// Shorthand for writing Vector3(float.NegativeInfinity,
/// double.NegativeInfinity, double.NegativeInfinity). /// float.NegativeInfinity, float.NegativeInfinity).
///</summary> ///</summary>
static initonly Vector3 NegativeInfinity = Vector3(std::numeric_limits<double>::lowest(), static initonly Vector3 NegativeInfinity = Vector3(std::numeric_limits<float>::lowest(),
std::numeric_limits<double>::lowest(), std::numeric_limits<float>::lowest(),
std::numeric_limits<double>::lowest()); std::numeric_limits<float>::lowest());
///<summary> ///<summary>
/// Shorthand for writing Vector3(1, 1, 1). /// Shorthand for writing Vector3(1, 1, 1).
///</summary> ///</summary>
static initonly Vector3 One = Vector3(1.0, 1.0, 1.0); static initonly Vector3 One = Vector3(1.0f, 1.0f, 1.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector3(double.PositiveInfinity, /// Shorthand for writing Vector3(float.PositiveInfinity,
/// double.PositiveInfinity, double.PositiveInfinity). /// float.PositiveInfinity, float.PositiveInfinity).
///</summary> ///</summary>
static initonly Vector3 PositiveInfinity = Vector3(std::numeric_limits<double>::max(), static initonly Vector3 PositiveInfinity = Vector3(std::numeric_limits<float>::max(),
std::numeric_limits<double>::max(), std::numeric_limits<float>::max(),
std::numeric_limits<double>::max()); std::numeric_limits<float>::max());
///<summary> ///<summary>
/// Shorthand for writing Vector3(1, 0, 0). /// Shorthand for writing Vector3(1, 0, 0).
///</summary> ///</summary>
static initonly Vector3 Right = Vector3(1.0, 0.0, 0.0); static initonly Vector3 Right = Vector3(1.0f, 0.0f, 0.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector3(0, 1, 0). /// Shorthand for writing Vector3(0, 1, 0).
///</summary> ///</summary>
static initonly Vector3 Up = Vector3(0.0, 1.0, 0.0); static initonly Vector3 Up = Vector3(0.0f, 1.0f, 0.0f);
///<summary> ///<summary>
/// Shorthand for writing Vector3(0, 0, 0). /// Shorthand for writing Vector3(0, 0, 0).
///</summary> ///</summary>
static initonly Vector3 Zero = Vector3(0.0, 0.0, 0.0); static initonly Vector3 Zero = Vector3(0.0f, 0.0f, 0.0f);
#pragma endregion #pragma endregion
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
@ -87,39 +87,39 @@ namespace SHADE
///<summary> ///<summary>
/// X-component of the Vector3. /// X-component of the Vector3.
///</summary> ///</summary>
double x; float x;
///<summary> ///<summary>
/// Y-component of the Vector3. /// Y-component of the Vector3.
///</summary> ///</summary>
double y; float y;
///<summary> ///<summary>
/// Z-component of the Vector3. /// Z-component of the Vector3.
///</summary> ///</summary>
double z; float z;
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Constructors */ /* Constructors */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/// <summary> /// <summary>
/// Constructor to construct a Vector3 with the specified components with the /// Constructor to construct a Vector3 with the specified components with the
/// Y and Z-component set to 0.0. /// Y and Z-component set to 0.0f.
/// </summary> /// </summary>
/// <param name="_x">X-coordinate to set.</param> /// <param name="_x">X-coordinate to set.</param>
Vector3(double _x); Vector3(float _x);
/// <summary> /// <summary>
/// Constructor to construct a Vector3 with the specified components with the /// Constructor to construct a Vector3 with the specified components with the
/// Z-component set to 0.0. /// Z-component set to 0.0f.
/// </summary> /// </summary>
/// <param name="_x">X-coordinate to set.</param> /// <param name="_x">X-coordinate to set.</param>
/// <param name="_y">Y-coordinate to set.</param> /// <param name="_y">Y-coordinate to set.</param>
Vector3(double _x, double _y); Vector3(float _x, float _y);
/// <summary> /// <summary>
/// Constructor to construct a Vector3 with the specified components. /// Constructor to construct a Vector3 with the specified components.
/// </summary> /// </summary>
/// <param name="_x">X-coordinate to set.</param> /// <param name="_x">X-coordinate to set.</param>
/// <param name="_y">Y-coordinate to set.</param> /// <param name="_y">Y-coordinate to set.</param>
/// <param name="_z">Z-coordinate to set.</param> /// <param name="_z">Z-coordinate to set.</param>
Vector3(double _x, double _y, double _z); Vector3(float _x, float _y, float _z);
/// <summary> /// <summary>
/// Conversion constructor to construct a Vector3 using a Vector2. /// Conversion constructor to construct a Vector3 using a Vector2.
/// </summary> /// </summary>
@ -149,24 +149,24 @@ namespace SHADE
/// need the precise magnitude, consider using GetSqrMagnitude() instead. /// need the precise magnitude, consider using GetSqrMagnitude() instead.
/// </summary> /// </summary>
/// <returns>Returns the length of this Vector3.</returns> /// <returns>Returns the length of this Vector3.</returns>
double GetMagnitude(); float GetMagnitude();
/// <summary> /// <summary>
/// Calculates and returns the squared magnitude of this Vector3. /// Calculates and returns the squared magnitude of this Vector3.
/// </summary> /// </summary>
/// <returns>Returns the squared length of this Vector3.</returns> /// <returns>Returns the squared length of this Vector3.</returns>
double GetSqrMagnitude(); float GetSqrMagnitude();
/// <summary> /// <summary>
/// Calculates and returns the angle of this vector from the right vector. This /// Calculates and returns the angle of this vector from the right vector. This
/// function returns values between -Math.PI and Math.PI. /// function returns values between -Math.PI and Math.PI.
/// </summary> /// </summary>
/// <returns>Returns the angle of this vector from the right vector in radians.</returns> /// <returns>Returns the angle of this vector from the right vector in radians.</returns>
double Angle2DFromRightRadians(); float Angle2DFromRightRadians();
/// <summary> /// <summary>
/// Calculates and returns the angle of this vector from the right vector. This /// Calculates and returns the angle of this vector from the right vector. This
/// function returns values between -180.0 and 180.0. /// function returns values between -180.0f and 180.0f.
/// </summary> /// </summary>
/// <returns>Returns the angle of this vector from the right vector in degrees.</returns> /// <returns>Returns the angle of this vector from the right vector in degrees.</returns>
double Angle2DFromRightDegrees(); float Angle2DFromRightDegrees();
/// <summary> /// <summary>
/// Checks if a specified point is near this Vector3 that represents a point with /// Checks if a specified point is near this Vector3 that represents a point with
/// a tolerance value of PLS_EPSILON. /// a tolerance value of PLS_EPSILON.
@ -188,7 +188,7 @@ namespace SHADE
/// True if this Vector3 representing a point and the specified point are within /// True if this Vector3 representing a point and the specified point are within
/// the range of the specified tolerance. False otherwise. /// the range of the specified tolerance. False otherwise.
/// </returns> /// </returns>
bool IsNearPoint(Vector3 point, double tolerance); bool IsNearPoint(Vector3 point, float tolerance);
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* IEquatable */ /* IEquatable */
@ -208,12 +208,12 @@ namespace SHADE
/// </summary> /// </summary>
/// <param name="o">The unboxed object to compare with.</param> /// <param name="o">The unboxed object to compare with.</param>
/// <returns>True if both objects are the same.</returns> /// <returns>True if both objects are the same.</returns>
bool Equals(Object^ o) override; bool Equals(Object^ o) override;
/// <summary> /// <summary>
/// Gets a unique hash for this object. /// Gets a unique hash for this object.
/// </summary> /// </summary>
/// <returns>Unique hash for this object.</returns> /// <returns>Unique hash for this object.</returns>
int GetHashCode() override; int GetHashCode() override;
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Static Functions */ /* Static Functions */
@ -236,14 +236,14 @@ namespace SHADE
/// <returns> /// <returns>
/// True if the two Vector3s are within the tolerance value specified /// True if the two Vector3s are within the tolerance value specified
/// </returns> /// </returns>
static bool IsNear(Vector3 lhs, Vector3 rhs, double tolerance); static bool IsNear(Vector3 lhs, Vector3 rhs, float tolerance);
/// <summary> /// <summary>
/// Computes and returns the dot product of 2 specified Vector3s. /// Computes and returns the dot product of 2 specified Vector3s.
/// </summary> /// </summary>
/// <param name="lhs">Vector3 to calculate dot product with.</param> /// <param name="lhs">Vector3 to calculate dot product with.</param>
/// <param name="rhs">Another Vector3 to calculate dot product with.</param> /// <param name="rhs">Another Vector3 to calculate dot product with.</param>
/// <returns>Scalar value representing the dot product of the two Vector3s.</returns> /// <returns>Scalar value representing the dot product of the two Vector3s.</returns>
static double Dot(Vector3 lhs, Vector3 rhs); static float Dot(Vector3 lhs, Vector3 rhs);
/// <summary> /// <summary>
/// Computes and returns the cross product of 2 specified Vector3s. /// Computes and returns the cross product of 2 specified Vector3s.
/// </summary> /// </summary>
@ -274,7 +274,7 @@ namespace SHADE
/// Angle to rotate the vector by in an anti-clockwise direction in radians. /// Angle to rotate the vector by in an anti-clockwise direction in radians.
/// </param> /// </param>
/// <returns>The Vector3 that represents the rotated vector.</returns> /// <returns>The Vector3 that represents the rotated vector.</returns>
static Vector3 RotateRadians(Vector3 vec, double radians); static Vector3 RotateRadians(Vector3 vec, float radians);
/// <summary> /// <summary>
/// Rotates a Vector3 on the Z-axis by a specified angle in an anti-clockwise /// Rotates a Vector3 on the Z-axis by a specified angle in an anti-clockwise
/// direction. /// direction.
@ -284,7 +284,7 @@ namespace SHADE
/// Angle to rotate the vector by in an anti-clockwise direction in degrees. /// Angle to rotate the vector by in an anti-clockwise direction in degrees.
/// </param> /// </param>
/// <returns>The Vector3 that represents the rotated vector.</returns> /// <returns>The Vector3 that represents the rotated vector.</returns>
static Vector3 RotateDegrees(Vector3 vec, double degrees); static Vector3 RotateDegrees(Vector3 vec, float degrees);
/// <summary> /// <summary>
/// Computes and returns a Vector3 that is made from the smallest components of /// Computes and returns a Vector3 that is made from the smallest components of
/// the two specified Vector3s. /// the two specified Vector3s.
@ -312,25 +312,25 @@ namespace SHADE
/// This is most commonly used to find a point some fraction of the way along a /// This is most commonly used to find a point some fraction of the way along a
/// line between two endpoints. /// line between two endpoints.
/// </summary> /// </summary>
/// <param name="a">The start Vector3, returned when t = 0.0.</param> /// <param name="a">The start Vector3, returned when t = 0.0f.</param>
/// <param name="b">The end Vector3, returned when t = 1.0.</param> /// <param name="b">The end Vector3, returned when t = 1.0f.</param>
/// <param name="t"> /// <param name="t">
/// Value used to interpolate between a and b which is clamped to /// Value used to interpolate between a and b which is clamped to
/// the range[0, 1]. /// the range[0, 1].
/// </param> /// </param>
/// <returns>The interpolated Vector3.</returns> /// <returns>The interpolated Vector3.</returns>
static Vector3 Lerp(Vector3 a, Vector3 b, double t); static Vector3 Lerp(Vector3 a, Vector3 b, float t);
/// <summary> /// <summary>
/// Linearly interpolates between two specified points. /// Linearly interpolates between two specified points.
/// This is most commonly used to find a point some fraction of the way along a /// This is most commonly used to find a point some fraction of the way along a
/// line between two endpoints. /// line between two endpoints.
/// Unlike Lerp(), t is not clamped to a range at all. /// Unlike Lerp(), t is not clamped to a range at all.
/// </summary> /// </summary>
/// <param name="a">The start Vector3, returned when t = 0.0.</param> /// <param name="a">The start Vector3, returned when t = 0.0f.</param>
/// <param name="b">The end Vector3, returned when t = 1.0.</param> /// <param name="b">The end Vector3, returned when t = 1.0f.</param>
/// <param name="t">Value used to interpolate between a and b.</param> /// <param name="t">Value used to interpolate between a and b.</param>
/// <returns>The interpolated Vector3.</returns> /// <returns>The interpolated Vector3.</returns>
static Vector3 LerpUnclamped(Vector3 a, Vector3 b, double t); static Vector3 LerpUnclamped(Vector3 a, Vector3 b, float t);
/// <summary> /// <summary>
/// Moves a point current towards target. /// Moves a point current towards target.
/// Similar to Lerp(), however, the function will ensure that the distance never /// Similar to Lerp(), however, the function will ensure that the distance never
@ -341,7 +341,7 @@ namespace SHADE
/// <param name="target">The target position to move to.</param> /// <param name="target">The target position to move to.</param>
/// <param name="maxDistanceDelta">Maximum distance moved per call.</param> /// <param name="maxDistanceDelta">Maximum distance moved per call.</param>
/// <returns>Vector representing the moved point.</returns> /// <returns>Vector representing the moved point.</returns>
static Vector3 MoveTowards(Vector3 current, Vector3 target, double maxDistanceDelta); static Vector3 MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta);
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Overloaded Operators */ /* Overloaded Operators */
@ -375,7 +375,7 @@ namespace SHADE
/// <param name="lhs">Vector3 to multiply with.</param> /// <param name="lhs">Vector3 to multiply with.</param>
/// <param name="rhs">Scalar to multiply with.</param> /// <param name="rhs">Scalar to multiply with.</param>
/// <returns>The result of the scalar multiplication.</returns> /// <returns>The result of the scalar multiplication.</returns>
static Vector3 operator*(Vector3 lhs, double rhs); static Vector3 operator*(Vector3 lhs, float rhs);
/// <summary> /// <summary>
/// Calculates the division of a Vector3 with a scalar value and returns /// Calculates the division of a Vector3 with a scalar value and returns
/// the result. /// the result.
@ -383,7 +383,7 @@ namespace SHADE
/// <param name="lhs">Scalar to divide with.</param> /// <param name="lhs">Scalar to divide with.</param>
/// <param name="rhs">Vector3 to divide with.</param> /// <param name="rhs">Vector3 to divide with.</param>
/// <returns>The result of the scalar division.</returns> /// <returns>The result of the scalar division.</returns>
static Vector3 operator/(Vector3 lhs, double rhs); static Vector3 operator/(Vector3 lhs, float rhs);
/// <summary> /// <summary>
/// Checks if two Vector3s are approximately equal. This is equivalent to /// Checks if two Vector3s are approximately equal. This is equivalent to
/// calling Vector3.IsNear() with default tolerance values. /// calling Vector3.IsNear() with default tolerance values.

View File

@ -35,10 +35,7 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
SHVec3 Convert::ToNative(Vector3 vec) SHVec3 Convert::ToNative(Vector3 vec)
{ {
const double X = vec.x; return SHVec3(vec.x, vec.y, vec.z);
const double Y = vec.y;
const double Z = vec.z;
return SHVec3(X, Y, Z);
} }
Vector3 Convert::ToCLI(const SHVec3& vec) Vector3 Convert::ToCLI(const SHVec3& vec)
{ {
@ -46,9 +43,7 @@ namespace SHADE
} }
SHVec2 Convert::ToNative(Vector2 vec) SHVec2 Convert::ToNative(Vector2 vec)
{ {
const double X = vec.x; return SHVec2(vec.x, vec.y);
const double Y = vec.y;
return SHVec2(X, Y);
} }
Vector2 Convert::ToCLI(const SHVec2& vec) Vector2 Convert::ToCLI(const SHVec2& vec)
@ -56,6 +51,16 @@ namespace SHADE
return Vector2(vec.x, vec.y); return Vector2(vec.x, vec.y);
} }
SHQuaternion Convert::ToNative(Quaternion quat)
{
return SHQuaternion{ quat.x, quat.y, quat.z, quat.w };
}
Quaternion Convert::ToCLI(const SHQuaternion& quat)
{
return Quaternion{ quat.x, quat.y, quat.z, quat.w };
}
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* String Conversions */ /* String Conversions */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/

View File

@ -18,10 +18,12 @@ of DigiPen Institute of Technology is prohibited.
#include "ECS_Base/Entity/SHEntity.h" #include "ECS_Base/Entity/SHEntity.h"
#include "Math/Vector/SHVec2.h" #include "Math/Vector/SHVec2.h"
#include "Math/Vector/SHVec3.h" #include "Math/Vector/SHVec3.h"
#include "Math/SHQuaternion.h"
// Project Includes // Project Includes
#include "Engine/Entity.hxx" #include "Engine/Entity.hxx"
#include "Math/Vector2.hxx" #include "Math/Vector2.hxx"
#include "Math/Vector3.hxx" #include "Math/Vector3.hxx"
#include "Math/Quaternion.hxx"
namespace SHADE namespace SHADE
{ {
@ -74,6 +76,18 @@ namespace SHADE
/// <param name="vec">The native Vector2 to convert from.</param> /// <param name="vec">The native Vector2 to convert from.</param>
/// <returns>Managed copy of a native Vector2.</returns> /// <returns>Managed copy of a native Vector2.</returns>
static Vector2 ToCLI(const SHVec2& vec); static Vector2 ToCLI(const SHVec2& vec);
/// <summary>
/// Converts from a managed Quaternion to a native Quaternion.
/// </summary>
/// <param name="quat">The managed Quaternion to convert from.</param>
/// <returns>Native copy of a managed Quaternion.</returns>
static SHQuaternion ToNative(Quaternion quat);
/// <summary>
/// Converts from a native Quaternion to a managed Quaternion.
/// </summary>
/// <param name="quat">The native Quaternion to convert from.</param>
/// <returns>Managed copy of a native Quaternion.</returns>
static Quaternion ToCLI(const SHQuaternion& quat);
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* String Conversions */ /* String Conversions */