+int plane_intersect2( v4f a, v4f b, v3f p, v3f n )
+{
+ float const epsilon = 1e-6f;
+
+ v4f c;
+ v3_cross( a, b, c );
+ float d = v3_length2( c );
+
+ if( (d < epsilon) && (d > -epsilon) )
+ return 0;
+
+ v3f v0, v1, vx;
+ v3_cross( c, b, v0 );
+ v3_cross( a, c, v1 );
+
+ v3_muls( v0, a[3], vx );
+ v3_muladds( vx, v1, b[3], vx );
+ v3_divs( vx, d, p );
+ v3_copy( c, n );
+
+ return 1;
+}
+
+static int plane_segment( v4f plane, v3f a, v3f b, v3f co )
+{
+ float d0 = v3_dot( a, plane ) - plane[3],
+ d1 = v3_dot( b, plane ) - plane[3];
+
+ if( d0*d1 < 0.0f )
+ {
+ float tot = 1.0f/( fabsf(d0)+fabsf(d1) );
+
+ v3_muls( a, fabsf(d1) * tot, co );
+ v3_muladds( co, b, fabsf(d0) * tot, co );
+ return 1;
+ }
+
+ return 0;
+}
+