mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-26 17:46:38 -05:00
1ae3b07dc2
* First commit of order tool * More flexible match on module name. Bugfix on blank_or_comment * Report inexact offset comments in verbose mode. Bugfix for exact regex * Refactor checkorder into reusable isledecomp module * Find bad comments in one pass, add awareness of TEMPLATE * Refactor of state machine to prepare for reccmp integration * Use isledecomp lib in reccmp * Build isledecomp in GH actions, fix mypy complaint * Ensure unit test cpp files will be ignored by reccmp * Allow multiple offset markers, pep8 cleanup * Remove unused variable * Code style, remove unneeded module and TODO * Final renaming and type hints * Fix checkorder issues, add GH action and enforce (#2) * Fix checkorder issues * Add GH action * Test error case * Works * Fixes --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
217 lines
5.2 KiB
C++
217 lines
5.2 KiB
C++
#ifndef VECTOR_H
|
|
#define VECTOR_H
|
|
|
|
#include <vec.h>
|
|
|
|
// TODO: Find proper compilation unit to put this
|
|
// OFFSET: LEGO1 0x1000c0f0 TEMPLATE
|
|
// Vector2Impl::Vector2Impl
|
|
|
|
/*
|
|
* 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]; }
|
|
};
|
|
|
|
// VTABLE 0x100d4288
|
|
// SIZE 0x8
|
|
class Vector2Impl {
|
|
public:
|
|
inline Vector2Impl(float* p_data) { this->SetData(p_data); }
|
|
|
|
// 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;
|
|
virtual void SetData(float* p_data) { this->m_data = p_data; }
|
|
|
|
// vtable + 0x20
|
|
virtual void EqualsImpl(float* p_data) = 0;
|
|
virtual float* GetData();
|
|
virtual const float* GetData() const;
|
|
virtual void Clear() = 0;
|
|
|
|
// vtable + 0x30
|
|
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;
|
|
virtual float Dot(float* p_a, float* p_b) const;
|
|
|
|
// vtable + 0x40
|
|
virtual float LenSquared() const = 0;
|
|
virtual int Unitize();
|
|
|
|
// vtable + 0x48
|
|
virtual void AddVector(Vector2Impl* p_other);
|
|
virtual void AddVector(float* p_other);
|
|
virtual void AddScalar(float p_value);
|
|
|
|
// vtable + 0x54
|
|
virtual void SubVector(Vector2Impl* p_other);
|
|
virtual void SubVector(float* p_other);
|
|
|
|
// vtable + 0x5C
|
|
virtual void MullScalar(float* p_value);
|
|
virtual void MullVector(Vector2Impl* p_other);
|
|
virtual void MullVector(float* p_other);
|
|
virtual void DivScalar(float* p_value);
|
|
|
|
// vtable + 0x6C
|
|
virtual void SetVector(Vector2Impl* p_other);
|
|
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]; }
|
|
|
|
protected:
|
|
float* m_data;
|
|
};
|
|
|
|
// VTABLE 0x100d4518
|
|
// SIZE 0x8
|
|
class Vector3Impl : public Vector2Impl {
|
|
public:
|
|
inline Vector3Impl(float* p_data) : Vector2Impl(p_data) {}
|
|
|
|
void AddScalarImpl(float p_value);
|
|
|
|
void AddVectorImpl(float* p_value);
|
|
|
|
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;
|
|
|
|
void EqualsImpl(float* p_data);
|
|
|
|
void Clear();
|
|
|
|
float LenSquared() const;
|
|
|
|
// vtable + 0x74
|
|
virtual void EqualsCrossImpl(float* p_a, float* p_b);
|
|
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);
|
|
virtual void EqualsScalar(float* p_value);
|
|
|
|
inline void Fill(float p_value) { EqualsScalar(&p_value); }
|
|
};
|
|
|
|
// VTABLE 0x100d45a0
|
|
// SIZE 0x8
|
|
class Vector4Impl : public Vector3Impl {
|
|
public:
|
|
inline Vector4Impl(float* p_data) : Vector3Impl(p_data) {}
|
|
|
|
void AddScalarImpl(float p_value);
|
|
|
|
void AddVectorImpl(float* p_value);
|
|
|
|
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;
|
|
|
|
void EqualsImpl(float* p_data);
|
|
|
|
void Clear();
|
|
|
|
float LenSquared() const;
|
|
|
|
void EqualsScalar(float* p_value);
|
|
|
|
// vtable + 0x84
|
|
virtual void SetMatrixProduct(Vector4Impl* p_a, float* p_b);
|
|
virtual void SetMatrixProductImpl(float* p_vec, float* p_mat);
|
|
virtual int NormalizeQuaternion();
|
|
virtual void UnknownQuaternionOp(Vector4Impl* p_a, Vector4Impl* p_b);
|
|
};
|
|
|
|
// VTABLE 0x100d4488
|
|
// SIZE 0x14
|
|
class Vector3Data : public Vector3Impl {
|
|
public:
|
|
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)
|
|
{
|
|
EqualsImpl(p_other.m_data);
|
|
|
|
float* dest = m_vector.elements;
|
|
float* src = p_other.m_vector.elements;
|
|
for (size_t i = sizeof(m_vector) / sizeof(float); i > 0; --i)
|
|
*dest++ = *src++;
|
|
}
|
|
|
|
private:
|
|
Vector3 m_vector;
|
|
};
|
|
|
|
// VTABLE 0x100d41e8
|
|
// SIZE 0x18
|
|
class Vector4Data : public Vector4Impl {
|
|
public:
|
|
inline Vector4Data() : Vector4Impl(m_vector.elements) {}
|
|
|
|
private:
|
|
Vector4 m_vector;
|
|
};
|
|
|
|
#endif // VECTOR_H
|