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>
This commit is contained in:
PouleyKetchoupp
2021-05-10 14:43:13 -07:00
parent 347737907d
commit 3877ed73d0
33 changed files with 3731 additions and 1534 deletions

View File

@@ -37,18 +37,26 @@
struct Vector2i;
struct Vector2 {
static const int AXIS_COUNT = 2;
enum Axis {
AXIS_X,
AXIS_Y,
};
union {
real_t x = 0;
real_t width;
};
union {
real_t y = 0;
real_t height;
struct {
union {
real_t x;
real_t width;
};
union {
real_t y;
real_t height;
};
};
real_t coord[2] = { 0 };
};
_FORCE_INLINE_ real_t &operator[](int p_idx) {
@@ -58,6 +66,18 @@ struct Vector2 {
return p_idx ? y : x;
}
_FORCE_INLINE_ void set_all(real_t p_value) {
x = y = p_value;
}
_FORCE_INLINE_ int min_axis() const {
return x < y ? 0 : 1;
}
_FORCE_INLINE_ int max_axis() const {
return x < y ? 1 : 0;
}
void normalize();
Vector2 normalized() const;
bool is_normalized() const;