==================== CG_BuildSolidList When a new cg.snap has been set, this function builds a sublist of the entities that are actually solid, to make for more efficient collision detection ==================== */
| 47 | ==================== |
| 48 | */ |
| 49 | void CG_BuildSolidList( void ) |
| 50 | { |
| 51 | int i; |
| 52 | centity_t *cent; |
| 53 | vec3_t difference; |
| 54 | float dsquared; |
| 55 | |
| 56 | cg_numSolidEntities = 0; |
| 57 | |
| 58 | if(!cg.snap) |
| 59 | { |
| 60 | return; |
| 61 | } |
| 62 | |
| 63 | for ( i = 0 ; i < cg.snap->numEntities ; i++ ) |
| 64 | { |
| 65 | if ( cg.snap->entities[ i ].number < ENTITYNUM_WORLD ) |
| 66 | { |
| 67 | cent = &cg_entities[ cg.snap->entities[ i ].number ]; |
| 68 | |
| 69 | if ( cent->gent != NULL && cent->gent->s.solid ) |
| 70 | { |
| 71 | cg_solidEntities[cg_numSolidEntities] = cent; |
| 72 | cg_numSolidEntities++; |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | dsquared = 5000+500; |
| 78 | dsquared *= dsquared; |
| 79 | |
| 80 | for(i=0;i<cg_numpermanents;i++) |
| 81 | { |
| 82 | cent = cg_permanents[i]; |
| 83 | VectorSubtract(cent->lerpOrigin, cg.snap->ps.origin, difference); |
| 84 | if (cent->currentState.eType == ET_TERRAIN || |
| 85 | ((difference[0]*difference[0]) + (difference[1]*difference[1]) + (difference[2]*difference[2])) <= dsquared) |
| 86 | { |
| 87 | cent->currentValid = qtrue; |
| 88 | if ( cent->nextState && cent->nextState->solid ) |
| 89 | { |
| 90 | cg_solidEntities[cg_numSolidEntities] = cent; |
| 91 | cg_numSolidEntities++; |
| 92 | } |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | cent->currentValid = qfalse; |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /* |
| 102 | ==================== |
no test coverage detected