isle-portable/LEGO1/realtime/vector.h

216 lines
5.2 KiB
C
Raw Normal View History

#ifndef VECTOR_H
#define VECTOR_H
2023-10-24 19:38:27 -04:00
#include <vec.h>
/*
* 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]; }
};
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// VTABLE: LEGO1 0x100d4288
// SIZE 0x8
class Vector2Impl {
public:
// FUNCTION: LEGO1 0x1000c0f0
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;
// 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();
virtual const float* GetData() const;
2023-10-24 19:38:27 -04:00
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;
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;
virtual int Unitize();
2023-10-24 19:38:27 -04:00
// vtable + 0x48
virtual void AddVector(Vector2Impl* p_other);
2023-10-24 19:38:27 -04:00
virtual void AddVector(float* p_other);
virtual void AddScalar(float p_value);
// vtable + 0x54
virtual void SubVector(Vector2Impl* p_other);
2023-10-24 19:38:27 -04:00
virtual void SubVector(float* p_other);
// vtable + 0x5C
virtual void MullScalar(float* p_value);
virtual void MullVector(Vector2Impl* p_other);
2023-10-24 19:38:27 -04:00
virtual void MullVector(float* p_other);
virtual void DivScalar(float* p_value);
// vtable + 0x6C
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]; }
protected:
2023-10-24 19:38:27 -04:00
float* m_data;
};
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// VTABLE: LEGO1 0x100d4518
// SIZE 0x8
class Vector3Impl : public Vector2Impl {
public:
inline Vector3Impl(float* p_data) : Vector2Impl(p_data) {}
2023-10-24 19:38:27 -04:00
void AddScalarImpl(float p_value);
2023-10-24 19:38:27 -04:00
void AddVectorImpl(float* p_value);
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-10-24 19:38:27 -04:00
void EqualsImpl(float* p_data);
2023-10-24 19:38:27 -04:00
void Clear();
2023-10-24 19:38:27 -04:00
float LenSquared() const;
2023-10-24 19:38:27 -04:00
// 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);
2023-10-24 19:38:27 -04:00
virtual void EqualsScalar(float* p_value);
2023-10-24 19:38:27 -04:00
inline void Fill(float p_value) { EqualsScalar(&p_value); }
};
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// VTABLE: LEGO1 0x100d45a0
// SIZE 0x8
class Vector4Impl : public Vector3Impl {
public:
inline Vector4Impl(float* p_data) : Vector3Impl(p_data) {}
2023-10-24 19:38:27 -04:00
void AddScalarImpl(float p_value);
2023-10-24 19:38:27 -04:00
void AddVectorImpl(float* p_value);
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-10-24 19:38:27 -04:00
void EqualsImpl(float* p_data);
2023-10-24 19:38:27 -04:00
void Clear();
2023-10-24 19:38:27 -04:00
float LenSquared() const;
2023-10-24 19:38:27 -04:00
void EqualsScalar(float* p_value);
2023-10-24 19:38:27 -04:00
// vtable + 0x84
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);
virtual int NormalizeQuaternion();
virtual void UnknownQuaternionOp(Vector4Impl* p_a, Vector4Impl* p_b);
};
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// VTABLE: LEGO1 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)
2023-10-24 19:38:27 -04:00
{
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)
2023-10-24 19:38:27 -04:00
*dest++ = *src++;
}
private:
Vector3 m_vector;
};
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// VTABLE: LEGO1 0x100d41e8
// SIZE 0x18
class Vector4Data : public Vector4Impl {
public:
inline Vector4Data() : Vector4Impl(m_vector.elements) {}
private:
Vector4 m_vector;
};
#endif // VECTOR_H