aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-11-11 08:18:36 +0100
committerSven Gothel <[email protected]>2012-11-11 08:18:36 +0100
commit802e80af821efbd20469d1e5b2157a9443dde0d9 (patch)
tree4cfb6d918e4a2e3170e885d53a1e8495c7ff039e
parent241f3bfdbbec655130234601652d88c30269fde4 (diff)
AABBox: Add public direct setSize(..), skipping redundant reset() / resize(..)
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
index 4cd5b31e2..b6e8ede2e 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
@@ -58,13 +58,8 @@ public class AABBox implements Cloneable {
* @param hz max z-coordinate
*/
public AABBox(float lx, float ly, float lz,
- float hx, float hy, float hz)
- {
- reset();
- resize(lx, ly, lz);
- resize(hx, hy, hz);
-
- computeCenter();
+ float hx, float hy, float hz) {
+ setSize(lx, ly, lz, hx, hy, hz);
}
/** Create a AABBox defining the low and high
@@ -72,11 +67,7 @@ public class AABBox implements Cloneable {
* @param high max xyz-coordinates
*/
public AABBox(float[] low, float[] high) {
- reset();
- resize(low[0],low[1],low[2]);
- resize(high[0],high[1],high[2]);
-
- computeCenter();
+ setSize(low[0],low[1],low[2], high[0],high[1],high[2]);
}
/** resets this box to the inverse low/high, allowing the next {@link #resize(float, float, float)} command to hit. */
@@ -114,6 +105,34 @@ public class AABBox implements Cloneable {
this.low[2] = lz;
}
+ private final void computeCenter() {
+ center[0] = (high[0] + low[0])/2;
+ center[1] = (high[1] + low[1])/2;
+ center[2] = (high[2] + low[2])/2;
+ }
+
+ /**
+ * Set size of the AABBox specifying the coordinates
+ * of the low and high.
+ *
+ * @param lx min x-coordinate
+ * @param ly min y-coordnate
+ * @param lz min z-coordinate
+ * @param hx max x-coordinate
+ * @param hy max y-coordinate
+ * @param hz max z-coordinate
+ */
+ public final void setSize(float lx, float ly, float lz,
+ float hx, float hy, float hz) {
+ this.low[0] = lx;
+ this.low[1] = ly;
+ this.low[2] = lz;
+ this.high[0] = hx;
+ this.high[1] = hy;
+ this.high[2] = hz;
+ computeCenter();
+ }
+
/** Resize the AABBox to encapsulate another AABox
* @param newBox AABBox to be encapsulated in
*/
@@ -140,12 +159,6 @@ public class AABBox implements Cloneable {
computeCenter();
}
- private final void computeCenter() {
- center[0] = (high[0] + low[0])/2;
- center[1] = (high[1] + low[1])/2;
- center[2] = (high[2] + low[2])/2;
- }
-
/** Resize the AABBox to encapsulate the passed
* xyz-coordinates.
* @param x x-axis coordinate value