| 289 | }; |
| 290 | |
| 291 | qboolean SV_PlayerCanSeeEnt( gentity_t *ent, int sightLevel ) |
| 292 | {//return true if this ent is in view |
| 293 | //NOTE: this is similar to the func CG_PlayerCanSeeCent in cg_players |
| 294 | vec3_t viewOrg, viewAngles, viewFwd, dir2Ent; |
| 295 | if ( !ent ) |
| 296 | { |
| 297 | return qfalse; |
| 298 | } |
| 299 | if ( VM_Call( CG_CAMERA_POS, viewOrg)) |
| 300 | { |
| 301 | if ( VM_Call( CG_CAMERA_ANG, viewAngles)) |
| 302 | { |
| 303 | float dot = 0.25f;//1.0f; |
| 304 | float range = sv_sightRangeForLevel[sightLevel]; |
| 305 | |
| 306 | VectorSubtract( ent->currentOrigin, viewOrg, dir2Ent ); |
| 307 | float entDist = VectorNormalize( dir2Ent ); |
| 308 | |
| 309 | if ( (ent->s.eFlags&EF_FORCE_VISIBLE) ) |
| 310 | {//no dist check on them? |
| 311 | } |
| 312 | else |
| 313 | { |
| 314 | if ( entDist < 128.0f ) |
| 315 | {//can always see them if they're really close |
| 316 | return qtrue; |
| 317 | } |
| 318 | |
| 319 | if ( entDist > range ) |
| 320 | {//too far away to see them |
| 321 | return qfalse; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | dot += (0.99f-dot)*entDist/range;//the farther away they are, the more in front they have to be |
| 326 | |
| 327 | AngleVectors( viewAngles, viewFwd, NULL, NULL ); |
| 328 | if ( DotProduct( viewFwd, dir2Ent ) < dot ) |
| 329 | { |
| 330 | return qfalse; |
| 331 | } |
| 332 | return qtrue; |
| 333 | } |
| 334 | } |
| 335 | return qfalse; |
| 336 | } |
| 337 | /* |
| 338 | =============== |
| 339 | SV_AddEntitiesVisibleFromPoint |
no test coverage detected