mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user