29 #include "../idlib/precompiled.h"
48 int c_testEdges, c_testPlanes, c_intersect;
61 startDir = end -
start;
63 startDir.
NormalVectors( planes[0].Normal(), planes[1].Normal() );
64 planes[0][3] = - start * planes[0].
Normal();
65 planes[1][3] = - start * planes[1].
Normal();
69 planes[2][3] = - start * planes[2].
Normal();
70 planes[3] = -startDir;
71 planes[3][3] = - end * planes[3].
Normal();
78 if ( ( totalOr ^ ( totalOr >> 4 ) ) & 3 ) {
84 if ( ( totalOr ^ ( totalOr >> 1 ) ) & 4 ) {
94 radiusSqr =
Square( radius );
95 startDir = end -
start;
101 for ( i = 0, j = 0; i < tri->
numIndexes; i += 3, j++ ) {
112 triOr = cullBits[ tri->
indexes[i+0] ];
113 triOr |= cullBits[ tri->
indexes[i+1] ];
114 triOr |= cullBits[ tri->
indexes[i+2] ];
117 if ( ( triOr ^ ( triOr >> 4 ) ) & 3 ) {
122 if ( ( triOr ^ ( triOr >> 1 ) ) & 4 ) {
144 f = d1 / ( d1 - d2 );
157 point = start + f * startDir;
165 cross = dir[0].
Cross( dir[1] );
168 if ( radiusSqr <= 0.0f ) {
173 if ( cross.
LengthSqr() > edgeLengthSqr * radiusSqr ) {
181 if ( dir[0].LengthSqr() > radiusSqr ) {
185 }
else if ( d > edgeLengthSqr ) {
189 if ( dir[1].LengthSqr() > radiusSqr ) {
198 cross = dir[1].
Cross( dir[2] );
201 if ( radiusSqr <= 0.0f ) {
206 if ( cross.
LengthSqr() > edgeLengthSqr * radiusSqr ) {
214 if ( dir[1].LengthSqr() > radiusSqr ) {
218 }
else if ( d > edgeLengthSqr ) {
222 if ( dir[2].LengthSqr() > radiusSqr ) {
229 cross = dir[2].
Cross( dir[0] );
232 if ( radiusSqr <= 0.0f ) {
237 if ( cross.
LengthSqr() > edgeLengthSqr * radiusSqr ) {
245 if ( dir[2].LengthSqr() > radiusSqr ) {
249 }
else if ( d > edgeLengthSqr ) {
253 if ( dir[0].LengthSqr() > radiusSqr ) {
274 common->
Printf(
"testVerts:%i c_testPlanes:%i c_testEdges:%i c_intersect:%i msec:%1.4f\n",
288 idVec3 dir[6], normal, point;
294 dir[0] = p[0] - p[1];
295 dir[1] = p[1] - p[2];
296 dir[2] = p[2] - p[0];
298 normal = dir[0].
Cross( dir[1] );
300 if ( normal * p[0] < normal * vieworg ) {
304 dir[0] = normal.
Cross( dir[0] );
305 dir[1] = normal.
Cross( dir[1] );
306 dir[2] = normal.
Cross( dir[2] );
314 for ( j = 0; j < 3; j++ ) {
317 dir[4] = ( dir[
j] + dir[k] ) * 0.5
f;
320 dir[3] = ( dir[
j] + dir[4] ) * 0.5
f;
323 dir[5] = ( dir[4] + dir[k] ) * 0.5
f;
326 point = p[k] + dir[
j] * radius;
329 point = p[k] + dir[3] * radius;
332 point = p[k] + dir[4] * radius;
335 point = p[k] + dir[5] * radius;
338 point = p[k] + dir[k] * radius;
358 idVec3 localStart, localEnd;
383 for ( i = 0 ; i < numDrawSurfs ; i++ ) {
414 if ( radius != 0.0
f ) {
421 hit =
R_LocalTrace( localStart, localEnd, radius, tri );
const srfTriangles_t * geo
void cross(float a[], float b[], float c[])
const idVec3 & Normal(void) const
#define qglDisableClientState
const int GLS_SRCBLEND_SRC_ALPHA
float Distance(const idVec3 &v) const
bool facePlanesCalculated
const int GLS_DEPTHFUNC_ALWAYS
double Milliseconds(void) const
idVec3 Cross(const idVec3 &a) const
const struct viewEntity_s * space
idCVar r_showTrace("r_showTrace","0", CVAR_RENDERER|CVAR_INTEGER,"show the intersection of an eye trace with the world", idCmdSystem::ArgCompletion_Integer< 0, 2 >)
void RB_ShowTrace(drawSurf_t **drawSurfs, int numDrawSurfs)
void RB_DrawElementsImmediate(const srfTriangles_t *tri)
void R_DeriveFacePlanes(srfTriangles_t *tri)
int GetInteger(void) const
idImageManager * globalImages
float LengthSqr(void) const
virtual void Printf(const char *fmt,...) id_attribute((format(printf
idBounds Expand(const float d) const
void R_GlobalPointToLocal(const float modelMatrix[16], const idVec3 &in, idVec3 &out)
virtual void VPCALL TracePointCull(byte *cullBits, byte &totalOr, const float radius, const idPlane *planes, const idDrawVert *verts, const int numVerts)=0
void RB_DrawExpandedTriangles(const srfTriangles_t *tri, const float radius, const idVec3 &vieworg)
const int GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA
bool LineIntersection(const idVec3 &start, const idVec3 &end) const
float modelViewMatrix[16]
void GL_State(int stateBits)
localTrace_t R_LocalTrace(const idVec3 &start, const idVec3 &end, const float radius, const srfTriangles_t *tri)
void RB_DrawBounds(const idBounds &bounds)
void NormalVectors(idVec3 &left, idVec3 &down) const
idSIMDProcessor * SIMDProcessor
const viewDef_t * viewDef