Fixed warnings and errors in Vector2/3 and GameObject

This commit is contained in:
Kah Wei 2022-09-13 18:37:05 +08:00
parent 32a68d22ae
commit 073cf902a9
5 changed files with 15 additions and 15 deletions

View File

@ -139,8 +139,8 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/* Constructors */
/*---------------------------------------------------------------------------------*/
GameObject::GameObject(EntityID entity)
: entity { entity }
GameObject::GameObject(const SHEntity& entity)
: entity { entity.GetEID() }
{}
GameObject::GameObject(Entity entity)

View File

@ -207,7 +207,7 @@ namespace SHADE
/// <param name="entity">
/// The ECS Entity that this GameObject should represent.
/// </param>
GameObject(SHEntity entity);
GameObject(const SHEntity& entity);
/// <summary>
/// Constructor for the GameObject.
/// </summary>

View File

@ -204,11 +204,11 @@ namespace SHADE
return target;
// Calculate new position
const Vector2 DELTA = (target - current).GetNormalised() * maxDistanceDelta;
Vector2 DELTA = (target - current).GetNormalised() * maxDistanceDelta;
Vector2 newPos = current + DELTA;
// Check if check if is behind or ahead of target
const Vector2 DIFF = target - newPos;
Vector2 DIFF = target - newPos;
if (Dot(DELTA, DIFF) < 0.0)
{
newPos = target;

View File

@ -37,37 +37,37 @@ namespace SHADE
///<summary>
/// Shorthand for writing Vector2(0, -1).
///</summary>
static const Vector2 Down = Vector2(0.0, -1.0);
static Vector2 Down = Vector2(0.0, -1.0);
///<summary>
/// Shorthand for writing Vector2(-1, 0).
///</summary>
static const Vector2 Left = Vector2(-1.0, 0.0);
static Vector2 Left = Vector2(-1.0, 0.0);
///<summary>
/// Shorthand for writing Vector2(double.NegativeInfinity,
/// double.NegativeInfinity).
///</summary>
static const Vector2 NegativeInfinity = Vector2(std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest());
static Vector2 NegativeInfinity = Vector2(std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest());
///<summary>
/// Shorthand for writing Vector2(1, 1).
///</summary>
static const Vector2 One = Vector2(1.0, 1.0);
static Vector2 One = Vector2(1.0, 1.0);
///<summary>
/// Shorthand for writing Vector2(double.PositiveInfinity,
/// double.PositiveInfinity).
///</summary>
static const Vector2 PositiveInfinity = Vector2(std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
static Vector2 PositiveInfinity = Vector2(std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
///<summary>
/// Shorthand for writing Vector2(1, 0).
///</summary>
static const Vector2 Right = Vector2(1.0, 0.0);
static Vector2 Right = Vector2(1.0, 0.0);
///<summary>
/// Shorthand for writing Vector2(0, 1).
///</summary>
static const Vector2 Up = Vector2(0.0, 1.0);
static Vector2 Up = Vector2(0.0, 1.0);
///<summary>
/// Shorthand for writing Vector2(0, 0).
///</summary>
static const Vector2 Zero = Vector2(0.0, 0.0);
static Vector2 Zero = Vector2(0.0, 0.0);
#pragma endregion
/*-----------------------------------------------------------------------------*/

View File

@ -201,11 +201,11 @@ namespace SHADE
return target;
// Calculate new position
const Vector3 DELTA = (target - current).GetNormalised() * maxDistanceDelta;
Vector3 DELTA = (target - current).GetNormalised() * maxDistanceDelta;
Vector3 newPos = current + DELTA;
// Check if check if is behind or ahead of target
const Vector3 DIFF = target - newPos;
Vector3 DIFF = target - newPos;
if (Dot(DELTA, DIFF) < 0.0)
{
newPos = target;