diff options
author | Harvey Harrison <[email protected]> | 2012-01-24 00:14:58 -0800 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2012-01-24 00:14:58 -0800 |
commit | 62ec83df630ecd77f5725169c59dd260fc37b05f (patch) | |
tree | 001f514f8b41f4efa7346e071dc78e8be1a7b270 /src | |
parent | 812718194fe41db01b25d540b7b179b98b4a24ef (diff) |
j3dcore: use the Bounds::getCenter(Point3d) function in the trivial cases
Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src')
4 files changed, 29 insertions, 36 deletions
diff --git a/src/classes/share/javax/media/j3d/CompressedGeometryRetained.java b/src/classes/share/javax/media/j3d/CompressedGeometryRetained.java index 9d2bd98..693c4bb 100644 --- a/src/classes/share/javax/media/j3d/CompressedGeometryRetained.java +++ b/src/classes/share/javax/media/j3d/CompressedGeometryRetained.java @@ -219,7 +219,7 @@ class CompressedGeometryRetained extends GeometryRetained { if (hdr.upperBound != null) this.geoBounds.setUpper(hdr.upperBound) ; - this.centroid.set(geoBounds.getCenter()); + geoBounds.getCenter(this.centroid); recompCentroid = false; this.majorVersionNumber = hdr.majorVersionNumber ; this.minorVersionNumber = hdr.minorVersionNumber ; diff --git a/src/classes/share/javax/media/j3d/GeometryArrayRetained.java b/src/classes/share/javax/media/j3d/GeometryArrayRetained.java index 7b2f666..3605582 100644 --- a/src/classes/share/javax/media/j3d/GeometryArrayRetained.java +++ b/src/classes/share/javax/media/j3d/GeometryArrayRetained.java @@ -504,7 +504,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } synchronized(centroid) { recompCentroid = false; - this.centroid.set(geoBounds.getCenter()); + geoBounds.getCenter(this.centroid); } } @@ -6193,6 +6193,9 @@ abstract class GeometryArrayRetained extends GeometryRetained{ for(i=0; i<4; i++) pCoor[i] = new Point3d(); + Point3d boxCenter = new Point3d(); + box.getCenter(boxCenter); + // left plane. pCoor[0].set(box.lower.x, box.lower.y, box.lower.z); pCoor[1].set(box.lower.x, box.lower.y, box.upper.z); @@ -6202,9 +6205,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ if (intersectPolygon(pCoor, coordinates)) { if (dist != null) { - computeMinDistance(pCoor, box.getCenter(), - null, - dist, iPnt); + computeMinDistance(pCoor, boxCenter, null, dist, iPnt); } return true; } @@ -6216,9 +6217,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ pCoor[3].set(box.upper.x, box.lower.y, box.upper.z); if (intersectPolygon(pCoor, coordinates)) { if (dist != null) { - computeMinDistance(pCoor, box.getCenter(), - null, - dist, iPnt); + computeMinDistance(pCoor, boxCenter, null, dist, iPnt); } return true; } @@ -6230,9 +6229,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ pCoor[3].set(box.upper.x, box.lower.y, box.lower.z); if (intersectPolygon(pCoor, coordinates)) { if (dist != null) { - computeMinDistance(pCoor, box.getCenter(), - null, - dist, iPnt); + computeMinDistance(pCoor, boxCenter, null, dist, iPnt); } return true; } @@ -6243,9 +6240,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ pCoor[3].set(box.lower.x, box.upper.y, box.upper.z); if (intersectPolygon(pCoor, coordinates)) { if (dist != null) { - computeMinDistance(pCoor, box.getCenter(), - null, - dist, iPnt); + computeMinDistance(pCoor, boxCenter, null, dist, iPnt); } return true; } @@ -6257,9 +6252,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ pCoor[3].set(box.upper.x, box.lower.y, box.upper.z); if (intersectPolygon(pCoor, coordinates)) { if (dist != null) { - computeMinDistance(pCoor, box.getCenter(), - null, - dist, iPnt); + computeMinDistance(pCoor, boxCenter, null, dist, iPnt); } return true; } @@ -6271,9 +6264,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ pCoor[3].set(box.lower.x, box.upper.y, box.lower.z); if (intersectPolygon(pCoor, coordinates)) { if (dist != null) { - computeMinDistance(pCoor, box.getCenter(), - null, - dist, iPnt); + computeMinDistance(pCoor, boxCenter, null, dist, iPnt); } return true; } @@ -6428,16 +6419,17 @@ abstract class GeometryArrayRetained extends GeometryRetained{ // we'll handle line separately. if (polytope.intersect( coordinates[0], coordinates[1], tP4d)) { - if (dist != null) { - iPnt.x = tP4d.x; - iPnt.y = tP4d.y; - iPnt.z = tP4d.z; - Point3d pc = polytope.getCenter(); - double x = iPnt.x - pc.x; - double y = iPnt.y - pc.y; - double z = iPnt.z - pc.z; - dist[0] = Math.sqrt(x*x + y*y + z*z); - } + if (dist != null) { + polytope.getCenter(iPnt); + + double x = tP4d.x - iPnt.x; + double y = tP4d.y - iPnt.y; + double z = tP4d.z - iPnt.z; + dist[0] = Math.sqrt(x * x + y * y + z * z); + iPnt.x = tP4d.x; + iPnt.y = tP4d.y; + iPnt.z = tP4d.z; + } return true; } return false; @@ -10672,7 +10664,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ geoBounds.combine(geo.geoBounds); } - this.centroid.set(geoBounds.getCenter()); + geoBounds.getCenter(this.centroid); } boolean isMergeable() { diff --git a/src/classes/share/javax/media/j3d/GeometryAtom.java b/src/classes/share/javax/media/j3d/GeometryAtom.java index dee2158..0651cf2 100644 --- a/src/classes/share/javax/media/j3d/GeometryAtom.java +++ b/src/classes/share/javax/media/j3d/GeometryAtom.java @@ -208,13 +208,14 @@ RenderAtom getRenderAtom(View view) { if (centroid == null) { centroid = new Point3d[geometryArray.length]; for (int j = 0; j < centroid.length; j++) { - centroid[j] = new Point3d(source.localBounds.getCenter()); + centroid[j] = new Point3d(); + source.localBounds.getCenter(centroid[j]); source.getCurrentLocalToVworld(0).transform(centroid[j]); } } else { for (int j = 0; j < centroid.length; j++) { - centroid[j].set(source.localBounds.getCenter()); + source.localBounds.getCenter(centroid[j]); source.getCurrentLocalToVworld(0).transform(centroid[j]); } } diff --git a/src/classes/share/javax/media/j3d/GeometryRetained.java b/src/classes/share/javax/media/j3d/GeometryRetained.java index a7181c9..a1345df 100644 --- a/src/classes/share/javax/media/j3d/GeometryRetained.java +++ b/src/classes/share/javax/media/j3d/GeometryRetained.java @@ -388,9 +388,9 @@ abstract class GeometryRetained extends NodeComponentRetained { } } - void computeCentroid() { - this.centroid.set(geoBounds.getCenter()); - } +void computeCentroid() { + geoBounds.getCenter(this.centroid); +} abstract int getClassType(); |