summaryrefslogtreecommitdiff
path: root/include/JSystem/JGeometry.h
diff options
context:
space:
mode:
authorlepelog <25211966+lepelog@users.noreply.github.com>2021-12-06 12:57:45 +0100
committerlepelog <25211966+lepelog@users.noreply.github.com>2021-12-06 13:14:13 +0100
commit9da2309be783fd453da060fd3fe1ccd5fbeba8a9 (patch)
tree594952e0140b501010236fd2d864fa179b1a2eb2 /include/JSystem/JGeometry.h
parentc15d8fcb3e91890c3aa779b391258ff9d6ce1e61 (diff)
J2DGrafContext and J2DOrthoGraph
Diffstat (limited to 'include/JSystem/JGeometry.h')
-rw-r--r--include/JSystem/JGeometry.h28
1 files changed, 15 insertions, 13 deletions
diff --git a/include/JSystem/JGeometry.h b/include/JSystem/JGeometry.h
index 2bb4e5f852..0da0a2718b 100644
--- a/include/JSystem/JGeometry.h
+++ b/include/JSystem/JGeometry.h
@@ -51,9 +51,9 @@ struct TVec2 {
}
void setMin(const TVec2<f32>& min) {
- if (min.x <= x)
+ if (x >= min.x)
x = min.x;
- if (min.y <= y)
+ if (y >= min.y)
y = min.y;
}
@@ -70,7 +70,7 @@ struct TVec2 {
}
bool isAbove(const TVec2<T>& other) const {
- return (other.x <= x) && (other.y <= y) ? true : false;
+ return (x >= other.x) && (y >= other.y) ? true : false;
}
T x;
@@ -90,14 +90,6 @@ template<> struct TBox<TVec2<f32> > {
f32 getWidth() const { return f.x - i.x; }
f32 getHeight() const { return f.y - i.y; }
- inline void operator= (const TBox<TVec2<f32> >& rhs) {
- // ???
- *(u32*)&i.x = *(u32*)&rhs.i.x;
- *(u32*)&i.y = *(u32*)&rhs.i.y;
- *(u32*)&f.x = *(u32*)&rhs.f.x;
- *(u32*)&f.y = *(u32*)&rhs.f.y;
- }
-
bool isValid() const { return f.isAbove(i); }
void addPos(const TVec2<f32>& pos) {
@@ -117,9 +109,19 @@ template<> struct TBox<TVec2<f32> > {
template <typename T>
struct TBox2 : TBox<TVec2<T> > {
TBox2() {}
+ TBox2(const TVec2<f32>& i, const TVec2<f32> f) { set(i, f); }
TBox2(f32 x0, f32 y0, f32 x1, f32 y1) { set(x0, y0, x1, y1); }
- inline const TBox2& operator=(const TBox2& rhs) { *(TBox<TVec2<T> >*)this = rhs; }
+ void absolute() {
+ if (!this->isValid()) {
+ TBox2<T> box(*this);
+ this->i.setMin(box.i);
+ this->i.setMin(box.f);
+ this->f.setMax(box.i);
+ this->f.setMax(box.f);
+ }
+ }
+
void set(const TBox2& other) { set(other.i, other.f); }
void set(const TVec2<f32>& i, const TVec2<f32> f) { this->i.set(i), this->f.set(f); }
void set(f32 x0, f32 y0, f32 x1, f32 y1) { i.set(x0, y0); f.set(x1, y1); }
@@ -129,4 +131,4 @@ struct TBox2 : TBox<TVec2<T> > {
} // namespace JGeometry
-#endif \ No newline at end of file
+#endif