#define FLOAT_BIAS (1.0/32.0)
int linePlane( Vector start, Vector end, Plane plane, Vector& hit, float& frac ){
hit = end;
frac = 1;
float dist0 = plane.distance( start );
float dist1 = plane.distance( end );
if( dist0 >= 0.0 && dist1 >= 0.0 ) return 0; // seg in front of plane
if( dist0 < 0.0 && dist1 < 0.0 ) return 1; // seg in back of plane
int side = dist0 < 0;
if( side ) frac = (dist0 + FLOAT_BIAS) / (dist0 - dist1);
else frac = (dist0 - FLOAT_BIAS) / (dist0 - dist1);
frac = clamp( frac, 0, 1 );
hit = start + (end - start) * frac;
return 2; // seg was split
}