g_vis.c File Reference

#include "g_local.h"
Include dependency graph for g_vis.c:

Go to the source code of this file.

Functions

qboolean G_FrustumVis (const edict_t *from, const vec3_t point)
 Checks whether a point is "visible" from the edicts position.
static qboolean G_LineVis (const vec3_t from, const vec3_t to)
 tests the visibility between two points
float G_ActorVis (const vec3_t from, const edict_t *check, qboolean full)
 calculate how much check is "visible" from from
float G_Vis (const int team, const edict_t *from, const edict_t *check, int flags)
 test if check is visible by from
int G_TestVis (const int team, edict_t *check, int flags)
 test if check is visible by team (or if visibility changed?)
static qboolean G_VisShouldStop (const edict_t *ent)
static int G_DoTestVis (const int team, edict_t *check, qboolean perish, int playerMask, const edict_t *ent)
int G_CheckVisPlayer (player_t *player, qboolean perish)
 Sets visible edict on player spawn.
int G_CheckVisTeam (const int team, edict_t *check, qboolean perish, const edict_t *ent)
 Checks whether an edict appear/perishes for a specific team - also updates the visflags each edict carries.
int G_CheckVisTeamAll (const int team, qboolean perish, const edict_t *ent)
 Do G_CheckVisTeam for all entities.
int G_CheckVis (edict_t *check, qboolean perish)
 Check if the edict appears/perishes for the other teams. If they appear for other teams, the needed information for those clients are also send in G_CheckVisTeam resp. G_AppearPerishEvent.
void G_ClearVisFlags (int team)
 Reset the visflags for all edicts in the global list for the given team - and only for the given team.

Detailed Description

Definition in file g_vis.c.


Function Documentation

float G_ActorVis ( const vec3_t  from,
const edict_t check,
qboolean  full 
)

calculate how much check is "visible" from from

Parameters:
[in] from The world coordinate to check from
[in] check The edict to check how good (or if at all) it is visible
[in] full Perform a full check in different directions. If this is false the actor is fully visible if one vis check returned true. With true this function can also return a value != 0.0 and != 1.0. Try to only use true if you really need the full check. Full checks are of course more expensive.
Returns:
a value between 0.0 and 1.0 which reflects the visibility from 0 to 100 percent
Note:
This call isn't cheap - try to do this only if you really need the visibility check or the statement whether one particular actor see another particular actor.
See also:
CL_ActorVis

Definition at line 63 of file g_vis.c.

References ACTOR_VIS_0, ACTOR_VIS_10, ACTOR_VIS_100, ACTOR_VIS_50, G_IsCrouched, G_IsDead, G_LineVis(), i, edict_s::origin, PLAYER_CROUCH, PLAYER_DEAD, PLAYER_MIN, PLAYER_STAND, VectorCopy, VectorMA(), and VectorNormalize().

Referenced by AI_CheckCrouch(), AI_CheckUsingDoor(), AI_CivilianCalcBestAction(), AI_SearchBestTarget(), AI_SearchDestroyableObject(), AIL_positionshoot(), G_Morale(), G_ReactionFireIsPossible(), G_SplashDamage(), and G_Vis().

int G_CheckVis ( edict_t check,
qboolean  perish 
)

Check if the edict appears/perishes for the other teams. If they appear for other teams, the needed information for those clients are also send in G_CheckVisTeam resp. G_AppearPerishEvent.

Parameters:
[in] perish Also check for perishing events
[in] check The edict that is maybe seen by others. If NULL, all edicts are checked
Returns:
Bitmask of VIS_* values
See also:
G_CheckVisTeam

Definition at line 334 of file g_vis.c.

References G_CheckVisTeam(), G_CheckVisTeamAll(), level, MAX_TEAMS, and level_locals_t::num_alive.

Referenced by Door_Use(), G_ActorDieOrStun(), G_ActorFall(), G_ActorInvMove(), G_ActorRevitalise(), G_ClientMove(), G_ClientStateChangeUpdate(), G_Damage(), G_InventoryToFloor(), G_SpawnAIPlayer(), G_SpawnItemOnFloor(), and G_SpawnParticle().

int G_CheckVisPlayer ( player_t player,
qboolean  perish 
)

Sets visible edict on player spawn.

See also:
G_ClientSpawn
G_CheckVisTeam
G_AppearPerishEvent

Definition at line 261 of file g_vis.c.

References G_DoTestVis(), G_EdictsGetNextInUse(), G_PlayerToPM, player_s::pers, and client_persistant_t::team.

Referenced by G_ClientSpawn().

int G_CheckVisTeam ( const int  team,
edict_t check,
qboolean  perish,
const edict_t ent 
)

Checks whether an edict appear/perishes for a specific team - also updates the visflags each edict carries.

