/* ================= R_TraceAgainstSurface ================= */ static bool R_TraceAgainstSurface( msurface_t *surf ) { int i; mesh_t *mesh; elem_t *elem; vec4_t *verts; float old_frac = trace_fraction; if( !surf ) return false; mesh = surf->mesh; if( !mesh ) return false; elem = mesh->elems; if( !elem ) return false; verts = mesh->xyzArray; if( !verts ) return false; // clip each triangle individually for( i = 0; i < mesh->numElems; i += 3, elem += 3 ) { R_TraceAgainstTriangle( verts[elem[0]], verts[elem[1]], verts[elem[2]] ); if( old_frac > trace_fraction ) { // flip normal is we are on the backside (does it really happen?)... if( surf->facetype == MST_PLANAR ) { if( DotProduct( trace_plane.normal, surf->plane->normal ) < 0 ) VectorNegate( trace_plane.normal, trace_plane.normal ); } return true; } } return false; }
/* * R_TraceAgainstSurface */ static bool R_TraceAgainstSurface( msurface_t *surf ) { int i; mesh_t *mesh = &surf->mesh; elem_t *elem = mesh->elems; vec4_t *verts = mesh->xyzArray; float old_frac = trace_fraction; bool isPlanar = ( surf->facetype == FACETYPE_PLANAR ) ? true : false; // clip each triangle individually for( i = 0; i < mesh->numElems; i += 3, elem += 3 ) { R_TraceAgainstTriangle( verts[elem[0]], verts[elem[1]], verts[elem[2]] ); if( old_frac > trace_fraction ) { // flip normal is we are on the backside (does it really happen?)... if( isPlanar ) { if( DotProduct( trace_plane.normal, surf->plane ) < 0 ) { VectorInverse( trace_plane.normal ); } } return true; } } return false; }