mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-12 16:15:20 +02:00
Add spatial index for objects (#14631)
This commit is contained in:
@@ -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); }
|
||||
|
||||
|
Reference in New Issue
Block a user