| 52 | } |
| 53 | |
| 54 | inline void expand_to(const Vector2& p_vector) |
| 55 | { // In place function for speed. |
| 56 | #ifdef MATH_CHECKS |
| 57 | if (unlikely(size.x < 0 || size.y < 0)) |
| 58 | { |
| 59 | ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); |
| 60 | } |
| 61 | #endif |
| 62 | Vector2 begin = position; |
| 63 | Vector2 end = position + size; |
| 64 | |
| 65 | if (p_vector.x < begin.x) |
| 66 | { |
| 67 | begin.x = p_vector.x; |
| 68 | } |
| 69 | if (p_vector.y < begin.y) |
| 70 | { |
| 71 | begin.y = p_vector.y; |
| 72 | } |
| 73 | |
| 74 | if (p_vector.x > end.x) |
| 75 | { |
| 76 | end.x = p_vector.x; |
| 77 | } |
| 78 | if (p_vector.y > end.y) |
| 79 | { |
| 80 | end.y = p_vector.y; |
| 81 | } |
| 82 | |
| 83 | position = begin; |
| 84 | size = end - begin; |
| 85 | } |
| 86 | }; |
| 87 | } // namespace godot |