Merge pull request #52878 from AnilBK/add-get-center
This commit is contained in:
commit
ba57252bd8
33 changed files with 133 additions and 56 deletions
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public:
|
|||
}
|
||||
|
||||
float delta_max = MAX(rect.size.width, rect.size.height);
|
||||
Vector2 center = rect.position + rect.size * 0.5;
|
||||
Vector2 center = rect.get_center();
|
||||
|
||||
points.push_back(Vector2(center.x - 20 * delta_max, center.y - delta_max));
|
||||
points.push_back(Vector2(center.x, center.y + 20 * delta_max));
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ struct Rect2 {
|
|||
|
||||
real_t get_area() const { return size.width * size.height; }
|
||||
|
||||
_FORCE_INLINE_ Vector2 get_center() const { return position + (size * 0.5); }
|
||||
|
||||
inline bool intersects(const Rect2 &p_rect, const bool p_include_borders = false) const {
|
||||
if (p_include_borders) {
|
||||
if (position.x > (p_rect.position.x + p_rect.size.width)) {
|
||||
|
|
@ -259,7 +261,7 @@ struct Rect2 {
|
|||
}
|
||||
|
||||
_FORCE_INLINE_ bool intersects_filled_polygon(const Vector2 *p_points, int p_point_count) const {
|
||||
Vector2 center = position + size * 0.5;
|
||||
Vector2 center = get_center();
|
||||
int side_plus = 0;
|
||||
int side_minus = 0;
|
||||
Vector2 end = position + size;
|
||||
|
|
@ -344,6 +346,8 @@ struct Rect2i {
|
|||
|
||||
int get_area() const { return size.width * size.height; }
|
||||
|
||||
_FORCE_INLINE_ Vector2i get_center() const { return position + (size / 2); }
|
||||
|
||||
inline bool intersects(const Rect2i &p_rect) const {
|
||||
if (position.x > (p_rect.position.x + p_rect.size.width)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, in
|
|||
int index = r_max_alloc++;
|
||||
BVH *_new = &p_bvh[index];
|
||||
_new->aabb = aabb;
|
||||
_new->center = aabb.position + aabb.size * 0.5;
|
||||
_new->center = aabb.get_center();
|
||||
_new->face_index = -1;
|
||||
_new->left = left;
|
||||
_new->right = right;
|
||||
|
|
@ -152,7 +152,7 @@ void TriangleMesh::create(const Vector<Vector3> &p_faces) {
|
|||
bw[i].left = -1;
|
||||
bw[i].right = -1;
|
||||
bw[i].face_index = i;
|
||||
bw[i].center = bw[i].aabb.position + bw[i].aabb.size * 0.5;
|
||||
bw[i].center = bw[i].aabb.get_center();
|
||||
}
|
||||
|
||||
vertices.resize(db.size());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue