From 145862f0370059961084b2f73638822de98e7aad Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Sat, 14 Jan 2012 19:03:02 -0800 Subject: j3dcore: small optimizations in BoundingBox constructors Avoid the calls to updateBoundsStates when we know exactly what bounds we set in the default cases. Also add a check to the (Bounds) constructor for an empty Bounds argument and directly set the empty state. Signed-off-by: Harvey Harrison --- src/classes/share/javax/media/j3d/BoundingBox.java | 61 +++++++++++----------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/src/classes/share/javax/media/j3d/BoundingBox.java b/src/classes/share/javax/media/j3d/BoundingBox.java index c8ce0a9..f102f46 100644 --- a/src/classes/share/javax/media/j3d/BoundingBox.java +++ b/src/classes/share/javax/media/j3d/BoundingBox.java @@ -82,41 +82,41 @@ final Point3d upper; } - /** - * Constructs and initializes a BoundingBox given min,max in x,y,z. - * @param lower the "small" corner - * @param upper the "large" corner - */ - public BoundingBox(Point3d lower, Point3d upper) { +/** + * Constructs and initializes a BoundingBox given min,max in x,y,z. + * @param lower the "small" corner + * @param upper the "large" corner + */ +public BoundingBox(Point3d lower, Point3d upper) { boundId = BOUNDING_BOX; this.lower = new Point3d(lower); this.upper = new Point3d(upper); updateBoundsStates(); - } +} - /** - * Constructs and initializes a 2X bounding box about the - * origin. The lower corner is initialized to (-1.0d, -1.0d, -1.0d) - * and the opper corner is initialized to (1.0d, 1.0d, 1.0d). - */ - public BoundingBox() { +/** + * Constructs and initializes a 2X bounding box about the origin. The lower + * corner is initialized to (-1.0d, -1.0d, -1.0d) and the upper corner is + * initialized to (1.0d, 1.0d, 1.0d). + */ +public BoundingBox() { boundId = BOUNDING_BOX; lower = new Point3d(-1.0d, -1.0d, -1.0d); upper = new Point3d( 1.0d, 1.0d, 1.0d); - updateBoundsStates(); - } + boundsIsEmpty = false; + boundsIsInfinite = false; +} - /** - * Constructs a BoundingBox from a bounding object. - * @param boundsObject a bounds object - */ - public BoundingBox(Bounds boundsObject) { - int i; +/** + * Constructs a BoundingBox from a bounding object. + * @param boundsObject a bounds object + */ +public BoundingBox(Bounds boundsObject) { boundId = BOUNDING_BOX; lower = new Point3d(); upper = new Point3d(); - if (boundsObject == null) { + if (boundsObject == null || boundsObject.boundsIsEmpty) { setEmptyBounds(); return; } @@ -152,7 +152,7 @@ final Point3d upper; lower.set(polytope.verts[0]); upper.set(polytope.verts[0]); - for(i=1;i