|
@@ -207,24 +207,24 @@ struct Transform2D;
|
|
|
|
|
|
struct Rect2 {
|
|
struct Rect2 {
|
|
|
|
|
|
- Point2 pos;
|
|
|
|
|
|
+ Point2 position;
|
|
Size2 size;
|
|
Size2 size;
|
|
|
|
|
|
- const Vector2 &get_pos() const { return pos; }
|
|
|
|
- void set_pos(const Vector2 &p_pos) { pos = p_pos; }
|
|
|
|
|
|
+ const Vector2 &get_position() const { return position; }
|
|
|
|
+ void set_position(const Vector2 &p_pos) { position = p_pos; }
|
|
const Vector2 &get_size() const { return size; }
|
|
const Vector2 &get_size() const { return size; }
|
|
void set_size(const Vector2 &p_size) { size = p_size; }
|
|
void set_size(const Vector2 &p_size) { size = p_size; }
|
|
|
|
|
|
real_t get_area() const { return size.width * size.height; }
|
|
real_t get_area() const { return size.width * size.height; }
|
|
|
|
|
|
inline bool intersects(const Rect2 &p_rect) const {
|
|
inline bool intersects(const Rect2 &p_rect) const {
|
|
- if (pos.x >= (p_rect.pos.x + p_rect.size.width))
|
|
|
|
|
|
+ if (position.x >= (p_rect.position.x + p_rect.size.width))
|
|
return false;
|
|
return false;
|
|
- if ((pos.x + size.width) <= p_rect.pos.x)
|
|
|
|
|
|
+ if ((position.x + size.width) <= p_rect.position.x)
|
|
return false;
|
|
return false;
|
|
- if (pos.y >= (p_rect.pos.y + p_rect.size.height))
|
|
|
|
|
|
+ if (position.y >= (p_rect.position.y + p_rect.size.height))
|
|
return false;
|
|
return false;
|
|
- if ((pos.y + size.height) <= p_rect.pos.y)
|
|
|
|
|
|
+ if ((position.y + size.height) <= p_rect.position.y)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
return true;
|
|
return true;
|
|
@@ -234,17 +234,17 @@ struct Rect2 {
|
|
|
|
|
|
real_t dist = 1e20;
|
|
real_t dist = 1e20;
|
|
|
|
|
|
- if (p_point.x < pos.x) {
|
|
|
|
- dist = MIN(dist, pos.x - p_point.x);
|
|
|
|
|
|
+ if (p_point.x < position.x) {
|
|
|
|
+ dist = MIN(dist, position.x - p_point.x);
|
|
}
|
|
}
|
|
- if (p_point.y < pos.y) {
|
|
|
|
- dist = MIN(dist, pos.y - p_point.y);
|
|
|
|
|
|
+ if (p_point.y < position.y) {
|
|
|
|
+ dist = MIN(dist, position.y - p_point.y);
|
|
}
|
|
}
|
|
- if (p_point.x >= (pos.x + size.x)) {
|
|
|
|
- dist = MIN(p_point.x - (pos.x + size.x), dist);
|
|
|
|
|
|
+ if (p_point.x >= (position.x + size.x)) {
|
|
|
|
+ dist = MIN(p_point.x - (position.x + size.x), dist);
|
|
}
|
|
}
|
|
- if (p_point.y >= (pos.y + size.y)) {
|
|
|
|
- dist = MIN(p_point.y - (pos.y + size.y), dist);
|
|
|
|
|
|
+ if (p_point.y >= (position.y + size.y)) {
|
|
|
|
+ dist = MIN(p_point.y - (position.y + size.y), dist);
|
|
}
|
|
}
|
|
|
|
|
|
if (dist == 1e20)
|
|
if (dist == 1e20)
|
|
@@ -259,9 +259,9 @@ struct Rect2 {
|
|
|
|
|
|
inline bool encloses(const Rect2 &p_rect) const {
|
|
inline bool encloses(const Rect2 &p_rect) const {
|
|
|
|
|
|
- return (p_rect.pos.x >= pos.x) && (p_rect.pos.y >= pos.y) &&
|
|
|
|
- ((p_rect.pos.x + p_rect.size.x) < (pos.x + size.x)) &&
|
|
|
|
- ((p_rect.pos.y + p_rect.size.y) < (pos.y + size.y));
|
|
|
|
|
|
+ return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) &&
|
|
|
|
+ ((p_rect.position.x + p_rect.size.x) < (position.x + size.x)) &&
|
|
|
|
+ ((p_rect.position.y + p_rect.size.y) < (position.y + size.y));
|
|
}
|
|
}
|
|
|
|
|
|
inline bool has_no_area() const {
|
|
inline bool has_no_area() const {
|
|
@@ -275,14 +275,14 @@ struct Rect2 {
|
|
if (!intersects(new_rect))
|
|
if (!intersects(new_rect))
|
|
return Rect2();
|
|
return Rect2();
|
|
|
|
|
|
- new_rect.pos.x = MAX(p_rect.pos.x, pos.x);
|
|
|
|
- new_rect.pos.y = MAX(p_rect.pos.y, pos.y);
|
|
|
|
|
|
+ new_rect.position.x = MAX(p_rect.position.x, position.x);
|
|
|
|
+ new_rect.position.y = MAX(p_rect.position.y, position.y);
|
|
|
|
|
|
- Point2 p_rect_end = p_rect.pos + p_rect.size;
|
|
|
|
- Point2 end = pos + size;
|
|
|
|
|
|
+ Point2 p_rect_end = p_rect.position + p_rect.size;
|
|
|
|
+ Point2 end = position + size;
|
|
|
|
|
|
- new_rect.size.x = MIN(p_rect_end.x, end.x) - new_rect.pos.x;
|
|
|
|
- new_rect.size.y = MIN(p_rect_end.y, end.y) - new_rect.pos.y;
|
|
|
|
|
|
+ new_rect.size.x = MIN(p_rect_end.x, end.x) - new_rect.position.x;
|
|
|
|
+ new_rect.size.y = MIN(p_rect_end.y, end.y) - new_rect.position.y;
|
|
|
|
|
|
return new_rect;
|
|
return new_rect;
|
|
}
|
|
}
|
|
@@ -291,25 +291,25 @@ struct Rect2 {
|
|
|
|
|
|
Rect2 new_rect;
|
|
Rect2 new_rect;
|
|
|
|
|
|
- new_rect.pos.x = MIN(p_rect.pos.x, pos.x);
|
|
|
|
- new_rect.pos.y = MIN(p_rect.pos.y, pos.y);
|
|
|
|
|
|
+ new_rect.position.x = MIN(p_rect.position.x, position.x);
|
|
|
|
+ new_rect.position.y = MIN(p_rect.position.y, position.y);
|
|
|
|
|
|
- new_rect.size.x = MAX(p_rect.pos.x + p_rect.size.x, pos.x + size.x);
|
|
|
|
- new_rect.size.y = MAX(p_rect.pos.y + p_rect.size.y, pos.y + size.y);
|
|
|
|
|
|
+ new_rect.size.x = MAX(p_rect.position.x + p_rect.size.x, position.x + size.x);
|
|
|
|
+ new_rect.size.y = MAX(p_rect.position.y + p_rect.size.y, position.y + size.y);
|
|
|
|
|
|
- new_rect.size = new_rect.size - new_rect.pos; //make relative again
|
|
|
|
|
|
+ new_rect.size = new_rect.size - new_rect.position; //make relative again
|
|
|
|
|
|
return new_rect;
|
|
return new_rect;
|
|
};
|
|
};
|
|
inline bool has_point(const Point2 &p_point) const {
|
|
inline bool has_point(const Point2 &p_point) const {
|
|
- if (p_point.x < pos.x)
|
|
|
|
|
|
+ if (p_point.x < position.x)
|
|
return false;
|
|
return false;
|
|
- if (p_point.y < pos.y)
|
|
|
|
|
|
+ if (p_point.y < position.y)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
- if (p_point.x >= (pos.x + size.x))
|
|
|
|
|
|
+ if (p_point.x >= (position.x + size.x))
|
|
return false;
|
|
return false;
|
|
- if (p_point.y >= (pos.y + size.y))
|
|
|
|
|
|
+ if (p_point.y >= (position.y + size.y))
|
|
return false;
|
|
return false;
|
|
|
|
|
|
return true;
|
|
return true;
|
|
@@ -317,14 +317,14 @@ struct Rect2 {
|
|
|
|
|
|
inline bool no_area() const { return (size.width <= 0 || size.height <= 0); }
|
|
inline bool no_area() const { return (size.width <= 0 || size.height <= 0); }
|
|
|
|
|
|
- bool operator==(const Rect2 &p_rect) const { return pos == p_rect.pos && size == p_rect.size; }
|
|
|
|
- bool operator!=(const Rect2 &p_rect) const { return pos != p_rect.pos || size != p_rect.size; }
|
|
|
|
|
|
+ bool operator==(const Rect2 &p_rect) const { return position == p_rect.position && size == p_rect.size; }
|
|
|
|
+ bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; }
|
|
|
|
|
|
inline Rect2 grow(real_t p_by) const {
|
|
inline Rect2 grow(real_t p_by) const {
|
|
|
|
|
|
Rect2 g = *this;
|
|
Rect2 g = *this;
|
|
- g.pos.x -= p_by;
|
|
|
|
- g.pos.y -= p_by;
|
|
|
|
|
|
+ g.position.x -= p_by;
|
|
|
|
+ g.position.y -= p_by;
|
|
g.size.width += p_by * 2;
|
|
g.size.width += p_by * 2;
|
|
g.size.height += p_by * 2;
|
|
g.size.height += p_by * 2;
|
|
return g;
|
|
return g;
|
|
@@ -339,8 +339,8 @@ struct Rect2 {
|
|
|
|
|
|
inline void expand_to(const Vector2 &p_vector) { //in place function for speed
|
|
inline void expand_to(const Vector2 &p_vector) { //in place function for speed
|
|
|
|
|
|
- Vector2 begin = pos;
|
|
|
|
- Vector2 end = pos + size;
|
|
|
|
|
|
+ Vector2 begin = position;
|
|
|
|
+ Vector2 end = position + size;
|
|
|
|
|
|
if (p_vector.x < begin.x)
|
|
if (p_vector.x < begin.x)
|
|
begin.x = p_vector.x;
|
|
begin.x = p_vector.x;
|
|
@@ -352,19 +352,19 @@ struct Rect2 {
|
|
if (p_vector.y > end.y)
|
|
if (p_vector.y > end.y)
|
|
end.y = p_vector.y;
|
|
end.y = p_vector.y;
|
|
|
|
|
|
- pos = begin;
|
|
|
|
|
|
+ position = begin;
|
|
size = end - begin;
|
|
size = end - begin;
|
|
}
|
|
}
|
|
|
|
|
|
- operator String() const { return String(pos) + ", " + String(size); }
|
|
|
|
|
|
+ operator String() const { return String(position) + ", " + String(size); }
|
|
|
|
|
|
Rect2() {}
|
|
Rect2() {}
|
|
Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height) {
|
|
Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height) {
|
|
- pos = Point2(p_x, p_y);
|
|
|
|
|
|
+ position = Point2(p_x, p_y);
|
|
size = Size2(p_width, p_height);
|
|
size = Size2(p_width, p_height);
|
|
}
|
|
}
|
|
Rect2(const Point2 &p_pos, const Size2 &p_size) {
|
|
Rect2(const Point2 &p_pos, const Size2 &p_size) {
|
|
- pos = p_pos;
|
|
|
|
|
|
+ position = p_pos;
|
|
size = p_size;
|
|
size = p_size;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -434,24 +434,24 @@ typedef Point2i Size2i;
|
|
|
|
|
|
struct Rect2i {
|
|
struct Rect2i {
|
|
|
|
|
|
- Point2i pos;
|
|
|
|
|
|
+ Point2i position;
|
|
Size2i size;
|
|
Size2i size;
|
|
|
|
|
|
- const Point2i &get_pos() const { return pos; }
|
|
|
|
- void set_pos(const Point2i &p_pos) { pos = p_pos; }
|
|
|
|
|
|
+ const Point2i &get_position() const { return position; }
|
|
|
|
+ void set_position(const Point2i &p_pos) { position = p_pos; }
|
|
const Point2i &get_size() const { return size; }
|
|
const Point2i &get_size() const { return size; }
|
|
void set_size(const Point2i &p_size) { size = p_size; }
|
|
void set_size(const Point2i &p_size) { size = p_size; }
|
|
|
|
|
|
int get_area() const { return size.width * size.height; }
|
|
int get_area() const { return size.width * size.height; }
|
|
|
|
|
|
inline bool intersects(const Rect2i &p_rect) const {
|
|
inline bool intersects(const Rect2i &p_rect) const {
|
|
- if (pos.x > (p_rect.pos.x + p_rect.size.width))
|
|
|
|
|
|
+ if (position.x > (p_rect.position.x + p_rect.size.width))
|
|
return false;
|
|
return false;
|
|
- if ((pos.x + size.width) < p_rect.pos.x)
|
|
|
|
|
|
+ if ((position.x + size.width) < p_rect.position.x)
|
|
return false;
|
|
return false;
|
|
- if (pos.y > (p_rect.pos.y + p_rect.size.height))
|
|
|
|
|
|
+ if (position.y > (p_rect.position.y + p_rect.size.height))
|
|
return false;
|
|
return false;
|
|
- if ((pos.y + size.height) < p_rect.pos.y)
|
|
|
|
|
|
+ if ((position.y + size.height) < p_rect.position.y)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
return true;
|
|
return true;
|
|
@@ -459,9 +459,9 @@ struct Rect2i {
|
|
|
|
|
|
inline bool encloses(const Rect2i &p_rect) const {
|
|
inline bool encloses(const Rect2i &p_rect) const {
|
|
|
|
|
|
- return (p_rect.pos.x >= pos.x) && (p_rect.pos.y >= pos.y) &&
|
|
|
|
- ((p_rect.pos.x + p_rect.size.x) < (pos.x + size.x)) &&
|
|
|
|
- ((p_rect.pos.y + p_rect.size.y) < (pos.y + size.y));
|
|
|
|
|
|
+ return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) &&
|
|
|
|
+ ((p_rect.position.x + p_rect.size.x) < (position.x + size.x)) &&
|
|
|
|
+ ((p_rect.position.y + p_rect.size.y) < (position.y + size.y));
|
|
}
|
|
}
|
|
|
|
|
|
inline bool has_no_area() const {
|
|
inline bool has_no_area() const {
|
|
@@ -475,14 +475,14 @@ struct Rect2i {
|
|
if (!intersects(new_rect))
|
|
if (!intersects(new_rect))
|
|
return Rect2i();
|
|
return Rect2i();
|
|
|
|
|
|
- new_rect.pos.x = MAX(p_rect.pos.x, pos.x);
|
|
|
|
- new_rect.pos.y = MAX(p_rect.pos.y, pos.y);
|
|
|
|
|
|
+ new_rect.position.x = MAX(p_rect.position.x, position.x);
|
|
|
|
+ new_rect.position.y = MAX(p_rect.position.y, position.y);
|
|
|
|
|
|
- Point2 p_rect_end = p_rect.pos + p_rect.size;
|
|
|
|
- Point2 end = pos + size;
|
|
|
|
|
|
+ Point2 p_rect_end = p_rect.position + p_rect.size;
|
|
|
|
+ Point2 end = position + size;
|
|
|
|
|
|
- new_rect.size.x = (int)(MIN(p_rect_end.x, end.x) - new_rect.pos.x);
|
|
|
|
- new_rect.size.y = (int)(MIN(p_rect_end.y, end.y) - new_rect.pos.y);
|
|
|
|
|
|
+ new_rect.size.x = (int)(MIN(p_rect_end.x, end.x) - new_rect.position.x);
|
|
|
|
+ new_rect.size.y = (int)(MIN(p_rect_end.y, end.y) - new_rect.position.y);
|
|
|
|
|
|
return new_rect;
|
|
return new_rect;
|
|
}
|
|
}
|
|
@@ -491,25 +491,25 @@ struct Rect2i {
|
|
|
|
|
|
Rect2i new_rect;
|
|
Rect2i new_rect;
|
|
|
|
|
|
- new_rect.pos.x = MIN(p_rect.pos.x, pos.x);
|
|
|
|
- new_rect.pos.y = MIN(p_rect.pos.y, pos.y);
|
|
|
|
|
|
+ new_rect.position.x = MIN(p_rect.position.x, position.x);
|
|
|
|
+ new_rect.position.y = MIN(p_rect.position.y, position.y);
|
|
|
|
|
|
- new_rect.size.x = MAX(p_rect.pos.x + p_rect.size.x, pos.x + size.x);
|
|
|
|
- new_rect.size.y = MAX(p_rect.pos.y + p_rect.size.y, pos.y + size.y);
|
|
|
|
|
|
+ new_rect.size.x = MAX(p_rect.position.x + p_rect.size.x, position.x + size.x);
|
|
|
|
+ new_rect.size.y = MAX(p_rect.position.y + p_rect.size.y, position.y + size.y);
|
|
|
|
|
|
- new_rect.size = new_rect.size - new_rect.pos; //make relative again
|
|
|
|
|
|
+ new_rect.size = new_rect.size - new_rect.position; //make relative again
|
|
|
|
|
|
return new_rect;
|
|
return new_rect;
|
|
};
|
|
};
|
|
bool has_point(const Point2 &p_point) const {
|
|
bool has_point(const Point2 &p_point) const {
|
|
- if (p_point.x < pos.x)
|
|
|
|
|
|
+ if (p_point.x < position.x)
|
|
return false;
|
|
return false;
|
|
- if (p_point.y < pos.y)
|
|
|
|
|
|
+ if (p_point.y < position.y)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
- if (p_point.x >= (pos.x + size.x))
|
|
|
|
|
|
+ if (p_point.x >= (position.x + size.x))
|
|
return false;
|
|
return false;
|
|
- if (p_point.y >= (pos.y + size.y))
|
|
|
|
|
|
+ if (p_point.y >= (position.y + size.y))
|
|
return false;
|
|
return false;
|
|
|
|
|
|
return true;
|
|
return true;
|
|
@@ -517,14 +517,14 @@ struct Rect2i {
|
|
|
|
|
|
bool no_area() { return (size.width <= 0 || size.height <= 0); }
|
|
bool no_area() { return (size.width <= 0 || size.height <= 0); }
|
|
|
|
|
|
- bool operator==(const Rect2i &p_rect) const { return pos == p_rect.pos && size == p_rect.size; }
|
|
|
|
- bool operator!=(const Rect2i &p_rect) const { return pos != p_rect.pos || size != p_rect.size; }
|
|
|
|
|
|
+ bool operator==(const Rect2i &p_rect) const { return position == p_rect.position && size == p_rect.size; }
|
|
|
|
+ bool operator!=(const Rect2i &p_rect) const { return position != p_rect.position || size != p_rect.size; }
|
|
|
|
|
|
Rect2i grow(int p_by) const {
|
|
Rect2i grow(int p_by) const {
|
|
|
|
|
|
Rect2i g = *this;
|
|
Rect2i g = *this;
|
|
- g.pos.x -= p_by;
|
|
|
|
- g.pos.y -= p_by;
|
|
|
|
|
|
+ g.position.x -= p_by;
|
|
|
|
+ g.position.y -= p_by;
|
|
g.size.width += p_by * 2;
|
|
g.size.width += p_by * 2;
|
|
g.size.height += p_by * 2;
|
|
g.size.height += p_by * 2;
|
|
return g;
|
|
return g;
|
|
@@ -532,8 +532,8 @@ struct Rect2i {
|
|
|
|
|
|
inline void expand_to(const Point2i &p_vector) {
|
|
inline void expand_to(const Point2i &p_vector) {
|
|
|
|
|
|
- Point2i begin = pos;
|
|
|
|
- Point2i end = pos + size;
|
|
|
|
|
|
+ Point2i begin = position;
|
|
|
|
+ Point2i end = position + size;
|
|
|
|
|
|
if (p_vector.x < begin.x)
|
|
if (p_vector.x < begin.x)
|
|
begin.x = p_vector.x;
|
|
begin.x = p_vector.x;
|
|
@@ -545,24 +545,24 @@ struct Rect2i {
|
|
if (p_vector.y > end.y)
|
|
if (p_vector.y > end.y)
|
|
end.y = p_vector.y;
|
|
end.y = p_vector.y;
|
|
|
|
|
|
- pos = begin;
|
|
|
|
|
|
+ position = begin;
|
|
size = end - begin;
|
|
size = end - begin;
|
|
}
|
|
}
|
|
|
|
|
|
- operator String() const { return String(pos) + ", " + String(size); }
|
|
|
|
|
|
+ operator String() const { return String(position) + ", " + String(size); }
|
|
|
|
|
|
- operator Rect2() const { return Rect2(pos, size); }
|
|
|
|
|
|
+ operator Rect2() const { return Rect2(position, size); }
|
|
Rect2i(const Rect2 &p_r2) {
|
|
Rect2i(const Rect2 &p_r2) {
|
|
- pos = p_r2.pos;
|
|
|
|
|
|
+ position = p_r2.position;
|
|
size = p_r2.size;
|
|
size = p_r2.size;
|
|
}
|
|
}
|
|
Rect2i() {}
|
|
Rect2i() {}
|
|
Rect2i(int p_x, int p_y, int p_width, int p_height) {
|
|
Rect2i(int p_x, int p_y, int p_width, int p_height) {
|
|
- pos = Point2(p_x, p_y);
|
|
|
|
|
|
+ position = Point2(p_x, p_y);
|
|
size = Size2(p_width, p_height);
|
|
size = Size2(p_width, p_height);
|
|
}
|
|
}
|
|
Rect2i(const Point2 &p_pos, const Size2 &p_size) {
|
|
Rect2i(const Point2 &p_pos, const Size2 &p_size) {
|
|
- pos = p_pos;
|
|
|
|
|
|
+ position = p_pos;
|
|
size = p_size;
|
|
size = p_size;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -668,30 +668,30 @@ bool Rect2::intersects_transformed(const Transform2D &p_xform, const Rect2 &p_re
|
|
//SAT intersection between local and transformed rect2
|
|
//SAT intersection between local and transformed rect2
|
|
|
|
|
|
Vector2 xf_points[4] = {
|
|
Vector2 xf_points[4] = {
|
|
- p_xform.xform(p_rect.pos),
|
|
|
|
- p_xform.xform(Vector2(p_rect.pos.x + p_rect.size.x, p_rect.pos.y)),
|
|
|
|
- p_xform.xform(Vector2(p_rect.pos.x, p_rect.pos.y + p_rect.size.y)),
|
|
|
|
- p_xform.xform(Vector2(p_rect.pos.x + p_rect.size.x, p_rect.pos.y + p_rect.size.y)),
|
|
|
|
|
|
+ p_xform.xform(p_rect.position),
|
|
|
|
+ p_xform.xform(Vector2(p_rect.position.x + p_rect.size.x, p_rect.position.y)),
|
|
|
|
+ p_xform.xform(Vector2(p_rect.position.x, p_rect.position.y + p_rect.size.y)),
|
|
|
|
+ p_xform.xform(Vector2(p_rect.position.x + p_rect.size.x, p_rect.position.y + p_rect.size.y)),
|
|
};
|
|
};
|
|
|
|
|
|
real_t low_limit;
|
|
real_t low_limit;
|
|
|
|
|
|
//base rect2 first (faster)
|
|
//base rect2 first (faster)
|
|
|
|
|
|
- if (xf_points[0].y > pos.y)
|
|
|
|
|
|
+ if (xf_points[0].y > position.y)
|
|
goto next1;
|
|
goto next1;
|
|
- if (xf_points[1].y > pos.y)
|
|
|
|
|
|
+ if (xf_points[1].y > position.y)
|
|
goto next1;
|
|
goto next1;
|
|
- if (xf_points[2].y > pos.y)
|
|
|
|
|
|
+ if (xf_points[2].y > position.y)
|
|
goto next1;
|
|
goto next1;
|
|
- if (xf_points[3].y > pos.y)
|
|
|
|
|
|
+ if (xf_points[3].y > position.y)
|
|
goto next1;
|
|
goto next1;
|
|
|
|
|
|
return false;
|
|
return false;
|
|
|
|
|
|
next1:
|
|
next1:
|
|
|
|
|
|
- low_limit = pos.y + size.y;
|
|
|
|
|
|
+ low_limit = position.y + size.y;
|
|
|
|
|
|
if (xf_points[0].y < low_limit)
|
|
if (xf_points[0].y < low_limit)
|
|
goto next2;
|
|
goto next2;
|
|
@@ -706,20 +706,20 @@ next1:
|
|
|
|
|
|
next2:
|
|
next2:
|
|
|
|
|
|
- if (xf_points[0].x > pos.x)
|
|
|
|
|
|
+ if (xf_points[0].x > position.x)
|
|
goto next3;
|
|
goto next3;
|
|
- if (xf_points[1].x > pos.x)
|
|
|
|
|
|
+ if (xf_points[1].x > position.x)
|
|
goto next3;
|
|
goto next3;
|
|
- if (xf_points[2].x > pos.x)
|
|
|
|
|
|
+ if (xf_points[2].x > position.x)
|
|
goto next3;
|
|
goto next3;
|
|
- if (xf_points[3].x > pos.x)
|
|
|
|
|
|
+ if (xf_points[3].x > position.x)
|
|
goto next3;
|
|
goto next3;
|
|
|
|
|
|
return false;
|
|
return false;
|
|
|
|
|
|
next3:
|
|
next3:
|
|
|
|
|
|
- low_limit = pos.x + size.x;
|
|
|
|
|
|
+ low_limit = position.x + size.x;
|
|
|
|
|
|
if (xf_points[0].x < low_limit)
|
|
if (xf_points[0].x < low_limit)
|
|
goto next4;
|
|
goto next4;
|
|
@@ -735,10 +735,10 @@ next3:
|
|
next4:
|
|
next4:
|
|
|
|
|
|
Vector2 xf_points2[4] = {
|
|
Vector2 xf_points2[4] = {
|
|
- pos,
|
|
|
|
- Vector2(pos.x + size.x, pos.y),
|
|
|
|
- Vector2(pos.x, pos.y + size.y),
|
|
|
|
- Vector2(pos.x + size.x, pos.y + size.y),
|
|
|
|
|
|
+ position,
|
|
|
|
+ Vector2(position.x + size.x, position.y),
|
|
|
|
+ Vector2(position.x, position.y + size.y),
|
|
|
|
+ Vector2(position.x + size.x, position.y + size.y),
|
|
};
|
|
};
|
|
|
|
|
|
real_t maxa = p_xform.elements[0].dot(xf_points2[0]);
|
|
real_t maxa = p_xform.elements[0].dot(xf_points2[0]);
|
|
@@ -847,10 +847,10 @@ Rect2 Transform2D::xform(const Rect2 &p_rect) const {
|
|
|
|
|
|
Vector2 x = elements[0] * p_rect.size.x;
|
|
Vector2 x = elements[0] * p_rect.size.x;
|
|
Vector2 y = elements[1] * p_rect.size.y;
|
|
Vector2 y = elements[1] * p_rect.size.y;
|
|
- Vector2 pos = xform(p_rect.pos);
|
|
|
|
|
|
+ Vector2 pos = xform(p_rect.position);
|
|
|
|
|
|
Rect2 new_rect;
|
|
Rect2 new_rect;
|
|
- new_rect.pos = pos;
|
|
|
|
|
|
+ new_rect.position = pos;
|
|
new_rect.expand_to(pos + x);
|
|
new_rect.expand_to(pos + x);
|
|
new_rect.expand_to(pos + y);
|
|
new_rect.expand_to(pos + y);
|
|
new_rect.expand_to(pos + x + y);
|
|
new_rect.expand_to(pos + x + y);
|
|
@@ -868,14 +868,14 @@ void Transform2D::set_rotation_and_scale(real_t p_rot, const Size2 &p_scale) {
|
|
Rect2 Transform2D::xform_inv(const Rect2 &p_rect) const {
|
|
Rect2 Transform2D::xform_inv(const Rect2 &p_rect) const {
|
|
|
|
|
|
Vector2 ends[4] = {
|
|
Vector2 ends[4] = {
|
|
- xform_inv(p_rect.pos),
|
|
|
|
- xform_inv(Vector2(p_rect.pos.x, p_rect.pos.y + p_rect.size.y)),
|
|
|
|
- xform_inv(Vector2(p_rect.pos.x + p_rect.size.x, p_rect.pos.y + p_rect.size.y)),
|
|
|
|
- xform_inv(Vector2(p_rect.pos.x + p_rect.size.x, p_rect.pos.y))
|
|
|
|
|
|
+ xform_inv(p_rect.position),
|
|
|
|
+ xform_inv(Vector2(p_rect.position.x, p_rect.position.y + p_rect.size.y)),
|
|
|
|
+ xform_inv(Vector2(p_rect.position.x + p_rect.size.x, p_rect.position.y + p_rect.size.y)),
|
|
|
|
+ xform_inv(Vector2(p_rect.position.x + p_rect.size.x, p_rect.position.y))
|
|
};
|
|
};
|
|
|
|
|
|
Rect2 new_rect;
|
|
Rect2 new_rect;
|
|
- new_rect.pos = ends[0];
|
|
|
|
|
|
+ new_rect.position = ends[0];
|
|
new_rect.expand_to(ends[1]);
|
|
new_rect.expand_to(ends[1]);
|
|
new_rect.expand_to(ends[2]);
|
|
new_rect.expand_to(ends[2]);
|
|
new_rect.expand_to(ends[3]);
|
|
new_rect.expand_to(ends[3]);
|