Isle
Loading...
Searching...
No Matches
vector.h
Go to the documentation of this file.
1#ifndef VECTOR_H
2#define VECTOR_H
3
4#include "compat.h"
5
6// Note: virtual function overloads appear in the virtual table
7// in reverse order of appearance.
8
9// VTABLE: LEGO1 0x100d4288
10// VTABLE: BETA10 0x101b8440
11// SIZE 0x08
16class Vector2 {
17protected:
22 inline virtual void AddImpl(const float* p_value); // vtable+0x04
23
28 inline virtual void AddImpl(float p_value); // vtable+0x00
29
34 inline virtual void SubImpl(const float* p_value); // vtable+0x08
35
40 inline virtual void MulImpl(const float* p_value); // vtable+0x10
41
46 inline virtual void MulImpl(const float& p_value); // vtable+0x0c
47
52 inline virtual void DivImpl(const float& p_value); // vtable+0x14
53
60 inline virtual float DotImpl(const float* p_a, const float* p_b) const; // vtable+0x18
61
66 inline virtual void SetData(float* p_data); // vtable+0x1c
67
72 inline virtual void EqualsImpl(const float* p_data); // vtable+0x20
73
77 float* m_data; // 0x04
78
79public:
84 Vector2(float* p_data) { SetData(p_data); }
85
91 Vector2(const float* p_data) { m_data = (float*) p_data; }
92
97 inline virtual float* GetData(); // vtable+0x28
98
103 inline virtual const float* GetData() const; // vtable+0x24
104
108 inline virtual void Clear(); // vtable+0x2c
109
116 inline virtual float Dot(const float* p_a, const float* p_b) const; // vtable+0x3c
117
124 inline virtual float Dot(const Vector2& p_a, const Vector2& p_b) const; // vtable+0x38
125
132 inline virtual float Dot(const float* p_a, const Vector2& p_b) const; // vtable+0x34
133
140 inline virtual float Dot(const Vector2& p_a, const float* p_b) const; // vtable+0x30
141
146 inline virtual float LenSquared() const; // vtable+0x40
147
152 inline virtual int Unitize(); // vtable+0x44
153
158 inline virtual void operator+=(float p_value); // vtable+0x50
159
164 inline virtual void operator+=(const float* p_other); // vtable+0x4c
165
170 inline virtual void operator+=(const Vector2& p_other); // vtable+0x48
171
176 inline virtual void operator-=(const float* p_other); // vtable+0x58
177
182 inline virtual void operator-=(const Vector2& p_other); // vtable+0x54
183
188 inline virtual void operator*=(const float* p_other); // vtable+0x64
189
194 inline virtual void operator*=(const Vector2& p_other); // vtable+0x60
195
200 inline virtual void operator*=(const float& p_value); // vtable+0x5c
201
206 inline virtual void operator/=(const float& p_value); // vtable+0x68
207
212 inline virtual void operator=(const float* p_other); // vtable+0x70
213
218 inline virtual void operator=(const Vector2& p_other); // vtable+0x6c
219
220 // SYNTHETIC: LEGO1 0x10010be0
221 // SYNTHETIC: BETA10 0x100121e0
222 // Vector3::operator=
223
224 // SYNTHETIC: BETA10 0x1004af40
225 // Vector4::operator=
226
232 float& operator[](int idx) { return m_data[idx]; }
233
239 const float& operator[](int idx) const { return m_data[idx]; }
240};
241
242// VTABLE: LEGO1 0x100d4518
243// VTABLE: BETA10 0x101b8398
244// SIZE 0x08
249class Vector3 : public Vector2 {
250protected:
254 inline void AddImpl(const float* p_value) override; // vtable+0x04
255
259 inline void AddImpl(float p_value) override; // vtable+0x00
260
264 inline void SubImpl(const float* p_value) override; // vtable+0x08
265
269 inline void MulImpl(const float* p_value) override; // vtable+0x10
270
274 inline void MulImpl(const float& p_value) override; // vtable+0x0c
275
279 inline void DivImpl(const float& p_value) override; // vtable+0x14
280
284 inline float DotImpl(const float* p_a, const float* p_b) const override; // vtable+0x18
285
289 inline void EqualsImpl(const float* p_data) override; // vtable+0x20
290
296 inline virtual void EqualsCrossImpl(const float* p_a, const float* p_b); // vtable+0x74
297
298public:
303 Vector3(float* p_data) : Vector2(p_data) {}
304
305 // Hack: Some code initializes a Vector3 from a (most likely) const float* source.
306 // Example: LegoCameraController::GetWorldUp
307 // Vector3 however is a class that can mutate its underlying source, making
308 // initialization with a const source fundamentally incompatible.
309
315 Vector3(const float* p_data) : Vector2(p_data) {}
316
320 inline void Clear() override; // vtable+0x2c
321
326 inline float LenSquared() const override; // vtable+0x40
327
333 inline virtual void EqualsCross(const Vector3& p_a, const Vector3& p_b); // vtable+0x80
334
340 inline virtual void EqualsCross(const Vector3& p_a, const float* p_b); // vtable+0x7c
341
347 inline virtual void EqualsCross(const float* p_a, const Vector3& p_b); // vtable+0x78
348
353 inline virtual void Fill(const float& p_value); // vtable+0x84
354
355 friend class Mx3DPointFloat;
356};
357
358// VTABLE: LEGO1 0x100d45a0
359// VTABLE: BETA10 0x101bac38
360// SIZE 0x08
365class Vector4 : public Vector3 {
366protected:
370 inline void AddImpl(const float* p_value) override; // vtable+0x04
371
375 inline void AddImpl(float p_value) override; // vtable+0x00
376
380 inline void SubImpl(const float* p_value) override; // vtable+0x08
381
385 inline void MulImpl(const float* p_value) override; // vtable+0x10
386
390 inline void MulImpl(const float& p_value) override; // vtable+0x0c
391
395 inline void DivImpl(const float& p_value) override; // vtable+0x14
396
400 inline float DotImpl(const float* p_a, const float* p_b) const override; // vtable+0x18
401
405 inline void EqualsImpl(const float* p_data) override; // vtable+0x20
406
407public:
412 Vector4(float* p_data) : Vector3(p_data) {}
413
419 Vector4(const float* p_data) : Vector3(p_data) {}
420
424 inline void Clear() override; // vtable+0x2c
425
430 inline float LenSquared() const override; // vtable+0x40
431
436 inline void Fill(const float& p_value) override; // vtable+0x84
437
443 inline virtual void SetMatrixProduct(const float* p_vec, const float* p_mat); // vtable+0x8c
444
450 inline virtual void SetMatrixProduct(const Vector4& p_a, const float* p_b); // vtable+0x88
451
456 inline virtual int NormalizeQuaternion(); // vtable+0x90
457
464 inline virtual int EqualsHamiltonProduct(const Vector4& p_a, const Vector4& p_b); // vtable+0x94
465
470 float& operator[](int idx) { return m_data[idx]; }
471
476 const float& operator[](int idx) const { return m_data[idx]; }
477
478 friend class Mx4DPointFloat;
479};
480
481#ifdef COMPAT_MODE
482#include "vector2d.inl.h"
483#include "vector3d.inl.h"
484#include "vector4d.inl.h"
485#endif
486
487#endif // VECTOR_H
[AI] Represents a 3D point with floating-point precision, inheriting from Vector3.
Definition: mxgeometry3d.h:14
[AI] 4D point class for floating point values.
Definition: mxgeometry4d.h:18
[AI] Represents a 2D mathematical vector with floating-point coordinates.
Definition: vector.h:16
float * m_data
[AI] Pointer to externally provided float storage (owned elsewhere).
Definition: vector.h:77
float & operator[](int idx)
[AI] Accesses the idx-th float in the vector (0 or 1).
Definition: vector.h:232
virtual float Dot(const Vector2 &p_a, const Vector2 &p_b) const
[AI] Compute the dot product of two Vector2 objects.
virtual void operator+=(float p_value)
[AI] In-place add a scalar to all coordinates.
virtual float Dot(const float *p_a, const Vector2 &p_b) const
[AI] Compute the dot product given a pointer and a Vector2 (second param).
virtual float Dot(const float *p_a, const float *p_b) const
[AI] Compute the dot product of the two float arrays interpreted as vectors of 2 elements.
virtual void AddImpl(float p_value)
[AI] Adds a scalar value to every element of this vector.
virtual void operator+=(const float *p_other)
[AI] In-place add vector elements via float pointer.
Vector2(float *p_data)
[AI] Construct a 2D vector using an external float buffer.
Definition: vector.h:84
virtual void operator/=(const float &p_value)
[AI] In-place scalar division.
virtual void AddImpl(const float *p_value)
[AI] Adds the values pointed to by p_value to this vector.
virtual void SetData(float *p_data)
[AI] Set the internal data pointer to external storage.
virtual void operator*=(const float &p_value)
[AI] In-place multiplication by a scalar.
virtual void operator-=(const Vector2 &p_other)
[AI] In-place subtraction of another Vector2.
virtual void DivImpl(const float &p_value)
[AI] Divides this vector by a scalar value.
virtual float * GetData()
[AI] Retrieves the mutable in-memory data pointer for this vector.
virtual float LenSquared() const
[AI] Compute the squared length (magnitude^2) of the vector.
virtual void SubImpl(const float *p_value)
[AI] Subtracts the vector specified by p_value from this vector.
virtual int Unitize()
[AI] Scales the vector so its norm is 1 (unit vector).
virtual void MulImpl(const float *p_value)
[AI] Multiplies this vector by another vector (per element).
virtual float Dot(const Vector2 &p_a, const float *p_b) const
[AI] Compute the dot product given a Vector2 (first param) and a pointer (second param).
const float & operator[](int idx) const
[AI] Const version of the index operator.
Definition: vector.h:239
virtual void operator*=(const Vector2 &p_other)
[AI] In-place per-element multiplication by another Vector2.
virtual const float * GetData() const
[AI] Retrieves the immutable data pointer for this vector.
virtual void operator+=(const Vector2 &p_other)
[AI] In-place add another Vector2.
Vector2(const float *p_data)
[AI] Construct a 2D vector from a (likely constant) array of floats without copying (just pointer ass...
Definition: vector.h:91
virtual void operator-=(const float *p_other)
[AI] In-place subtraction of vector pointed to by p_other.
virtual void operator*=(const float *p_other)
[AI] In-place per-element multiplication of this vector by another array.
virtual void operator=(const Vector2 &p_other)
[AI] Assigns this vector's elements from another Vector2.
virtual void EqualsImpl(const float *p_data)
[AI] Assigns values from provided array to this vector.
virtual void Clear()
[AI] Zeros all elements (sets all coordinates to 0.0).
virtual void operator=(const float *p_other)
[AI] Assigns this vector's elements from a pointer to two floats.
virtual void MulImpl(const float &p_value)
[AI] Multiplies this vector by a scalar value.
virtual float DotImpl(const float *p_a, const float *p_b) const
[AI] Computes the dot product of two arrays interpreted as vectors.
[AI] 3D vector class, providing vector and cross-product operations in 3D space.
Definition: vector.h:249
virtual void EqualsCrossImpl(const float *p_a, const float *p_b)
[AI] Assigns this vector to the cross product of p_a and p_b.
void EqualsImpl(const float *p_data) override
[AI] Assigns values from provided array to this vector.
float DotImpl(const float *p_a, const float *p_b) const override
void AddImpl(float p_value) override
[AI] Adds a scalar value to every element of this vector.
Vector3(float *p_data)
[AI] Construct a 3D vector pointing at external data storage.
Definition: vector.h:303
virtual void EqualsCross(const Vector3 &p_a, const float *p_b)
[AI] Sets this vector to be the cross product of p_a and p_b, with b as a pointer.
virtual void EqualsCross(const float *p_a, const Vector3 &p_b)
[AI] Sets this vector to be the cross product of p_a and p_b, with a as a pointer.
void MulImpl(const float &p_value) override
[AI] Multiplies this vector by a scalar value.
void Clear() override
[AI] Sets every coordinate (x, y, z) to zero.
virtual void Fill(const float &p_value)
[AI] Fills all coordinates with p_value.
void DivImpl(const float &p_value) override
[AI] Divides this vector by a scalar value.
void MulImpl(const float *p_value) override
[AI] Multiplies this vector by another vector (per element).
void SubImpl(const float *p_value) override
[AI] Subtracts the vector specified by p_value from this vector.
float LenSquared() const override
[AI] Computes the squared magnitude (x^2 + y^2 + z^2) of this vector.
void AddImpl(const float *p_value) override
[AI] Adds the values pointed to by p_value to this vector.
virtual void EqualsCross(const Vector3 &p_a, const Vector3 &p_b)
[AI] Sets this vector to be the cross product of p_a and p_b.
Vector3(const float *p_data)
[AI] Construct a 3D vector from const float* (pointer is cast to non-const in base).
Definition: vector.h:315
[AI] A four-dimensional vector, supporting operations relevant for matrix and quaternion math (homoge...
Definition: vector.h:365
virtual int EqualsHamiltonProduct(const Vector4 &p_a, const Vector4 &p_b)
[AI] Set this vector to the Hamilton product of two quaternion Vector4s.
void Clear() override
[AI] Sets all four components to zero.
void AddImpl(float p_value) override
[AI] Adds a scalar value to every element of this vector.
virtual void SetMatrixProduct(const float *p_vec, const float *p_mat)
[AI] Set this vector to the result of a matrix-vector product: result = p_mat * p_vec.
void AddImpl(const float *p_value) override
[AI] Adds the values pointed to by p_value to this vector.
Vector4(float *p_data)
[AI] Constructs a Vector4 using external float storage.
Definition: vector.h:412
Vector4(const float *p_data)
[AI] Constructs a Vector4 using a const float pointer (pointer is reinterpreted as mutable).
Definition: vector.h:419
virtual int NormalizeQuaternion()
[AI] Normalize this quaternion (interpreted as vector) in place.
float DotImpl(const float *p_a, const float *p_b) const override
void EqualsImpl(const float *p_data) override
[AI] Assigns values from provided array to this vector.
const float & operator[](int idx) const
[AI] Const version for coordinate access (0...3).
Definition: vector.h:476
void SubImpl(const float *p_value) override
[AI] Subtracts the vector specified by p_value from this vector.
void MulImpl(const float *p_value) override
[AI] Multiplies this vector by another vector (per element).
void Fill(const float &p_value) override
[AI] Fill all four floats with p_value.
float LenSquared() const override
[AI] Computes the squared magnitude of the 4D vector.
virtual void SetMatrixProduct(const Vector4 &p_a, const float *p_b)
[AI] Set this vector to result of matrix-vector product with source given as Vector4,...
void MulImpl(const float &p_value) override
[AI] Multiplies this vector by a scalar value.
float & operator[](int idx)
[AI] Indexes 0-3: returns reference to the fast access coordinate.
Definition: vector.h:470
void DivImpl(const float &p_value) override
[AI] Divides this vector by a scalar value.