blob: 31ddc3e8c287b13ac5bb077f968d3f85d0f3d462 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
package NET.worlds.scape;
public class BoundBoxTemp {
private static Recycler recycler = new Recycler();
public Point3Temp lo;
public Point3Temp hi;
public static BoundBoxTemp make(Point3Temp a, Point3Temp b) {
BoundBoxTemp t = (BoundBoxTemp)recycler.alloc();
if (t == null) {
recycler.recycle(new BoundBoxTemp());
t = (BoundBoxTemp)recycler.alloc();
}
t.lo = Point3Temp.make(a);
t.hi = Point3Temp.make(b);
if (a.x > b.x) {
t.lo.x = b.x;
t.hi.x = a.x;
}
if (a.y > b.y) {
t.lo.y = b.y;
t.hi.y = a.y;
}
if (a.z > b.z) {
t.lo.z = b.z;
t.hi.z = a.z;
}
return t;
}
public static BoundBoxTemp make(BoundBoxTemp b) {
return make(b.lo, b.hi);
}
private BoundBoxTemp() {
}
public boolean contains(Point3Temp p) {
return p.x >= this.lo.x && p.x <= this.hi.x && p.y >= this.lo.y && p.y <= this.hi.y && p.z >= this.lo.z && p.z <= this.hi.z;
}
public boolean isEmpty() {
return this.lo.x == this.hi.x && this.lo.y == this.hi.y && this.lo.z == this.hi.z;
}
public boolean overlaps(BoundBoxTemp r) {
return !(this.hi.x < r.lo.x) && !(r.hi.x < this.lo.x) && !(this.hi.y < r.lo.y) && !(r.hi.y < this.lo.y) && !(this.hi.z < r.lo.z) && !(r.hi.z < this.lo.z);
}
public void encompass(Point3Temp p) {
if (p.x < this.lo.x) {
this.lo.x = p.x;
}
if (p.y < this.lo.y) {
this.lo.y = p.y;
}
if (p.z < this.lo.z) {
this.lo.z = p.z;
}
if (p.x > this.hi.x) {
this.hi.x = p.x;
}
if (p.y > this.hi.y) {
this.hi.y = p.y;
}
if (p.z > this.hi.z) {
this.hi.z = p.z;
}
}
@Override
public String toString() {
return "BoundBoxTemp[lo=" + this.lo + ", hi=" + this.hi + "]";
}
}
|