NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
ut_Rect.h
1#ifndef NW4R_UT_RECT_H
2#define NW4R_UT_RECT_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/math.h>
6
7namespace nw4r {
8namespace ut {
9
10struct Rect {
11 f32 left; // at 0x0
12 f32 top; // at 0x4
13 f32 right; // at 0x8
14 f32 bottom; // at 0xC
15
16 Rect() : left(0.0f), top(0.0f), right(0.0f), bottom(0.0f) {}
17 Rect(f32 l, f32 t, f32 r, f32 b) : left(l), top(t), right(r), bottom(b) {}
18 ~Rect() {}
19
20 void SetWidth(f32 width) {
21 right = left + width;
22 }
23 f32 GetWidth() const {
24 return right - left;
25 }
26
27 void SetHeight(f32 height) {
28 bottom = top + height;
29 }
30 f32 GetHeight() const {
31 return bottom - top;
32 }
33
34 void Normalize() {
35 f32 l = left;
36 f32 t = top;
37 f32 r = right;
38 f32 b = bottom;
39
40 left = math::FSelect(r - l, l, r); // min(r, l)
41 right = math::FSelect(r - l, r, l); // max(r, l)
42 top = math::FSelect(b - t, t, b); // min(b, t)
43 bottom = math::FSelect(b - t, b, t); // max(b, t)
44 }
45
46 void MoveTo(f32 x, f32 y) {
47 right = x + GetWidth();
48 left = x;
49 bottom = y + GetHeight();
50 top = y;
51 }
52};
53
54} // namespace ut
55} // namespace nw4r
56
57#endif
Debugging library which includes various utilities used by the rest of nw4r.
Definition ut_list.cpp:4