UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
g_vis.h File Reference
#include "g_local.h"

Go to the source code of this file.

Macros

#define TEAM_ALL   0xFFFFFFFF
 
#define VIS_APPEAR   1
 
#define VIS_PERISH   2
 
#define VIS_STOP   4
 
#define VS_CHANGE   1
 
#define VS_YES   2
 
#define VT_PERISHCHK   1
 
#define VT_NOFRUSTUM   2
 
#define VT_NEW   4
 
#define ACTOR_VIS_100   1.0f
 
#define ACTOR_VIS_50   0.5f
 
#define ACTOR_VIS_10   0.1f
 
#define ACTOR_VIS_0   0.0f
 

Typedefs

typedef unsigned int teammask_t
 
typedef unsigned int vischeckflags_t
 

Functions

bool G_FrustumVis (const Edict *from, const vec3_t point)
 Checks whether a point is "visible" from the edicts position. More...
 
bool G_SmokeVis (const vec3_t from, const Edict *check)
 tests for smoke interference More...
 
float G_ActorVis (const Edict *ent, const Edict *check, bool full)
 calculate how much check is "visible" by ent More...
 
void G_VisFlagsClear (int team)
 Reset the visflags for all edicts in the global list for the given team - and only for the given team. More...
 
void G_VisFlagsAdd (Edict &ent, teammask_t teamMask)
 
void G_VisFlagsSwap (Edict &ent, teammask_t teamMask)
 
void G_VisFlagsReset (Edict &ent)
 
void G_VisMakeEverythingVisible (void)
 Make everything visible to anyone who can't already see it. More...
 
void G_CheckVis (Edict *check, const vischeckflags_t visFlags=VT_PERISHCHK)
 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. More...
 
void G_CheckVisPlayer (Player &player, const vischeckflags_t visFlags)
 Sets visible edict on player spawn. More...
 
int G_CheckVisTeamAll (const int team, const vischeckflags_t visFlags, const Edict *ent)
 Do G_CheckVisTeam for all entities ent is the one that is looking at the others. More...
 
int G_TestVis (const int team, Edict *check, const vischeckflags_t flags)
 test if check is visible by team (or if visibility changed?) More...
 
bool G_Vis (const int team, const Edict *from, const Edict *check, const vischeckflags_t flags)
 test if check is visible by from More...
 
int G_VisCheckDist (const Edict *const ent)
 

Macro Definition Documentation

#define ACTOR_VIS_0   0.0f
#define ACTOR_VIS_100   1.0f

Actor visibility constants

Definition at line 61 of file g_vis.h.

Referenced by G_ActorVis().

#define ACTOR_VIS_50   0.5f

Definition at line 62 of file g_vis.h.

Referenced by AI_CheckCrouch(), and G_ActorVis().

#define TEAM_ALL   0xFFFFFFFF

Definition at line 32 of file g_vis.h.

Referenced by AIL_Init(), AIL_missiontargets(), AIL_positionhide(), AIL_see(), and G_BuildForbiddenList().

#define VIS_APPEAR   1

Edict became visible

Definition at line 36 of file g_vis.h.

Referenced by G_ActorShouldStopInMidMove(), G_ClientEndRound(), and G_DoTestVis().

#define VIS_PERISH   2

Edict became invisible

Definition at line 38 of file g_vis.h.

Referenced by G_DoTestVis().

#define VIS_STOP   4

stop the current action if actor appears

Definition at line 40 of file g_vis.h.

Referenced by G_ActorDoTurn(), G_ActorShouldStopInMidMove(), G_ClientMove(), and G_DoTestVis().

#define VS_CHANGE   1

the visibility changed - (invisible to visible or vice versa)

Definition at line 44 of file g_vis.h.

Referenced by G_DoTestVis(), and G_TestVis().

#define VS_YES   2

actor is visible

Definition at line 46 of file g_vis.h.

Referenced by AI_IsExposed(), AIL_positionapproach(), AIL_positionflee(), G_DoTestVis(), and G_TestVis().

#define VT_NEW   4

