aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/share
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2004-11-04 22:59:21 +0000
committerChien Yang <[email protected]>2004-11-04 22:59:21 +0000
commit846032c284f4516664dff398f71b3f7f6327281c (patch)
tree7fc7297d4fdb65031f5cd2583e7aea680c4ae39a /src/classes/share
parentea6311a5ff3ccc1acfab62b8a76868c1c5e0c67f (diff)
1) Do not compute cachedFrustum if j3d.viewFrustumCulling is false.
2) Removed an unuse method in CachedFrustum.java. git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@70 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes/share')
-rw-r--r--src/classes/share/javax/media/j3d/CachedFrustum.java131
-rw-r--r--src/classes/share/javax/media/j3d/Canvas3D.java6
2 files changed, 5 insertions, 132 deletions
diff --git a/src/classes/share/javax/media/j3d/CachedFrustum.java b/src/classes/share/javax/media/j3d/CachedFrustum.java
index a034e7d..e4d1df1 100644
--- a/src/classes/share/javax/media/j3d/CachedFrustum.java
+++ b/src/classes/share/javax/media/j3d/CachedFrustum.java
@@ -437,135 +437,4 @@ class CachedFrustum {
}
-
- /**
- * Tests for intersection of six sided hull and the frustum
- * @param six sided bounding box ( lower (x,y,z), upper (x,y,z))
- * @return true if they intersect
- */
- boolean intersect( double lx, double ly, double lz,
- double ux, double uy, double uz) {
- int i,index;
-
- // System.out.println("intersect frustum with box : lower ( " + lx + ", " + ly + ", " + lz +
- // ") upper( " + ux + ", " + uy + ", " + uz + ")");
- // System.out.println("frustum "+this.toString());
- // check if box and bounding box of frustum intersect
- if( ux > this.lower.x &&
- lx < this.upper.x &&
- uy > this.lower.y &&
- ly < this.upper.y &&
- uz > this.lower.z &&
- lz < this.upper.z ) {
- } else {
- // System.out.println("false box and bounding box of frustum do not intersect");
- return false;
- }
-
- // check if all box points out any frustum plane
- for(i=0;i<6;i++){
- if(( ux*this.clipPlanes[i].x +
- uy*this.clipPlanes[i].y +
- uz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue; // corner inside plane
- }
- if(( ux*this.clipPlanes[i].x +
- ly*this.clipPlanes[i].y +
- uz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ){
- continue;
- }
- if(( ux*this.clipPlanes[i].x +
- ly*this.clipPlanes[i].y +
- lz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ){
- continue;
- }
- if(( ux*this.clipPlanes[i].x +
- uy*this.clipPlanes[i].y +
- lz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue;
- }
- if(( lx*this.clipPlanes[i].x +
- uy*this.clipPlanes[i].y +
- uz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue;
- }
- if(( lx*this.clipPlanes[i].x +
- ly*this.clipPlanes[i].y +
- uz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue;
- }
- if(( lx*this.clipPlanes[i].x +
- ly*this.clipPlanes[i].y +
- lz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue;
- }
- if(( lx*this.clipPlanes[i].x +
- uy*this.clipPlanes[i].y +
- lz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue;
- }
- // System.out.println("false all corners outside this frustum plane"+frustum.clipPlanes[i].toString());
- return false; // all corners outside this frustum plane
- }
-
- // check if any box corner is inside of the frustum silhoette edges in the 3 views
- // y-z
- for(i=0;i<this.nxEdges;i++){
- index = this.xEdgeList[i];
- if(( uy*this.xEdges[index].y +
- uz*this.xEdges[index].z + this.xEdges[index].w ) < EPSILON ) break; // corner inside ege
- if(( uy*this.xEdges[index].y +
- lz*this.xEdges[index].z + this.xEdges[index].w ) < EPSILON ) break;
- if(( ly*this.xEdges[index].y +
- uz*this.xEdges[index].z + this.xEdges[index].w ) < EPSILON ) break;
- if(( ly*this.xEdges[index].y +
- lz*this.xEdges[index].z + this.xEdges[index].w ) < EPSILON ) break;
- if( i == this.nxEdges-1) {
- // System.out.println("false all box corners outside yz silhouette edges ");
- return false; // all box corners outside yz silhouette edges
- }
- }
- // x-z
- for(i=0;i<this.nyEdges;i++){
- index = this.yEdgeList[i];
- if(( ux*this.yEdges[index].x +
- uz*this.yEdges[index].z + this.yEdges[index].w ) < EPSILON ) break;
- if(( ux*this.yEdges[index].x +
- lz*this.yEdges[index].z + this.yEdges[index].w ) < EPSILON ) break;
- if(( lx*this.yEdges[index].x +
- uz*this.yEdges[index].z + this.yEdges[index].w ) < EPSILON ) break;
- if(( lx*this.yEdges[index].x +
- lz*this.yEdges[index].z + this.yEdges[index].w ) < EPSILON ) break;
- if( i == this.nyEdges-1) {
- // System.out.println("false all box corners outside xz silhouette edges");
- return false; // all box corners outside xz silhouette edges
- }
- }
- // x-y
- for(i=0;i<this.nzEdges;i++){
- index = this.zEdgeList[i];
- if(( uy*this.zEdges[index].y +
- uz*this.zEdges[index].z + this.zEdges[index].w ) < EPSILON ) break;
- if(( uy*this.zEdges[index].y +
- lz*this.zEdges[index].z + this.zEdges[index].w ) < EPSILON ) break;
- if(( ly*this.zEdges[index].y +
- uz*this.zEdges[index].z + this.zEdges[index].w ) < EPSILON ) break;
- if(( ly*this.zEdges[index].y +
- lz*this.zEdges[index].z + this.zEdges[index].w ) < EPSILON ) break;
- if( i == this.nzEdges-1) {
- /*
- System.out.println("false all box corners outside xy silhouette edges");
- System.out.println("xy silhouette edges=");
- for(int j=0;j<this.nzEdges;j++){
- System.out.println(this.zEdges[j].toString());
- }
- */
- return false; // all box corners outside xy silhouette edges
- }
- }
- // System.out.println("true");
- return true;
- }
-
-
}
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java
index 4505897..8a7dc82 100644
--- a/src/classes/share/javax/media/j3d/Canvas3D.java
+++ b/src/classes/share/javax/media/j3d/Canvas3D.java
@@ -1536,7 +1536,11 @@ public class Canvas3D extends Canvas {
}
void setFrustumPlanes(Vector4d[] planes) {
- viewFrustum.set(planes);
+
+ if(VirtualUniverse.mc.viewFrustumCulling) {
+ /* System.out.println("Canvas3D.setFrustumPlanes()"); */
+ viewFrustum.set(planes);
+ }
}