summaryrefslogtreecommitdiff
path: root/core/math/rect2.h
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2021-05-10 14:43:13 -0700
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2021-05-10 16:28:55 -0700
commit3877ed73d01bbbf764d0a2756fe6b310ba9dc6f4 (patch)
tree9edd26823e479617f919733d20f950bb54295387 /core/math/rect2.h
parent347737907dbf3118b2d56b73cee5880f2c7ae5d2 (diff)
Dynamic BVH broadphase in 2D & 3D Godot Physics
Port lawnjelly's dynamic BVH implementation from 3.x to be used in both 2D and 3D broadphases. Removed alternative broadphase implementations which are not meant to be used anymore since they are much slower. Includes changes in Rect2, Vector2, Vector3 that help with the template implementation of the dynamic BVH by uniformizing the interface between 2D and 3D math. Co-authored-by: lawnjelly <lawnjelly@gmail.com>
Diffstat (limited to 'core/math/rect2.h')
-rw-r--r--core/math/rect2.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/core/math/rect2.h b/core/math/rect2.h
index 512499bdb2..1dc027cf72 100644
--- a/core/math/rect2.h
+++ b/core/math/rect2.h
@@ -182,13 +182,17 @@ struct Rect2 {
inline Rect2 grow(real_t p_amount) const {
Rect2 g = *this;
- g.position.x -= p_amount;
- g.position.y -= p_amount;
- g.size.width += p_amount * 2;
- g.size.height += p_amount * 2;
+ g.grow_by(p_amount);
return g;
}
+ inline void grow_by(real_t p_amount) {
+ position.x -= p_amount;
+ position.y -= p_amount;
+ size.width += p_amount * 2;
+ size.height += p_amount * 2;
+ }
+
inline Rect2 grow_side(Side p_side, real_t p_amount) const {
Rect2 g = *this;
g = g.grow_individual((SIDE_LEFT == p_side) ? p_amount : 0,