If the actor doesn't become visible add it as a hidden actor (sends the EV_ACTOR_ADD event)

Definition at line 58 of file g_vis.h.

Referenced by G_DoTestVis(), and G_SpawnAIPlayer().

#define VT_NOFRUSTUM   2

don't perform a frustum vis check via G_FrustumVis in G_Vis

Definition at line 55 of file g_vis.h.

Referenced by AI_HideNeeded(), AI_IsExposed(), AIL_positionapproach(), AIL_positionflee(), AIL_see(), and G_Vis().

#define VT_PERISHCHK   1

check whether edict is still visible - it maybe is currently visible but this might have changed due to some action

Definition at line 53 of file g_vis.h.

Referenced by AI_IsExposed(), AIL_positionapproach(), AIL_positionflee(), G_SpawnAIPlayer(), and G_TestVis().

Typedef Documentation

typedef unsigned int teammask_t
Todo:
make this a byte

Definition at line 30 of file g_vis.h.

typedef unsigned int vischeckflags_t

Definition at line 49 of file g_vis.h.

Function Documentation

float G_ActorVis ( const Edict ent,
const Edict check,
bool  full 
)

calculate how much check is "visible" by ent

Parameters
[in]entThe source edict of the check
[in]checkThe edict to check how good (or if at all) it is visible
[in]fullPerform 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 (one of the ACTOR_VIS_* constants) 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 100 of file g_vis.cpp.

References ACTOR_VIS_0, ACTOR_VIS_10, ACTOR_VIS_100, ACTOR_VIS_50, G_ActorGetEyeVector(), G_IsCrouched, G_IsDead, G_LineVis(), G_SmokeVis(), i, Edict::origin, PLAYER_CROUCH, PLAYER_DEAD, PLAYER_MIN, PLAYER_STAND, VectorCopy, VectorMA(), and VectorNormalizeFast().

Referenced by AI_CheckCrouch(), AI_CheckUsingDoor(), AI_CivilianCalcActionScore(), AI_FighterCalcActionScore(), AI_FindBestFiredef(), AI_PanicCalcActionScore(), AI_SearchDestroyableObject(), AIL_positionshoot(), ReactionFire::canSee(), G_Morale(), and G_Vis().

void G_CheckVis ( Edict check,
const vischeckflags_t  visFlags 
)

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]checkThe edict that is maybe seen by others. If nullptr, all edicts are checked
visFlagsModifiers for the checks
See also
G_CheckVisTeam

Definition at line 409 of file g_vis.cpp.

References G_CheckVisTeam(), G_CheckVisTeamAll(), level, MAX_TEAMS, and level_locals_s::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_SpawnAIPlayers(), G_SpawnItemOnFloor(), G_SpawnParticle(), SP_misc_smoke(), and Think_SmokeAndFire().

void G_CheckVisPlayer ( Player &  player,
const vischeckflags_t  visFlags 
)

Sets visible edict on player spawn.

See also
G_ClientStartMatch
G_CheckVisTeam
G_AppearPerishEvent

Definition at line 327 of file g_vis.cpp.

References G_DoTestVis(), G_EdictsGetNextInUse(), and G_PlayerToPM.

Referenced by G_ClientStartMatch().

int G_CheckVisTeamAll ( const int  team,
const vischeckflags_t  visFlags,
const Edict ent 
)

Do G_CheckVisTeam for all entities ent is the one that is looking at the others.

Definition at line 376 of file g_vis.cpp.

References G_CheckVisTeam(), and G_EdictsGetNextInUse().

Referenced by AIL_see(), Door_Use(), G_ActorDieOrStun(), G_ActorDoTurn(), G_ActorRevitalise(), G_CheckVis(), G_ClientEndRound(), G_ClientMove(), G_ClientShoot(), G_ClientStateChangeUpdate(), G_Damage(), and G_SpawnAIPlayer().

bool G_FrustumVis ( const Edict from,
const vec3_t  point 
)

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

See also
FrustumVis

Definition at line 38 of file g_vis.cpp.

