Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sv_novis #185

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/pages/cvars-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,17 @@ This allows to set starting stats for when starting levels with the `map` or `re
Dedicated max speed value used only while noclip.
Its value is `320` by default.

##### `sv_novis`

When set to 1, entities are not PVS culled before being sent to the client. In
practice this means that all enemies are visible when `r_outline_monsters` is
used, and that all monsters are recorded in demos. The latter is useful for
being able to see entities that the player can't see in recams or when using the
freefly feature.

This naturally inflates demo size, so be careful using it with entity heavy
maps.

#### Network

##### `net_connectsearch`
Expand Down
36 changes: 22 additions & 14 deletions trunk/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ int sv_protocol = PROTOCOL_NETQUAKE;
extern qboolean pr_alpha_supported; //johnfitz

vec3_t sv_velocity; //joe: for more accurate player speed value
static cvar_t sv_novis = {"sv_novis", "0"};

//============================================================================

Expand Down Expand Up @@ -95,6 +96,7 @@ void SV_Init (void)
Cvar_Register (&sv_nostep);
Cvar_Register (&sv_altnoclip); //johnfitz
Cvar_Register (&sv_noclipspeed);
Cvar_Register (&sv_novis);

Cmd_AddCommand("sv_protocol", &SV_Protocol_f); //johnfitz

Expand Down Expand Up @@ -567,7 +569,9 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg, qboolean nomap)

// find the client's PVS
VectorAdd (clent->v.origin, clent->v.view_ofs, org);
pvs = SV_FatPVS (org, sv.worldmodel);

if (!sv_novis.value)
pvs = SV_FatPVS (org, sv.worldmodel);

// send over all entities (excpet the client) that touch the pvs
ent = NEXT_EDICT(sv.edicts);
Expand All @@ -584,19 +588,23 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg, qboolean nomap)
if (sv.protocol == PROTOCOL_NETQUAKE && (int)ent->v.modelindex & 0xFF00)
continue;

// ignore if not touching a PV leaf
for (i = 0; i < ent->num_leafs; i++)
if (pvs[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i] & 7)))
break;

// ericw -- added ent->num_leafs < MAX_ENT_LEAFS condition.
//
// if ent->num_leafs == MAX_ENT_LEAFS, the ent is visible from too many leafs
// for us to say whether it's in the PVS, so don't try to vis cull it.
// this commonly happens with rotators, because they often have huge bboxes
// spanning the entire map, or really tall lifts, etc.
if (i == ent->num_leafs && ent->num_leafs < MAX_ENT_LEAFS)
continue; // not visible
if (!sv_novis.value)
{
// ignore if not touching a PV leaf
for (i = 0; i < ent->num_leafs; i++)
if (pvs[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i] & 7)))
break;

// ericw -- added ent->num_leafs < MAX_ENT_LEAFS condition.
//
// if ent->num_leafs == MAX_ENT_LEAFS, the ent is visible from too many leafs
// for us to say whether it's in the PVS, so don't try to vis cull it.
// this commonly happens with rotators, because they often have huge bboxes
// spanning the entire map, or really tall lifts, etc.
if (i == ent->num_leafs && ent->num_leafs < MAX_ENT_LEAFS)
continue; // not visible

}

// joe, from ProQuake: don't send updates if the client doesn't have the map
if (nomap)
Expand Down