See also:
G_TestVis
Parameters:
[in] team Team to check the vis for
[in] check The edict that you want to check (and which maybe will appear or perish for the given team). If this is NULL every edict will be checked.
[in] perish Also check whether the edict (the actor) is going to become invisible for the given team
[in] ent The edict that is (maybe) seeing other edicts
Returns:
If an actor get visible who's no civilian VIS_STOP is added to the bit mask, VIS_YES means, he is visible, VIS_CHANGE means that the actor flipped its visibility (invisible to visible or vice versa), VIS_PERISH means that the actor (the edict) is getting invisible for the queried team
Note:
the edict may not only be actors, but also items of course
See also:
G_TeamToPM
G_TestVis
G_AppearPerishEvent
G_CheckVisPlayer
G_CheckVisTeamAll
Note:
If something appears, the needed information for those clients that are affected are also send in G_AppearPerishEvent

Definition at line 298 of file g_vis.c.

References G_DoTestVis(), G_TeamToPM(), and edict_s::inuse.

Referenced by Destroy_Breakable(), G_CheckVis(), and G_CheckVisTeamAll().

int G_CheckVisTeamAll ( const int  team,
qboolean  perish,
const edict_t ent 
)
void G_ClearVisFlags ( int  team  ) 

Reset the visflags for all edicts in the global list for the given team - and only for the given team.

Definition at line 355 of file g_vis.c.

References G_EdictsGetNextInUse(), G_TeamToVisMask, and edict_s::visflags.

Referenced by G_ClientSpawn(), and G_SpawnAIPlayer().

static int G_DoTestVis ( const int  team,
edict_t check,
qboolean  perish,
int  playerMask,
const edict_t ent 
) [static]
qboolean G_FrustumVis ( const edict_t from,
const vec3_t  point 
)

Checks whether a point is "visible" from the edicts position.

See also:
FrustumVis

Definition at line 31 of file g_vis.c.

References edict_s::dir, FrustumVis(), and edict_s::origin.

Referenced by AI_CheckCrouch(), AI_CheckUsingDoor(), G_Morale(), G_ReactionFireIsPossible(), G_SplashDamage(), G_TeamPointVis(), and G_Vis().

static qboolean G_LineVis ( const vec3_t  from,
const vec3_t  to 
) [static]

tests the visibility between two points

Parameters:
[in] from The point to check visibility from
[in] to The point to check visibility to
Returns:
true if the points are invisible from each other (trace hit something), false otherwise.

Definition at line 42 of file g_vis.c.

References G_TestLineWithEnts().

Referenced by G_ActorVis(), and G_Vis().

int G_TestVis ( const int  team,
edict_t check,
int  flags 
)

test if check is visible by team (or if visibility changed?)

See also:
G_CheckVisTeam
AI_FighterCalcBestAction
Parameters:
[in] team the team the edict may become visible for or perish from their view
[in] check the edict we are talking about - which may become visible or perish
[in] flags if you want to check whether the edict may also perish from other players view, you should use the VT_PERISH bits
Note:
If the edict is already visible and flags doesn't contain the bits of VT_PERISH, no further checks are performed - only the VIS_YES bits are returned

Definition at line 205 of file g_vis.c.

References g_aidebug, G_EdictsGetNextInUse(), G_IsVisibleForTeam, G_Vis(), cvar_s::integer, VIS_YES, and VT_PERISH.

Referenced by AI_FighterCalcBestAction(), AI_FindHidingLocation(), and G_DoTestVis().

float G_Vis ( const int  team,
const edict_t from,
const edict_t check,
int  flags 
)

test if check is visible by from

Parameters:
[in] team Living team members are always visible. If this is a negative number we inverse the team rules (see comments included). In combination with VT_NOFRUSTUM we can check whether there is any edict (that is no in our team) that can see check
[in] from is from team team and must be a living actor
[in] check The edict we want to get the visibility for
[in] flags VT_NOFRUSTUM, ...

Definition at line 132 of file g_vis.c.

References ACTOR_VIS_0, ACTOR_VIS_100, ET_ACTOR, ET_ACTOR2x2, ET_ITEM, ET_PARTICLE, EYE_CROUCH, EYE_STAND, G_ActorVis(), G_FrustumVis(), G_IsCivilian, G_IsCrouched, G_IsDead, G_IsLivingActor(), G_IsPaniced, G_IsVisibleOnBattlefield, G_LineVis(), edict_s::inuse, MAX_SPOT_DIST, edict_s::origin, edict_s::pos, qfalse, edict_s::team, edict_s::type, VectorCompare, VectorCopy, VectorDistSqr, and VT_NOFRUSTUM.

Referenced by AI_HideNeeded(), AIL_see(), and G_TestVis().

static qboolean G_VisShouldStop ( const edict_t ent  )  [static]

Definition at line 227 of file g_vis.c.

References G_IsCivilian, and G_IsLivingActor().

Referenced by G_DoTestVis().


Generated by  doxygen 1.6.2