References Edict::camera, Edict::dir, FrustumVis(), G_IsActiveCamera, Edict::origin, and camera_edict_data_s::rotate.

Referenced by AI_CheckCrouch(), AI_CheckUsingDoor(), ReactionFire::canSee(), G_Morale(), G_SplashDamage(), G_TeamPointVis(), and G_Vis().

bool G_SmokeVis ( const vec3_t  from,
const Edict check 
)

tests for smoke interference

Parameters
[in]fromThe point to check visibility from
[in]checkThe edict to check visibility to
Returns
true if check is invisible from from (smoke is in the way), false otherwise.

Definition at line 65 of file g_vis.cpp.

References Edict::absBox, f, G_EdictsGetNextInUse(), G_IsSmoke, AABB::maxs, AABB::mins, Edict::origin, RayIntersectAABB(), UNIT_SIZE, and VectorDist.

Referenced by G_ActorVis(), and G_SplashDamage().

int G_TestVis ( const int  team,
Edict check,
const vischeckflags_t  flags 
)

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

See also
G_CheckVisTeam
Parameters
[in]teamthe team the edict may become visible for or perish from their view
[in]checkthe edict we are talking about - which may become visible or perish
[in]flagsif you want to check whether the edict may also perish from other players view, you should use the VT_PERISHCHK bits
Note
If the edict is already visible and flags doesn't contain the bits of VT_PERISHCHK, no further checks are performed - only the VS_YES bits are returned
Returns
VS_CHANGE is added to the bit mask if the edict flipped its visibility (invisible to visible or vice versa) VS_YES means the edict is visible for the given team

Definition at line 255 of file g_vis.cpp.

References g_aidebug, G_EdictsGetNextInUse(), G_IsVisibleForTeam, G_Vis(), cvar_s::integer, VS_CHANGE, VS_YES, and VT_PERISHCHK.

Referenced by AI_IsExposed(), AIL_positionapproach(), AIL_positionflee(), and G_DoTestVis().

bool G_Vis ( const int  team,
const Edict from,
const Edict check,
const vischeckflags_t  flags 
)

test if check is visible by from

Parameters
[in]teamLiving 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]fromis from team team and must be a living actor
[in]checkThe edict we want to get the visibility for
[in]flagsVT_NOFRUSTUM, ...

Definition at line 183 of file g_vis.cpp.

References ACTOR_VIS_0, ET_ACTOR, ET_ACTOR2x2, ET_CAMERA, ET_ITEM, ET_PARTICLE, G_ActorGetEyeVector(), G_ActorVis(), G_FrustumVis(), G_IsActiveCamera, G_IsDead, G_IsLivingActor(), G_IsVisibleOnBattlefield, G_LineVis(), G_VisCheckDist(), Edict::getTeam(), Edict::inuse, Edict::origin, Edict::pos, Edict::type, VectorCompare, VectorDistSqr, and VT_NOFRUSTUM.

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

void G_VisFlagsAdd ( Edict ent,
teammask_t  teamMask 
)

Definition at line 433 of file g_vis.cpp.

References Edict::visflags.

Referenced by G_ClientSendEdictsAndBrushModels(), and G_SplashDamage().

void G_VisFlagsClear ( 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 424 of file g_vis.cpp.

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

Referenced by G_ClientStartMatch(), and G_SpawnAIPlayers().

void G_VisFlagsReset ( Edict ent)
void G_VisFlagsSwap ( Edict ent,
teammask_t  teamMask 
)

Definition at line 443 of file g_vis.cpp.

References Edict::visflags.

Referenced by G_AppearPerishEvent(), and G_DoTestVis().

void G_VisMakeEverythingVisible ( void  )

Make everything visible to anyone who can't already see it.

Definition at line 390 of file g_vis.cpp.

References G_AppearPerishEvent(), G_EdictsGetNextInUse(), G_IsActor, G_SendInventory(), G_TeamToPM(), G_VisToPM(), Edict::getTeam(), and Edict::visflags.

Referenced by G_MatchSendResults().