fixed compile errors
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "Matrix3x3.h"
|
||||
#include "Math.h"
|
||||
#include "../Types/String.h"
|
||||
#include "Engine/Core/Math/Transform.h"
|
||||
|
||||
Quaternion Quaternion::Zero(0, 0, 0, 0);
|
||||
Quaternion Quaternion::One(1, 1, 1, 1);
|
||||
@@ -532,3 +533,14 @@ void Quaternion::RotationYawPitchRoll(float yaw, float pitch, float roll, Quater
|
||||
result.Y = sinYawOver2 * cosPitchOver2 * cosRollOver2 - cosYawOver2 * sinPitchOver2 * sinRollOver2;
|
||||
result.Z = cosYawOver2 * cosPitchOver2 * sinRollOver2 - sinYawOver2 * sinPitchOver2 * cosRollOver2;
|
||||
}
|
||||
|
||||
Quaternion Quaternion::GetRotacionFromNormal(const Vector3& InNormal, const Transform& InRefrenceTransform)
|
||||
{
|
||||
Float3 up = InRefrenceTransform.GetUp();
|
||||
auto dot = Vector3::Dot(InNormal, up);
|
||||
if (Math::NearEqual(Math::Abs(dot), 1))
|
||||
{
|
||||
up = InRefrenceTransform.GetRight();
|
||||
}
|
||||
return Quaternion::LookRotation(InNormal, up);
|
||||
}
|
||||
|
||||
@@ -670,17 +670,7 @@ public:
|
||||
/// <param name="InNormal">the normal vector</param>
|
||||
/// <param name="InRefrenceTransform">relative to</param>
|
||||
/// <returns>normal as rotacion</returns>
|
||||
static Quaternion GetRotacionFromNormal(const Vector3& InNormal, const Transform& InRefrenceTransform)
|
||||
{
|
||||
Float3 up = InRefrenceTransform.GetUp();
|
||||
auto dot = Vector3::Dot(InNormal, up);
|
||||
if (Math::NearEqual(Math::Abs(dot), 1))
|
||||
{
|
||||
up = InRefrenceTransform.GetRight();
|
||||
}
|
||||
return Quaternion::LookRotation(InNormal, up);
|
||||
}
|
||||
|
||||
static Quaternion GetRotacionFromNormal(const Vector3& InNormal, const Transform& InRefrenceTransform);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -324,6 +324,26 @@ float Float3::Angle(const Float3& from, const Float3& to)
|
||||
return Math::Acos(dot);
|
||||
}
|
||||
|
||||
template<>
|
||||
Float3 Float3::SnapToRotatedGridWithOffset(const Float3& InPoint, const Float3& InCenterPoint, const Float3& InOffset, const Quaternion& InOrientation, const Float3& InGridSize)
|
||||
{
|
||||
return (InOrientation * (InOrientation.Conjugated() * Float3::SnapToGrid((InPoint - InCenterPoint), InGridSize) + InOffset)) + InCenterPoint;
|
||||
}
|
||||
|
||||
template<>
|
||||
Float3 Float3::SnapToGrid(const Float3& pos, const Float3& gridSize)
|
||||
{
|
||||
return Float3(Math::Ceil((pos.X - (gridSize.X * 0.5f)) / gridSize.X) * gridSize.X,
|
||||
Math::Ceil((pos.Y - (gridSize.Y * 0.5f)) / gridSize.Y) * gridSize.Y,
|
||||
Math::Ceil((pos.Z - (gridSize.Z * 0.5f)) / gridSize.Z) * gridSize.Z);
|
||||
}
|
||||
|
||||
template<>
|
||||
Float3 Float3::SnapToRotatedGrid(const Float3& InPoint, const Float3& InCenterPoint, const Quaternion& InOrientation, const Float3& InGridSize)
|
||||
{
|
||||
return (InOrientation * InOrientation.Conjugated() * Float3::SnapToGrid((InPoint - InCenterPoint), InGridSize)) + InCenterPoint;
|
||||
}
|
||||
|
||||
// Double
|
||||
|
||||
static_assert(sizeof(Double3) == 24, "Invalid Double3 type size.");
|
||||
@@ -638,6 +658,26 @@ double Double3::Angle(const Double3& from, const Double3& to)
|
||||
return Math::Acos(dot);
|
||||
}
|
||||
|
||||
template<>
|
||||
Double3 Double3::SnapToRotatedGridWithOffset(const Double3& InPoint, const Double3& InCenterPoint, const Double3& InOffset, const Quaternion& InOrientation, const Double3& InGridSize)
|
||||
{
|
||||
return (InOrientation * (InOrientation.Conjugated() * Float3::SnapToGrid((InPoint - InCenterPoint), InGridSize) + InOffset)) + InCenterPoint;
|
||||
}
|
||||
|
||||
template<>
|
||||
Double3 Double3::SnapToGrid(const Double3& pos, const Double3& gridSize)
|
||||
{
|
||||
return Double3(Math::Ceil((pos.X - (gridSize.X * 0.5f)) / gridSize.X) * gridSize.X,
|
||||
Math::Ceil((pos.Y - (gridSize.Y * 0.5f)) / gridSize.Y) * gridSize.Y,
|
||||
Math::Ceil((pos.Z - (gridSize.Z * 0.5f)) / gridSize.Z) * gridSize.Z);
|
||||
}
|
||||
|
||||
template<>
|
||||
Double3 Double3::SnapToRotatedGrid(const Double3& InPoint, const Double3& InCenterPoint, const Quaternion& InOrientation, const Double3& InGridSize)
|
||||
{
|
||||
return (InOrientation * InOrientation.Conjugated() * Float3::SnapToGrid((InPoint - InCenterPoint), InGridSize)) + InCenterPoint;
|
||||
}
|
||||
|
||||
// Int
|
||||
|
||||
static_assert(sizeof(Int3) == 12, "Invalid Int3 type size.");
|
||||
@@ -852,3 +892,23 @@ int32 Int3::Angle(const Int3& from, const Int3& to)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
Int3 Int3::SnapToRotatedGridWithOffset(const Int3& InPoint, const Int3& InCenterPoint, const Int3& InOffset, const Quaternion& InOrientation, const Int3& InGridSize)
|
||||
{
|
||||
return (InOrientation * (InOrientation.Conjugated() * Int3::SnapToGrid((InPoint - InCenterPoint), InGridSize) + InOffset)) + InCenterPoint;
|
||||
}
|
||||
|
||||
template<>
|
||||
Int3 Int3::SnapToGrid(const Int3& pos, const Int3& gridSize)
|
||||
{
|
||||
return Double3(Math::Ceil((pos.X - (gridSize.X * 0.5f)) / gridSize.X) * gridSize.X,
|
||||
Math::Ceil((pos.Y - (gridSize.Y * 0.5f)) / gridSize.Y) * gridSize.Y,
|
||||
Math::Ceil((pos.Z - (gridSize.Z * 0.5f)) / gridSize.Z) * gridSize.Z);
|
||||
}
|
||||
|
||||
template<>
|
||||
Int3 Int3::SnapToRotatedGrid(const Int3& InPoint, const Int3& InCenterPoint, const Quaternion& InOrientation, const Int3& InGridSize)
|
||||
{
|
||||
return (InOrientation * InOrientation.Conjugated() * Int3::SnapToGrid((InPoint - InCenterPoint), InGridSize)) + InCenterPoint;
|
||||
}
|
||||
|
||||
@@ -934,13 +934,7 @@ public:
|
||||
/// <param name="pos">The position to snap.</param>
|
||||
/// <param name="gridSize">The size of the grid.</param>
|
||||
/// <returns>The position snapped to the grid.</returns>
|
||||
static Vector3 SnapToGrid(const Vector3& pos, Vector3 gridSize)
|
||||
{
|
||||
pos.X = Math::Ceil((pos.X - (gridSize.X * 0.5f)) / gridSize.X) * gridSize.X;
|
||||
pos.Y = Math::Ceil((pos.Y - (gridSize.Y * 0.5f)) / gridSize.Y) * gridSize.Y;
|
||||
pos.Z = Math::Ceil((pos.Z - (gridSize.Z * 0.5f)) / gridSize.Z) * gridSize.Z;
|
||||
return pos;
|
||||
}
|
||||
static Vector3Base SnapToGrid(const Vector3Base& pos,const Vector3Base& gridSize);
|
||||
|
||||
/// <summary>
|
||||
/// Snaps the <paramref name="InPoint"/> on to rotate grid.<br/>
|
||||
@@ -951,10 +945,7 @@ public:
|
||||
/// <param name="InOrientation">The rotation of the grid.</param>
|
||||
/// <param name="InGridSize">The size of the grid.</param>
|
||||
/// <returns>The position snapped to the grid.</returns>
|
||||
static Vector3 SnapToRotatedGrid(const Vector3& InPoint, const Vector3& InCenterPoint, const Quaternion& InOrientation, const Vector3& InGridSize)
|
||||
{
|
||||
return (Vector3::SnapToGrid((InPoint - InCenterPoint) * InOrientation.Conjugated(), InGridSize) * InOrientation) + InCenterPoint;
|
||||
}
|
||||
static Vector3Base SnapToRotatedGrid(const Vector3Base& InPoint, const Vector3Base& InCenterPoint, const Quaternion& InOrientation, const Vector3Base& InGridSize);
|
||||
/// <summary>
|
||||
/// The same as <see cref="SnapToRotatedGrid"/> but with local offset applied after point is spapend
|
||||
/// </summary>
|
||||
@@ -964,10 +955,7 @@ public:
|
||||
/// <param name="InGridSize">The size of the grid.</param>
|
||||
/// <param name="InOffset">The local grid offset to applay after snaping</param>
|
||||
/// <returns></returns>
|
||||
static Vector3 SnapToRotatedGridWithOffset(const Vector3& InPoint, const Vector3& InCenterPoint, const Vector3& InOffset, const Quaternion& InOrientation, const Vector3& InGridSize)
|
||||
{
|
||||
return ((Vector3::SnapToGrid((InPoint - InCenterPoint) * InOrientation.Conjugated(), InGridSize) + InOffset) * InOrientation) + InCenterPoint;
|
||||
}
|
||||
static Vector3Base SnapToRotatedGridWithOffset(const Vector3Base& InPoint, const Vector3Base& InCenterPoint, const Vector3Base& InOffset, const Quaternion& InOrientation, const Vector3Base& InGridSize);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
||||
Reference in New Issue
Block a user