2023-11-19 09:38:07 -05:00
|
|
|
#ifndef VECTOR_H
|
|
|
|
#define VECTOR_H
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2023-10-24 08:27:24 -04:00
|
|
|
#include <vec.h>
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-11-19 09:38:07 -05:00
|
|
|
/*
|
|
|
|
* A simple array of three floats that can be indexed into.
|
|
|
|
*/
|
|
|
|
class Vector3 {
|
|
|
|
public:
|
|
|
|
float elements[3]; // storage is public for easy access
|
|
|
|
|
|
|
|
Vector3() {}
|
|
|
|
Vector3(float x, float y, float z)
|
|
|
|
{
|
|
|
|
elements[0] = x;
|
|
|
|
elements[1] = y;
|
|
|
|
elements[2] = z;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector3(const float v[3])
|
|
|
|
{
|
|
|
|
elements[0] = v[0];
|
|
|
|
elements[1] = v[1];
|
|
|
|
elements[2] = v[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
const float& operator[](long i) const { return elements[i]; }
|
|
|
|
float& operator[](long i) { return elements[i]; }
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A simple array of four floats that can be indexed into.
|
|
|
|
*/
|
|
|
|
struct Vector4 {
|
|
|
|
public:
|
|
|
|
float elements[4]; // storage is public for easy access
|
|
|
|
|
|
|
|
inline Vector4() {}
|
|
|
|
Vector4(float x, float y, float z, float w)
|
|
|
|
{
|
|
|
|
elements[0] = x;
|
|
|
|
elements[1] = y;
|
|
|
|
elements[2] = z;
|
|
|
|
elements[3] = w;
|
|
|
|
}
|
|
|
|
Vector4(const float v[4])
|
|
|
|
{
|
|
|
|
elements[0] = v[0];
|
|
|
|
elements[1] = v[1];
|
|
|
|
elements[2] = v[2];
|
|
|
|
elements[3] = v[3];
|
|
|
|
}
|
|
|
|
|
|
|
|
const float& operator[](long i) const { return elements[i]; }
|
|
|
|
float& operator[](long i) { return elements[i]; }
|
|
|
|
};
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// VTABLE: LEGO1 0x100d4288
|
2023-08-03 14:25:29 -04:00
|
|
|
// SIZE 0x8
|
2023-11-19 09:38:07 -05:00
|
|
|
class Vector2Impl {
|
2023-08-03 14:25:29 -04:00
|
|
|
public:
|
2023-12-12 14:27:17 -05:00
|
|
|
// FUNCTION: LEGO1 0x1000c0f0
|
2023-11-19 09:38:07 -05:00
|
|
|
inline Vector2Impl(float* p_data) { this->SetData(p_data); }
|
2023-10-24 19:38:27 -04:00
|
|
|
|
|
|
|
// vtable + 0x00 (no virtual destructor)
|
|
|
|
virtual void AddScalarImpl(float p_value) = 0;
|
|
|
|
virtual void AddVectorImpl(float* p_value) = 0;
|
|
|
|
virtual void SubVectorImpl(float* p_value) = 0;
|
|
|
|
virtual void MullScalarImpl(float* p_value) = 0;
|
|
|
|
|
|
|
|
// vtable + 0x10
|
|
|
|
virtual void MullVectorImpl(float* p_value) = 0;
|
|
|
|
virtual void DivScalarImpl(float* p_value) = 0;
|
|
|
|
virtual float DotImpl(float* p_a, float* p_b) const = 0;
|
2023-12-12 14:27:17 -05:00
|
|
|
// FUNCTION: LEGO1 0x10002060
|
2023-10-24 19:38:27 -04:00
|
|
|
virtual void SetData(float* p_data) { this->m_data = p_data; }
|
|
|
|
|
|
|
|
// vtable + 0x20
|
|
|
|
virtual void EqualsImpl(float* p_data) = 0;
|
|
|
|
virtual float* GetData();
|
2023-11-19 09:38:07 -05:00
|
|
|
virtual const float* GetData() const;
|
2023-10-24 19:38:27 -04:00
|
|
|
virtual void Clear() = 0;
|
|
|
|
|
|
|
|
// vtable + 0x30
|
2023-11-19 09:38:07 -05:00
|
|
|
virtual float Dot(Vector2Impl* p_a, float* p_b) const;
|
|
|
|
virtual float Dot(float* p_a, Vector2Impl* p_b) const;
|
|
|
|
virtual float Dot(Vector2Impl* p_a, Vector2Impl* p_b) const;
|
2023-10-24 19:38:27 -04:00
|
|
|
virtual float Dot(float* p_a, float* p_b) const;
|
|
|
|
|
|
|
|
// vtable + 0x40
|
|
|
|
virtual float LenSquared() const = 0;
|
2023-11-19 09:38:07 -05:00
|
|
|
virtual int Unitize();
|
2023-10-24 19:38:27 -04:00
|
|
|
|
|
|
|
// vtable + 0x48
|
2023-12-14 11:50:29 -05:00
|
|
|
virtual void Add(Vector2Impl* p_other);
|
|
|
|
virtual void Add(float* p_other);
|
|
|
|
virtual void Add(float p_value);
|
2023-10-24 19:38:27 -04:00
|
|
|
|
|
|
|
// vtable + 0x54
|
2023-12-14 11:50:29 -05:00
|
|
|
virtual void Sub(Vector2Impl* p_other);
|
|
|
|
virtual void Sub(float* p_other);
|
2023-10-24 19:38:27 -04:00
|
|
|
|
|
|
|
// vtable + 0x5C
|
2023-12-14 11:50:29 -05:00
|
|
|
virtual void Mul(float* p_value);
|
|
|
|
virtual void Mul(Vector2Impl* p_other);
|
|
|
|
virtual void Mul(float& p_other);
|
|
|
|
virtual void Div(float& p_value);
|
2023-10-24 19:38:27 -04:00
|
|
|
|
|
|
|
// vtable + 0x6C
|
2023-11-19 09:38:07 -05:00
|
|
|
virtual void SetVector(Vector2Impl* p_other);
|
2023-10-24 19:38:27 -04:00
|
|
|
virtual void SetVector(float* p_other);
|
|
|
|
|
|
|
|
inline float& operator[](size_t idx) { return m_data[idx]; }
|
|
|
|
inline const float& operator[](size_t idx) const { return m_data[idx]; }
|
|
|
|
|
2023-08-03 14:25:29 -04:00
|
|
|
protected:
|
2023-10-24 19:38:27 -04:00
|
|
|
float* m_data;
|
2023-08-03 14:25:29 -04:00
|
|
|
};
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// VTABLE: LEGO1 0x100d4518
|
2023-08-03 14:25:29 -04:00
|
|
|
// SIZE 0x8
|
2023-11-19 09:38:07 -05:00
|
|
|
class Vector3Impl : public Vector2Impl {
|
2023-08-03 14:25:29 -04:00
|
|
|
public:
|
2023-11-19 09:38:07 -05:00
|
|
|
inline Vector3Impl(float* p_data) : Vector2Impl(p_data) {}
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void AddScalarImpl(float p_value);
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void AddVectorImpl(float* p_value);
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void SubVectorImpl(float* p_value);
|
|
|
|
void MullScalarImpl(float* p_value);
|
|
|
|
void MullVectorImpl(float* p_value);
|
|
|
|
void DivScalarImpl(float* p_value);
|
|
|
|
float DotImpl(float* p_a, float* p_b) const;
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void EqualsImpl(float* p_data);
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void Clear();
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
float LenSquared() const;
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
// vtable + 0x74
|
|
|
|
virtual void EqualsCrossImpl(float* p_a, float* p_b);
|
2023-11-19 09:38:07 -05:00
|
|
|
virtual void EqualsCross(float* p_a, Vector3Impl* p_b);
|
|
|
|
virtual void EqualsCross(Vector3Impl* p_a, float* p_b);
|
|
|
|
virtual void EqualsCross(Vector3Impl* p_a, Vector3Impl* p_b);
|
2023-10-24 19:38:27 -04:00
|
|
|
virtual void EqualsScalar(float* p_value);
|
2023-10-07 14:00:20 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
inline void Fill(float p_value) { EqualsScalar(&p_value); }
|
2023-08-03 14:25:29 -04:00
|
|
|
};
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// VTABLE: LEGO1 0x100d45a0
|
2023-08-03 14:25:29 -04:00
|
|
|
// SIZE 0x8
|
2023-11-19 09:38:07 -05:00
|
|
|
class Vector4Impl : public Vector3Impl {
|
2023-08-03 14:25:29 -04:00
|
|
|
public:
|
2023-11-19 09:38:07 -05:00
|
|
|
inline Vector4Impl(float* p_data) : Vector3Impl(p_data) {}
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void AddScalarImpl(float p_value);
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void AddVectorImpl(float* p_value);
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void SubVectorImpl(float* p_value);
|
|
|
|
void MullScalarImpl(float* p_value);
|
|
|
|
void MullVectorImpl(float* p_value);
|
|
|
|
void DivScalarImpl(float* p_value);
|
|
|
|
float DotImpl(float* p_a, float* p_b) const;
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void EqualsImpl(float* p_data);
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void Clear();
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
float LenSquared() const;
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void EqualsScalar(float* p_value);
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2023-12-21 10:59:26 -05:00
|
|
|
// vtable + 0x88
|
2023-11-19 09:38:07 -05:00
|
|
|
virtual void SetMatrixProduct(Vector4Impl* p_a, float* p_b);
|
2023-10-24 19:38:27 -04:00
|
|
|
virtual void SetMatrixProductImpl(float* p_vec, float* p_mat);
|
2023-11-19 09:38:07 -05:00
|
|
|
virtual int NormalizeQuaternion();
|
|
|
|
virtual void UnknownQuaternionOp(Vector4Impl* p_a, Vector4Impl* p_b);
|
2023-12-21 10:59:26 -05:00
|
|
|
|
|
|
|
inline Vector4& GetVector() { return *((Vector4*) m_data); }
|
2023-08-03 14:25:29 -04:00
|
|
|
};
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// VTABLE: LEGO1 0x100d4488
|
2023-08-03 14:25:29 -04:00
|
|
|
// SIZE 0x14
|
2023-11-19 09:38:07 -05:00
|
|
|
class Vector3Data : public Vector3Impl {
|
2023-08-03 14:25:29 -04:00
|
|
|
public:
|
2023-11-19 09:38:07 -05:00
|
|
|
inline Vector3Data() : Vector3Impl(m_vector.elements) {}
|
|
|
|
inline Vector3Data(float p_x, float p_y, float p_z) : Vector3Impl(m_vector.elements), m_vector(p_x, p_y, p_z) {}
|
|
|
|
|
|
|
|
void CopyFrom(Vector3Data& p_other)
|
2023-10-24 19:38:27 -04:00
|
|
|
{
|
|
|
|
EqualsImpl(p_other.m_data);
|
|
|
|
|
2023-11-19 09:38:07 -05:00
|
|
|
float* dest = m_vector.elements;
|
|
|
|
float* src = p_other.m_vector.elements;
|
|
|
|
for (size_t i = sizeof(m_vector) / sizeof(float); i > 0; --i)
|
2023-10-24 19:38:27 -04:00
|
|
|
*dest++ = *src++;
|
|
|
|
}
|
2023-12-14 11:50:29 -05:00
|
|
|
inline void EqualsCross(Vector3Data& p_a, Vector3Data& p_b) { EqualsCrossImpl(p_a.m_data, p_b.m_data); }
|
2023-11-19 09:38:07 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
Vector3 m_vector;
|
2023-08-03 14:25:29 -04:00
|
|
|
};
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// VTABLE: LEGO1 0x100d41e8
|
2023-08-03 14:25:29 -04:00
|
|
|
// SIZE 0x18
|
2023-11-19 09:38:07 -05:00
|
|
|
class Vector4Data : public Vector4Impl {
|
2023-08-03 14:25:29 -04:00
|
|
|
public:
|
2023-11-19 09:38:07 -05:00
|
|
|
inline Vector4Data() : Vector4Impl(m_vector.elements) {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Vector4 m_vector;
|
2023-08-03 14:25:29 -04:00
|
|
|
};
|
|
|
|
|
2023-11-19 09:38:07 -05:00
|
|
|
#endif // VECTOR_H
|