2023-11-19 09:38:07 -05:00
|
|
|
#ifndef VECTOR_H
|
|
|
|
#define VECTOR_H
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
#include "compat.h"
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
#include <math.h>
|
|
|
|
#include <memory.h>
|
|
|
|
|
2024-03-28 09:19:32 -04:00
|
|
|
// Note: Many functions most likely take const references/pointers instead of non-const.
|
|
|
|
// The class needs to undergo a very careful refactoring to fix that (no matches should break).
|
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// VTABLE: LEGO1 0x100d4288
|
2024-08-04 15:13:12 -04:00
|
|
|
// VTABLE: BETA10 0x101b8440
|
2024-01-12 19:34:38 -05:00
|
|
|
// SIZE 0x08
|
|
|
|
class Vector2 {
|
2023-11-19 09:38:07 -05:00
|
|
|
public:
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x1000c0f0
|
2024-08-04 15:13:12 -04:00
|
|
|
// FUNCTION: BETA10 0x100116a0
|
2024-07-04 19:06:32 -04:00
|
|
|
Vector2(float* p_data) { SetData(p_data); }
|
2023-11-19 09:38:07 -05:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// Note: virtual function overloads appear in the virtual table
|
|
|
|
// in reverse order of appearance.
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10001f80
|
|
|
|
virtual void AddImpl(float* p_value)
|
2023-11-19 09:38:07 -05:00
|
|
|
{
|
2024-01-12 19:34:38 -05:00
|
|
|
m_data[0] += p_value[0];
|
|
|
|
m_data[1] += p_value[1];
|
|
|
|
} // vtable+0x04
|
2023-11-19 09:38:07 -05:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10001fa0
|
|
|
|
virtual void AddImpl(float p_value)
|
2023-11-19 09:38:07 -05:00
|
|
|
{
|
2024-01-12 19:34:38 -05:00
|
|
|
m_data[0] += p_value;
|
|
|
|
m_data[1] += p_value;
|
|
|
|
} // vtable+0x00
|
2023-11-19 09:38:07 -05:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10001fc0
|
|
|
|
virtual void SubImpl(float* p_value)
|
|
|
|
{
|
|
|
|
m_data[0] -= p_value[0];
|
|
|
|
m_data[1] -= p_value[1];
|
|
|
|
} // vtable+0x08
|
2023-11-19 09:38:07 -05:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// Those are also overloads in all likelihood,
|
|
|
|
// but we need a type to do that.
|
2023-11-19 09:38:07 -05:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10002000
|
|
|
|
virtual void MulScalarImpl(float* p_value)
|
2023-11-19 09:38:07 -05:00
|
|
|
{
|
2024-01-12 19:34:38 -05:00
|
|
|
m_data[0] *= *p_value;
|
|
|
|
m_data[1] *= *p_value;
|
|
|
|
} // vtable+0x0c
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10001fe0
|
|
|
|
virtual void MulVectorImpl(float* p_value)
|
2023-11-19 09:38:07 -05:00
|
|
|
{
|
2024-01-12 19:34:38 -05:00
|
|
|
m_data[0] *= p_value[0];
|
|
|
|
m_data[1] *= p_value[1];
|
|
|
|
} // vtable+0x10
|
2023-11-19 09:38:07 -05:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10002020
|
|
|
|
virtual void DivScalarImpl(float* p_value)
|
|
|
|
{
|
|
|
|
m_data[0] /= *p_value;
|
|
|
|
m_data[1] /= *p_value;
|
|
|
|
} // vtable+0x14
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002040
|
|
|
|
virtual float DotImpl(float* p_a, float* p_b) const { return p_b[0] * p_a[0] + p_b[1] * p_a[1]; } // vtable+0x18
|
2023-11-19 09:38:07 -05:00
|
|
|
|
2023-12-12 14:27:17 -05:00
|
|
|
// FUNCTION: LEGO1 0x10002060
|
2024-08-04 15:13:12 -04:00
|
|
|
// FUNCTION: BETA10 0x10010c90
|
2024-01-12 19:34:38 -05:00
|
|
|
virtual void SetData(float* p_data) { m_data = p_data; } // vtable+0x1c
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002070
|
|
|
|
virtual void EqualsImpl(float* p_data) { memcpy(m_data, p_data, sizeof(float) * 2); } // vtable+0x20
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002090
|
|
|
|
virtual float* GetData() { return m_data; } // vtable+0x28
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100020a0
|
|
|
|
virtual const float* GetData() const { return m_data; } // vtable+0x24
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100020b0
|
|
|
|
virtual void Clear() { memset(m_data, 0, sizeof(float) * 2); } // vtable+0x2c
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100020d0
|
|
|
|
virtual float Dot(float* p_a, float* p_b) const { return DotImpl(p_a, p_b); } // vtable+0x3c
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100020f0
|
2024-08-29 14:54:23 -04:00
|
|
|
// FUNCTION: BETA10 0x100108c0
|
2024-01-12 19:34:38 -05:00
|
|
|
virtual float Dot(Vector2* p_a, Vector2* p_b) const { return DotImpl(p_a->m_data, p_b->m_data); } // vtable+0x38
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002110
|
|
|
|
virtual float Dot(float* p_a, Vector2* p_b) const { return DotImpl(p_a, p_b->m_data); } // vtable+0x34
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002130
|
|
|
|
virtual float Dot(Vector2* p_a, float* p_b) const { return DotImpl(p_a->m_data, p_b); } // vtable+0x30
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002150
|
|
|
|
virtual float LenSquared() const { return m_data[0] * m_data[0] + m_data[1] * m_data[1]; } // vtable+0x40
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002160
|
2024-08-04 15:13:12 -04:00
|
|
|
// FUNCTION: BETA10 0x10010900
|
2024-01-12 19:34:38 -05:00
|
|
|
virtual int Unitize()
|
|
|
|
{
|
|
|
|
float sq = LenSquared();
|
2024-04-11 07:35:15 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
if (sq > 0.0f) {
|
|
|
|
float root = sqrt(sq);
|
2024-05-19 16:36:11 -04:00
|
|
|
if (root > 0.0f) {
|
2024-01-12 19:34:38 -05:00
|
|
|
DivScalarImpl(&root);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2024-04-11 07:35:15 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
return -1;
|
|
|
|
} // vtable+0x44
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100021c0
|
|
|
|
virtual void Add(float p_value) { AddImpl(p_value); } // vtable+0x50
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100021d0
|
|
|
|
virtual void Add(float* p_other) { AddImpl(p_other); } // vtable+0x4c
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100021e0
|
2024-06-06 11:45:37 -04:00
|
|
|
virtual void Add(const Vector2& p_other) { AddImpl((float*) p_other.m_data); } // vtable+0x48
|
2024-01-12 19:34:38 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100021f0
|
2024-05-09 16:24:45 -04:00
|
|
|
virtual void Sub(const float* p_other) { SubImpl((float*) p_other); } // vtable+0x58
|
2024-01-12 19:34:38 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002200
|
2024-06-06 11:45:37 -04:00
|
|
|
virtual void Sub(const Vector2& p_other) { SubImpl((float*) p_other.m_data); } // vtable+0x54
|
2024-01-12 19:34:38 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002210
|
|
|
|
virtual void Mul(float* p_other) { MulVectorImpl(p_other); } // vtable+0x64
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002220
|
|
|
|
virtual void Mul(Vector2* p_other) { MulVectorImpl(p_other->m_data); } // vtable+0x60
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002230
|
2024-03-28 09:19:32 -04:00
|
|
|
virtual void Mul(const float& p_value) { MulScalarImpl((float*) &p_value); } // vtable+0x5c
|
2024-01-12 19:34:38 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002240
|
2024-06-13 16:09:14 -04:00
|
|
|
virtual void Div(const float& p_value) { DivScalarImpl((float*) &p_value); } // vtable+0x68
|
2024-01-12 19:34:38 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002250
|
|
|
|
virtual void SetVector(float* p_other) { EqualsImpl(p_other); } // vtable+0x70
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002260
|
2024-03-05 14:31:57 -05:00
|
|
|
virtual void SetVector(const Vector2* p_other) { EqualsImpl(p_other->m_data); } // vtable+0x6c
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2024-03-05 14:31:57 -05:00
|
|
|
// SYNTHETIC: LEGO1 0x10010be0
|
|
|
|
// Vector3::operator=
|
|
|
|
|
2024-09-09 15:45:48 -04:00
|
|
|
// SYNTHETIC: BETA10 0x1004af40
|
|
|
|
// Vector4::operator=
|
|
|
|
|
2024-07-04 19:06:32 -04:00
|
|
|
Vector2& operator=(const Vector2& p_other)
|
2024-03-05 14:31:57 -05:00
|
|
|
{
|
|
|
|
Vector2::SetVector(&p_other);
|
|
|
|
return *this;
|
|
|
|
}
|
2024-08-04 15:13:12 -04:00
|
|
|
|
2024-09-09 15:45:48 -04:00
|
|
|
// SYNTHETIC: BETA10 0x10013460
|
|
|
|
// Vector3::operator[]
|
|
|
|
|
|
|
|
// FUNCTION: BETA10 0x10010890
|
2024-07-04 19:06:32 -04:00
|
|
|
float& operator[](int idx) { return m_data[idx]; }
|
2024-08-04 15:13:12 -04:00
|
|
|
|
|
|
|
// FUNCTION: BETA10 0x1001d140
|
2024-07-04 19:06:32 -04:00
|
|
|
const float& operator[](int idx) const { return m_data[idx]; }
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2023-08-03 14:25:29 -04:00
|
|
|
protected:
|
2024-02-27 11:49:31 -05:00
|
|
|
float* m_data; // 0x04
|
2023-08-03 14:25:29 -04:00
|
|
|
};
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// VTABLE: LEGO1 0x100d4518
|
2024-08-03 01:29:21 -04:00
|
|
|
// VTABLE: BETA10 0x101b8398
|
2024-01-12 19:34:38 -05:00
|
|
|
// SIZE 0x08
|
|
|
|
class Vector3 : public Vector2 {
|
2023-08-03 14:25:29 -04:00
|
|
|
public:
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x1001d150
|
2024-10-04 11:19:42 -04:00
|
|
|
// FUNCTION: BETA10 0x10011660
|
2024-07-04 19:06:32 -04:00
|
|
|
Vector3(float* p_data) : Vector2(p_data) {}
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// Hack: Some code initializes a Vector3 from a (most likely) const float* source.
|
|
|
|
// Example: LegoCameraController::GetWorldUp
|
|
|
|
// Vector3 however is a class that can mutate its underlying source, making
|
|
|
|
// initialization with a const source fundamentally incompatible.
|
2024-07-04 19:06:32 -04:00
|
|
|
Vector3(const float* p_data) : Vector2((float*) p_data) {}
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// Note: virtual function overloads appear in the virtual table
|
|
|
|
// in reverse order of appearance.
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10002270
|
2024-08-29 14:54:23 -04:00
|
|
|
// FUNCTION: BETA10 0x10011350
|
2024-07-04 19:06:32 -04:00
|
|
|
virtual void EqualsCrossImpl(float* p_a, float* p_b)
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] = p_a[1] * p_b[2] - p_a[2] * p_b[1];
|
|
|
|
m_data[1] = p_a[2] * p_b[0] - p_a[0] * p_b[2];
|
|
|
|
m_data[2] = p_a[0] * p_b[1] - p_a[1] * p_b[0];
|
|
|
|
} // vtable+0x74
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x100022c0
|
2024-08-04 15:13:12 -04:00
|
|
|
// FUNCTION: BETA10 0x10011430
|
2024-01-12 19:34:38 -05:00
|
|
|
virtual void EqualsCross(Vector3* p_a, Vector3* p_b) { EqualsCrossImpl(p_a->m_data, p_b->m_data); } // vtable+0x80
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x100022e0
|
|
|
|
virtual void EqualsCross(Vector3* p_a, float* p_b) { EqualsCrossImpl(p_a->m_data, p_b); } // vtable+0x7c
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10002300
|
|
|
|
virtual void EqualsCross(float* p_a, Vector3* p_b) { EqualsCrossImpl(p_a, p_b->m_data); } // vtable+0x78
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10003bf0
|
2024-05-03 08:01:27 -04:00
|
|
|
virtual void Fill(const float& p_value)
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
2024-05-03 08:01:27 -04:00
|
|
|
m_data[0] = p_value;
|
|
|
|
m_data[1] = p_value;
|
|
|
|
m_data[2] = p_value;
|
2024-01-12 19:34:38 -05:00
|
|
|
} // vtable+0x84
|
2023-10-07 14:00:20 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// Vector2 overrides
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10003a60
|
2024-02-01 15:42:10 -05:00
|
|
|
void AddImpl(float* p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] += p_value[0];
|
|
|
|
m_data[1] += p_value[1];
|
|
|
|
m_data[2] += p_value[2];
|
|
|
|
} // vtable+0x04
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10003a90
|
2024-02-01 15:42:10 -05:00
|
|
|
void AddImpl(float p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] += p_value;
|
|
|
|
m_data[1] += p_value;
|
|
|
|
m_data[2] += p_value;
|
|
|
|
} // vtable+0x00
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10003ac0
|
2024-02-01 15:42:10 -05:00
|
|
|
void SubImpl(float* p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] -= p_value[0];
|
|
|
|
m_data[1] -= p_value[1];
|
|
|
|
m_data[2] -= p_value[2];
|
|
|
|
} // vtable+0x08
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10003b20
|
2024-07-04 19:06:32 -04:00
|
|
|
void MulScalarImpl(float* p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] *= *p_value;
|
|
|
|
m_data[1] *= *p_value;
|
|
|
|
m_data[2] *= *p_value;
|
|
|
|
} // vtable+0x0c
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10003af0
|
2024-02-01 15:42:10 -05:00
|
|
|
void MulVectorImpl(float* p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] *= p_value[0];
|
|
|
|
m_data[1] *= p_value[1];
|
|
|
|
m_data[2] *= p_value[2];
|
|
|
|
} // vtable+0x10
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10003b50
|
2024-02-01 15:42:10 -05:00
|
|
|
void DivScalarImpl(float* p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] /= *p_value;
|
|
|
|
m_data[1] /= *p_value;
|
|
|
|
m_data[2] /= *p_value;
|
|
|
|
} // vtable+0x14
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10003b80
|
2024-02-01 15:42:10 -05:00
|
|
|
float DotImpl(float* p_a, float* p_b) const override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
return p_a[0] * p_b[0] + p_a[2] * p_b[2] + p_a[1] * p_b[1];
|
|
|
|
} // vtable+0x18
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10003ba0
|
2024-08-04 15:13:12 -04:00
|
|
|
// FUNCTION: BETA10 0x100113f0
|
2024-02-01 15:42:10 -05:00
|
|
|
void EqualsImpl(float* p_data) override { memcpy(m_data, p_data, sizeof(float) * 3); } // vtable+0x20
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10003bc0
|
2024-08-29 14:54:23 -04:00
|
|
|
// FUNCTION: BETA10 0x100114f0
|
2024-02-01 15:42:10 -05:00
|
|
|
void Clear() override { memset(m_data, 0, sizeof(float) * 3); } // vtable+0x2c
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10003bd0
|
2024-02-01 15:42:10 -05:00
|
|
|
float LenSquared() const override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
2024-04-07 08:03:21 -04:00
|
|
|
return m_data[0] * m_data[0] + m_data[1] * m_data[1] + m_data[2] * m_data[2];
|
2024-01-12 19:34:38 -05:00
|
|
|
} // vtable+0x40
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
friend class Mx3DPointFloat;
|
2023-08-03 14:25:29 -04:00
|
|
|
};
|
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// VTABLE: LEGO1 0x100d45a0
|
2024-06-30 16:45:10 -04:00
|
|
|
// VTABLE: BETA10 0x101bac38
|
2024-01-29 16:17:17 -05:00
|
|
|
// SIZE 0x08
|
2024-01-12 19:34:38 -05:00
|
|
|
class Vector4 : public Vector3 {
|
2023-08-03 14:25:29 -04:00
|
|
|
public:
|
2024-10-04 11:19:42 -04:00
|
|
|
// FUNCTION: BETA10 0x10048780
|
2024-07-04 19:06:32 -04:00
|
|
|
Vector4(float* p_data) : Vector3(p_data) {}
|
2024-01-12 19:34:38 -05:00
|
|
|
|
2024-09-03 16:50:30 -04:00
|
|
|
// Hack: Some code initializes a Vector4 from a (most likely) const float* source.
|
|
|
|
// Example: LegoCarBuild::VTable0x6c
|
|
|
|
// Vector4 however is a class that can mutate its underlying source, making
|
|
|
|
// initialization with a const source fundamentally incompatible.
|
|
|
|
Vector4(const float* p_data) : Vector3((float*) p_data) {}
|
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// Note: virtual function overloads appear in the virtual table
|
|
|
|
// in reverse order of appearance.
|
2023-11-19 09:38:07 -05:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10002a40
|
|
|
|
virtual void SetMatrixProduct(float* p_vec, float* p_mat)
|
2023-10-24 19:38:27 -04:00
|
|
|
{
|
2024-01-12 19:34:38 -05:00
|
|
|
m_data[0] = p_vec[0] * p_mat[0] + p_vec[1] * p_mat[4] + p_vec[2] * p_mat[8] + p_vec[3] * p_mat[12];
|
|
|
|
m_data[1] = p_vec[0] * p_mat[1] + p_vec[1] * p_mat[5] + p_vec[2] * p_mat[9] + p_vec[4] * p_mat[13];
|
|
|
|
m_data[2] = p_vec[0] * p_mat[2] + p_vec[1] * p_mat[6] + p_vec[2] * p_mat[10] + p_vec[4] * p_mat[14];
|
|
|
|
m_data[3] = p_vec[0] * p_mat[3] + p_vec[1] * p_mat[7] + p_vec[2] * p_mat[11] + p_vec[4] * p_mat[15];
|
|
|
|
} // vtable+0x8c
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10002ae0
|
|
|
|
virtual void SetMatrixProduct(Vector4* p_a, float* p_b) { SetMatrixProduct(p_a->m_data, p_b); } // vtable+0x88
|
2023-11-19 09:38:07 -05:00
|
|
|
|
2024-06-30 16:45:10 -04:00
|
|
|
inline virtual int NormalizeQuaternion(); // vtable+0x90
|
|
|
|
inline virtual int EqualsHamiltonProduct(Vector4* p_a, Vector4* p_b); // vtable+0x94
|
2023-08-03 14:25:29 -04:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// Vector3 overrides
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002870
|
2024-02-01 15:42:10 -05:00
|
|
|
void AddImpl(float* p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] += p_value[0];
|
|
|
|
m_data[1] += p_value[1];
|
|
|
|
m_data[2] += p_value[2];
|
|
|
|
m_data[3] += p_value[3];
|
|
|
|
} // vtable+0x04
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100028b0
|
2024-02-01 15:42:10 -05:00
|
|
|
void AddImpl(float p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] += p_value;
|
|
|
|
m_data[1] += p_value;
|
|
|
|
m_data[2] += p_value;
|
|
|
|
m_data[3] += p_value;
|
|
|
|
} // vtable+0x00
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100028f0
|
2024-02-01 15:42:10 -05:00
|
|
|
void SubImpl(float* p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] -= p_value[0];
|
|
|
|
m_data[1] -= p_value[1];
|
|
|
|
m_data[2] -= p_value[2];
|
|
|
|
m_data[3] -= p_value[3];
|
|
|
|
} // vtable+0x08
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002970
|
2024-02-01 15:42:10 -05:00
|
|
|
void MulScalarImpl(float* p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] *= *p_value;
|
|
|
|
m_data[1] *= *p_value;
|
|
|
|
m_data[2] *= *p_value;
|
|
|
|
m_data[3] *= *p_value;
|
|
|
|
} // vtable+0x0c
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002930
|
2024-02-01 15:42:10 -05:00
|
|
|
void MulVectorImpl(float* p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] *= p_value[0];
|
|
|
|
m_data[1] *= p_value[1];
|
|
|
|
m_data[2] *= p_value[2];
|
|
|
|
m_data[3] *= p_value[3];
|
|
|
|
} // vtable+0x10
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100029b0
|
2024-02-01 15:42:10 -05:00
|
|
|
void DivScalarImpl(float* p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
m_data[0] /= *p_value;
|
|
|
|
m_data[1] /= *p_value;
|
|
|
|
m_data[2] /= *p_value;
|
|
|
|
m_data[3] /= *p_value;
|
|
|
|
} // vtable+0x14
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100029f0
|
2024-02-01 15:42:10 -05:00
|
|
|
float DotImpl(float* p_a, float* p_b) const override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
return p_a[0] * p_b[0] + p_a[2] * p_b[2] + (p_a[1] * p_b[1] + p_a[3] * p_b[3]);
|
|
|
|
} // vtable+0x18
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002a20
|
2024-02-01 15:42:10 -05:00
|
|
|
void EqualsImpl(float* p_data) override { memcpy(m_data, p_data, sizeof(float) * 4); } // vtable+0x20
|
2024-01-12 19:34:38 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002b00
|
2024-02-01 15:42:10 -05:00
|
|
|
void Clear() override { memset(m_data, 0, sizeof(float) * 4); } // vtable+0x2c
|
2023-11-19 09:38:07 -05:00
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10002b20
|
2024-02-01 15:42:10 -05:00
|
|
|
float LenSquared() const override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
|
|
|
return m_data[1] * m_data[1] + m_data[0] * m_data[0] + m_data[2] * m_data[2] + m_data[3] * m_data[3];
|
|
|
|
} // vtable+0x40
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10002b40
|
2024-05-03 08:01:27 -04:00
|
|
|
void Fill(const float& p_value) override
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
2024-05-03 08:01:27 -04:00
|
|
|
m_data[0] = p_value;
|
|
|
|
m_data[1] = p_value;
|
|
|
|
m_data[2] = p_value;
|
|
|
|
m_data[3] = p_value;
|
2024-01-12 19:34:38 -05:00
|
|
|
} // vtable+0x84
|
2024-03-12 13:21:58 -04:00
|
|
|
|
|
|
|
friend class Mx4DPointFloat;
|
2023-08-03 14:25:29 -04:00
|
|
|
};
|
|
|
|
|
2024-06-30 16:45:10 -04:00
|
|
|
// FUNCTION: LEGO1 0x10002b70
|
|
|
|
// FUNCTION: BETA10 0x10048ad0
|
2024-01-12 19:34:38 -05:00
|
|
|
inline int Vector4::NormalizeQuaternion()
|
|
|
|
{
|
|
|
|
float* v = m_data;
|
2024-06-30 16:45:10 -04:00
|
|
|
float magnitude = v[0] * v[0] + v[2] * v[2] + v[1] * v[1];
|
2024-01-12 19:34:38 -05:00
|
|
|
if (magnitude > 0.0f) {
|
|
|
|
float theta = v[3] * 0.5f;
|
|
|
|
v[3] = cos(theta);
|
2024-06-30 16:45:10 -04:00
|
|
|
magnitude = sin(theta) / sqrt(magnitude);
|
|
|
|
Vector3::MulScalarImpl(&magnitude);
|
2024-01-12 19:34:38 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2024-06-30 16:45:10 -04:00
|
|
|
inline static float QuaternionProductScalarPart(float* bDat, float* aDat)
|
|
|
|
{
|
|
|
|
// We have no indication from the beta that this function exists,
|
|
|
|
// but it helps with the stack layout of Vector4::EqualsHamiltonProduct()
|
|
|
|
return aDat[3] * bDat[3] - (aDat[0] * bDat[0] + aDat[2] * bDat[2] + aDat[1] * bDat[1]);
|
|
|
|
}
|
|
|
|
|
2024-01-12 19:34:38 -05:00
|
|
|
// FUNCTION: LEGO1 0x10002bf0
|
2024-06-30 16:45:10 -04:00
|
|
|
// FUNCTION: BETA10 0x10048c20
|
|
|
|
inline int Vector4::EqualsHamiltonProduct(Vector4* p_a, Vector4* p_b)
|
2024-01-12 19:34:38 -05:00
|
|
|
{
|
2024-06-30 16:45:10 -04:00
|
|
|
m_data[3] = QuaternionProductScalarPart(p_a->m_data, p_b->m_data);
|
2024-01-12 19:34:38 -05:00
|
|
|
|
2024-06-30 16:45:10 -04:00
|
|
|
Vector3::EqualsCrossImpl(p_a->m_data, p_b->m_data);
|
2024-01-12 19:34:38 -05:00
|
|
|
|
|
|
|
m_data[0] = p_b->m_data[3] * p_a->m_data[0] + p_a->m_data[3] * p_b->m_data[0] + m_data[0];
|
|
|
|
m_data[1] = p_b->m_data[1] * p_a->m_data[3] + p_a->m_data[1] * p_b->m_data[3] + m_data[1];
|
|
|
|
m_data[2] = p_b->m_data[2] * p_a->m_data[3] + p_a->m_data[2] * p_b->m_data[3] + m_data[2];
|
2024-06-30 16:45:10 -04:00
|
|
|
|
|
|
|
return 0;
|
2024-01-12 19:34:38 -05:00
|
|
|
}
|
|
|
|
|
2023-11-19 09:38:07 -05:00
|
|
|
#endif // VECTOR_H
|