mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 09:48:20 +00:00
refactor: allow usage of NiPoint3 and NiQuaternion in constexpr context (#1414)
* allow usage of NiPoint3 and NiQuaternion in constexpr context * removed .cpp files entirely * moving circular dependency circumvention stuff to an .inl file * real world usage!!!!! * reverting weird branch cross-pollination * removing more weird branch cross-pollination * remove comment * added inverse header guard to inl file * Update NiPoint3.inl * trying different constructor syntax * reorganize into .inl files for readability * uncomment include * moved non-constexpr definitions to cpp file * moved static definitions back to inl files * testing fix * moved constants into seperate namespace * Undo change in build-and-test.yml * nodiscard
This commit is contained in:
parent
2f247b1fc9
commit
a0d51e21ca
@ -1,210 +1,24 @@
|
|||||||
#include "NiPoint3.h"
|
#include "NiPoint3.h"
|
||||||
#include "NiQuaternion.h"
|
|
||||||
|
|
||||||
// C++
|
// C++
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
// Static Variables
|
// MARK: Member Functions
|
||||||
const NiPoint3 NiPoint3::ZERO(0.0f, 0.0f, 0.0f);
|
|
||||||
const NiPoint3 NiPoint3::UNIT_X(1.0f, 0.0f, 0.0f);
|
|
||||||
const NiPoint3 NiPoint3::UNIT_Y(0.0f, 1.0f, 0.0f);
|
|
||||||
const NiPoint3 NiPoint3::UNIT_Z(0.0f, 0.0f, 1.0f);
|
|
||||||
const NiPoint3 NiPoint3::UNIT_ALL(1.0f, 1.0f, 1.0f);
|
|
||||||
|
|
||||||
//! Initializer
|
|
||||||
NiPoint3::NiPoint3(void) {
|
|
||||||
this->x = 0;
|
|
||||||
this->y = 0;
|
|
||||||
this->z = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Initializer
|
|
||||||
NiPoint3::NiPoint3(float x, float y, float z) {
|
|
||||||
this->x = x;
|
|
||||||
this->y = y;
|
|
||||||
this->z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Copy Constructor
|
|
||||||
NiPoint3::NiPoint3(const NiPoint3& point) {
|
|
||||||
this->x = point.x;
|
|
||||||
this->y = point.y;
|
|
||||||
this->z = point.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Destructor
|
|
||||||
NiPoint3::~NiPoint3(void) {}
|
|
||||||
|
|
||||||
// MARK: Getters / Setters
|
|
||||||
|
|
||||||
//! Gets the X coordinate
|
|
||||||
float NiPoint3::GetX(void) const {
|
|
||||||
return this->x;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Sets the X coordinate
|
|
||||||
void NiPoint3::SetX(float x) {
|
|
||||||
this->x = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Gets the Y coordinate
|
|
||||||
float NiPoint3::GetY(void) const {
|
|
||||||
return this->y;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Sets the Y coordinate
|
|
||||||
void NiPoint3::SetY(float y) {
|
|
||||||
this->y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Gets the Z coordinate
|
|
||||||
float NiPoint3::GetZ(void) const {
|
|
||||||
return this->z;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Sets the Z coordinate
|
|
||||||
void NiPoint3::SetZ(float z) {
|
|
||||||
this->z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: Functions
|
|
||||||
|
|
||||||
//! Gets the length of the vector
|
//! Gets the length of the vector
|
||||||
float NiPoint3::Length(void) const {
|
float NiPoint3::Length() const {
|
||||||
return sqrt(x * x + y * y + z * z);
|
return std::sqrt(x * x + y * y + z * z);
|
||||||
}
|
|
||||||
|
|
||||||
//! Gets the squared length of a vector
|
|
||||||
float NiPoint3::SquaredLength(void) const {
|
|
||||||
return (x * x + y * y + z * z);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Returns the dot product of the vector dotted with another vector
|
|
||||||
float NiPoint3::DotProduct(const Vector3& vec) const {
|
|
||||||
return ((this->x * vec.x) + (this->y * vec.y) + (this->z * vec.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Returns the cross product of the vector crossed with another vector
|
|
||||||
Vector3 NiPoint3::CrossProduct(const Vector3& vec) const {
|
|
||||||
return Vector3(((this->y * vec.z) - (this->z * vec.y)),
|
|
||||||
((this->z * vec.x) - (this->x * vec.z)),
|
|
||||||
((this->x * vec.y) - (this->y * vec.x)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Unitize the vector
|
//! Unitize the vector
|
||||||
NiPoint3 NiPoint3::Unitize(void) const {
|
NiPoint3 NiPoint3::Unitize() const {
|
||||||
float length = this->Length();
|
float length = this->Length();
|
||||||
|
|
||||||
return length != 0 ? *this / length : NiPoint3::ZERO;
|
return length != 0 ? *this / length : NiPoint3Constant::ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: Operators
|
|
||||||
|
|
||||||
//! Operator to check for equality
|
|
||||||
bool NiPoint3::operator==(const NiPoint3& point) const {
|
|
||||||
return point.x == this->x && point.y == this->y && point.z == this->z;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator to check for inequality
|
|
||||||
bool NiPoint3::operator!=(const NiPoint3& point) const {
|
|
||||||
return !(*this == point);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator for subscripting
|
|
||||||
float& NiPoint3::operator[](int i) {
|
|
||||||
float* base = &x;
|
|
||||||
return base[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator for subscripting
|
|
||||||
const float& NiPoint3::operator[](int i) const {
|
|
||||||
const float* base = &x;
|
|
||||||
return base[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator for addition of vectors
|
|
||||||
NiPoint3 NiPoint3::operator+(const NiPoint3& point) const {
|
|
||||||
return NiPoint3(this->x + point.x, this->y + point.y, this->z + point.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator for addition of vectors
|
|
||||||
NiPoint3& NiPoint3::operator+=(const NiPoint3& point) {
|
|
||||||
this->x += point.x;
|
|
||||||
this->y += point.y;
|
|
||||||
this->z += point.z;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
NiPoint3& NiPoint3::operator*=(const float scalar) {
|
|
||||||
this->x *= scalar;
|
|
||||||
this->y *= scalar;
|
|
||||||
this->z *= scalar;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator for subtraction of vectors
|
|
||||||
NiPoint3 NiPoint3::operator-(const NiPoint3& point) const {
|
|
||||||
return NiPoint3(this->x - point.x, this->y - point.y, this->z - point.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator for addition of a scalar on all vector components
|
|
||||||
NiPoint3 NiPoint3::operator+(float fScalar) const {
|
|
||||||
return NiPoint3(this->x + fScalar, this->y + fScalar, this->z + fScalar);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator for subtraction of a scalar on all vector components
|
|
||||||
NiPoint3 NiPoint3::operator-(float fScalar) const {
|
|
||||||
return NiPoint3(this->x - fScalar, this->y - fScalar, this->z - fScalar);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator for scalar multiplication of a vector
|
|
||||||
NiPoint3 NiPoint3::operator*(float fScalar) const {
|
|
||||||
return NiPoint3(this->x * fScalar, this->y * fScalar, this->z * fScalar);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator for scalar division of a vector
|
|
||||||
NiPoint3 NiPoint3::operator/(float fScalar) const {
|
|
||||||
float retX = this->x != 0 ? this->x / fScalar : 0;
|
|
||||||
float retY = this->y != 0 ? this->y / fScalar : 0;
|
|
||||||
float retZ = this->z != 0 ? this->z / fScalar : 0;
|
|
||||||
return NiPoint3(retX, retY, retZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// MARK: Helper Functions
|
// MARK: Helper Functions
|
||||||
|
|
||||||
//! Checks to see if the point (or vector) is with an Axis-Aligned Bounding Box
|
|
||||||
bool NiPoint3::IsWithinAxisAlignedBox(const NiPoint3& minPoint, const NiPoint3& maxPoint) {
|
|
||||||
if (this->x < minPoint.x) return false;
|
|
||||||
if (this->x > maxPoint.x) return false;
|
|
||||||
if (this->y < minPoint.y) return false;
|
|
||||||
if (this->y > maxPoint.y) return false;
|
|
||||||
|
|
||||||
return (this->z < maxPoint.z && this->z > minPoint.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Checks to see if the point (or vector) is within a sphere
|
|
||||||
bool NiPoint3::IsWithinSpehere(const NiPoint3& sphereCenter, float radius) {
|
|
||||||
Vector3 diffVec = Vector3(x - sphereCenter.GetX(), y - sphereCenter.GetY(), z - sphereCenter.GetZ());
|
|
||||||
return (diffVec.SquaredLength() <= (radius * radius));
|
|
||||||
}
|
|
||||||
|
|
||||||
NiPoint3 NiPoint3::ClosestPointOnLine(const NiPoint3& a, const NiPoint3& b, const NiPoint3& p) {
|
|
||||||
if (a == b) return a;
|
|
||||||
|
|
||||||
const auto pa = p - a;
|
|
||||||
const auto ab = b - a;
|
|
||||||
|
|
||||||
const auto t = pa.DotProduct(ab) / ab.SquaredLength();
|
|
||||||
|
|
||||||
if (t <= 0.0f) return a;
|
|
||||||
|
|
||||||
if (t >= 1.0f) return b;
|
|
||||||
|
|
||||||
return a + ab * t;
|
|
||||||
}
|
|
||||||
|
|
||||||
float NiPoint3::Angle(const NiPoint3& a, const NiPoint3& b) {
|
float NiPoint3::Angle(const NiPoint3& a, const NiPoint3& b) {
|
||||||
const auto dot = a.DotProduct(b);
|
const auto dot = a.DotProduct(b);
|
||||||
const auto lenA = a.SquaredLength();
|
const auto lenA = a.SquaredLength();
|
||||||
@ -220,15 +34,7 @@ float NiPoint3::Distance(const NiPoint3& a, const NiPoint3& b) {
|
|||||||
return std::sqrt(dx * dx + dy * dy + dz * dz);
|
return std::sqrt(dx * dx + dy * dy + dz * dz);
|
||||||
}
|
}
|
||||||
|
|
||||||
float NiPoint3::DistanceSquared(const NiPoint3& a, const NiPoint3& b) {
|
NiPoint3 NiPoint3::MoveTowards(const NiPoint3& current, const NiPoint3& target, const float maxDistanceDelta) {
|
||||||
const auto dx = a.x - b.x;
|
|
||||||
const auto dy = a.y - b.y;
|
|
||||||
const auto dz = a.z - b.z;
|
|
||||||
|
|
||||||
return dx * dx + dy * dy + dz * dz;
|
|
||||||
}
|
|
||||||
|
|
||||||
NiPoint3 NiPoint3::MoveTowards(const NiPoint3& current, const NiPoint3& target, float maxDistanceDelta) {
|
|
||||||
float dx = target.x - current.x;
|
float dx = target.x - current.x;
|
||||||
float dy = target.y - current.y;
|
float dy = target.y - current.y;
|
||||||
float dz = target.z - current.z;
|
float dz = target.z - current.z;
|
||||||
@ -249,29 +55,3 @@ NiPoint3 NiPoint3::MoveTowards(const NiPoint3& current, const NiPoint3& target,
|
|||||||
float length = std::sqrt(lengthSquared);
|
float length = std::sqrt(lengthSquared);
|
||||||
return NiPoint3(current.x + dx / length * maxDistanceDelta, current.y + dy / length * maxDistanceDelta, current.z + dz / length * maxDistanceDelta);
|
return NiPoint3(current.x + dx / length * maxDistanceDelta, current.y + dy / length * maxDistanceDelta, current.z + dz / length * maxDistanceDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
//This code is yoinked from the MS XNA code, so it should be right, even if it's horrible.
|
|
||||||
NiPoint3 NiPoint3::RotateByQuaternion(const NiQuaternion& rotation) {
|
|
||||||
Vector3 vector;
|
|
||||||
float num12 = rotation.x + rotation.x;
|
|
||||||
float num2 = rotation.y + rotation.y;
|
|
||||||
float num = rotation.z + rotation.z;
|
|
||||||
float num11 = rotation.w * num12;
|
|
||||||
float num10 = rotation.w * num2;
|
|
||||||
float num9 = rotation.w * num;
|
|
||||||
float num8 = rotation.x * num12;
|
|
||||||
float num7 = rotation.x * num2;
|
|
||||||
float num6 = rotation.x * num;
|
|
||||||
float num5 = rotation.y * num2;
|
|
||||||
float num4 = rotation.y * num;
|
|
||||||
float num3 = rotation.z * num;
|
|
||||||
|
|
||||||
NiPoint3 value = *this;
|
|
||||||
float num15 = ((value.x * ((1.0f - num5) - num3)) + (value.y * (num7 - num9))) + (value.z * (num6 + num10));
|
|
||||||
float num14 = ((value.x * (num7 + num9)) + (value.y * ((1.0f - num8) - num3))) + (value.z * (num4 - num11));
|
|
||||||
float num13 = ((value.x * (num6 - num10)) + (value.y * (num4 + num11))) + (value.z * ((1.0f - num8) - num5));
|
|
||||||
vector.x = num15;
|
|
||||||
vector.y = num14;
|
|
||||||
vector.z = num13;
|
|
||||||
return vector;
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef __NIPOINT3_H__
|
||||||
|
#define __NIPOINT3_H__
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file NiPoint3.hpp
|
\file NiPoint3.hpp
|
||||||
@ -12,13 +13,13 @@ typedef NiPoint3 Vector3; //!< The Vector3 class is technically the NiPoin
|
|||||||
//! A custom class the defines a point in space
|
//! A custom class the defines a point in space
|
||||||
class NiPoint3 {
|
class NiPoint3 {
|
||||||
public:
|
public:
|
||||||
float x; //!< The x position
|
float x{ 0 }; //!< The x position
|
||||||
float y; //!< The y position
|
float y{ 0 }; //!< The y position
|
||||||
float z; //!< The z position
|
float z{ 0 }; //!< The z position
|
||||||
|
|
||||||
|
|
||||||
//! Initializer
|
//! Initializer
|
||||||
NiPoint3(void);
|
constexpr NiPoint3() = default;
|
||||||
|
|
||||||
//! Initializer
|
//! Initializer
|
||||||
/*!
|
/*!
|
||||||
@ -26,23 +27,21 @@ public:
|
|||||||
\param y The y coordinate
|
\param y The y coordinate
|
||||||
\param z The z coordinate
|
\param z The z coordinate
|
||||||
*/
|
*/
|
||||||
NiPoint3(float x, float y, float z);
|
constexpr NiPoint3(const float x, const float y, const float z) noexcept
|
||||||
|
: x{ x }
|
||||||
|
, y{ y }
|
||||||
|
, z{ z } {
|
||||||
|
}
|
||||||
|
|
||||||
//! Copy Constructor
|
//! Copy Constructor
|
||||||
/*!
|
/*!
|
||||||
\param point The point to copy
|
\param point The point to copy
|
||||||
*/
|
*/
|
||||||
NiPoint3(const NiPoint3& point);
|
constexpr NiPoint3(const NiPoint3& point) noexcept
|
||||||
|
: x{ point.x }
|
||||||
//! Destructor
|
, y{ point.y }
|
||||||
~NiPoint3(void);
|
, z{ point.z } {
|
||||||
|
}
|
||||||
// MARK: Constants
|
|
||||||
static const NiPoint3 ZERO; //!< Point(0, 0, 0)
|
|
||||||
static const NiPoint3 UNIT_X; //!< Point(1, 0, 0)
|
|
||||||
static const NiPoint3 UNIT_Y; //!< Point(0, 1, 0)
|
|
||||||
static const NiPoint3 UNIT_Z; //!< Point(0, 0, 1)
|
|
||||||
static const NiPoint3 UNIT_ALL; //!< Point(1, 1, 1)
|
|
||||||
|
|
||||||
// MARK: Getters / Setters
|
// MARK: Getters / Setters
|
||||||
|
|
||||||
@ -50,38 +49,37 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
\return The x coordinate
|
\return The x coordinate
|
||||||
*/
|
*/
|
||||||
float GetX(void) const;
|
[[nodiscard]] constexpr float GetX() const noexcept;
|
||||||
|
|
||||||
//! Sets the X coordinate
|
//! Sets the X coordinate
|
||||||
/*!
|
/*!
|
||||||
\param x The x coordinate
|
\param x The x coordinate
|
||||||
*/
|
*/
|
||||||
void SetX(float x);
|
constexpr void SetX(const float x) noexcept;
|
||||||
|
|
||||||
//! Gets the Y coordinate
|
//! Gets the Y coordinate
|
||||||
/*!
|
/*!
|
||||||
\return The y coordinate
|
\return The y coordinate
|
||||||
*/
|
*/
|
||||||
float GetY(void) const;
|
[[nodiscard]] constexpr float GetY() const noexcept;
|
||||||
|
|
||||||
//! Sets the Y coordinate
|
//! Sets the Y coordinate
|
||||||
/*!
|
/*!
|
||||||
\param y The y coordinate
|
\param y The y coordinate
|
||||||
*/
|
*/
|
||||||
void SetY(float y);
|
constexpr void SetY(const float y) noexcept;
|
||||||
|
|
||||||
//! Gets the Z coordinate
|
//! Gets the Z coordinate
|
||||||
/*!
|
/*!
|
||||||
\return The z coordinate
|
\return The z coordinate
|
||||||
*/
|
*/
|
||||||
float GetZ(void) const;
|
[[nodiscard]] constexpr float GetZ() const noexcept;
|
||||||
|
|
||||||
//! Sets the Z coordinate
|
//! Sets the Z coordinate
|
||||||
/*!
|
/*!
|
||||||
\param z The z coordinate
|
\param z The z coordinate
|
||||||
*/
|
*/
|
||||||
void SetZ(float z);
|
constexpr void SetZ(const float z) noexcept;
|
||||||
|
|
||||||
|
|
||||||
// MARK: Member Functions
|
// MARK: Member Functions
|
||||||
|
|
||||||
@ -89,72 +87,70 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
\return The scalar length of the vector
|
\return The scalar length of the vector
|
||||||
*/
|
*/
|
||||||
float Length(void) const;
|
[[nodiscard]] float Length() const;
|
||||||
|
|
||||||
//! Gets the squared length of a vector
|
//! Gets the squared length of a vector
|
||||||
/*!
|
/*!
|
||||||
\return The squared length of a vector
|
\return The squared length of a vector
|
||||||
*/
|
*/
|
||||||
float SquaredLength(void) const;
|
[[nodiscard]] constexpr float SquaredLength() const noexcept;
|
||||||
|
|
||||||
//! Returns the dot product of the vector dotted with another vector
|
//! Returns the dot product of the vector dotted with another vector
|
||||||
/*!
|
/*!
|
||||||
\param vec The second vector
|
\param vec The second vector
|
||||||
\return The dot product of the two vectors
|
\return The dot product of the two vectors
|
||||||
*/
|
*/
|
||||||
float DotProduct(const Vector3& vec) const;
|
[[nodiscard]] constexpr float DotProduct(const Vector3& vec) const noexcept;
|
||||||
|
|
||||||
//! Returns the cross product of the vector crossed with another vector
|
//! Returns the cross product of the vector crossed with another vector
|
||||||
/*!
|
/*!
|
||||||
\param vec The second vector
|
\param vec The second vector
|
||||||
\return The cross product of the two vectors
|
\return The cross product of the two vectors
|
||||||
*/
|
*/
|
||||||
Vector3 CrossProduct(const Vector3& vec) const;
|
[[nodiscard]] constexpr Vector3 CrossProduct(const Vector3& vec) const noexcept;
|
||||||
|
|
||||||
//! Unitize the vector
|
//! Unitize the vector
|
||||||
/*!
|
/*!
|
||||||
\returns The current vector
|
\returns The current vector
|
||||||
*/
|
*/
|
||||||
NiPoint3 Unitize(void) const;
|
[[nodiscard]] NiPoint3 Unitize() const;
|
||||||
|
|
||||||
|
|
||||||
// MARK: Operators
|
// MARK: Operators
|
||||||
|
|
||||||
//! Operator to check for equality
|
//! Operator to check for equality
|
||||||
bool operator==(const NiPoint3& point) const;
|
constexpr bool operator==(const NiPoint3& point) const noexcept;
|
||||||
|
|
||||||
//! Operator to check for inequality
|
//! Operator to check for inequality
|
||||||
bool operator!=(const NiPoint3& point) const;
|
constexpr bool operator!=(const NiPoint3& point) const noexcept;
|
||||||
|
|
||||||
//! Operator for subscripting
|
//! Operator for subscripting
|
||||||
float& operator[](int i);
|
constexpr float& operator[](const int i) noexcept;
|
||||||
|
|
||||||
//! Operator for subscripting
|
//! Operator for subscripting
|
||||||
const float& operator[](int i) const;
|
constexpr const float& operator[](const int i) const noexcept;
|
||||||
|
|
||||||
//! Operator for addition of vectors
|
//! Operator for addition of vectors
|
||||||
NiPoint3 operator+(const NiPoint3& point) const;
|
constexpr NiPoint3 operator+(const NiPoint3& point) const noexcept;
|
||||||
|
|
||||||
//! Operator for addition of vectors
|
//! Operator for addition of vectors
|
||||||
NiPoint3& operator+=(const NiPoint3& point);
|
constexpr NiPoint3& operator+=(const NiPoint3& point) noexcept;
|
||||||
|
|
||||||
NiPoint3& operator*=(const float scalar);
|
constexpr NiPoint3& operator*=(const float scalar) noexcept;
|
||||||
|
|
||||||
//! Operator for subtraction of vectors
|
//! Operator for subtraction of vectors
|
||||||
NiPoint3 operator-(const NiPoint3& point) const;
|
constexpr NiPoint3 operator-(const NiPoint3& point) const noexcept;
|
||||||
|
|
||||||
//! Operator for addition of a scalar on all vector components
|
//! Operator for addition of a scalar on all vector components
|
||||||
NiPoint3 operator+(float fScalar) const;
|
constexpr NiPoint3 operator+(const float fScalar) const noexcept;
|
||||||
|
|
||||||
//! Operator for subtraction of a scalar on all vector components
|
//! Operator for subtraction of a scalar on all vector components
|
||||||
NiPoint3 operator-(float fScalar) const;
|
constexpr NiPoint3 operator-(const float fScalar) const noexcept;
|
||||||
|
|
||||||
//! Operator for scalar multiplication of a vector
|
//! Operator for scalar multiplication of a vector
|
||||||
NiPoint3 operator*(float fScalar) const;
|
constexpr NiPoint3 operator*(const float fScalar) const noexcept;
|
||||||
|
|
||||||
//! Operator for scalar division of a vector
|
//! Operator for scalar division of a vector
|
||||||
NiPoint3 operator/(float fScalar) const;
|
constexpr NiPoint3 operator/(const float fScalar) const noexcept;
|
||||||
|
|
||||||
|
|
||||||
// MARK: Helper Functions
|
// MARK: Helper Functions
|
||||||
|
|
||||||
@ -164,14 +160,14 @@ public:
|
|||||||
\param maxPoint The maximum point of the bounding box
|
\param maxPoint The maximum point of the bounding box
|
||||||
\return Whether or not this point lies within the box
|
\return Whether or not this point lies within the box
|
||||||
*/
|
*/
|
||||||
bool IsWithinAxisAlignedBox(const NiPoint3& minPoint, const NiPoint3& maxPoint);
|
[[nodiscard]] constexpr bool IsWithinAxisAlignedBox(const NiPoint3& minPoint, const NiPoint3& maxPoint) noexcept;
|
||||||
|
|
||||||
//! Checks to see if the point (or vector) is within a sphere
|
//! Checks to see if the point (or vector) is within a sphere
|
||||||
/*!
|
/*!
|
||||||
\param sphereCenter The sphere center
|
\param sphereCenter The sphere center
|
||||||
\param radius The radius
|
\param radius The radius
|
||||||
*/
|
*/
|
||||||
bool IsWithinSpehere(const NiPoint3& sphereCenter, float radius);
|
[[nodiscard]] constexpr bool IsWithinSphere(const NiPoint3& sphereCenter, const float radius) noexcept;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\param a Start of line
|
\param a Start of line
|
||||||
@ -179,15 +175,30 @@ public:
|
|||||||
\param p Refrence point
|
\param p Refrence point
|
||||||
\return The point of line AB which is closest to P
|
\return The point of line AB which is closest to P
|
||||||
*/
|
*/
|
||||||
static NiPoint3 ClosestPointOnLine(const NiPoint3& a, const NiPoint3& b, const NiPoint3& p);
|
[[nodiscard]] static constexpr NiPoint3 ClosestPointOnLine(const NiPoint3& a, const NiPoint3& b, const NiPoint3& p) noexcept;
|
||||||
|
|
||||||
static float Angle(const NiPoint3& a, const NiPoint3& b);
|
[[nodiscard]] static float Angle(const NiPoint3& a, const NiPoint3& b);
|
||||||
|
|
||||||
static float Distance(const NiPoint3& a, const NiPoint3& b);
|
[[nodiscard]] static float Distance(const NiPoint3& a, const NiPoint3& b);
|
||||||
|
|
||||||
static float DistanceSquared(const NiPoint3& a, const NiPoint3& b);
|
[[nodiscard]] static constexpr float DistanceSquared(const NiPoint3& a, const NiPoint3& b) noexcept;
|
||||||
|
|
||||||
static NiPoint3 MoveTowards(const NiPoint3& current, const NiPoint3& target, float maxDistanceDelta);
|
[[nodiscard]] static NiPoint3 MoveTowards(const NiPoint3& current, const NiPoint3& target, const float maxDistanceDelta);
|
||||||
|
|
||||||
NiPoint3 RotateByQuaternion(const NiQuaternion& rotation);
|
//This code is yoinked from the MS XNA code, so it should be right, even if it's horrible.
|
||||||
|
[[nodiscard]] constexpr NiPoint3 RotateByQuaternion(const NiQuaternion& rotation) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Static Variables
|
||||||
|
namespace NiPoint3Constant {
|
||||||
|
constexpr NiPoint3 ZERO(0.0f, 0.0f, 0.0f);
|
||||||
|
constexpr NiPoint3 UNIT_X(1.0f, 0.0f, 0.0f);
|
||||||
|
constexpr NiPoint3 UNIT_Y(0.0f, 1.0f, 0.0f);
|
||||||
|
constexpr NiPoint3 UNIT_Z(0.0f, 0.0f, 1.0f);
|
||||||
|
constexpr NiPoint3 UNIT_ALL(1.0f, 1.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// .inl file needed for code organization and to circumvent circular dependency issues
|
||||||
|
#include "NiPoint3.inl"
|
||||||
|
|
||||||
|
#endif // !__NIPOINT3_H__
|
||||||
|
196
dCommon/NiPoint3.inl
Normal file
196
dCommon/NiPoint3.inl
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef __NIPOINT3_H__
|
||||||
|
#error "This should only be included inline in NiPoint3.h: Do not include directly!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "NiQuaternion.h"
|
||||||
|
|
||||||
|
// MARK: Getters / Setters
|
||||||
|
|
||||||
|
//! Gets the X coordinate
|
||||||
|
constexpr float NiPoint3::GetX() const noexcept {
|
||||||
|
return this->x;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Sets the X coordinate
|
||||||
|
constexpr void NiPoint3::SetX(const float x) noexcept {
|
||||||
|
this->x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Gets the Y coordinate
|
||||||
|
constexpr float NiPoint3::GetY() const noexcept {
|
||||||
|
return this->y;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Sets the Y coordinate
|
||||||
|
constexpr void NiPoint3::SetY(const float y) noexcept {
|
||||||
|
this->y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Gets the Z coordinate
|
||||||
|
constexpr float NiPoint3::GetZ() const noexcept {
|
||||||
|
return this->z;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Sets the Z coordinate
|
||||||
|
constexpr void NiPoint3::SetZ(const float z) noexcept {
|
||||||
|
this->z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Member Functions
|
||||||
|
|
||||||
|
//! Gets the squared length of a vector
|
||||||
|
constexpr float NiPoint3::SquaredLength() const noexcept {
|
||||||
|
return (x * x + y * y + z * z);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Returns the dot product of the vector dotted with another vector
|
||||||
|
constexpr float NiPoint3::DotProduct(const Vector3& vec) const noexcept {
|
||||||
|
return ((this->x * vec.x) + (this->y * vec.y) + (this->z * vec.z));
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Returns the cross product of the vector crossed with another vector
|
||||||
|
constexpr Vector3 NiPoint3::CrossProduct(const Vector3& vec) const noexcept {
|
||||||
|
return Vector3(((this->y * vec.z) - (this->z * vec.y)),
|
||||||
|
((this->z * vec.x) - (this->x * vec.z)),
|
||||||
|
((this->x * vec.y) - (this->y * vec.x)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Operators
|
||||||
|
|
||||||
|
//! Operator to check for equality
|
||||||
|
constexpr bool NiPoint3::operator==(const NiPoint3& point) const noexcept {
|
||||||
|
return point.x == this->x && point.y == this->y && point.z == this->z;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Operator to check for inequality
|
||||||
|
constexpr bool NiPoint3::operator!=(const NiPoint3& point) const noexcept {
|
||||||
|
return !(*this == point);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Operator for subscripting
|
||||||
|
constexpr float& NiPoint3::operator[](const int i) noexcept {
|
||||||
|
float* base = &x;
|
||||||
|
return base[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Operator for subscripting
|
||||||
|
constexpr const float& NiPoint3::operator[](const int i) const noexcept {
|
||||||
|
const float* base = &x;
|
||||||
|
return base[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Operator for addition of vectors
|
||||||
|
constexpr NiPoint3 NiPoint3::operator+(const NiPoint3& point) const noexcept {
|
||||||
|
return NiPoint3(this->x + point.x, this->y + point.y, this->z + point.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Operator for addition of vectors
|
||||||
|
constexpr NiPoint3& NiPoint3::operator+=(const NiPoint3& point) noexcept {
|
||||||
|
this->x += point.x;
|
||||||
|
this->y += point.y;
|
||||||
|
this->z += point.z;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr NiPoint3& NiPoint3::operator*=(const float scalar) noexcept {
|
||||||
|
this->x *= scalar;
|
||||||
|
this->y *= scalar;
|
||||||
|
this->z *= scalar;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Operator for subtraction of vectors
|
||||||
|
constexpr NiPoint3 NiPoint3::operator-(const NiPoint3& point) const noexcept {
|
||||||
|
return NiPoint3(this->x - point.x, this->y - point.y, this->z - point.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Operator for addition of a scalar on all vector components
|
||||||
|
constexpr NiPoint3 NiPoint3::operator+(const float fScalar) const noexcept {
|
||||||
|
return NiPoint3(this->x + fScalar, this->y + fScalar, this->z + fScalar);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Operator for subtraction of a scalar on all vector components
|
||||||
|
constexpr NiPoint3 NiPoint3::operator-(const float fScalar) const noexcept {
|
||||||
|
return NiPoint3(this->x - fScalar, this->y - fScalar, this->z - fScalar);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Operator for scalar multiplication of a vector
|
||||||
|
constexpr NiPoint3 NiPoint3::operator*(const float fScalar) const noexcept {
|
||||||
|
return NiPoint3(this->x * fScalar, this->y * fScalar, this->z * fScalar);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Operator for scalar division of a vector
|
||||||
|
constexpr NiPoint3 NiPoint3::operator/(const float fScalar) const noexcept {
|
||||||
|
float retX = this->x != 0 ? this->x / fScalar : 0;
|
||||||
|
float retY = this->y != 0 ? this->y / fScalar : 0;
|
||||||
|
float retZ = this->z != 0 ? this->z / fScalar : 0;
|
||||||
|
return NiPoint3(retX, retY, retZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Helper Functions
|
||||||
|
|
||||||
|
//! Checks to see if the point (or vector) is with an Axis-Aligned Bounding Box
|
||||||
|
constexpr bool NiPoint3::IsWithinAxisAlignedBox(const NiPoint3& minPoint, const NiPoint3& maxPoint) noexcept {
|
||||||
|
if (this->x < minPoint.x) return false;
|
||||||
|
if (this->x > maxPoint.x) return false;
|
||||||
|
if (this->y < minPoint.y) return false;
|
||||||
|
if (this->y > maxPoint.y) return false;
|
||||||
|
|
||||||
|
return (this->z < maxPoint.z && this->z > minPoint.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Checks to see if the point (or vector) is within a sphere
|
||||||
|
constexpr bool NiPoint3::IsWithinSphere(const NiPoint3& sphereCenter, const float radius) noexcept {
|
||||||
|
Vector3 diffVec = Vector3(x - sphereCenter.GetX(), y - sphereCenter.GetY(), z - sphereCenter.GetZ());
|
||||||
|
return (diffVec.SquaredLength() <= (radius * radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr NiPoint3 NiPoint3::ClosestPointOnLine(const NiPoint3& a, const NiPoint3& b, const NiPoint3& p) noexcept {
|
||||||
|
if (a == b) return a;
|
||||||
|
|
||||||
|
const auto pa = p - a;
|
||||||
|
const auto ab = b - a;
|
||||||
|
|
||||||
|
const auto t = pa.DotProduct(ab) / ab.SquaredLength();
|
||||||
|
|
||||||
|
if (t <= 0.0f) return a;
|
||||||
|
|
||||||
|
if (t >= 1.0f) return b;
|
||||||
|
|
||||||
|
return a + ab * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr float NiPoint3::DistanceSquared(const NiPoint3& a, const NiPoint3& b) noexcept {
|
||||||
|
const auto dx = a.x - b.x;
|
||||||
|
const auto dy = a.y - b.y;
|
||||||
|
const auto dz = a.z - b.z;
|
||||||
|
|
||||||
|
return dx * dx + dy * dy + dz * dz;
|
||||||
|
}
|
||||||
|
|
||||||
|
//This code is yoinked from the MS XNA code, so it should be right, even if it's horrible.
|
||||||
|
constexpr NiPoint3 NiPoint3::RotateByQuaternion(const NiQuaternion& rotation) noexcept {
|
||||||
|
Vector3 vector;
|
||||||
|
float num12 = rotation.x + rotation.x;
|
||||||
|
float num2 = rotation.y + rotation.y;
|
||||||
|
float num = rotation.z + rotation.z;
|
||||||
|
float num11 = rotation.w * num12;
|
||||||
|
float num10 = rotation.w * num2;
|
||||||
|
float num9 = rotation.w * num;
|
||||||
|
float num8 = rotation.x * num12;
|
||||||
|
float num7 = rotation.x * num2;
|
||||||
|
float num6 = rotation.x * num;
|
||||||
|
float num5 = rotation.y * num2;
|
||||||
|
float num4 = rotation.y * num;
|
||||||
|
float num3 = rotation.z * num;
|
||||||
|
|
||||||
|
NiPoint3 value = *this;
|
||||||
|
float num15 = ((value.x * ((1.0f - num5) - num3)) + (value.y * (num7 - num9))) + (value.z * (num6 + num10));
|
||||||
|
float num14 = ((value.x * (num7 + num9)) + (value.y * ((1.0f - num8) - num3))) + (value.z * (num4 - num11));
|
||||||
|
float num13 = ((value.x * (num6 - num10)) + (value.y * (num4 + num11))) + (value.z * ((1.0f - num8) - num5));
|
||||||
|
vector.x = num15;
|
||||||
|
vector.y = num14;
|
||||||
|
vector.z = num13;
|
||||||
|
return vector;
|
||||||
|
}
|
@ -3,89 +3,8 @@
|
|||||||
// C++
|
// C++
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
// Static Variables
|
|
||||||
const NiQuaternion NiQuaternion::IDENTITY(1, 0, 0, 0);
|
|
||||||
|
|
||||||
//! The initializer
|
|
||||||
NiQuaternion::NiQuaternion(void) {
|
|
||||||
this->w = 1;
|
|
||||||
this->x = 0;
|
|
||||||
this->y = 0;
|
|
||||||
this->z = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! The initializer
|
|
||||||
NiQuaternion::NiQuaternion(float w, float x, float y, float z) {
|
|
||||||
this->w = w;
|
|
||||||
this->x = x;
|
|
||||||
this->y = y;
|
|
||||||
this->z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Destructor
|
|
||||||
NiQuaternion::~NiQuaternion(void) {}
|
|
||||||
|
|
||||||
|
|
||||||
// MARK: Setters / Getters
|
|
||||||
|
|
||||||
//! Gets the W coordinate
|
|
||||||
float NiQuaternion::GetW(void) const {
|
|
||||||
return this->w;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Sets the W coordinate
|
|
||||||
void NiQuaternion::SetW(float w) {
|
|
||||||
this->w = w;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Gets the X coordinate
|
|
||||||
float NiQuaternion::GetX(void) const {
|
|
||||||
return this->x;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Sets the X coordinate
|
|
||||||
void NiQuaternion::SetX(float x) {
|
|
||||||
this->x = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Gets the Y coordinate
|
|
||||||
float NiQuaternion::GetY(void) const {
|
|
||||||
return this->y;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Sets the Y coordinate
|
|
||||||
void NiQuaternion::SetY(float y) {
|
|
||||||
this->y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Gets the Z coordinate
|
|
||||||
float NiQuaternion::GetZ(void) const {
|
|
||||||
return this->z;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Sets the Z coordinate
|
|
||||||
void NiQuaternion::SetZ(float z) {
|
|
||||||
this->z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// MARK: Member Functions
|
// MARK: Member Functions
|
||||||
|
|
||||||
//! Returns the forward vector from the quaternion
|
|
||||||
Vector3 NiQuaternion::GetForwardVector(void) const {
|
|
||||||
return Vector3(2 * (x * z + w * y), 2 * (y * z - w * x), 1 - 2 * (x * x + y * y));
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Returns the up vector from the quaternion
|
|
||||||
Vector3 NiQuaternion::GetUpVector(void) const {
|
|
||||||
return Vector3(2 * (x * y - w * z), 1 - 2 * (x * x + z * z), 2 * (y * z + w * x));
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Returns the right vector from the quaternion
|
|
||||||
Vector3 NiQuaternion::GetRightVector(void) const {
|
|
||||||
return Vector3(1 - 2 * (y * y + z * z), 2 * (x * y + w * z), 2 * (x * z - w * y));
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector3 NiQuaternion::GetEulerAngles() const {
|
Vector3 NiQuaternion::GetEulerAngles() const {
|
||||||
Vector3 angles;
|
Vector3 angles;
|
||||||
|
|
||||||
@ -111,22 +30,9 @@ Vector3 NiQuaternion::GetEulerAngles() const {
|
|||||||
return angles;
|
return angles;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Operators
|
|
||||||
|
|
||||||
//! Operator to check for equality
|
|
||||||
bool NiQuaternion::operator==(const NiQuaternion& rot) const {
|
|
||||||
return rot.x == this->x && rot.y == this->y && rot.z == this->z && rot.w == this->w;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator to check for inequality
|
|
||||||
bool NiQuaternion::operator!=(const NiQuaternion& rot) const {
|
|
||||||
return !(*this == rot);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// MARK: Helper Functions
|
// MARK: Helper Functions
|
||||||
|
|
||||||
//! Look from a specific point in space to another point in space
|
//! Look from a specific point in space to another point in space (Y-locked)
|
||||||
NiQuaternion NiQuaternion::LookAt(const NiPoint3& sourcePoint, const NiPoint3& destPoint) {
|
NiQuaternion NiQuaternion::LookAt(const NiPoint3& sourcePoint, const NiPoint3& destPoint) {
|
||||||
//To make sure we don't orient around the X/Z axis:
|
//To make sure we don't orient around the X/Z axis:
|
||||||
NiPoint3 source = sourcePoint;
|
NiPoint3 source = sourcePoint;
|
||||||
@ -136,7 +42,7 @@ NiQuaternion NiQuaternion::LookAt(const NiPoint3& sourcePoint, const NiPoint3& d
|
|||||||
|
|
||||||
NiPoint3 forwardVector = NiPoint3(dest - source).Unitize();
|
NiPoint3 forwardVector = NiPoint3(dest - source).Unitize();
|
||||||
|
|
||||||
NiPoint3 posZ = NiPoint3::UNIT_Z;
|
NiPoint3 posZ = NiPoint3Constant::UNIT_Z;
|
||||||
NiPoint3 vecA = posZ.CrossProduct(forwardVector).Unitize();
|
NiPoint3 vecA = posZ.CrossProduct(forwardVector).Unitize();
|
||||||
|
|
||||||
float dot = posZ.DotProduct(forwardVector);
|
float dot = posZ.DotProduct(forwardVector);
|
||||||
@ -148,10 +54,11 @@ NiQuaternion NiQuaternion::LookAt(const NiPoint3& sourcePoint, const NiPoint3& d
|
|||||||
return NiQuaternion::CreateFromAxisAngle(vecA, rotAngle);
|
return NiQuaternion::CreateFromAxisAngle(vecA, rotAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Look from a specific point in space to another point in space
|
||||||
NiQuaternion NiQuaternion::LookAtUnlocked(const NiPoint3& sourcePoint, const NiPoint3& destPoint) {
|
NiQuaternion NiQuaternion::LookAtUnlocked(const NiPoint3& sourcePoint, const NiPoint3& destPoint) {
|
||||||
NiPoint3 forwardVector = NiPoint3(destPoint - sourcePoint).Unitize();
|
NiPoint3 forwardVector = NiPoint3(destPoint - sourcePoint).Unitize();
|
||||||
|
|
||||||
NiPoint3 posZ = NiPoint3::UNIT_Z;
|
NiPoint3 posZ = NiPoint3Constant::UNIT_Z;
|
||||||
NiPoint3 vecA = posZ.CrossProduct(forwardVector).Unitize();
|
NiPoint3 vecA = posZ.CrossProduct(forwardVector).Unitize();
|
||||||
|
|
||||||
float dot = posZ.DotProduct(forwardVector);
|
float dot = posZ.DotProduct(forwardVector);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef __NIQUATERNION_H__
|
||||||
|
#define __NIQUATERNION_H__
|
||||||
|
|
||||||
// Custom Classes
|
// Custom Classes
|
||||||
#include "NiPoint3.h"
|
#include "NiPoint3.h"
|
||||||
@ -14,14 +15,14 @@ typedef NiQuaternion Quaternion; //!< A typedef for a shorthand version o
|
|||||||
//! A class that defines a rotation in space
|
//! A class that defines a rotation in space
|
||||||
class NiQuaternion {
|
class NiQuaternion {
|
||||||
public:
|
public:
|
||||||
float w; //!< The w coordinate
|
float w{ 1 }; //!< The w coordinate
|
||||||
float x; //!< The x coordinate
|
float x{ 0 }; //!< The x coordinate
|
||||||
float y; //!< The y coordinate
|
float y{ 0 }; //!< The y coordinate
|
||||||
float z; //!< The z coordinate
|
float z{ 0 }; //!< The z coordinate
|
||||||
|
|
||||||
|
|
||||||
//! The initializer
|
//! The initializer
|
||||||
NiQuaternion(void);
|
constexpr NiQuaternion() = default;
|
||||||
|
|
||||||
//! The initializer
|
//! The initializer
|
||||||
/*!
|
/*!
|
||||||
@ -30,13 +31,12 @@ public:
|
|||||||
\param y The y coordinate
|
\param y The y coordinate
|
||||||
\param z The z coordinate
|
\param z The z coordinate
|
||||||
*/
|
*/
|
||||||
NiQuaternion(float w, float x, float y, float z);
|
constexpr NiQuaternion(const float w, const float x, const float y, const float z) noexcept
|
||||||
|
: w{ w }
|
||||||
//! Destructor
|
, x{ x }
|
||||||
~NiQuaternion(void);
|
, y{ y }
|
||||||
|
, z{ z } {
|
||||||
// MARK: Constants
|
}
|
||||||
static const NiQuaternion IDENTITY; //!< Quaternion(1, 0, 0, 0)
|
|
||||||
|
|
||||||
// MARK: Setters / Getters
|
// MARK: Setters / Getters
|
||||||
|
|
||||||
@ -44,50 +44,49 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
\return The w coordinate
|
\return The w coordinate
|
||||||
*/
|
*/
|
||||||
float GetW(void) const;
|
[[nodiscard]] constexpr float GetW() const noexcept;
|
||||||
|
|
||||||
//! Sets the W coordinate
|
//! Sets the W coordinate
|
||||||
/*!
|
/*!
|
||||||
\param w The w coordinate
|
\param w The w coordinate
|
||||||
*/
|
*/
|
||||||
void SetW(float w);
|
constexpr void SetW(const float w) noexcept;
|
||||||
|
|
||||||
//! Gets the X coordinate
|
//! Gets the X coordinate
|
||||||
/*!
|
/*!
|
||||||
\return The x coordinate
|
\return The x coordinate
|
||||||
*/
|
*/
|
||||||
float GetX(void) const;
|
[[nodiscard]] constexpr float GetX() const noexcept;
|
||||||
|
|
||||||
//! Sets the X coordinate
|
//! Sets the X coordinate
|
||||||
/*!
|
/*!
|
||||||
\param x The x coordinate
|
\param x The x coordinate
|
||||||
*/
|
*/
|
||||||
void SetX(float x);
|
constexpr void SetX(const float x) noexcept;
|
||||||
|
|
||||||
//! Gets the Y coordinate
|
//! Gets the Y coordinate
|
||||||
/*!
|
/*!
|
||||||
\return The y coordinate
|
\return The y coordinate
|
||||||
*/
|
*/
|
||||||
float GetY(void) const;
|
[[nodiscard]] constexpr float GetY() const noexcept;
|
||||||
|
|
||||||
//! Sets the Y coordinate
|
//! Sets the Y coordinate
|
||||||
/*!
|
/*!
|
||||||
\param y The y coordinate
|
\param y The y coordinate
|
||||||
*/
|
*/
|
||||||
void SetY(float y);
|
constexpr void SetY(const float y) noexcept;
|
||||||
|
|
||||||
//! Gets the Z coordinate
|
//! Gets the Z coordinate
|
||||||
/*!
|
/*!
|
||||||
\return The z coordinate
|
\return The z coordinate
|
||||||
*/
|
*/
|
||||||
float GetZ(void) const;
|
[[nodiscard]] constexpr float GetZ() const noexcept;
|
||||||
|
|
||||||
//! Sets the Z coordinate
|
//! Sets the Z coordinate
|
||||||
/*!
|
/*!
|
||||||
\param z The z coordinate
|
\param z The z coordinate
|
||||||
*/
|
*/
|
||||||
void SetZ(float z);
|
constexpr void SetZ(const float z) noexcept;
|
||||||
|
|
||||||
|
|
||||||
// MARK: Member Functions
|
// MARK: Member Functions
|
||||||
|
|
||||||
@ -95,31 +94,29 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
\return The forward vector of the quaternion
|
\return The forward vector of the quaternion
|
||||||
*/
|
*/
|
||||||
Vector3 GetForwardVector(void) const;
|
[[nodiscard]] constexpr Vector3 GetForwardVector() const noexcept;
|
||||||
|
|
||||||
//! Returns the up vector from the quaternion
|
//! Returns the up vector from the quaternion
|
||||||
/*!
|
/*!
|
||||||
\return The up vector fo the quaternion
|
\return The up vector fo the quaternion
|
||||||
*/
|
*/
|
||||||
Vector3 GetUpVector(void) const;
|
[[nodiscard]] constexpr Vector3 GetUpVector() const noexcept;
|
||||||
|
|
||||||
//! Returns the right vector from the quaternion
|
//! Returns the right vector from the quaternion
|
||||||
/*!
|
/*!
|
||||||
\return The right vector of the quaternion
|
\return The right vector of the quaternion
|
||||||
*/
|
*/
|
||||||
Vector3 GetRightVector(void) const;
|
[[nodiscard]] constexpr Vector3 GetRightVector() const noexcept;
|
||||||
|
|
||||||
Vector3 GetEulerAngles() const;
|
|
||||||
|
|
||||||
|
[[nodiscard]] Vector3 GetEulerAngles() const;
|
||||||
|
|
||||||
// MARK: Operators
|
// MARK: Operators
|
||||||
|
|
||||||
//! Operator to check for equality
|
//! Operator to check for equality
|
||||||
bool operator==(const NiQuaternion& rot) const;
|
constexpr bool operator==(const NiQuaternion& rot) const noexcept;
|
||||||
|
|
||||||
//! Operator to check for inequality
|
//! Operator to check for inequality
|
||||||
bool operator!=(const NiQuaternion& rot) const;
|
constexpr bool operator!=(const NiQuaternion& rot) const noexcept;
|
||||||
|
|
||||||
|
|
||||||
// MARK: Helper Functions
|
// MARK: Helper Functions
|
||||||
|
|
||||||
@ -129,7 +126,7 @@ public:
|
|||||||
\param destPoint The destination location
|
\param destPoint The destination location
|
||||||
\return The Quaternion with the rotation towards the destination
|
\return The Quaternion with the rotation towards the destination
|
||||||
*/
|
*/
|
||||||
static NiQuaternion LookAt(const NiPoint3& sourcePoint, const NiPoint3& destPoint);
|
[[nodiscard]] static NiQuaternion LookAt(const NiPoint3& sourcePoint, const NiPoint3& destPoint);
|
||||||
|
|
||||||
//! Look from a specific point in space to another point in space
|
//! Look from a specific point in space to another point in space
|
||||||
/*!
|
/*!
|
||||||
@ -137,7 +134,7 @@ public:
|
|||||||
\param destPoint The destination location
|
\param destPoint The destination location
|
||||||
\return The Quaternion with the rotation towards the destination
|
\return The Quaternion with the rotation towards the destination
|
||||||
*/
|
*/
|
||||||
static NiQuaternion LookAtUnlocked(const NiPoint3& sourcePoint, const NiPoint3& destPoint);
|
[[nodiscard]] static NiQuaternion LookAtUnlocked(const NiPoint3& sourcePoint, const NiPoint3& destPoint);
|
||||||
|
|
||||||
//! Creates a Quaternion from a specific axis and angle relative to that axis
|
//! Creates a Quaternion from a specific axis and angle relative to that axis
|
||||||
/*!
|
/*!
|
||||||
@ -145,7 +142,17 @@ public:
|
|||||||
\param angle The angle relative to this axis
|
\param angle The angle relative to this axis
|
||||||
\return A quaternion created from the axis and angle
|
\return A quaternion created from the axis and angle
|
||||||
*/
|
*/
|
||||||
static NiQuaternion CreateFromAxisAngle(const Vector3& axis, float angle);
|
[[nodiscard]] static NiQuaternion CreateFromAxisAngle(const Vector3& axis, float angle);
|
||||||
|
|
||||||
static NiQuaternion FromEulerAngles(const NiPoint3& eulerAngles);
|
[[nodiscard]] static NiQuaternion FromEulerAngles(const NiPoint3& eulerAngles);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Static Variables
|
||||||
|
namespace NiQuaternionConstant {
|
||||||
|
constexpr NiQuaternion IDENTITY(1, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Include constexpr and inline function definitions in a seperate file for readability
|
||||||
|
#include "NiQuaternion.inl"
|
||||||
|
|
||||||
|
#endif // !__NIQUATERNION_H__
|
||||||
|
75
dCommon/NiQuaternion.inl
Normal file
75
dCommon/NiQuaternion.inl
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef __NIQUATERNION_H__
|
||||||
|
#error "This should only be included inline in NiQuaternion.h: Do not include directly!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// MARK: Setters / Getters
|
||||||
|
|
||||||
|
//! Gets the W coordinate
|
||||||
|
constexpr float NiQuaternion::GetW() const noexcept {
|
||||||
|
return this->w;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Sets the W coordinate
|
||||||
|
constexpr void NiQuaternion::SetW(const float w) noexcept {
|
||||||
|
this->w = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Gets the X coordinate
|
||||||
|
constexpr float NiQuaternion::GetX() const noexcept {
|
||||||
|
return this->x;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Sets the X coordinate
|
||||||
|
constexpr void NiQuaternion::SetX(const float x) noexcept {
|
||||||
|
this->x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Gets the Y coordinate
|
||||||
|
constexpr float NiQuaternion::GetY() const noexcept {
|
||||||
|
return this->y;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Sets the Y coordinate
|
||||||
|
constexpr void NiQuaternion::SetY(const float y) noexcept {
|
||||||
|
this->y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Gets the Z coordinate
|
||||||
|
constexpr float NiQuaternion::GetZ() const noexcept {
|
||||||
|
return this->z;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Sets the Z coordinate
|
||||||
|
constexpr void NiQuaternion::SetZ(const float z) noexcept {
|
||||||
|
this->z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Member Functions
|
||||||
|
|
||||||
|
//! Returns the forward vector from the quaternion
|
||||||
|
constexpr Vector3 NiQuaternion::GetForwardVector() const noexcept {
|
||||||
|
return Vector3(2 * (x * z + w * y), 2 * (y * z - w * x), 1 - 2 * (x * x + y * y));
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Returns the up vector from the quaternion
|
||||||
|
constexpr Vector3 NiQuaternion::GetUpVector() const noexcept {
|
||||||
|
return Vector3(2 * (x * y - w * z), 1 - 2 * (x * x + z * z), 2 * (y * z + w * x));
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Returns the right vector from the quaternion
|
||||||
|
constexpr Vector3 NiQuaternion::GetRightVector() const noexcept {
|
||||||
|
return Vector3(1 - 2 * (y * y + z * z), 2 * (x * y + w * z), 2 * (x * z - w * y));
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Operators
|
||||||
|
|
||||||
|
//! Operator to check for equality
|
||||||
|
constexpr bool NiQuaternion::operator==(const NiQuaternion& rot) const noexcept {
|
||||||
|
return rot.x == this->x && rot.y == this->y && rot.z == this->z && rot.w == this->w;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Operator to check for inequality
|
||||||
|
constexpr bool NiQuaternion::operator!=(const NiQuaternion& rot) const noexcept {
|
||||||
|
return !(*this == rot);
|
||||||
|
}
|
@ -32,17 +32,17 @@ struct RemoteInputInfo {
|
|||||||
|
|
||||||
struct LocalSpaceInfo {
|
struct LocalSpaceInfo {
|
||||||
LWOOBJID objectId = LWOOBJID_EMPTY;
|
LWOOBJID objectId = LWOOBJID_EMPTY;
|
||||||
NiPoint3 position = NiPoint3::ZERO;
|
NiPoint3 position = NiPoint3Constant::ZERO;
|
||||||
NiPoint3 linearVelocity = NiPoint3::ZERO;
|
NiPoint3 linearVelocity = NiPoint3Constant::ZERO;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PositionUpdate {
|
struct PositionUpdate {
|
||||||
NiPoint3 position = NiPoint3::ZERO;
|
NiPoint3 position = NiPoint3Constant::ZERO;
|
||||||
NiQuaternion rotation = NiQuaternion::IDENTITY;
|
NiQuaternion rotation = NiQuaternionConstant::IDENTITY;
|
||||||
bool onGround = false;
|
bool onGround = false;
|
||||||
bool onRail = false;
|
bool onRail = false;
|
||||||
NiPoint3 velocity = NiPoint3::ZERO;
|
NiPoint3 velocity = NiPoint3Constant::ZERO;
|
||||||
NiPoint3 angularVelocity = NiPoint3::ZERO;
|
NiPoint3 angularVelocity = NiPoint3Constant::ZERO;
|
||||||
LocalSpaceInfo localSpaceInfo;
|
LocalSpaceInfo localSpaceInfo;
|
||||||
RemoteInputInfo remoteInputInfo;
|
RemoteInputInfo remoteInputInfo;
|
||||||
};
|
};
|
||||||
|
@ -451,7 +451,7 @@ void Character::LoadXmlRespawnCheckpoints() {
|
|||||||
auto* r = points->FirstChildElement("r");
|
auto* r = points->FirstChildElement("r");
|
||||||
while (r != nullptr) {
|
while (r != nullptr) {
|
||||||
int32_t map = 0;
|
int32_t map = 0;
|
||||||
NiPoint3 point = NiPoint3::ZERO;
|
NiPoint3 point = NiPoint3Constant::ZERO;
|
||||||
|
|
||||||
r->QueryAttribute("w", &map);
|
r->QueryAttribute("w", &map);
|
||||||
r->QueryAttribute("x", &point.x);
|
r->QueryAttribute("x", &point.x);
|
||||||
@ -513,7 +513,7 @@ void Character::SetRespawnPoint(LWOMAPID map, const NiPoint3& point) {
|
|||||||
const NiPoint3& Character::GetRespawnPoint(LWOMAPID map) const {
|
const NiPoint3& Character::GetRespawnPoint(LWOMAPID map) const {
|
||||||
const auto& pair = m_WorldRespawnCheckpoints.find(map);
|
const auto& pair = m_WorldRespawnCheckpoints.find(map);
|
||||||
|
|
||||||
if (pair == m_WorldRespawnCheckpoints.end()) return NiPoint3::ZERO;
|
if (pair == m_WorldRespawnCheckpoints.end()) return NiPoint3Constant::ZERO;
|
||||||
|
|
||||||
return pair->second;
|
return pair->second;
|
||||||
}
|
}
|
||||||
|
@ -1857,7 +1857,7 @@ const NiPoint3& Entity::GetPosition() const {
|
|||||||
return vehicel->GetPosition();
|
return vehicel->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NiPoint3::ZERO;
|
return NiPoint3Constant::ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NiQuaternion& Entity::GetRotation() const {
|
const NiQuaternion& Entity::GetRotation() const {
|
||||||
@ -1885,7 +1885,7 @@ const NiQuaternion& Entity::GetRotation() const {
|
|||||||
return vehicel->GetRotation();
|
return vehicel->GetRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NiQuaternion::IDENTITY;
|
return NiQuaternionConstant::IDENTITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::SetPosition(const NiPoint3& position) {
|
void Entity::SetPosition(const NiPoint3& position) {
|
||||||
@ -2086,9 +2086,9 @@ void Entity::ProcessPositionUpdate(PositionUpdate& update) {
|
|||||||
havokVehiclePhysicsComponent->SetIsOnGround(update.onGround);
|
havokVehiclePhysicsComponent->SetIsOnGround(update.onGround);
|
||||||
havokVehiclePhysicsComponent->SetIsOnRail(update.onRail);
|
havokVehiclePhysicsComponent->SetIsOnRail(update.onRail);
|
||||||
havokVehiclePhysicsComponent->SetVelocity(update.velocity);
|
havokVehiclePhysicsComponent->SetVelocity(update.velocity);
|
||||||
havokVehiclePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3::ZERO);
|
havokVehiclePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3Constant::ZERO);
|
||||||
havokVehiclePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
havokVehiclePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
||||||
havokVehiclePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3::ZERO);
|
havokVehiclePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3Constant::ZERO);
|
||||||
havokVehiclePhysicsComponent->SetRemoteInputInfo(update.remoteInputInfo);
|
havokVehiclePhysicsComponent->SetRemoteInputInfo(update.remoteInputInfo);
|
||||||
} else {
|
} else {
|
||||||
// Need to get the mount's controllable physics
|
// Need to get the mount's controllable physics
|
||||||
@ -2099,17 +2099,17 @@ void Entity::ProcessPositionUpdate(PositionUpdate& update) {
|
|||||||
possessedControllablePhysicsComponent->SetIsOnGround(update.onGround);
|
possessedControllablePhysicsComponent->SetIsOnGround(update.onGround);
|
||||||
possessedControllablePhysicsComponent->SetIsOnRail(update.onRail);
|
possessedControllablePhysicsComponent->SetIsOnRail(update.onRail);
|
||||||
possessedControllablePhysicsComponent->SetVelocity(update.velocity);
|
possessedControllablePhysicsComponent->SetVelocity(update.velocity);
|
||||||
possessedControllablePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3::ZERO);
|
possessedControllablePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3Constant::ZERO);
|
||||||
possessedControllablePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
possessedControllablePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
||||||
possessedControllablePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3::ZERO);
|
possessedControllablePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3Constant::ZERO);
|
||||||
}
|
}
|
||||||
Game::entityManager->SerializeEntity(possassableEntity);
|
Game::entityManager->SerializeEntity(possassableEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!updateChar) {
|
if (!updateChar) {
|
||||||
update.velocity = NiPoint3::ZERO;
|
update.velocity = NiPoint3Constant::ZERO;
|
||||||
update.angularVelocity = NiPoint3::ZERO;
|
update.angularVelocity = NiPoint3Constant::ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle statistics
|
// Handle statistics
|
||||||
@ -2123,9 +2123,9 @@ void Entity::ProcessPositionUpdate(PositionUpdate& update) {
|
|||||||
controllablePhysicsComponent->SetIsOnGround(update.onGround);
|
controllablePhysicsComponent->SetIsOnGround(update.onGround);
|
||||||
controllablePhysicsComponent->SetIsOnRail(update.onRail);
|
controllablePhysicsComponent->SetIsOnRail(update.onRail);
|
||||||
controllablePhysicsComponent->SetVelocity(update.velocity);
|
controllablePhysicsComponent->SetVelocity(update.velocity);
|
||||||
controllablePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3::ZERO);
|
controllablePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3Constant::ZERO);
|
||||||
controllablePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
controllablePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
||||||
controllablePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3::ZERO);
|
controllablePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3Constant::ZERO);
|
||||||
|
|
||||||
auto* ghostComponent = GetComponent<GhostComponent>();
|
auto* ghostComponent = GetComponent<GhostComponent>();
|
||||||
if (ghostComponent) ghostComponent->SetGhostReferencePoint(update.position);
|
if (ghostComponent) ghostComponent->SetGhostReferencePoint(update.position);
|
||||||
|
@ -229,8 +229,8 @@ public:
|
|||||||
void TriggerEvent(eTriggerEventType event, Entity* optionalTarget = nullptr);
|
void TriggerEvent(eTriggerEventType event, Entity* optionalTarget = nullptr);
|
||||||
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }
|
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }
|
||||||
|
|
||||||
virtual const NiPoint3& GetRespawnPosition() const { return NiPoint3::ZERO; }
|
virtual const NiPoint3& GetRespawnPosition() const { return NiPoint3Constant::ZERO; }
|
||||||
virtual const NiQuaternion& GetRespawnRotation() const { return NiQuaternion::IDENTITY; }
|
virtual const NiQuaternion& GetRespawnRotation() const { return NiQuaternionConstant::IDENTITY; }
|
||||||
|
|
||||||
void Sleep();
|
void Sleep();
|
||||||
void Wake();
|
void Wake();
|
||||||
|
@ -33,7 +33,7 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_useMouseposit && !branch.isSync) {
|
if (m_useMouseposit && !branch.isSync) {
|
||||||
NiPoint3 targetPosition = NiPoint3::ZERO;
|
NiPoint3 targetPosition = NiPoint3Constant::ZERO;
|
||||||
if (!bitStream->Read(targetPosition)) {
|
if (!bitStream->Read(targetPosition)) {
|
||||||
LOG("Unable to read targetPosition from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
LOG("Unable to read targetPosition from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||||
return;
|
return;
|
||||||
|
@ -185,7 +185,7 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
|
|||||||
bool stunnedThisFrame = m_Stunned;
|
bool stunnedThisFrame = m_Stunned;
|
||||||
CalculateCombat(deltaTime); // Putting this here for now
|
CalculateCombat(deltaTime); // Putting this here for now
|
||||||
|
|
||||||
if (m_StartPosition == NiPoint3::ZERO) {
|
if (m_StartPosition == NiPoint3Constant::ZERO) {
|
||||||
m_StartPosition = m_Parent->GetPosition();
|
m_StartPosition = m_Parent->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ void BuildBorderComponent::OnUse(Entity* originator) {
|
|||||||
4,
|
4,
|
||||||
0,
|
0,
|
||||||
-1,
|
-1,
|
||||||
NiPoint3::ZERO,
|
NiPoint3Constant::ZERO,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "GhostComponent.h"
|
#include "GhostComponent.h"
|
||||||
|
|
||||||
GhostComponent::GhostComponent(Entity* parent) : Component(parent) {
|
GhostComponent::GhostComponent(Entity* parent) : Component(parent) {
|
||||||
m_GhostReferencePoint = NiPoint3::ZERO;
|
m_GhostReferencePoint = NiPoint3Constant::ZERO;
|
||||||
m_GhostOverridePoint = NiPoint3::ZERO;
|
m_GhostOverridePoint = NiPoint3Constant::ZERO;
|
||||||
m_GhostOverride = false;
|
m_GhostOverride = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
|
|
||||||
HavokVehiclePhysicsComponent::HavokVehiclePhysicsComponent(Entity* parent) : PhysicsComponent(parent) {
|
HavokVehiclePhysicsComponent::HavokVehiclePhysicsComponent(Entity* parent) : PhysicsComponent(parent) {
|
||||||
m_Velocity = NiPoint3::ZERO;
|
m_Velocity = NiPoint3Constant::ZERO;
|
||||||
m_AngularVelocity = NiPoint3::ZERO;
|
m_AngularVelocity = NiPoint3Constant::ZERO;
|
||||||
m_IsOnGround = true;
|
m_IsOnGround = true;
|
||||||
m_IsOnRail = false;
|
m_IsOnRail = false;
|
||||||
m_DirtyPosition = true;
|
m_DirtyPosition = true;
|
||||||
|
@ -1223,7 +1223,7 @@ void InventoryComponent::SpawnPet(Item* item) {
|
|||||||
EntityInfo info{};
|
EntityInfo info{};
|
||||||
info.lot = item->GetLot();
|
info.lot = item->GetLot();
|
||||||
info.pos = m_Parent->GetPosition();
|
info.pos = m_Parent->GetPosition();
|
||||||
info.rot = NiQuaternion::IDENTITY;
|
info.rot = NiQuaternionConstant::IDENTITY;
|
||||||
info.spawnerID = m_Parent->GetObjectID();
|
info.spawnerID = m_Parent->GetObjectID();
|
||||||
|
|
||||||
auto* pet = Game::entityManager->CreateEntity(info);
|
auto* pet = Game::entityManager->CreateEntity(info);
|
||||||
|
@ -43,7 +43,7 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) :
|
|||||||
m_NextWaypoint = m_Parent->GetPosition();
|
m_NextWaypoint = m_Parent->GetPosition();
|
||||||
m_Acceleration = 0.4f;
|
m_Acceleration = 0.4f;
|
||||||
m_PullingToPoint = false;
|
m_PullingToPoint = false;
|
||||||
m_PullPoint = NiPoint3::ZERO;
|
m_PullPoint = NiPoint3Constant::ZERO;
|
||||||
m_HaltDistance = 0;
|
m_HaltDistance = 0;
|
||||||
m_TimeToTravel = 0;
|
m_TimeToTravel = 0;
|
||||||
m_TimeTravelled = 0;
|
m_TimeTravelled = 0;
|
||||||
@ -88,7 +88,7 @@ void MovementAIComponent::Update(const float deltaTime) {
|
|||||||
|
|
||||||
SetPosition(source);
|
SetPosition(source);
|
||||||
|
|
||||||
NiPoint3 velocity = NiPoint3::ZERO;
|
NiPoint3 velocity = NiPoint3Constant::ZERO;
|
||||||
|
|
||||||
if (m_Acceleration > 0 && m_BaseSpeed > 0 && AdvanceWaypointIndex()) // Do we have another waypoint to seek?
|
if (m_Acceleration > 0 && m_BaseSpeed > 0 && AdvanceWaypointIndex()) // Do we have another waypoint to seek?
|
||||||
{
|
{
|
||||||
@ -203,7 +203,7 @@ void MovementAIComponent::Stop() {
|
|||||||
|
|
||||||
SetPosition(ApproximateLocation());
|
SetPosition(ApproximateLocation());
|
||||||
|
|
||||||
SetVelocity(NiPoint3::ZERO);
|
SetVelocity(NiPoint3Constant::ZERO);
|
||||||
|
|
||||||
m_TimeToTravel = 0;
|
m_TimeToTravel = 0;
|
||||||
m_TimeTravelled = 0;
|
m_TimeTravelled = 0;
|
||||||
|
@ -84,7 +84,7 @@ PetComponent::PetComponent(Entity* parentEntity, uint32_t componentId) : Compone
|
|||||||
m_DatabaseId = LWOOBJID_EMPTY;
|
m_DatabaseId = LWOOBJID_EMPTY;
|
||||||
m_Status = 67108866; // Tamable
|
m_Status = 67108866; // Tamable
|
||||||
m_Ability = ePetAbilityType::Invalid;
|
m_Ability = ePetAbilityType::Invalid;
|
||||||
m_StartPosition = NiPoint3::ZERO;
|
m_StartPosition = NiPoint3Constant::ZERO;
|
||||||
m_MovementAI = nullptr;
|
m_MovementAI = nullptr;
|
||||||
m_TresureTime = 0;
|
m_TresureTime = 0;
|
||||||
m_Preconditions = nullptr;
|
m_Preconditions = nullptr;
|
||||||
@ -312,7 +312,7 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::Update(float deltaTime) {
|
void PetComponent::Update(float deltaTime) {
|
||||||
if (m_StartPosition == NiPoint3::ZERO) {
|
if (m_StartPosition == NiPoint3Constant::ZERO) {
|
||||||
m_StartPosition = m_Parent->GetPosition();
|
m_StartPosition = m_Parent->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
if (distance < 5 * 5) {
|
if (distance < 5 * 5) {
|
||||||
m_Interaction = closestTresure->GetObjectID();
|
m_Interaction = closestTresure->GetObjectID();
|
||||||
|
|
||||||
Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, 202, true);
|
Command(NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 1, 202, true);
|
||||||
|
|
||||||
m_TresureTime = 2;
|
m_TresureTime = 2;
|
||||||
} else if (distance < 10 * 10) {
|
} else if (distance < 10 * 10) {
|
||||||
@ -531,7 +531,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
|||||||
EntityInfo info{};
|
EntityInfo info{};
|
||||||
info.lot = cached->second.puzzleModelLot;
|
info.lot = cached->second.puzzleModelLot;
|
||||||
info.pos = position;
|
info.pos = position;
|
||||||
info.rot = NiQuaternion::IDENTITY;
|
info.rot = NiQuaternionConstant::IDENTITY;
|
||||||
info.spawnerID = tamer->GetObjectID();
|
info.spawnerID = tamer->GetObjectID();
|
||||||
|
|
||||||
auto* modelEntity = Game::entityManager->CreateEntity(info);
|
auto* modelEntity = Game::entityManager->CreateEntity(info);
|
||||||
@ -591,9 +591,9 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
|||||||
LWOOBJID_EMPTY,
|
LWOOBJID_EMPTY,
|
||||||
false,
|
false,
|
||||||
ePetTamingNotifyType::NAMINGPET,
|
ePetTamingNotifyType::NAMINGPET,
|
||||||
NiPoint3::ZERO,
|
NiPoint3Constant::ZERO,
|
||||||
NiPoint3::ZERO,
|
NiPoint3Constant::ZERO,
|
||||||
NiQuaternion::IDENTITY,
|
NiQuaternionConstant::IDENTITY,
|
||||||
UNASSIGNED_SYSTEM_ADDRESS
|
UNASSIGNED_SYSTEM_ADDRESS
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -671,9 +671,9 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
|||||||
m_Tamer,
|
m_Tamer,
|
||||||
false,
|
false,
|
||||||
ePetTamingNotifyType::SUCCESS,
|
ePetTamingNotifyType::SUCCESS,
|
||||||
NiPoint3::ZERO,
|
NiPoint3Constant::ZERO,
|
||||||
NiPoint3::ZERO,
|
NiPoint3Constant::ZERO,
|
||||||
NiQuaternion::IDENTITY,
|
NiQuaternionConstant::IDENTITY,
|
||||||
UNASSIGNED_SYSTEM_ADDRESS
|
UNASSIGNED_SYSTEM_ADDRESS
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -712,9 +712,9 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
|||||||
m_Tamer,
|
m_Tamer,
|
||||||
false,
|
false,
|
||||||
ePetTamingNotifyType::QUIT,
|
ePetTamingNotifyType::QUIT,
|
||||||
NiPoint3::ZERO,
|
NiPoint3Constant::ZERO,
|
||||||
NiPoint3::ZERO,
|
NiPoint3Constant::ZERO,
|
||||||
NiQuaternion::IDENTITY,
|
NiQuaternionConstant::IDENTITY,
|
||||||
UNASSIGNED_SYSTEM_ADDRESS
|
UNASSIGNED_SYSTEM_ADDRESS
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -763,9 +763,9 @@ void PetComponent::ClientFailTamingMinigame() {
|
|||||||
m_Tamer,
|
m_Tamer,
|
||||||
false,
|
false,
|
||||||
ePetTamingNotifyType::FAILED,
|
ePetTamingNotifyType::FAILED,
|
||||||
NiPoint3::ZERO,
|
NiPoint3Constant::ZERO,
|
||||||
NiPoint3::ZERO,
|
NiPoint3Constant::ZERO,
|
||||||
NiQuaternion::IDENTITY,
|
NiQuaternionConstant::IDENTITY,
|
||||||
UNASSIGNED_SYSTEM_ADDRESS
|
UNASSIGNED_SYSTEM_ADDRESS
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : PhysicsCompon
|
|||||||
dpWorld::AddEntity(m_dpEntity);
|
dpWorld::AddEntity(m_dpEntity);
|
||||||
} else if (info->physicsAsset == "miscellaneous\\misc_phys_640x640.hkx") {
|
} else if (info->physicsAsset == "miscellaneous\\misc_phys_640x640.hkx") {
|
||||||
// Move this down by 13.521004 units so it is still effectively at the same height as before
|
// Move this down by 13.521004 units so it is still effectively at the same height as before
|
||||||
m_Position = m_Position - NiPoint3::UNIT_Y * 13.521004f;
|
m_Position = m_Position - NiPoint3Constant::UNIT_Y * 13.521004f;
|
||||||
// TODO Fix physics simulation to do simulation at high velocities due to bullet through paper problem...
|
// TODO Fix physics simulation to do simulation at high velocities due to bullet through paper problem...
|
||||||
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 1638.4f, 13.521004f * 2.0f, 1638.4f);
|
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 1638.4f, 13.521004f * 2.0f, 1638.4f);
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "PhysicsComponent.h"
|
#include "PhysicsComponent.h"
|
||||||
|
|
||||||
PhysicsComponent::PhysicsComponent(Entity* parent) : Component(parent) {
|
PhysicsComponent::PhysicsComponent(Entity* parent) : Component(parent) {
|
||||||
m_Position = NiPoint3::ZERO;
|
m_Position = NiPoint3Constant::ZERO;
|
||||||
m_Rotation = NiQuaternion::IDENTITY;
|
m_Rotation = NiQuaternionConstant::IDENTITY;
|
||||||
m_DirtyPosition = false;
|
m_DirtyPosition = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
|
|||||||
|
|
||||||
const auto modelLOT = item->GetLot();
|
const auto modelLOT = item->GetLot();
|
||||||
|
|
||||||
if (rotation != NiQuaternion::IDENTITY) {
|
if (rotation != NiQuaternionConstant::IDENTITY) {
|
||||||
rotation = { rotation.w, rotation.z, rotation.y, rotation.x };
|
rotation = { rotation.w, rotation.z, rotation.y, rotation.x };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
|||||||
|
|
||||||
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3::ZERO, LWOOBJID_EMPTY, 16, NiQuaternion::IDENTITY);
|
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 16, NiQuaternionConstant::IDENTITY);
|
||||||
|
|
||||||
if (spawner != nullptr) {
|
if (spawner != nullptr) {
|
||||||
Game::zoneManager->RemoveSpawner(spawner->m_Info.spawnerID);
|
Game::zoneManager->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||||
@ -534,7 +534,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
|||||||
|
|
||||||
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3::ZERO, LWOOBJID_EMPTY, 16, NiQuaternion::IDENTITY);
|
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 16, NiQuaternionConstant::IDENTITY);
|
||||||
|
|
||||||
if (spawner != nullptr) {
|
if (spawner != nullptr) {
|
||||||
Game::zoneManager->RemoveSpawner(spawner->m_Info.spawnerID);
|
Game::zoneManager->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||||
|
@ -253,13 +253,13 @@ void QuickBuildComponent::OnUse(Entity* originator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QuickBuildComponent::SpawnActivator() {
|
void QuickBuildComponent::SpawnActivator() {
|
||||||
if (!m_SelfActivator || m_ActivatorPosition != NiPoint3::ZERO) {
|
if (!m_SelfActivator || m_ActivatorPosition != NiPoint3Constant::ZERO) {
|
||||||
if (!m_Activator) {
|
if (!m_Activator) {
|
||||||
EntityInfo info;
|
EntityInfo info;
|
||||||
|
|
||||||
info.lot = 6604;
|
info.lot = 6604;
|
||||||
info.spawnerID = m_Parent->GetObjectID();
|
info.spawnerID = m_Parent->GetObjectID();
|
||||||
info.pos = m_ActivatorPosition == NiPoint3::ZERO ? m_Parent->GetPosition() : m_ActivatorPosition;
|
info.pos = m_ActivatorPosition == NiPoint3Constant::ZERO ? m_Parent->GetPosition() : m_ActivatorPosition;
|
||||||
|
|
||||||
m_Activator = Game::entityManager->CreateEntity(info, nullptr, m_Parent);
|
m_Activator = Game::entityManager->CreateEntity(info, nullptr, m_Parent);
|
||||||
if (m_Activator) {
|
if (m_Activator) {
|
||||||
|
@ -242,7 +242,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* The position that the quickbuild activator is spawned at
|
* The position that the quickbuild activator is spawned at
|
||||||
*/
|
*/
|
||||||
NiPoint3 m_ActivatorPosition = NiPoint3::ZERO;
|
NiPoint3 m_ActivatorPosition = NiPoint3Constant::ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The entity that represents the quickbuild activator
|
* The entity that represents the quickbuild activator
|
||||||
|
@ -119,8 +119,8 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
|||||||
GeneralUtils::UTF16ToWTF8(m_PathName));
|
GeneralUtils::UTF16ToWTF8(m_PathName));
|
||||||
|
|
||||||
auto spawnPointEntities = Game::entityManager->GetEntitiesByLOT(4843);
|
auto spawnPointEntities = Game::entityManager->GetEntitiesByLOT(4843);
|
||||||
auto startPosition = NiPoint3::ZERO;
|
auto startPosition = NiPoint3Constant::ZERO;
|
||||||
auto startRotation = NiQuaternion::IDENTITY;
|
auto startRotation = NiQuaternionConstant::IDENTITY;
|
||||||
const std::string placementAsString = std::to_string(positionNumber);
|
const std::string placementAsString = std::to_string(positionNumber);
|
||||||
for (auto entity : spawnPointEntities) {
|
for (auto entity : spawnPointEntities) {
|
||||||
if (!entity) continue;
|
if (!entity) continue;
|
||||||
@ -818,7 +818,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
|||||||
|
|
||||||
// Some offset up to make they don't fall through the terrain on a
|
// Some offset up to make they don't fall through the terrain on a
|
||||||
// respawn, seems to fix itself to the track anyhow
|
// respawn, seems to fix itself to the track anyhow
|
||||||
player.respawnPosition = position + NiPoint3::UNIT_Y * 5;
|
player.respawnPosition = position + NiPoint3Constant::UNIT_Y * 5;
|
||||||
player.respawnRotation = vehicle->GetRotation();
|
player.respawnRotation = vehicle->GetRotation();
|
||||||
player.respawnIndex = respawnIndex;
|
player.respawnIndex = respawnIndex;
|
||||||
|
|
||||||
|
@ -87,12 +87,12 @@ private:
|
|||||||
/**
|
/**
|
||||||
* The current velocity of the entity
|
* The current velocity of the entity
|
||||||
*/
|
*/
|
||||||
NiPoint3 m_Velocity = NiPoint3::ZERO;
|
NiPoint3 m_Velocity = NiPoint3Constant::ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current angular velocity of the entity
|
* The current angular velocity of the entity
|
||||||
*/
|
*/
|
||||||
NiPoint3 m_AngularVelocity = NiPoint3::ZERO;
|
NiPoint3 m_AngularVelocity = NiPoint3Constant::ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the velocity has changed
|
* Whether or not the velocity has changed
|
||||||
|
@ -218,7 +218,7 @@ void TriggerComponent::HandleMoveObject(Entity* targetEntity, std::vector<std::s
|
|||||||
if (argArray.size() <= 2) return;
|
if (argArray.size() <= 2) return;
|
||||||
|
|
||||||
auto position = targetEntity->GetPosition();
|
auto position = targetEntity->GetPosition();
|
||||||
NiPoint3 offset = NiPoint3::ZERO;
|
NiPoint3 offset = NiPoint3Constant::ZERO;
|
||||||
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), offset);
|
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), offset);
|
||||||
|
|
||||||
position += offset;
|
position += offset;
|
||||||
@ -228,7 +228,7 @@ void TriggerComponent::HandleMoveObject(Entity* targetEntity, std::vector<std::s
|
|||||||
void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std::string> argArray){
|
void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std::string> argArray){
|
||||||
if (argArray.size() <= 2) return;
|
if (argArray.size() <= 2) return;
|
||||||
|
|
||||||
NiPoint3 vector = NiPoint3::ZERO;
|
NiPoint3 vector = NiPoint3Constant::ZERO;
|
||||||
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), vector);
|
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), vector);
|
||||||
|
|
||||||
NiQuaternion rotation = NiQuaternion::FromEulerAngles(vector);
|
NiQuaternion rotation = NiQuaternion::FromEulerAngles(vector);
|
||||||
@ -246,7 +246,7 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::s
|
|||||||
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
||||||
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::PUSH);
|
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::PUSH);
|
||||||
phantomPhysicsComponent->SetDirectionalMultiplier(1);
|
phantomPhysicsComponent->SetDirectionalMultiplier(1);
|
||||||
NiPoint3 direction = NiPoint3::ZERO;
|
NiPoint3 direction = NiPoint3Constant::ZERO;
|
||||||
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), direction);
|
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), direction);
|
||||||
phantomPhysicsComponent->SetDirection(direction);
|
phantomPhysicsComponent->SetDirection(direction);
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::v
|
|||||||
phantomPhysicsComponent->SetEffectType(effectType);
|
phantomPhysicsComponent->SetEffectType(effectType);
|
||||||
phantomPhysicsComponent->SetDirectionalMultiplier(std::stof(argArray.at(1)));
|
phantomPhysicsComponent->SetDirectionalMultiplier(std::stof(argArray.at(1)));
|
||||||
if (argArray.size() > 4) {
|
if (argArray.size() > 4) {
|
||||||
NiPoint3 direction = NiPoint3::ZERO;
|
NiPoint3 direction = NiPoint3Constant::ZERO;
|
||||||
GeneralUtils::TryParse(argArray.at(2), argArray.at(3), argArray.at(4), direction);
|
GeneralUtils::TryParse(argArray.at(2), argArray.at(3), argArray.at(4), direction);
|
||||||
phantomPhysicsComponent->SetDirection(direction);
|
phantomPhysicsComponent->SetDirection(direction);
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,13 @@ public:
|
|||||||
bUsedMouse = false;
|
bUsedMouse = false;
|
||||||
fCasterLatency = 0.0f;
|
fCasterLatency = 0.0f;
|
||||||
iCastType = 0;
|
iCastType = 0;
|
||||||
lastClickedPosit = NiPoint3::ZERO;
|
lastClickedPosit = NiPoint3Constant::ZERO;
|
||||||
optionalTargetID = LWOOBJID_EMPTY;
|
optionalTargetID = LWOOBJID_EMPTY;
|
||||||
originatorRot = NiQuaternion::IDENTITY;
|
originatorRot = NiQuaternionConstant::IDENTITY;
|
||||||
uiSkillHandle = 0;
|
uiSkillHandle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EchoStartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = NiQuaternion::IDENTITY, uint32_t _uiSkillHandle = 0) {
|
EchoStartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3Constant::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = NiQuaternionConstant::IDENTITY, uint32_t _uiSkillHandle = 0) {
|
||||||
bUsedMouse = _bUsedMouse;
|
bUsedMouse = _bUsedMouse;
|
||||||
fCasterLatency = _fCasterLatency;
|
fCasterLatency = _fCasterLatency;
|
||||||
iCastType = _iCastType;
|
iCastType = _iCastType;
|
||||||
@ -50,16 +50,16 @@ public:
|
|||||||
stream->Write(iCastType != 0);
|
stream->Write(iCastType != 0);
|
||||||
if (iCastType != 0) stream->Write(iCastType);
|
if (iCastType != 0) stream->Write(iCastType);
|
||||||
|
|
||||||
stream->Write(lastClickedPosit != NiPoint3::ZERO);
|
stream->Write(lastClickedPosit != NiPoint3Constant::ZERO);
|
||||||
if (lastClickedPosit != NiPoint3::ZERO) stream->Write(lastClickedPosit);
|
if (lastClickedPosit != NiPoint3Constant::ZERO) stream->Write(lastClickedPosit);
|
||||||
|
|
||||||
stream->Write(optionalOriginatorID);
|
stream->Write(optionalOriginatorID);
|
||||||
|
|
||||||
stream->Write(optionalTargetID != LWOOBJID_EMPTY);
|
stream->Write(optionalTargetID != LWOOBJID_EMPTY);
|
||||||
if (optionalTargetID != LWOOBJID_EMPTY) stream->Write(optionalTargetID);
|
if (optionalTargetID != LWOOBJID_EMPTY) stream->Write(optionalTargetID);
|
||||||
|
|
||||||
stream->Write(originatorRot != NiQuaternion::IDENTITY);
|
stream->Write(originatorRot != NiQuaternionConstant::IDENTITY);
|
||||||
if (originatorRot != NiQuaternion::IDENTITY) stream->Write(originatorRot);
|
if (originatorRot != NiQuaternionConstant::IDENTITY) stream->Write(originatorRot);
|
||||||
|
|
||||||
uint32_t sBitStreamLength = sBitStream.length();
|
uint32_t sBitStreamLength = sBitStream.length();
|
||||||
stream->Write(sBitStreamLength);
|
stream->Write(sBitStreamLength);
|
||||||
|
@ -385,8 +385,8 @@ void GameMessages::SendPlatformResync(Entity* entity, const SystemAddress& sysAd
|
|||||||
float fIdleTimeElapsed = 0.0f;
|
float fIdleTimeElapsed = 0.0f;
|
||||||
float fMoveTimeElapsed = 0.0f;
|
float fMoveTimeElapsed = 0.0f;
|
||||||
float fPercentBetweenPoints = 0.0f;
|
float fPercentBetweenPoints = 0.0f;
|
||||||
NiPoint3 ptUnexpectedLocation = NiPoint3::ZERO;
|
NiPoint3 ptUnexpectedLocation = NiPoint3Constant::ZERO;
|
||||||
NiQuaternion qUnexpectedRotation = NiQuaternion::IDENTITY;
|
NiQuaternion qUnexpectedRotation = NiQuaternionConstant::IDENTITY;
|
||||||
|
|
||||||
bitStream.Write(bReverse);
|
bitStream.Write(bReverse);
|
||||||
bitStream.Write(bStopAtDesiredWaypoint);
|
bitStream.Write(bStopAtDesiredWaypoint);
|
||||||
@ -403,8 +403,8 @@ void GameMessages::SendPlatformResync(Entity* entity, const SystemAddress& sysAd
|
|||||||
bitStream.Write(ptUnexpectedLocation.y);
|
bitStream.Write(ptUnexpectedLocation.y);
|
||||||
bitStream.Write(ptUnexpectedLocation.z);
|
bitStream.Write(ptUnexpectedLocation.z);
|
||||||
|
|
||||||
bitStream.Write(qUnexpectedRotation != NiQuaternion::IDENTITY);
|
bitStream.Write(qUnexpectedRotation != NiQuaternionConstant::IDENTITY);
|
||||||
if (qUnexpectedRotation != NiQuaternion::IDENTITY) {
|
if (qUnexpectedRotation != NiQuaternionConstant::IDENTITY) {
|
||||||
bitStream.Write(qUnexpectedRotation.x);
|
bitStream.Write(qUnexpectedRotation.x);
|
||||||
bitStream.Write(qUnexpectedRotation.y);
|
bitStream.Write(qUnexpectedRotation.y);
|
||||||
bitStream.Write(qUnexpectedRotation.z);
|
bitStream.Write(qUnexpectedRotation.z);
|
||||||
@ -770,7 +770,7 @@ void GameMessages::SendSetCurrency(Entity* entity, int64_t currency, int lootTyp
|
|||||||
bitStream.Write(lootType != LOOTTYPE_NONE);
|
bitStream.Write(lootType != LOOTTYPE_NONE);
|
||||||
if (lootType != LOOTTYPE_NONE) bitStream.Write(lootType);
|
if (lootType != LOOTTYPE_NONE) bitStream.Write(lootType);
|
||||||
|
|
||||||
bitStream.Write(NiPoint3::ZERO);
|
bitStream.Write(NiPoint3Constant::ZERO);
|
||||||
|
|
||||||
bitStream.Write(sourceLOT != LOT_NULL);
|
bitStream.Write(sourceLOT != LOT_NULL);
|
||||||
if (sourceLOT != LOT_NULL) bitStream.Write(sourceLOT);
|
if (sourceLOT != LOT_NULL) bitStream.Write(sourceLOT);
|
||||||
@ -1079,7 +1079,7 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID,
|
|||||||
entity->RegisterCoinDrop(currency);
|
entity->RegisterCoinDrop(currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spawnPos != NiPoint3::ZERO) {
|
if (spawnPos != NiPoint3Constant::ZERO) {
|
||||||
bUsePosition = true;
|
bUsePosition = true;
|
||||||
|
|
||||||
//Calculate where the loot will go:
|
//Calculate where the loot will go:
|
||||||
@ -1101,8 +1101,8 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID,
|
|||||||
|
|
||||||
bitStream.Write(bUsePosition);
|
bitStream.Write(bUsePosition);
|
||||||
|
|
||||||
bitStream.Write(finalPosition != NiPoint3::ZERO);
|
bitStream.Write(finalPosition != NiPoint3Constant::ZERO);
|
||||||
if (finalPosition != NiPoint3::ZERO) bitStream.Write(finalPosition);
|
if (finalPosition != NiPoint3Constant::ZERO) bitStream.Write(finalPosition);
|
||||||
|
|
||||||
bitStream.Write(currency);
|
bitStream.Write(currency);
|
||||||
bitStream.Write(item);
|
bitStream.Write(item);
|
||||||
@ -1110,8 +1110,8 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID,
|
|||||||
bitStream.Write(owner);
|
bitStream.Write(owner);
|
||||||
bitStream.Write(sourceID);
|
bitStream.Write(sourceID);
|
||||||
|
|
||||||
bitStream.Write(spawnPos != NiPoint3::ZERO);
|
bitStream.Write(spawnPos != NiPoint3Constant::ZERO);
|
||||||
if (spawnPos != NiPoint3::ZERO) bitStream.Write(spawnPos);
|
if (spawnPos != NiPoint3Constant::ZERO) bitStream.Write(spawnPos);
|
||||||
|
|
||||||
auto* team = TeamManager::Instance()->GetTeam(owner);
|
auto* team = TeamManager::Instance()->GetTeam(owner);
|
||||||
|
|
||||||
@ -1170,7 +1170,7 @@ void GameMessages::SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPo
|
|||||||
bitStream.Write(position.y);
|
bitStream.Write(position.y);
|
||||||
bitStream.Write(position.z);
|
bitStream.Write(position.z);
|
||||||
|
|
||||||
const bool bIsNotIdentity = rotation != NiQuaternion::IDENTITY;
|
const bool bIsNotIdentity = rotation != NiQuaternionConstant::IDENTITY;
|
||||||
bitStream.Write(bIsNotIdentity);
|
bitStream.Write(bIsNotIdentity);
|
||||||
|
|
||||||
if (bIsNotIdentity) {
|
if (bIsNotIdentity) {
|
||||||
@ -1646,8 +1646,8 @@ void GameMessages::SendNotifyClientShootingGalleryScore(LWOOBJID objectId, const
|
|||||||
|
|
||||||
void GameMessages::HandleUpdateShootingGalleryRotation(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
void GameMessages::HandleUpdateShootingGalleryRotation(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||||
float angle = 0.0f;
|
float angle = 0.0f;
|
||||||
NiPoint3 facing = NiPoint3::ZERO;
|
NiPoint3 facing = NiPoint3Constant::ZERO;
|
||||||
NiPoint3 muzzlePos = NiPoint3::ZERO;
|
NiPoint3 muzzlePos = NiPoint3Constant::ZERO;
|
||||||
inStream->Read(angle);
|
inStream->Read(angle);
|
||||||
inStream->Read(facing);
|
inStream->Read(facing);
|
||||||
inStream->Read(muzzlePos);
|
inStream->Read(muzzlePos);
|
||||||
@ -2103,8 +2103,8 @@ void GameMessages::SendPlaceModelResponse(LWOOBJID objectId, const SystemAddress
|
|||||||
bitStream.Write(objectId);
|
bitStream.Write(objectId);
|
||||||
bitStream.Write(eGameMessageType::PLACE_MODEL_RESPONSE);
|
bitStream.Write(eGameMessageType::PLACE_MODEL_RESPONSE);
|
||||||
|
|
||||||
bitStream.Write(position != NiPoint3::ZERO);
|
bitStream.Write(position != NiPoint3Constant::ZERO);
|
||||||
if (position != NiPoint3::ZERO) {
|
if (position != NiPoint3Constant::ZERO) {
|
||||||
bitStream.Write(position);
|
bitStream.Write(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2118,8 +2118,8 @@ void GameMessages::SendPlaceModelResponse(LWOOBJID objectId, const SystemAddress
|
|||||||
bitStream.Write(response);
|
bitStream.Write(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
bitStream.Write(rotation != NiQuaternion::IDENTITY);
|
bitStream.Write(rotation != NiQuaternionConstant::IDENTITY);
|
||||||
if (rotation != NiQuaternion::IDENTITY) {
|
if (rotation != NiQuaternionConstant::IDENTITY) {
|
||||||
bitStream.Write(response);
|
bitStream.Write(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2271,7 +2271,7 @@ void GameMessages::HandleSetBuildMode(RakNet::BitStream* inStream, Entity* entit
|
|||||||
bool modePaused{};
|
bool modePaused{};
|
||||||
int modeValue = 1;
|
int modeValue = 1;
|
||||||
LWOOBJID playerId{};
|
LWOOBJID playerId{};
|
||||||
NiPoint3 startPosition = NiPoint3::ZERO;
|
NiPoint3 startPosition = NiPoint3Constant::ZERO;
|
||||||
|
|
||||||
inStream->Read(start);
|
inStream->Read(start);
|
||||||
|
|
||||||
@ -2290,7 +2290,7 @@ void GameMessages::HandleSetBuildMode(RakNet::BitStream* inStream, Entity* entit
|
|||||||
|
|
||||||
auto* player = Game::entityManager->GetEntity(playerId);
|
auto* player = Game::entityManager->GetEntity(playerId);
|
||||||
|
|
||||||
if (startPosition == NiPoint3::ZERO) {
|
if (startPosition == NiPoint3Constant::ZERO) {
|
||||||
startPosition = player->GetPosition();
|
startPosition = player->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2384,13 +2384,13 @@ void GameMessages::HandlePlacePropertyModel(RakNet::BitStream* inStream, Entity*
|
|||||||
|
|
||||||
inStream->Read(model);
|
inStream->Read(model);
|
||||||
|
|
||||||
PropertyManagementComponent::Instance()->UpdateModelPosition(model, NiPoint3::ZERO, NiQuaternion::IDENTITY);
|
PropertyManagementComponent::Instance()->UpdateModelPosition(model, NiPoint3Constant::ZERO, NiQuaternionConstant::IDENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMessages::HandleUpdatePropertyModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
void GameMessages::HandleUpdatePropertyModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||||
LWOOBJID model;
|
LWOOBJID model;
|
||||||
NiPoint3 position;
|
NiPoint3 position;
|
||||||
NiQuaternion rotation = NiQuaternion::IDENTITY;
|
NiQuaternion rotation = NiQuaternionConstant::IDENTITY;
|
||||||
|
|
||||||
inStream->Read(model);
|
inStream->Read(model);
|
||||||
inStream->Read(position);
|
inStream->Read(position);
|
||||||
@ -2612,7 +2612,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
|
|||||||
IPropertyContents::Model model;
|
IPropertyContents::Model model;
|
||||||
model.id = newIDL;
|
model.id = newIDL;
|
||||||
model.ugcId = blueprintIDSmall;
|
model.ugcId = blueprintIDSmall;
|
||||||
model.position = NiPoint3::ZERO;
|
model.position = NiPoint3Constant::ZERO;
|
||||||
model.rotation = NiQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
|
model.rotation = NiQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
model.lot = 14;
|
model.lot = 14;
|
||||||
Database::Get()->InsertNewPropertyModel(propertyId, model, "Objects_14_name");
|
Database::Get()->InsertNewPropertyModel(propertyId, model, "Objects_14_name");
|
||||||
@ -3393,7 +3393,7 @@ void GameMessages::SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId
|
|||||||
bitStream.Write(petsDestPos);
|
bitStream.Write(petsDestPos);
|
||||||
bitStream.Write(telePos);
|
bitStream.Write(telePos);
|
||||||
|
|
||||||
const bool hasDefault = teleRot != NiQuaternion::IDENTITY;
|
const bool hasDefault = teleRot != NiQuaternionConstant::IDENTITY;
|
||||||
bitStream.Write(hasDefault);
|
bitStream.Write(hasDefault);
|
||||||
if (hasDefault) bitStream.Write(teleRot);
|
if (hasDefault) bitStream.Write(teleRot);
|
||||||
|
|
||||||
@ -4218,7 +4218,7 @@ void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* in
|
|||||||
LWOOBJID pickupObjID = LWOOBJID_EMPTY;
|
LWOOBJID pickupObjID = LWOOBJID_EMPTY;
|
||||||
LWOOBJID pickupSpawnerID = LWOOBJID_EMPTY;
|
LWOOBJID pickupSpawnerID = LWOOBJID_EMPTY;
|
||||||
int32_t pickupSpawnerIndex = -1;
|
int32_t pickupSpawnerIndex = -1;
|
||||||
NiPoint3 vehiclePosition = NiPoint3::ZERO;
|
NiPoint3 vehiclePosition = NiPoint3Constant::ZERO;
|
||||||
|
|
||||||
if (inStream->ReadBit()) inStream->Read(pickupObjID);
|
if (inStream->ReadBit()) inStream->Read(pickupObjID);
|
||||||
if (inStream->ReadBit()) inStream->Read(pickupSpawnerID);
|
if (inStream->ReadBit()) inStream->Read(pickupSpawnerID);
|
||||||
|
@ -55,14 +55,14 @@ namespace GameMessages {
|
|||||||
const SystemAddress& sysAddr,
|
const SystemAddress& sysAddr,
|
||||||
bool bFirstTime = true,
|
bool bFirstTime = true,
|
||||||
const LWOOBJID& buildAreaID = LWOOBJID_EMPTY,
|
const LWOOBJID& buildAreaID = LWOOBJID_EMPTY,
|
||||||
NiPoint3 buildStartPOS = NiPoint3::ZERO,
|
NiPoint3 buildStartPOS = NiPoint3Constant::ZERO,
|
||||||
int sourceBAG = 0,
|
int sourceBAG = 0,
|
||||||
const LWOOBJID& sourceID = LWOOBJID_EMPTY,
|
const LWOOBJID& sourceID = LWOOBJID_EMPTY,
|
||||||
LOT sourceLOT = 0,
|
LOT sourceLOT = 0,
|
||||||
int sourceTYPE = 8,
|
int sourceTYPE = 8,
|
||||||
const LWOOBJID& targetID = 0,
|
const LWOOBJID& targetID = 0,
|
||||||
LOT targetLOT = 0,
|
LOT targetLOT = 0,
|
||||||
NiPoint3 targetPOS = NiPoint3::ZERO,
|
NiPoint3 targetPOS = NiPoint3Constant::ZERO,
|
||||||
int targetTYPE = 0
|
int targetTYPE = 0
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ namespace GameMessages {
|
|||||||
void SendStop2DAmbientSound(Entity* entity, bool force, std::string audioGUID, bool result = false);
|
void SendStop2DAmbientSound(Entity* entity, bool force, std::string audioGUID, bool result = false);
|
||||||
void SendPlay2DAmbientSound(Entity* entity, std::string audioGUID, bool result = false);
|
void SendPlay2DAmbientSound(Entity* entity, std::string audioGUID, bool result = false);
|
||||||
void SendSetNetworkScriptVar(Entity* entity, const SystemAddress& sysAddr, std::string data);
|
void SendSetNetworkScriptVar(Entity* entity, const SystemAddress& sysAddr, std::string data);
|
||||||
void SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID, LOT item, int currency, NiPoint3 spawnPos = NiPoint3::ZERO, int count = 1);
|
void SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID, LOT item, int currency, NiPoint3 spawnPos = NiPoint3Constant::ZERO, int count = 1);
|
||||||
|
|
||||||
void SendSetPlayerControlScheme(Entity* entity, eControlScheme controlScheme);
|
void SendSetPlayerControlScheme(Entity* entity, eControlScheme controlScheme);
|
||||||
void SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPoint3& position, const NiQuaternion& rotation);
|
void SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPoint3& position, const NiQuaternion& rotation);
|
||||||
@ -239,7 +239,7 @@ namespace GameMessages {
|
|||||||
|
|
||||||
void SendLockNodeRotation(Entity* entity, std::string nodeName);
|
void SendLockNodeRotation(Entity* entity, std::string nodeName);
|
||||||
|
|
||||||
void SendSetBuildModeConfirmed(LWOOBJID objectId, const SystemAddress& sysAddr, bool start, bool warnVisitors, bool modePaused, int32_t modeValue, LWOOBJID playerId, NiPoint3 startPos = NiPoint3::ZERO);
|
void SendSetBuildModeConfirmed(LWOOBJID objectId, const SystemAddress& sysAddr, bool start, bool warnVisitors, bool modePaused, int32_t modeValue, LWOOBJID playerId, NiPoint3 startPos = NiPoint3Constant::ZERO);
|
||||||
|
|
||||||
void SendGetModelsOnProperty(LWOOBJID objectId, std::map<LWOOBJID, LWOOBJID> models, const SystemAddress& sysAddr);
|
void SendGetModelsOnProperty(LWOOBJID objectId, std::map<LWOOBJID, LWOOBJID> models, const SystemAddress& sysAddr);
|
||||||
|
|
||||||
|
@ -16,13 +16,13 @@ public:
|
|||||||
consumableItemID = LWOOBJID_EMPTY;
|
consumableItemID = LWOOBJID_EMPTY;
|
||||||
fCasterLatency = 0.0f;
|
fCasterLatency = 0.0f;
|
||||||
iCastType = 0;
|
iCastType = 0;
|
||||||
lastClickedPosit = NiPoint3::ZERO;
|
lastClickedPosit = NiPoint3Constant::ZERO;
|
||||||
optionalTargetID = LWOOBJID_EMPTY;
|
optionalTargetID = LWOOBJID_EMPTY;
|
||||||
originatorRot = NiQuaternion::IDENTITY;
|
originatorRot = NiQuaternionConstant::IDENTITY;
|
||||||
uiSkillHandle = 0;
|
uiSkillHandle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
StartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, LWOOBJID _consumableItemID = LWOOBJID_EMPTY, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = NiQuaternion::IDENTITY, uint32_t _uiSkillHandle = 0) {
|
StartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, LWOOBJID _consumableItemID = LWOOBJID_EMPTY, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3Constant::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = NiQuaternionConstant::IDENTITY, uint32_t _uiSkillHandle = 0) {
|
||||||
bUsedMouse = _bUsedMouse;
|
bUsedMouse = _bUsedMouse;
|
||||||
consumableItemID = _consumableItemID;
|
consumableItemID = _consumableItemID;
|
||||||
fCasterLatency = _fCasterLatency;
|
fCasterLatency = _fCasterLatency;
|
||||||
@ -57,16 +57,16 @@ public:
|
|||||||
stream->Write(iCastType != 0);
|
stream->Write(iCastType != 0);
|
||||||
if (iCastType != 0) stream->Write(iCastType);
|
if (iCastType != 0) stream->Write(iCastType);
|
||||||
|
|
||||||
stream->Write(lastClickedPosit != NiPoint3::ZERO);
|
stream->Write(lastClickedPosit != NiPoint3Constant::ZERO);
|
||||||
if (lastClickedPosit != NiPoint3::ZERO) stream->Write(lastClickedPosit);
|
if (lastClickedPosit != NiPoint3Constant::ZERO) stream->Write(lastClickedPosit);
|
||||||
|
|
||||||
stream->Write(optionalOriginatorID);
|
stream->Write(optionalOriginatorID);
|
||||||
|
|
||||||
stream->Write(optionalTargetID != LWOOBJID_EMPTY);
|
stream->Write(optionalTargetID != LWOOBJID_EMPTY);
|
||||||
if (optionalTargetID != LWOOBJID_EMPTY) stream->Write(optionalTargetID);
|
if (optionalTargetID != LWOOBJID_EMPTY) stream->Write(optionalTargetID);
|
||||||
|
|
||||||
stream->Write(originatorRot != NiQuaternion::IDENTITY);
|
stream->Write(originatorRot != NiQuaternionConstant::IDENTITY);
|
||||||
if (originatorRot != NiQuaternion::IDENTITY) stream->Write(originatorRot);
|
if (originatorRot != NiQuaternionConstant::IDENTITY) stream->Write(originatorRot);
|
||||||
|
|
||||||
uint32_t sBitStreamLength = sBitStream.length();
|
uint32_t sBitStreamLength = sBitStream.length();
|
||||||
stream->Write(sBitStreamLength);
|
stream->Write(sBitStreamLength);
|
||||||
|
@ -85,7 +85,7 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
|
|||||||
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SetColGroup", 10, 0, 0, "", UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SetColGroup", 10, 0, 0, "", UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
//First rotate for anim
|
//First rotate for anim
|
||||||
NiQuaternion rot = NiQuaternion::IDENTITY;
|
NiQuaternion rot = NiQuaternionConstant::IDENTITY;
|
||||||
|
|
||||||
controllable->SetStatic(false);
|
controllable->SetStatic(false);
|
||||||
|
|
||||||
@ -402,7 +402,7 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
|
|||||||
const auto withdrawn = self->GetBoolean(u"isWithdrawn");
|
const auto withdrawn = self->GetBoolean(u"isWithdrawn");
|
||||||
if (!withdrawn) return;
|
if (!withdrawn) return;
|
||||||
|
|
||||||
NiQuaternion rot = NiQuaternion::IDENTITY;
|
NiQuaternion rot = NiQuaternionConstant::IDENTITY;
|
||||||
|
|
||||||
//First rotate for anim
|
//First rotate for anim
|
||||||
controllable->SetStatic(false);
|
controllable->SetStatic(false);
|
||||||
@ -597,12 +597,12 @@ void BossSpiderQueenEnemyServer::OnUpdate(Entity* self) {
|
|||||||
|
|
||||||
if (!isWithdrawn) return;
|
if (!isWithdrawn) return;
|
||||||
|
|
||||||
if (controllable->GetRotation() == NiQuaternion::IDENTITY) {
|
if (controllable->GetRotation() == NiQuaternionConstant::IDENTITY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
controllable->SetStatic(false);
|
controllable->SetStatic(false);
|
||||||
controllable->SetRotation(NiQuaternion::IDENTITY);
|
controllable->SetRotation(NiQuaternionConstant::IDENTITY);
|
||||||
controllable->SetStatic(true);
|
controllable->SetStatic(true);
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(self);
|
Game::entityManager->SerializeEntity(self);
|
||||||
|
@ -13,7 +13,7 @@ void AgLaserSensorServer::OnStartup(Entity* self) {
|
|||||||
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
||||||
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
|
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
|
||||||
phantomPhysicsComponent->SetDirectionalMultiplier(repelForce);
|
phantomPhysicsComponent->SetDirectionalMultiplier(repelForce);
|
||||||
phantomPhysicsComponent->SetDirection(NiPoint3::UNIT_Y);
|
phantomPhysicsComponent->SetDirection(NiPoint3Constant::UNIT_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ void AmDrawBridge::OnTimerDone(Entity* self, std::string timerName) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
simplePhysicsComponent->SetAngularVelocity(NiPoint3::ZERO);
|
simplePhysicsComponent->SetAngularVelocity(NiPoint3Constant::ZERO);
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(bridge);
|
Game::entityManager->SerializeEntity(bridge);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ void MastTeleport::OnTimerDone(Entity* self, std::string timerName) {
|
|||||||
|
|
||||||
GameMessages::SendOrientToAngle(playerId, true, rads, player->GetSystemAddress());
|
GameMessages::SendOrientToAngle(playerId, true, rads, player->GetSystemAddress());
|
||||||
|
|
||||||
GameMessages::SendTeleport(playerId, position, NiQuaternion::IDENTITY, player->GetSystemAddress());
|
GameMessages::SendTeleport(playerId, position, NiQuaternionConstant::IDENTITY, player->GetSystemAddress());
|
||||||
|
|
||||||
GameMessages::SendSetStunned(playerId, eStateChangeType::POP, player->GetSystemAddress(),
|
GameMessages::SendSetStunned(playerId, eStateChangeType::POP, player->GetSystemAddress(),
|
||||||
LWOOBJID_EMPTY, true, true, true, true, true, true, true
|
LWOOBJID_EMPTY, true, true, true, true, true, true, true
|
||||||
|
@ -40,6 +40,6 @@ void PetFromDigServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eP
|
|||||||
return;
|
return;
|
||||||
// TODO: Remove custom group?
|
// TODO: Remove custom group?
|
||||||
// Command the pet to the player as it may otherwise go to its spawn point which is non existant
|
// Command the pet to the player as it may otherwise go to its spawn point which is non existant
|
||||||
// petComponent->Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 6, 202, true);
|
// petComponent->Command(NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 6, 202, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ void GfBanana::OnHit(Entity* self, Entity* attacker) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bananaEntity->SetPosition(bananaEntity->GetPosition() - NiPoint3::UNIT_Y * 8);
|
bananaEntity->SetPosition(bananaEntity->GetPosition() - NiPoint3Constant::UNIT_Y * 8);
|
||||||
|
|
||||||
auto* bananaDestroyable = bananaEntity->GetComponent<DestroyableComponent>();
|
auto* bananaDestroyable = bananaEntity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
|
@ -39,6 +39,6 @@ void CrabServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTami
|
|||||||
return;
|
return;
|
||||||
// TODO: Remove custom group?
|
// TODO: Remove custom group?
|
||||||
// Command the pet to the player as it may otherwise go to its spawn point which is non existant
|
// Command the pet to the player as it may otherwise go to its spawn point which is non existant
|
||||||
// petComponent->Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 6, 202, true);
|
// petComponent->Command(NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 6, 202, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1031,8 +1031,8 @@ void HandlePacket(Packet* packet) {
|
|||||||
|
|
||||||
Game::entityManager->ConstructEntity(player, UNASSIGNED_SYSTEM_ADDRESS, true);
|
Game::entityManager->ConstructEntity(player, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||||
|
|
||||||
if (respawnPoint != NiPoint3::ZERO) {
|
if (respawnPoint != NiPoint3Constant::ZERO) {
|
||||||
GameMessages::SendPlayerReachedRespawnCheckpoint(player, respawnPoint, NiQuaternion::IDENTITY);
|
GameMessages::SendPlayerReachedRespawnCheckpoint(player, respawnPoint, NiQuaternionConstant::IDENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::entityManager->ConstructAllEntities(packet->systemAddress);
|
Game::entityManager->ConstructAllEntities(packet->systemAddress);
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
#include "EntityInfo.h"
|
#include "EntityInfo.h"
|
||||||
|
|
||||||
struct SpawnerNode {
|
struct SpawnerNode {
|
||||||
NiPoint3 position = NiPoint3::ZERO;
|
NiPoint3 position = NiPoint3Constant::ZERO;
|
||||||
NiQuaternion rotation = NiQuaternion::IDENTITY;
|
NiQuaternion rotation = NiQuaternionConstant::IDENTITY;
|
||||||
uint32_t nodeID = 0;
|
uint32_t nodeID = 0;
|
||||||
uint32_t nodeMax = 1;
|
uint32_t nodeMax = 1;
|
||||||
std::vector<LWOOBJID> entities;
|
std::vector<LWOOBJID> entities;
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
*/
|
*/
|
||||||
TEST(dCommonTests, NiPoint3Test) {
|
TEST(dCommonTests, NiPoint3Test) {
|
||||||
// Check that Unitize works
|
// Check that Unitize works
|
||||||
ASSERT_EQ(NiPoint3(3, 0, 0).Unitize(), NiPoint3::UNIT_X);
|
ASSERT_EQ(NiPoint3(3, 0, 0).Unitize(), NiPoint3Constant::UNIT_X);
|
||||||
// Check what unitize does to a vector of length 0
|
// Check what unitize does to a vector of length 0
|
||||||
ASSERT_EQ(NiPoint3::ZERO.Unitize(), NiPoint3::ZERO);
|
ASSERT_EQ(NiPoint3Constant::ZERO.Unitize(), NiPoint3Constant::ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(dCommonTests, NiPoint3OperatorTest) {
|
TEST(dCommonTests, NiPoint3OperatorTest) {
|
||||||
|
@ -25,8 +25,8 @@ public:
|
|||||||
class GameDependenciesTest : public ::testing::Test {
|
class GameDependenciesTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUpDependencies() {
|
void SetUpDependencies() {
|
||||||
info.pos = NiPoint3::ZERO;
|
info.pos = NiPoint3Constant::ZERO;
|
||||||
info.rot = NiQuaternion::IDENTITY;
|
info.rot = NiQuaternionConstant::IDENTITY;
|
||||||
info.scale = 1.0f;
|
info.scale = 1.0f;
|
||||||
info.spawner = nullptr;
|
info.spawner = nullptr;
|
||||||
info.lot = 999;
|
info.lot = 999;
|
||||||
|
Loading…
Reference in New Issue
Block a user