mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Add length and length_squared to Vector2i/3i
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#ifndef VECTOR3I_H
|
||||
#define VECTOR3I_H
|
||||
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/typedefs.h"
|
||||
|
||||
@@ -65,6 +66,9 @@ struct Vector3i {
|
||||
Vector3i::Axis min_axis_index() const;
|
||||
Vector3i::Axis max_axis_index() const;
|
||||
|
||||
_FORCE_INLINE_ int64_t length_squared() const;
|
||||
_FORCE_INLINE_ double length() const;
|
||||
|
||||
_FORCE_INLINE_ void zero();
|
||||
|
||||
_FORCE_INLINE_ Vector3i abs() const;
|
||||
@@ -110,6 +114,14 @@ struct Vector3i {
|
||||
}
|
||||
};
|
||||
|
||||
int64_t Vector3i::length_squared() const {
|
||||
return x * (int64_t)x + y * (int64_t)y + z * (int64_t)z;
|
||||
}
|
||||
|
||||
double Vector3i::length() const {
|
||||
return Math::sqrt((double)length_squared());
|
||||
}
|
||||
|
||||
Vector3i Vector3i::abs() const {
|
||||
return Vector3i(ABS(x), ABS(y), ABS(z));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user