1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add spatial index for objects (#14631)

This commit is contained in:
Lars Müller 2025-04-08 08:44:53 +02:00 committed by GitHub
parent bed36139db
commit a3648b0b16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 982 additions and 116 deletions

View file

@ -7,6 +7,7 @@
#include "irrMath.h"
#include <functional>
#include <array>
namespace irr
{
@ -32,6 +33,9 @@ public:
//! Constructor with the same value for all elements
explicit constexpr vector3d(T n) :
X(n), Y(n), Z(n) {}
//! Array - vector conversion
constexpr vector3d(const std::array<T, 3> &arr) :
X(arr[0]), Y(arr[1]), Z(arr[2]) {}
template <class U>
constexpr static vector3d<T> from(const vector3d<U> &other)
@ -187,6 +191,8 @@ public:
return *this;
}
std::array<T, 3> toArray() const { return {X, Y, Z}; }
//! Get length of the vector.
T getLength() const { return core::squareroot(X * X + Y * Y + Z * Z); }