2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Base/Vector3.hpp"
|
|
|
|
#include "Base/Vector4.hpp"
|
|
|
|
#include "Base/Quaternion.hpp"
|
2016-08-24 21:29:00 +02:00
|
|
|
#include "Base/DynArg.hpp"
|
2021-01-30 07:51:39 +01:00
|
|
|
#include "Core/Buffer.hpp"
|
|
|
|
#include "Core/Utility.hpp"
|
2022-09-18 14:02:39 +02:00
|
|
|
#include "Library/JSON.hpp"
|
2016-06-05 03:15:23 +02:00
|
|
|
#include "Library/Numeric/Random.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-04 02:21:43 +02:00
|
|
|
#define STOVAL(v) static_cast< Vector3::Value >(v)
|
|
|
|
|
2016-11-15 20:21:19 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_DECL_TYPENAME(Typename, _SC("Vector3"))
|
2016-11-15 20:21:19 +01:00
|
|
|
|
2016-08-04 02:21:43 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const Vector3 Vector3::NIL(STOVAL(0.0));
|
|
|
|
const Vector3 Vector3::MIN(std::numeric_limits< Vector3::Value >::min());
|
|
|
|
const Vector3 Vector3::MAX(std::numeric_limits< Vector3::Value >::max());
|
|
|
|
const Vector3 Vector3::LEFT(STOVAL(-1.0), STOVAL(0.0), STOVAL(0.0));
|
|
|
|
const Vector3 Vector3::RIGHT(STOVAL(1.0), STOVAL(0.0), STOVAL(0.0));
|
|
|
|
const Vector3 Vector3::UP(STOVAL(0.0), STOVAL(1.0), STOVAL(0.0));
|
|
|
|
const Vector3 Vector3::DOWN(STOVAL(0.0), STOVAL(-1.0), STOVAL(0.0));
|
|
|
|
const Vector3 Vector3::FORWARD(STOVAL(0.0), STOVAL(0.0), STOVAL(1.0));
|
|
|
|
const Vector3 Vector3::BACK(STOVAL(0.0), STOVAL(0.0), STOVAL(-1.0));
|
|
|
|
const Vector3 Vector3::ONE(STOVAL(1.0), STOVAL(1.0), STOVAL(1.0));
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQChar Vector3::Delim = ',';
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2020-03-22 08:16:40 +01:00
|
|
|
Vector3::Vector3(Value sv) noexcept
|
2016-02-20 23:25:00 +01:00
|
|
|
: x(sv), y(sv), z(sv)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2020-03-22 08:16:40 +01:00
|
|
|
Vector3::Vector3(Value xv, Value yv, Value zv) noexcept
|
2016-02-20 23:25:00 +01:00
|
|
|
: x(xv), y(yv), z(zv)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator = (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x = s;
|
|
|
|
y = s;
|
|
|
|
z = s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator = (const Vector4 & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x = v.x;
|
|
|
|
y = v.y;
|
|
|
|
z = v.z;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator = (const Quaternion & q)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x = q.x;
|
|
|
|
y = q.y;
|
|
|
|
z = q.z;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator += (const Vector3 & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x += v.x;
|
|
|
|
y += v.y;
|
|
|
|
z += v.z;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator -= (const Vector3 & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x -= v.x;
|
|
|
|
y -= v.y;
|
|
|
|
z -= v.z;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator *= (const Vector3 & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x *= v.x;
|
|
|
|
y *= v.y;
|
|
|
|
z *= v.z;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator /= (const Vector3 & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x /= v.x;
|
|
|
|
y /= v.y;
|
|
|
|
z /= v.z;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator %= (const Vector3 & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
x = fmodf(x, v.x);
|
|
|
|
y = fmodf(y, v.y);
|
|
|
|
z = fmodf(z, v.z);
|
2015-09-30 02:56:11 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator += (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x += s;
|
|
|
|
y += s;
|
|
|
|
z += s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator -= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x -= s;
|
|
|
|
y -= s;
|
|
|
|
z -= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator *= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x *= s;
|
|
|
|
y *= s;
|
|
|
|
z *= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator /= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x /= s;
|
|
|
|
y /= s;
|
|
|
|
z /= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator %= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
x = fmodf(x, s);
|
|
|
|
y = fmodf(y, s);
|
|
|
|
z = fmodf(z, s);
|
2015-09-30 02:56:11 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator ++ ()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
++x;
|
|
|
|
++y;
|
|
|
|
++z;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & Vector3::operator -- ()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
--x;
|
|
|
|
--y;
|
|
|
|
--z;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2020-03-22 08:16:40 +01:00
|
|
|
Vector3 Vector3::operator ++ (int) // NOLINT(cert-dcl21-cpp)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
Vector3 state(*this);
|
|
|
|
++x;
|
|
|
|
++y;
|
|
|
|
++z;
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2020-03-22 08:16:40 +01:00
|
|
|
Vector3 Vector3::operator -- (int) // NOLINT(cert-dcl21-cpp)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
Vector3 state(*this);
|
|
|
|
--x;
|
|
|
|
--y;
|
|
|
|
--z;
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator + (const Vector3 & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {x + v.x, y + v.y, z + v.z};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator - (const Vector3 & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {x - v.x, y - v.y, z - v.z};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator * (const Vector3 & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {x * v.x, y * v.y, z * v.z};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator / (const Vector3 & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {x / v.x, y / v.y, z / v.z};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator % (const Vector3 & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return {fmodf(x, v.x), fmodf(y, v.y), fmodf(z, v.z)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator + (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {x + s, y + s, z + s};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator - (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {x - s, y - s, z - s};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator * (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {x * s, y * s, z * s};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator / (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {x / s, y / s, z / s};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator % (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return {fmodf(x, s), fmodf(y, s), fmodf(z, s)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator + () const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return {fabsf(x), fabsf(y), fabsf(z)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::operator - () const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {-x, -y, -z};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector3::operator == (const Vector3 & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return EpsEq(x, v.x) && EpsEq(y, v.y) && EpsEq(z, v.z);
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector3::operator != (const Vector3 & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-07-29 17:00:10 +02:00
|
|
|
return !EpsEq(x, v.x) || !EpsEq(y, v.y) || !EpsEq(z, v.z);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector3::operator < (const Vector3 & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return EpsLt(x, v.x) && EpsLt(y, v.y) && EpsLt(z, v.z);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector3::operator > (const Vector3 & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return EpsGt(x, v.x) && EpsGt(y, v.y) && EpsGt(z, v.z);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector3::operator <= (const Vector3 & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return EpsLtEq(x, v.x) && EpsLtEq(y, v.y) && EpsLtEq(z, v.z);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector3::operator >= (const Vector3 & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return EpsGtEq(x, v.x) && EpsGtEq(y, v.y) && EpsGtEq(z, v.z);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t Vector3::Cmp(const Vector3 & o) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
if (*this == o)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return 0;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
else if (*this > o)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return 1;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
else
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return -1;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
String Vector3::ToString() const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return fmt::format("{},{},{}", x, y, z);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2022-09-18 14:02:39 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::ToJSON(CtxJSON & ctx) const
|
|
|
|
{
|
|
|
|
if (ctx.mObjectOverArray)
|
|
|
|
{
|
|
|
|
fmt::format_to(std::back_inserter(ctx.mOutput), "{{x:{},y:{},z:{}}},", x, y, z);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fmt::format_to(std::back_inserter(ctx.mOutput), "[{},{},{}],", x, y, z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-07-24 23:10:46 +02:00
|
|
|
void Vector3::SetScalar(Value ns)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x = ns;
|
|
|
|
y = ns;
|
|
|
|
z = ns;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::SetVector3(const Vector3 & v)
|
|
|
|
{
|
|
|
|
x = v.x;
|
|
|
|
y = v.y;
|
|
|
|
z = v.z;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::SetVector3Ex(Value nx, Value ny, Value nz)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x = nx;
|
|
|
|
y = ny;
|
|
|
|
z = nz;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-07-24 23:10:46 +02:00
|
|
|
void Vector3::SetVector4(const Vector4 & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x = v.x;
|
|
|
|
y = v.y;
|
|
|
|
z = v.z;
|
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::SetVector4Ex(Value nx, Value ny, Value nz, Value /*nw*/)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-07-24 23:10:46 +02:00
|
|
|
x = nx;
|
|
|
|
y = ny;
|
|
|
|
z = nz;
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::SetQuaternion(const Quaternion & q)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-08-04 02:30:19 +02:00
|
|
|
SetQuaternionEx(q.x, q.y, q.z, q.w);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-04 02:30:19 +02:00
|
|
|
void Vector3::SetQuaternionEx(Value qx, Value qy, Value qz, Value qw)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-08-04 02:30:19 +02:00
|
|
|
// Quick conversion to Euler angles to give tilt to user
|
|
|
|
const Value sqx = (qx * qx), sqy = (qy * qy), sqz = (qz * qz), sqw = (qw * qw);
|
|
|
|
|
2021-01-30 07:51:39 +01:00
|
|
|
y = asinf(STOVAL(2.0) * ((qw * qy) - (qx * qz)));
|
2016-08-04 02:30:19 +02:00
|
|
|
|
|
|
|
if (EpsGt((SQMOD_PI * STOVAL(0.5)) - std::abs(y), STOVAL(1e-10)))
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
z = atan2f(STOVAL(2.0) * ((qx * qy) + (qw * qz)), sqx - sqy - sqz + sqw);
|
|
|
|
x = atan2f(STOVAL(2.0) * ((qw * qx) + (qy * qz)), sqw - sqx - sqy + sqz);
|
2016-08-04 02:30:19 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Compute heading from local 'down' vector
|
2021-01-30 07:51:39 +01:00
|
|
|
z = atan2f((STOVAL(2.0) * qy * qz) - (STOVAL(2.0) * qx * qw),
|
2016-08-04 02:30:19 +02:00
|
|
|
(STOVAL(2.0) * qx * qz) + (STOVAL(2.0) * qy * qw));
|
|
|
|
x = STOVAL(0.0);
|
2016-08-24 21:29:00 +02:00
|
|
|
|
2016-08-04 02:30:19 +02:00
|
|
|
// If facing down, reverse yaw
|
|
|
|
if (EpsLt(y, STOVAL(0.0)))
|
|
|
|
{
|
|
|
|
z -= SQMOD_PI;
|
|
|
|
}
|
|
|
|
}
|
2016-07-24 23:10:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
void Vector3::SetStr(SQChar delim, StackStrF & values)
|
2016-07-24 23:10:46 +02:00
|
|
|
{
|
2016-11-16 15:20:11 +01:00
|
|
|
SetVector3(Vector3::GetEx(delim, values));
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-03-20 16:56:38 +01:00
|
|
|
Vector3 & Vector3::Generate()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
x = GetRandomFloat32();
|
|
|
|
y = GetRandomFloat32();
|
|
|
|
z = GetRandomFloat32();
|
2021-03-20 16:56:38 +01:00
|
|
|
// Allow chaining
|
|
|
|
return *this;
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-03-20 16:56:38 +01:00
|
|
|
Vector3 & Vector3::GenerateB(Value min, Value max)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
if (EpsLt(max, min))
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("max value is lower than min value");
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
x = GetRandomFloat32(min, max);
|
|
|
|
y = GetRandomFloat32(min, max);
|
|
|
|
z = GetRandomFloat32(min, max);
|
2021-03-20 16:56:38 +01:00
|
|
|
// Allow chaining
|
|
|
|
return *this;
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 23:10:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-03-20 16:56:38 +01:00
|
|
|
Vector3 & Vector3::GenerateR(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin))
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("max value is lower than min value");
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
x = GetRandomFloat32(xmin, xmax);
|
|
|
|
y = GetRandomFloat32(ymin, ymax);
|
|
|
|
z = GetRandomFloat32(zmin, zmax);
|
2021-03-20 16:56:38 +01:00
|
|
|
// Allow chaining
|
|
|
|
return *this;
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Vector3::Abs() const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return {fabsf(x), fabsf(y), fabsf(z)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-08-04 02:34:16 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool Vector3::IsNaN() const
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return isnanf(x) || isnanf(y) || isnanf(z);
|
2016-08-04 02:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Vector3::Value Vector3::GetLength() const
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sqrtf((x * x) + (y * y) + (z * z));
|
2016-08-04 02:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::SetLength(Value length)
|
|
|
|
{
|
|
|
|
Normalize();
|
|
|
|
// Assign the specified length
|
|
|
|
*this *= length;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Vector3::Value Vector3::GetLengthSquared() const
|
|
|
|
{
|
|
|
|
return ((x * x) + (y * y) + (z * z));
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::SetLengthSquared(Value length)
|
|
|
|
{
|
|
|
|
Normalize();
|
|
|
|
// Assign the specified length
|
2021-01-30 07:51:39 +01:00
|
|
|
*this *= sqrtf(length);
|
2016-08-04 02:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Vector3 Vector3::Normalized() const
|
|
|
|
{
|
|
|
|
const Value len_squared = GetLengthSquared();
|
|
|
|
|
|
|
|
if (!EpsEq(len_squared, STOVAL(1.0)) && EpsLt(len_squared, STOVAL(0.0)))
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return (*this * (STOVAL(1.0) / sqrtf(len_squared)));
|
2016-08-04 02:34:16 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::Normalize()
|
|
|
|
{
|
|
|
|
const Value len_squared = GetLengthSquared();
|
|
|
|
|
|
|
|
if (!EpsEq(len_squared, STOVAL(1.0)) && EpsGt(len_squared, STOVAL(0.0)))
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
const Value inv_len = STOVAL(1.0) / sqrtf(len_squared);
|
2016-08-04 02:34:16 +02:00
|
|
|
x *= inv_len;
|
|
|
|
y *= inv_len;
|
|
|
|
z *= inv_len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-04 02:37:26 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Vector3::Value Vector3::DotProduct(const Vector3 & vec) const
|
|
|
|
{
|
|
|
|
return ((x * vec.x) + (y * vec.y) + (z * vec.z));
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Vector3::Value Vector3::AbsDotProduct(const Vector3 & vec) const
|
|
|
|
{
|
|
|
|
return (std::abs(x * vec.x) + std::abs(y * vec.y) + std::abs(z * vec.z));
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Vector3 Vector3::CrossProduct(const Vector3 & vec) const
|
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {(y * vec.z) - (z * vec.y), (z * vec.x) - (x * vec.z), (x * vec.y) - (y * vec.x)};
|
2016-08-04 02:37:26 +02:00
|
|
|
}
|
|
|
|
|
2016-08-04 02:38:54 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Vector3::Value Vector3::Angle(const Vector3 & vec) const
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return acosf(DotProduct(vec) / (GetLength() * vec.GetLength()));
|
2016-08-04 02:38:54 +02:00
|
|
|
}
|
|
|
|
|
2016-08-04 02:35:27 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Vector3::Value Vector3::GetDistanceTo(const Vector3 & vec) const
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sqrtf(powf(x - vec.x, 2) + powf(y - vec.y, 2) + powf(z - vec.z, 2));
|
2016-08-04 02:35:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Vector3::Value Vector3::GetSquaredDistanceTo(const Vector3 & vec) const
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return (powf(x - vec.x, 2) + powf(y - vec.y, 2) + powf(z - vec.z, 2));
|
2016-08-04 02:35:27 +02:00
|
|
|
}
|
|
|
|
|
2016-08-04 02:38:54 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool Vector3::IsBetweenPoints(const Vector3 & begin, const Vector3 & end) const
|
|
|
|
{
|
|
|
|
const Value length = (end - begin).GetLengthSquared();
|
|
|
|
return EpsLtEq(GetSquaredDistanceTo(begin), length) && EpsLtEq(GetSquaredDistanceTo(end), length);
|
|
|
|
}
|
|
|
|
|
2016-08-04 02:40:01 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::Interpolate(const Vector3 & a, const Vector3 & b, Value d)
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
x = STOVAL(static_cast< double >(b.x) + ((a.x - b.x) * d));
|
|
|
|
y = STOVAL(static_cast< double >(b.y) + ((a.y - b.y) * d));
|
|
|
|
z = STOVAL(static_cast< double >(b.z) + ((a.z - b.z) * d));
|
2016-08-04 02:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Vector3 Vector3::Interpolated(const Vector3 & vec, Value d) const
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
const double inv = 1.0 - d;
|
2020-03-22 08:16:40 +01:00
|
|
|
return {
|
2016-08-04 02:40:01 +02:00
|
|
|
STOVAL((vec.x * inv) + (x * d)),
|
|
|
|
STOVAL((vec.y * inv) + (y * d)),
|
|
|
|
STOVAL((vec.z * inv) + (z * d))
|
2020-03-22 08:16:40 +01:00
|
|
|
};
|
2016-08-04 02:40:01 +02:00
|
|
|
}
|
|
|
|
|
2016-08-04 02:41:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Vector3 Vector3::Rotated(const Vector3 & axis, Value angle) const
|
|
|
|
{
|
|
|
|
const Vector3 o(axis * axis.DotProduct(*this));
|
2021-01-30 07:51:39 +01:00
|
|
|
return (o + ((*this - o) * cosf(angle)) + (axis.CrossProduct(*this) * sinf(angle)));
|
2016-08-04 02:41:46 +02:00
|
|
|
}
|
|
|
|
|
2016-08-04 02:42:48 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::CenterRotateXZBy(Value degrees, const Vector3 & center)
|
|
|
|
{
|
|
|
|
degrees *= SQMOD_DEGTORAD;
|
2021-01-30 07:51:39 +01:00
|
|
|
const Value cs = cosf(degrees);
|
|
|
|
const Value sn = sinf(degrees);
|
2016-08-04 02:42:48 +02:00
|
|
|
x -= center.x;
|
|
|
|
z -= center.z;
|
|
|
|
x = static_cast< Value >((x * cs) - (z * sn)) + center.x;
|
|
|
|
z = static_cast< Value >((x * sn) + (z * cs)) + center.z;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::CenterRotateXYBy(Value degrees, const Vector3 & center)
|
|
|
|
{
|
|
|
|
degrees *= SQMOD_DEGTORAD;
|
2021-01-30 07:51:39 +01:00
|
|
|
const Value cs = cosf(degrees);
|
|
|
|
const Value sn = sinf(degrees);
|
2016-08-04 02:42:48 +02:00
|
|
|
x -= center.x;
|
|
|
|
y -= center.y;
|
|
|
|
x = static_cast< Value >((x * cs) - (y * sn)) + center.x;
|
|
|
|
y = static_cast< Value >((x * sn) + (y * cs)) + center.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Vector3::CenterRotateYZBy(Value degrees, const Vector3 & center)
|
|
|
|
{
|
|
|
|
degrees *= SQMOD_DEGTORAD;
|
2021-01-30 07:51:39 +01:00
|
|
|
const Value cs = cosf(degrees);
|
|
|
|
const Value sn = sinf(degrees);
|
2016-08-04 02:42:48 +02:00
|
|
|
z -= center.z;
|
|
|
|
y -= center.y;
|
|
|
|
y = static_cast< Value >((y * cs) - (z * sn)) + center.z;
|
|
|
|
z = static_cast< Value >((y * sn) + (z * cs)) + center.y;
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:33:51 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
String Vector3::Format(StackStrF & str) const
|
2020-09-03 19:33:51 +02:00
|
|
|
{
|
2021-07-03 13:09:58 +02:00
|
|
|
return fmt::format(fmt::runtime(str.ToStr())
|
2021-01-30 07:51:39 +01:00
|
|
|
, fmt::arg("x", x)
|
|
|
|
, fmt::arg("y", y)
|
|
|
|
, fmt::arg("z", z)
|
|
|
|
);
|
2020-09-03 19:33:51 +02:00
|
|
|
}
|
|
|
|
|
2016-03-21 21:37:58 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
const Vector3 & Vector3::Get(StackStrF & str)
|
2016-03-21 21:37:58 +01:00
|
|
|
{
|
2016-11-16 15:20:11 +01:00
|
|
|
return Vector3::GetEx(Vector3::Delim, str);
|
2016-03-21 21:37:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
const Vector3 & Vector3::GetEx(SQChar delim, StackStrF & str)
|
2016-03-21 21:37:58 +01:00
|
|
|
{
|
|
|
|
static Vector3 vec;
|
|
|
|
// Clear previous values, if any
|
|
|
|
vec.Clear();
|
|
|
|
// Is the specified string empty?
|
2016-11-16 15:20:11 +01:00
|
|
|
if (str.mLen <= 0)
|
2016-03-21 21:37:58 +01:00
|
|
|
{
|
|
|
|
return vec; // Return the value as is!
|
|
|
|
}
|
2020-09-03 17:26:24 +02:00
|
|
|
// The format specifications that will be used to scan the string
|
|
|
|
SQChar fs[] = _SC(" %f , %f , %f ");
|
2016-03-21 21:37:58 +01:00
|
|
|
// Assign the specified delimiter
|
|
|
|
fs[4] = delim;
|
|
|
|
fs[9] = delim;
|
|
|
|
// Attempt to extract the component values from the specified string
|
2016-11-16 15:20:11 +01:00
|
|
|
std::sscanf(str.mPtr, &fs[0], &vec.x, &vec.y, &vec.z);
|
2016-03-21 21:37:58 +01:00
|
|
|
// Return the resulted value
|
|
|
|
return vec;
|
|
|
|
}
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ================================================================================================
|
2016-02-20 23:25:00 +01:00
|
|
|
void Register_Vector3(HSQUIRRELVM vm)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
typedef Vector3::Value Val;
|
|
|
|
|
2016-11-15 20:55:03 +01:00
|
|
|
RootTable(vm).Bind(Typename::Str,
|
|
|
|
Class< Vector3 >(vm, Typename::Str)
|
2016-05-22 05:20:38 +02:00
|
|
|
// Constructors
|
2015-09-30 02:56:11 +02:00
|
|
|
.Ctor()
|
2016-02-20 23:25:00 +01:00
|
|
|
.Ctor< Val >()
|
|
|
|
.Ctor< Val, Val, Val >()
|
2016-08-04 02:21:43 +02:00
|
|
|
// Static variables
|
|
|
|
.SetStaticValue(_SC("NIL"), &Vector3::NIL)
|
|
|
|
.SetStaticValue(_SC("MIN"), &Vector3::MIN)
|
|
|
|
.SetStaticValue(_SC("MAX"), &Vector3::MAX)
|
|
|
|
.SetStaticValue(_SC("LEFT"), &Vector3::LEFT)
|
|
|
|
.SetStaticValue(_SC("RIGHT"), &Vector3::RIGHT)
|
|
|
|
.SetStaticValue(_SC("UP"), &Vector3::UP)
|
|
|
|
.SetStaticValue(_SC("DOWN"), &Vector3::DOWN)
|
|
|
|
.SetStaticValue(_SC("FORWARD"), &Vector3::FORWARD)
|
|
|
|
.SetStaticValue(_SC("BACK"), &Vector3::BACK)
|
|
|
|
.SetStaticValue(_SC("ONE"), &Vector3::ONE)
|
2016-05-22 05:20:38 +02:00
|
|
|
// Member Variables
|
2016-07-17 14:39:59 +02:00
|
|
|
.Var(_SC("x"), &Vector3::x)
|
|
|
|
.Var(_SC("y"), &Vector3::y)
|
|
|
|
.Var(_SC("z"), &Vector3::z)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Var(_SC("X"), &Vector3::x)
|
|
|
|
.Var(_SC("Y"), &Vector3::y)
|
|
|
|
.Var(_SC("Z"), &Vector3::z)
|
2016-06-03 20:26:19 +02:00
|
|
|
// Core Meta-methods
|
2016-08-24 21:29:00 +02:00
|
|
|
.SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< Vector3 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector3 >)
|
2016-11-15 20:21:19 +01:00
|
|
|
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
|
|
|
.Func(_SC("_tostring"), &Vector3::ToString)
|
2022-09-18 14:02:39 +02:00
|
|
|
.Func(_SC("_tojson"), &Vector3::ToJSON)
|
2016-06-03 20:26:19 +02:00
|
|
|
// Meta-methods
|
2016-08-24 21:29:00 +02:00
|
|
|
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< Vector3 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector3 >)
|
|
|
|
.SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< Vector3 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector3 >)
|
|
|
|
.SquirrelFunc(_SC("_mul"), &SqDynArgFwd< SqDynArgMulFn< Vector3 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector3 >)
|
|
|
|
.SquirrelFunc(_SC("_div"), &SqDynArgFwd< SqDynArgDivFn< Vector3 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector3 >)
|
|
|
|
.SquirrelFunc(_SC("_modulo"), &SqDynArgFwd< SqDynArgModFn< Vector3 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector3 >)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Func< Vector3 (Vector3::*)(void) const >(_SC("_unm"), &Vector3::operator -)
|
2016-07-24 23:10:46 +02:00
|
|
|
// Properties
|
|
|
|
.Prop(_SC("Abs"), &Vector3::Abs)
|
2016-08-04 02:34:16 +02:00
|
|
|
.Prop(_SC("NaN"), &Vector3::IsNaN)
|
|
|
|
.Prop(_SC("Length"), &Vector3::GetLength, &Vector3::SetLength)
|
|
|
|
.Prop(_SC("LengthSq"), &Vector3::GetLengthSquared, &Vector3::SetLengthSquared)
|
|
|
|
.Prop(_SC("Normalized"), &Vector3::Normalized)
|
2016-07-24 23:10:46 +02:00
|
|
|
// Member Methods
|
|
|
|
.Func(_SC("SetScalar"), &Vector3::SetScalar)
|
|
|
|
.Func(_SC("SetVector3"), &Vector3::SetVector3)
|
|
|
|
.Func(_SC("SetVector3Ex"), &Vector3::SetVector3Ex)
|
|
|
|
.Func(_SC("SetVector4"), &Vector3::SetVector4)
|
|
|
|
.Func(_SC("SetVector4Ex"), &Vector3::SetVector4Ex)
|
|
|
|
.Func(_SC("SetQuaternion"), &Vector3::SetQuaternion)
|
|
|
|
.Func(_SC("SetQuaternionEx"), &Vector3::SetQuaternionEx)
|
2016-11-16 15:20:11 +01:00
|
|
|
.FmtFunc(_SC("SetStr"), &Vector3::SetStr)
|
2016-07-24 23:10:46 +02:00
|
|
|
.Func(_SC("Clear"), &Vector3::Clear)
|
2020-09-03 19:33:51 +02:00
|
|
|
.FmtFunc(_SC("Format"), &Vector3::Format)
|
2016-08-04 02:34:16 +02:00
|
|
|
.Func(_SC("Normalize"), &Vector3::Normalize)
|
2016-08-04 02:37:26 +02:00
|
|
|
.Func(_SC("Dot"), &Vector3::DotProduct)
|
|
|
|
.Func(_SC("AbsDot"), &Vector3::AbsDotProduct)
|
|
|
|
.Func(_SC("Cross"), &Vector3::CrossProduct)
|
2016-08-04 02:38:54 +02:00
|
|
|
.Func(_SC("Angle"), &Vector3::Angle)
|
2016-08-04 02:35:27 +02:00
|
|
|
.Func(_SC("DistanceTo"), &Vector3::GetDistanceTo)
|
|
|
|
.Func(_SC("SqDistanceTo"), &Vector3::GetSquaredDistanceTo)
|
2016-08-04 02:38:54 +02:00
|
|
|
.Func(_SC("IsBetweenPoints"), &Vector3::IsBetweenPoints)
|
2016-08-04 02:40:01 +02:00
|
|
|
.Func(_SC("Interpolate"), &Vector3::Interpolate)
|
|
|
|
.Func(_SC("Interpolated"), &Vector3::Interpolated)
|
2016-08-04 02:41:46 +02:00
|
|
|
.Func(_SC("Rotated"), &Vector3::Rotated)
|
2016-08-04 02:42:48 +02:00
|
|
|
.Func(_SC("RotateXZBy"), &Vector3::RotateXZBy)
|
|
|
|
.Func(_SC("CenterRotateXZBy"), &Vector3::CenterRotateXZBy)
|
|
|
|
.Func(_SC("RotateXYBy"), &Vector3::RotateXYBy)
|
|
|
|
.Func(_SC("CenterRotateXYBy"), &Vector3::CenterRotateXYBy)
|
|
|
|
.Func(_SC("RotateYZBy"), &Vector3::RotateYZBy)
|
|
|
|
.Func(_SC("CenterRotateYZBy"), &Vector3::CenterRotateYZBy)
|
2016-07-24 23:10:46 +02:00
|
|
|
// Member Overloads
|
2021-03-20 16:56:38 +01:00
|
|
|
.Overload(_SC("Generate"), &Vector3::Generate)
|
|
|
|
.Overload(_SC("Generate"), &Vector3::GenerateB)
|
|
|
|
.Overload(_SC("Generate"), &Vector3::GenerateR)
|
2016-07-24 20:29:37 +02:00
|
|
|
// Static Functions
|
|
|
|
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Vector3 >)
|
|
|
|
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Vector3 >)
|
2016-11-16 15:20:11 +01:00
|
|
|
.StaticFmtFunc(_SC("FromStr"), &Vector3::Get)
|
|
|
|
.StaticFmtFunc(_SC("FromStrEx"), &Vector3::GetEx)
|
2015-09-30 02:56:11 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|