All pastes #604934 Raw Edit

Monkeyman

public java v1 · immutable
·published 2007-07-05 21:16 UTC
rendered paste body
public static boolean intersectBB( Vector3 min, Vector3 max, Vector3 origin, Vector3 direction )    {        float txmin, txmax, tymin, tymax, tzmin, tzmax;                direction.x += 0.000001;        direction.y += 0.000001;        direction.z += 0.000001;                if( direction.x >= 0 )        {            txmin = ( min.x - origin.x ) / direction.x;            txmax = ( max.x - origin.x ) / direction.x;        }        else        {            txmin = ( max.x - origin.x ) / direction.x;            txmax = ( min.x - origin.x ) / direction.x;        }                if( direction.y >= 0 )        {            tymin = ( min.y - origin.y ) / direction.y;            tymax = ( max.y - origin.y ) / direction.y;        }        else        {            tymin = ( max.y - origin.y ) / direction.y;            tymax = ( min.y - origin.y ) / direction.y;        }                if( direction.z >= 0 )        {            tzmin = ( min.z - origin.z ) / direction.z;            tzmax = ( max.z - origin.z ) / direction.z;        }        else        {            tzmin = ( max.z - origin.z ) / direction.z;            tzmax = ( min.z - origin.z ) / direction.z;        }                if( ( txmin > tzmax ) | ( tymin > txmax ) | ( tzmin > tymax ) )        {            return false;        }        else        {            System.out.println( "Tx: " + txmin + ", " + txmax );            System.out.println( "Ty: " + tymin + ", " + tymax  );            System.out.println( "Tz: " + tzmin + ", " + tzmax  );                        return true;        }    }