summaryrefslogtreecommitdiff
path: root/core/math/aabb.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/math/aabb.h')
-rw-r--r--core/math/aabb.h22
1 files changed, 13 insertions, 9 deletions
diff --git a/core/math/aabb.h b/core/math/aabb.h
index 24908ae59d..02ce2501a0 100644
--- a/core/math/aabb.h
+++ b/core/math/aabb.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -46,8 +46,8 @@ public:
Vector3 position;
Vector3 size;
- real_t get_area() const; /// get area
- _FORCE_INLINE_ bool has_no_area() const {
+ real_t get_volume() const;
+ _FORCE_INLINE_ bool has_no_volume() const {
return (size.x <= 0 || size.y <= 0 || size.z <= 0);
}
@@ -107,8 +107,8 @@ public:
Variant intersects_segment_bind(const Vector3 &p_from, const Vector3 &p_to) const;
Variant intersects_ray_bind(const Vector3 &p_from, const Vector3 &p_dir) const;
- _FORCE_INLINE_ void quantize(float p_unit);
- _FORCE_INLINE_ AABB quantized(float p_unit) const;
+ _FORCE_INLINE_ void quantize(real_t p_unit);
+ _FORCE_INLINE_ AABB quantized(real_t p_unit) const;
_FORCE_INLINE_ void set_end(const Vector3 &p_end) {
size = p_end - position;
@@ -118,6 +118,10 @@ public:
return position + size;
}
+ _FORCE_INLINE_ Vector3 get_center() const {
+ return position + (size * 0.5);
+ }
+
operator String() const;
_FORCE_INLINE_ AABB() {}
@@ -196,7 +200,7 @@ Vector3 AABB::get_support(const Vector3 &p_normal) const {
(p_normal.x > 0) ? half_extents.x : -half_extents.x,
(p_normal.y > 0) ? half_extents.y : -half_extents.y,
(p_normal.z > 0) ? half_extents.z : -half_extents.z) +
- ofs;
+ ofs;
}
Vector3 AABB::get_endpoint(int p_point) const {
@@ -430,7 +434,7 @@ void AABB::grow_by(real_t p_amount) {
size.z += 2.0 * p_amount;
}
-void AABB::quantize(float p_unit) {
+void AABB::quantize(real_t p_unit) {
size += position;
position.x -= Math::fposmodp(position.x, p_unit);
@@ -448,7 +452,7 @@ void AABB::quantize(float p_unit) {
size -= position;
}
-AABB AABB::quantized(float p_unit) const {
+AABB AABB::quantized(real_t p_unit) const {
AABB ret = *this;
ret.quantize(p_unit);
return ret;