- if ( bspPlanes[ i ].dist > 0 ){
- if ( bspPlanes[ i ].normal[0] ){
- bspPlanes[ i ].dist += scale[0];
- continue;
- }
- else if ( bspPlanes[ i ].normal[1] ){
- bspPlanes[ i ].dist += scale[1];
- continue;
- }
- else if ( bspPlanes[ i ].normal[2] ){
- bspPlanes[ i ].dist += scale[2];
- continue;
- }
- }
- else{
- if ( bspPlanes[ i ].normal[0] ){
- bspPlanes[ i ].dist -= scale[0];
- continue;
- }
- else if ( bspPlanes[ i ].normal[1] ){
- bspPlanes[ i ].dist -= scale[1];
- continue;
- }
- else if ( bspPlanes[ i ].normal[2] ){
- bspPlanes[ i ].dist -= scale[2];
- continue;
- }
+ //find point on plane
+ for ( j=0; j<3; j++ ){
+ if ( fabs( bspPlanes[ i ].normal[j] ) > 0.5 ){
+ point[j] = bspPlanes[ i ].dist / bspPlanes[ i ].normal[j];
+ point[(j+1)%3] = point[(j+2)%3] = 0;
+ break;
+ }