mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 13:10:34 +00:00
[model] Clean up the brush leaf api a little
Those functions now all take mod_brush_t since they don't work with any other type of model.
This commit is contained in:
parent
d7e312ab8b
commit
ecb9a15946
16 changed files with 65 additions and 63 deletions
|
@ -432,13 +432,13 @@ model_t *Mod_ForName (const char *name, bool crash);
|
||||||
void Mod_TouchModel (const char *name);
|
void Mod_TouchModel (const char *name);
|
||||||
void Mod_UnloadModel (model_t *model);
|
void Mod_UnloadModel (model_t *model);
|
||||||
// brush specific
|
// brush specific
|
||||||
mleaf_t *Mod_PointInLeaf (vec4f_t p, model_t *model) __attribute__((pure));
|
mleaf_t *Mod_PointInLeaf (vec4f_t p, const mod_brush_t *brush) __attribute__((pure));
|
||||||
struct set_s *Mod_LeafPVS (const mleaf_t *leaf, const model_t *model);
|
struct set_s *Mod_LeafPVS (const mleaf_t *leaf, const mod_brush_t *brush);
|
||||||
|
|
||||||
void Mod_LeafPVS_set (const mleaf_t *leaf, const model_t *model, byte defvis,
|
void Mod_LeafPVS_set (const mleaf_t *leaf, const mod_brush_t *brush,
|
||||||
struct set_s *pvs);
|
byte defvis, struct set_s *pvs);
|
||||||
void Mod_LeafPVS_mix (const mleaf_t *leaf, const model_t *model, byte defvis,
|
void Mod_LeafPVS_mix (const mleaf_t *leaf, const mod_brush_t *brush,
|
||||||
struct set_s *pvs);
|
byte defvis, struct set_s *pvs);
|
||||||
|
|
||||||
void Mod_Print (void);
|
void Mod_Print (void);
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ SCR_CShift (void)
|
||||||
if (_vs->active && cl_world.scene->worldmodel) {
|
if (_vs->active && cl_world.scene->worldmodel) {
|
||||||
vec4f_t origin;
|
vec4f_t origin;
|
||||||
origin = Transform_GetWorldPosition (_vs->camera_transform);
|
origin = Transform_GetWorldPosition (_vs->camera_transform);
|
||||||
leaf = Mod_PointInLeaf (origin, cl_world.scene->worldmodel);
|
leaf = Mod_PointInLeaf (origin, &cl_world.scene->worldmodel->brush);
|
||||||
contents = leaf->contents;
|
contents = leaf->contents;
|
||||||
}
|
}
|
||||||
V_SetContentsColor (_vs, contents);
|
V_SetContentsColor (_vs, contents);
|
||||||
|
|
|
@ -61,18 +61,18 @@ VISIBLE int mod_sky_divide; //FIXME visibility?
|
||||||
VISIBLE int mod_lightmap_bytes = 1; //FIXME should this be visible?
|
VISIBLE int mod_lightmap_bytes = 1; //FIXME should this be visible?
|
||||||
|
|
||||||
VISIBLE mleaf_t *
|
VISIBLE mleaf_t *
|
||||||
Mod_PointInLeaf (vec4f_t p, model_t *model)
|
Mod_PointInLeaf (vec4f_t p, const mod_brush_t *brush)
|
||||||
{
|
{
|
||||||
float d;
|
float d;
|
||||||
|
|
||||||
if (!model || !model->brush.nodes)
|
if (!brush || !brush->nodes)
|
||||||
Sys_Error ("Mod_PointInLeaf: bad model");
|
Sys_Error ("Mod_PointInLeaf: bad brush");
|
||||||
|
|
||||||
int node_id = 0;
|
int node_id = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (node_id < 0)
|
if (node_id < 0)
|
||||||
return model->brush.leafs + ~node_id;
|
return brush->leafs + ~node_id;
|
||||||
mnode_t *node = model->brush.nodes + node_id;
|
mnode_t *node = brush->nodes + node_id;
|
||||||
d = dotf (p, node->plane)[0];
|
d = dotf (p, node->plane)[0];
|
||||||
node_id = node->children[d < 0];
|
node_id = node->children[d < 0];
|
||||||
}
|
}
|
||||||
|
@ -148,14 +148,14 @@ Mod_DecompressVis_mix (const byte *in, const mod_brush_t *brush, byte defvis,
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE set_t *
|
VISIBLE set_t *
|
||||||
Mod_LeafPVS (const mleaf_t *leaf, const model_t *model)
|
Mod_LeafPVS (const mleaf_t *leaf, const mod_brush_t *brush)
|
||||||
{
|
{
|
||||||
static set_t *novis;
|
static set_t *novis;
|
||||||
static set_t *decompressed;
|
static set_t *decompressed;
|
||||||
unsigned numvis = model->brush.visleafs;
|
unsigned numvis = brush->visleafs;
|
||||||
unsigned excess = SET_SIZE (numvis) - numvis;
|
unsigned excess = SET_SIZE (numvis) - numvis;
|
||||||
|
|
||||||
if (leaf == model->brush.leafs) {
|
if (leaf == brush->leafs) {
|
||||||
if (!novis) {
|
if (!novis) {
|
||||||
novis = set_new_size (numvis);
|
novis = set_new_size (numvis);
|
||||||
}
|
}
|
||||||
|
@ -171,38 +171,37 @@ Mod_LeafPVS (const mleaf_t *leaf, const model_t *model)
|
||||||
decompressed = set_new ();
|
decompressed = set_new ();
|
||||||
}
|
}
|
||||||
set_expand (decompressed, numvis);
|
set_expand (decompressed, numvis);
|
||||||
Mod_DecompressVis_set (leaf->compressed_vis, &model->brush, 0xff,
|
Mod_DecompressVis_set (leaf->compressed_vis, brush, 0xff, decompressed);
|
||||||
decompressed);
|
|
||||||
decompressed->map[SET_WORDS (decompressed) - 1] &= (~SET_ZERO) >> excess;
|
decompressed->map[SET_WORDS (decompressed) - 1] &= (~SET_ZERO) >> excess;
|
||||||
return decompressed;
|
return decompressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE void
|
VISIBLE void
|
||||||
Mod_LeafPVS_set (const mleaf_t *leaf, const model_t *model, byte defvis,
|
Mod_LeafPVS_set (const mleaf_t *leaf, const mod_brush_t *brush, byte defvis,
|
||||||
set_t *out)
|
set_t *out)
|
||||||
{
|
{
|
||||||
unsigned numvis = model->brush.visleafs;
|
unsigned numvis = brush->visleafs;
|
||||||
unsigned excess = SET_SIZE (numvis) - numvis;
|
unsigned excess = SET_SIZE (numvis) - numvis;
|
||||||
|
|
||||||
set_expand (out, numvis);
|
set_expand (out, numvis);
|
||||||
if (leaf == model->brush.leafs) {
|
if (leaf == brush->leafs) {
|
||||||
memset (out->map, defvis, SET_WORDS (out) * sizeof (*out->map));
|
memset (out->map, defvis, SET_WORDS (out) * sizeof (*out->map));
|
||||||
out->map[SET_WORDS (out) - 1] &= (~SET_ZERO) >> excess;
|
out->map[SET_WORDS (out) - 1] &= (~SET_ZERO) >> excess;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Mod_DecompressVis_set (leaf->compressed_vis, &model->brush, defvis, out);
|
Mod_DecompressVis_set (leaf->compressed_vis, brush, defvis, out);
|
||||||
out->map[SET_WORDS (out) - 1] &= (~SET_ZERO) >> excess;
|
out->map[SET_WORDS (out) - 1] &= (~SET_ZERO) >> excess;
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE void
|
VISIBLE void
|
||||||
Mod_LeafPVS_mix (const mleaf_t *leaf, const model_t *model, byte defvis,
|
Mod_LeafPVS_mix (const mleaf_t *leaf, const mod_brush_t *brush, byte defvis,
|
||||||
set_t *out)
|
set_t *out)
|
||||||
{
|
{
|
||||||
unsigned numvis = model->brush.visleafs;
|
unsigned numvis = brush->visleafs;
|
||||||
unsigned excess = SET_SIZE (numvis) - numvis;
|
unsigned excess = SET_SIZE (numvis) - numvis;
|
||||||
|
|
||||||
set_expand (out, numvis);
|
set_expand (out, numvis);
|
||||||
if (leaf == model->brush.leafs) {
|
if (leaf == brush->leafs) {
|
||||||
byte *o = (byte *) out->map;
|
byte *o = (byte *) out->map;
|
||||||
for (int i = SET_WORDS (out) * sizeof (*out->map); i-- > 0; ) {
|
for (int i = SET_WORDS (out) * sizeof (*out->map); i-- > 0; ) {
|
||||||
*o++ |= defvis;
|
*o++ |= defvis;
|
||||||
|
@ -210,7 +209,7 @@ Mod_LeafPVS_mix (const mleaf_t *leaf, const model_t *model, byte defvis,
|
||||||
out->map[SET_WORDS (out) - 1] &= (~SET_ZERO) >> excess;
|
out->map[SET_WORDS (out) - 1] &= (~SET_ZERO) >> excess;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Mod_DecompressVis_mix (leaf->compressed_vis, &model->brush, defvis, out);
|
Mod_DecompressVis_mix (leaf->compressed_vis, brush, defvis, out);
|
||||||
out->map[SET_WORDS (out) - 1] &= (~SET_ZERO) >> excess;
|
out->map[SET_WORDS (out) - 1] &= (~SET_ZERO) >> excess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
#include "QF/simd/vec4f.h"
|
#include "QF/simd/vec4f.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
expand_pvs (set_t *pvs, model_t *model)
|
expand_pvs (set_t *pvs, mod_brush_t *brush)
|
||||||
{
|
{
|
||||||
set_t base_pvs = SET_STATIC_INIT (model->brush.visleafs, alloca);
|
set_t base_pvs = SET_STATIC_INIT (brush->visleafs, alloca);
|
||||||
set_assign (&base_pvs, pvs);
|
set_assign (&base_pvs, pvs);
|
||||||
for (unsigned i = 0; i < model->brush.visleafs; i++) {
|
for (unsigned i = 0; i < brush->visleafs; i++) {
|
||||||
if (set_is_member (&base_pvs, i)) {
|
if (set_is_member (&base_pvs, i)) {
|
||||||
Mod_LeafPVS_mix (model->brush.leafs + i + 1, model, 0, pvs);
|
Mod_LeafPVS_mix (brush->leafs + i + 1, brush, 0, pvs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ Light_AddLight (lightingdata_t *ldata, const light_t *light, int style)
|
||||||
int visleaf = -1; // directional light
|
int visleaf = -1; // directional light
|
||||||
if (light->position[3]) {
|
if (light->position[3]) {
|
||||||
// positional light
|
// positional light
|
||||||
mleaf_t *leaf = Mod_PointInLeaf (light->position, model);
|
mleaf_t *leaf = Mod_PointInLeaf (light->position, &model->brush);
|
||||||
visleaf = leaf - model->brush.leafs - 1;
|
visleaf = leaf - model->brush.leafs - 1;
|
||||||
} else if (!DotProduct (light->direction, light->direction)) {
|
} else if (!DotProduct (light->direction, light->direction)) {
|
||||||
// ambient light
|
// ambient light
|
||||||
|
@ -92,24 +92,24 @@ void
|
||||||
Light_EnableSun (lightingdata_t *ldata)
|
Light_EnableSun (lightingdata_t *ldata)
|
||||||
{
|
{
|
||||||
scene_t *scene = ldata->scene;
|
scene_t *scene = ldata->scene;
|
||||||
model_t *model = scene->worldmodel;
|
auto brush = &scene->worldmodel->brush;
|
||||||
|
|
||||||
if (!ldata->sun_pvs) {
|
if (!ldata->sun_pvs) {
|
||||||
ldata->sun_pvs = set_new_size (model->brush.visleafs);
|
ldata->sun_pvs = set_new_size (brush->visleafs);
|
||||||
}
|
}
|
||||||
set_expand (ldata->sun_pvs, model->brush.visleafs);
|
set_expand (ldata->sun_pvs, brush->visleafs);
|
||||||
set_empty (ldata->sun_pvs);
|
set_empty (ldata->sun_pvs);
|
||||||
// Any leaf with sky surfaces can potentially see the sun, thus put
|
// Any leaf with sky surfaces can potentially see the sun, thus put
|
||||||
// the sun "in" every leaf with a sky surface
|
// the sun "in" every leaf with a sky surface
|
||||||
// however, skip leaf 0 as it is the exterior solid leaf
|
// however, skip leaf 0 as it is the exterior solid leaf
|
||||||
for (unsigned l = 1; l < model->brush.modleafs; l++) {
|
for (unsigned l = 1; l < brush->modleafs; l++) {
|
||||||
if (model->brush.leaf_flags[l] & SURF_DRAWSKY) {
|
if (brush->leaf_flags[l] & SURF_DRAWSKY) {
|
||||||
set_add (ldata->sun_pvs, l - 1); //pvs is 1-based
|
set_add (ldata->sun_pvs, l - 1); //pvs is 1-based
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// any leaf visible from a leaf with a sky surface (and thus the sun)
|
// any leaf visible from a leaf with a sky surface (and thus the sun)
|
||||||
// can receive shadows from the sun
|
// can receive shadows from the sun
|
||||||
expand_pvs (ldata->sun_pvs, model);
|
expand_pvs (ldata->sun_pvs, brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -117,28 +117,28 @@ Light_FindVisibleLights (lightingdata_t *ldata)
|
||||||
{
|
{
|
||||||
scene_t *scene = ldata->scene;
|
scene_t *scene = ldata->scene;
|
||||||
mleaf_t *leaf = scene->viewleaf;
|
mleaf_t *leaf = scene->viewleaf;
|
||||||
model_t *model = scene->worldmodel;
|
auto brush = &scene->worldmodel->brush;
|
||||||
|
|
||||||
if (!leaf) {
|
if (!leaf) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ldata->pvs) {
|
if (!ldata->pvs) {
|
||||||
ldata->pvs = set_new_size (model->brush.visleafs);
|
ldata->pvs = set_new_size (brush->visleafs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leaf != ldata->leaf) {
|
if (leaf != ldata->leaf) {
|
||||||
//double start = Sys_DoubleTime ();
|
//double start = Sys_DoubleTime ();
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
if (leaf == model->brush.leafs) {
|
if (leaf == brush->leafs) {
|
||||||
set_everything (ldata->pvs);
|
set_everything (ldata->pvs);
|
||||||
flags = SURF_DRAWSKY;
|
flags = SURF_DRAWSKY;
|
||||||
} else {
|
} else {
|
||||||
Mod_LeafPVS_set (leaf, model, 0, ldata->pvs);
|
Mod_LeafPVS_set (leaf, brush, 0, ldata->pvs);
|
||||||
if (set_is_intersecting (ldata->pvs, ldata->sun_pvs)) {
|
if (set_is_intersecting (ldata->pvs, ldata->sun_pvs)) {
|
||||||
flags |= SURF_DRAWSKY;
|
flags |= SURF_DRAWSKY;
|
||||||
}
|
}
|
||||||
expand_pvs (ldata->pvs, model);
|
expand_pvs (ldata->pvs, brush);
|
||||||
}
|
}
|
||||||
ldata->leaf = leaf;
|
ldata->leaf = leaf;
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ R_MarkLeaves (mleaf_t *viewleaf, int *node_visframes, int *leaf_visframes,
|
||||||
}
|
}
|
||||||
vis = solid;
|
vis = solid;
|
||||||
} else
|
} else
|
||||||
vis = Mod_LeafPVS (viewleaf, r_refdef.worldmodel);
|
vis = Mod_LeafPVS (viewleaf, brush);
|
||||||
|
|
||||||
for (unsigned i = 0; i < brush->visleafs; i++) {
|
for (unsigned i = 0; i < brush->visleafs; i++) {
|
||||||
if (set_is_member (vis, i)) {
|
if (set_is_member (vis, i)) {
|
||||||
|
|
|
@ -264,7 +264,7 @@ R_MarkLights (vec4f_t lightorigin, dlight_t *light, int lightnum,
|
||||||
model_t *model)
|
model_t *model)
|
||||||
{
|
{
|
||||||
mod_brush_t *brush = &model->brush;
|
mod_brush_t *brush = &model->brush;
|
||||||
mleaf_t *pvsleaf = Mod_PointInLeaf (lightorigin, model);
|
mleaf_t *pvsleaf = Mod_PointInLeaf (lightorigin, brush);
|
||||||
|
|
||||||
if (!pvsleaf->compressed_vis) {
|
if (!pvsleaf->compressed_vis) {
|
||||||
int node_id = brush->hulls[0].firstclipnode;
|
int node_id = brush->hulls[0].firstclipnode;
|
||||||
|
|
|
@ -316,7 +316,8 @@ SCR_UpdateScreen (transform_t camera, double realtime, SCR_Func *scr_funcs)
|
||||||
if (scr_scene && scr_scene->worldmodel) {
|
if (scr_scene && scr_scene->worldmodel) {
|
||||||
scr_scene->viewleaf = 0;
|
scr_scene->viewleaf = 0;
|
||||||
vec4f_t position = refdef->frame.position;
|
vec4f_t position = refdef->frame.position;
|
||||||
scr_scene->viewleaf = Mod_PointInLeaf (position, scr_scene->worldmodel);
|
auto brush = &scr_scene->worldmodel->brush;
|
||||||
|
scr_scene->viewleaf = Mod_PointInLeaf (position, brush);
|
||||||
r_dowarpold = r_dowarp;
|
r_dowarpold = r_dowarp;
|
||||||
if (r_waterwarp) {
|
if (r_waterwarp) {
|
||||||
r_dowarp = scr_scene->viewleaf->contents <= CONTENTS_WATER;
|
r_dowarp = scr_scene->viewleaf->contents <= CONTENTS_WATER;
|
||||||
|
|
|
@ -655,7 +655,7 @@ CL_Frame (void)
|
||||||
vec4f_t origin;
|
vec4f_t origin;
|
||||||
|
|
||||||
origin = Transform_GetWorldPosition (cl.viewstate.camera_transform);
|
origin = Transform_GetWorldPosition (cl.viewstate.camera_transform);
|
||||||
l = Mod_PointInLeaf (origin, cl_world.scene->worldmodel);
|
l = Mod_PointInLeaf (origin, &cl_world.scene->worldmodel->brush);
|
||||||
if (l)
|
if (l)
|
||||||
asl = l->ambient_sound_level;
|
asl = l->ambient_sound_level;
|
||||||
S_Update (cl.viewstate.camera_transform, asl);
|
S_Update (cl.viewstate.camera_transform, asl);
|
||||||
|
|
|
@ -386,7 +386,7 @@ SV_AddToFatPVS (vec4f_t org, int node_id)
|
||||||
if (node_id < 0) {
|
if (node_id < 0) {
|
||||||
mleaf_t *leaf = sv.worldmodel->brush.leafs + ~node_id;
|
mleaf_t *leaf = sv.worldmodel->brush.leafs + ~node_id;
|
||||||
if (leaf->contents != CONTENTS_SOLID) {
|
if (leaf->contents != CONTENTS_SOLID) {
|
||||||
set_union (fatpvs, Mod_LeafPVS (leaf, sv.worldmodel));
|
set_union (fatpvs, Mod_LeafPVS (leaf, &sv.worldmodel->brush));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -584,11 +584,11 @@ PF_newcheckclient (progs_t *pr, unsigned check)
|
||||||
vec4f_t org;
|
vec4f_t org;
|
||||||
VectorAdd (SVvector (ent, origin), SVvector (ent, view_ofs), org);
|
VectorAdd (SVvector (ent, origin), SVvector (ent, view_ofs), org);
|
||||||
org[3] = 1;
|
org[3] = 1;
|
||||||
leaf = Mod_PointInLeaf (org, sv.worldmodel);
|
leaf = Mod_PointInLeaf (org, &sv.worldmodel->brush);
|
||||||
if (!checkpvs) {
|
if (!checkpvs) {
|
||||||
checkpvs = set_new_size (sv.worldmodel->brush.visleafs);
|
checkpvs = set_new_size (sv.worldmodel->brush.visleafs);
|
||||||
}
|
}
|
||||||
set_assign (checkpvs, Mod_LeafPVS (leaf, sv.worldmodel));
|
set_assign (checkpvs, Mod_LeafPVS (leaf, &sv.worldmodel->brush));
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -633,7 +633,7 @@ PF_checkclient (progs_t *pr, void *data)
|
||||||
vec4f_t view;
|
vec4f_t view;
|
||||||
VectorAdd (SVvector (self, origin), SVvector (self, view_ofs), view);
|
VectorAdd (SVvector (self, origin), SVvector (self, view_ofs), view);
|
||||||
view[3] = 1;
|
view[3] = 1;
|
||||||
leaf = Mod_PointInLeaf (view, sv.worldmodel);
|
leaf = Mod_PointInLeaf (view, &sv.worldmodel->brush);
|
||||||
l = (leaf - sv.worldmodel->brush.leafs) - 1;
|
l = (leaf - sv.worldmodel->brush.leafs) - 1;
|
||||||
if (!set_is_member (checkpvs, l)) {
|
if (!set_is_member (checkpvs, l)) {
|
||||||
c_notvis++;
|
c_notvis++;
|
||||||
|
|
|
@ -982,17 +982,18 @@ emit_entities (client_t *client, packet_entities_t *to, sizebuf_t *msg)
|
||||||
static void
|
static void
|
||||||
add_to_fat_pvs (vec4f_t org, int node_id, server_t *sv)
|
add_to_fat_pvs (vec4f_t org, int node_id, server_t *sv)
|
||||||
{
|
{
|
||||||
|
auto brush = &sv->worldmodel->brush;
|
||||||
while (1) {
|
while (1) {
|
||||||
// if this is a leaf, accumulate the pvs bits
|
// if this is a leaf, accumulate the pvs bits
|
||||||
if (node_id < 0) {
|
if (node_id < 0) {
|
||||||
mleaf_t *leaf = sv->worldmodel->brush.leafs + ~node_id;
|
mleaf_t *leaf = sv->worldmodel->brush.leafs + ~node_id;
|
||||||
if (leaf->contents != CONTENTS_SOLID) {
|
if (leaf->contents != CONTENTS_SOLID) {
|
||||||
set_union (sv->fatpvs, Mod_LeafPVS (leaf, sv->worldmodel));
|
set_union (sv->fatpvs, Mod_LeafPVS (leaf, brush));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mnode_t *node = sv->worldmodel->brush.nodes + node_id;
|
mnode_t *node = brush->nodes + node_id;
|
||||||
float d = dotf (node->plane, org)[0];
|
float d = dotf (node->plane, org)[0];
|
||||||
if (d > 8)
|
if (d > 8)
|
||||||
node_id = node->children[0];
|
node_id = node->children[0];
|
||||||
|
|
|
@ -1962,7 +1962,7 @@ Host_Frame (float time)
|
||||||
vec4f_t origin;
|
vec4f_t origin;
|
||||||
|
|
||||||
origin = Transform_GetWorldPosition (cl.viewstate.camera_transform);
|
origin = Transform_GetWorldPosition (cl.viewstate.camera_transform);
|
||||||
l = Mod_PointInLeaf (origin, cl_world.scene->worldmodel);
|
l = Mod_PointInLeaf (origin, &cl_world.scene->worldmodel->brush);
|
||||||
if (l)
|
if (l)
|
||||||
asl = l->ambient_sound_level;
|
asl = l->ambient_sound_level;
|
||||||
S_Update (cl.viewstate.camera_transform, asl);
|
S_Update (cl.viewstate.camera_transform, asl);
|
||||||
|
|
|
@ -64,18 +64,19 @@ static void
|
||||||
SV_AddToFatPVS (vec4f_t org, int node_id)
|
SV_AddToFatPVS (vec4f_t org, int node_id)
|
||||||
{
|
{
|
||||||
float d;
|
float d;
|
||||||
|
auto brush = &sv.worldmodel->brush;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// if this is a leaf, accumulate the pvs bits
|
// if this is a leaf, accumulate the pvs bits
|
||||||
if (node_id < 0) {
|
if (node_id < 0) {
|
||||||
mleaf_t *leaf = sv.worldmodel->brush.leafs + ~node_id;
|
mleaf_t *leaf = brush->leafs + ~node_id;
|
||||||
if (leaf->contents != CONTENTS_SOLID) {
|
if (leaf->contents != CONTENTS_SOLID) {
|
||||||
set_union (fatpvs, Mod_LeafPVS (leaf, sv.worldmodel));
|
set_union (fatpvs, Mod_LeafPVS (leaf, brush));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mnode_t *node = sv.worldmodel->brush.nodes + node_id;
|
mnode_t *node = brush->nodes + node_id;
|
||||||
d = dotf (org, node->plane)[0];
|
d = dotf (org, node->plane)[0];
|
||||||
if (d > 8)
|
if (d > 8)
|
||||||
node_id = node->children[0];
|
node_id = node->children[0];
|
||||||
|
|
|
@ -255,12 +255,12 @@ SV_CalcPHS (void)
|
||||||
|
|
||||||
SV_Printf ("Building PHS...\n");
|
SV_Printf ("Building PHS...\n");
|
||||||
|
|
||||||
num = sv.worldmodel->brush.modleafs;
|
auto brush = &sv.worldmodel->brush;
|
||||||
|
num = brush->modleafs;
|
||||||
sv.pvs = sv_alloc_vis_array (num);
|
sv.pvs = sv_alloc_vis_array (num);
|
||||||
vcount = 0;
|
vcount = 0;
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
Mod_LeafPVS_set (sv.worldmodel->brush.leafs + i, sv.worldmodel, 0xff,
|
Mod_LeafPVS_set (brush->leafs + i, brush, 0xff, &sv.pvs[i]);
|
||||||
&sv.pvs[i]);
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
continue;
|
continue;
|
||||||
vcount += set_count (&sv.pvs[i]);
|
vcount += set_count (&sv.pvs[i]);
|
||||||
|
|
|
@ -505,11 +505,11 @@ PF_newcheckclient (progs_t *pr, int check)
|
||||||
vec4f_t org;
|
vec4f_t org;
|
||||||
VectorAdd (SVvector (ent, origin), SVvector (ent, view_ofs), org);
|
VectorAdd (SVvector (ent, origin), SVvector (ent, view_ofs), org);
|
||||||
org[3] = 1;
|
org[3] = 1;
|
||||||
leaf = Mod_PointInLeaf (org, sv.worldmodel);
|
leaf = Mod_PointInLeaf (org, &sv.worldmodel->brush);
|
||||||
if (!checkpvs) {
|
if (!checkpvs) {
|
||||||
checkpvs = set_new_size (sv.worldmodel->brush.visleafs);
|
checkpvs = set_new_size (sv.worldmodel->brush.visleafs);
|
||||||
}
|
}
|
||||||
set_assign (checkpvs, Mod_LeafPVS (leaf, sv.worldmodel));
|
set_assign (checkpvs, Mod_LeafPVS (leaf, &sv.worldmodel->brush));
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,7 @@ PF_checkclient (progs_t *pr, void *data)
|
||||||
vec4f_t view;
|
vec4f_t view;
|
||||||
VectorAdd (SVvector (self, origin), SVvector (self, view_ofs), view);
|
VectorAdd (SVvector (self, origin), SVvector (self, view_ofs), view);
|
||||||
view[3] = 1;
|
view[3] = 1;
|
||||||
leaf = Mod_PointInLeaf (view, sv.worldmodel);
|
leaf = Mod_PointInLeaf (view, &sv.worldmodel->brush);
|
||||||
l = (leaf - sv.worldmodel->brush.leafs) - 1;
|
l = (leaf - sv.worldmodel->brush.leafs) - 1;
|
||||||
if (!set_is_member (checkpvs, l)) {
|
if (!set_is_member (checkpvs, l)) {
|
||||||
c_notvis++;
|
c_notvis++;
|
||||||
|
|
|
@ -302,7 +302,7 @@ SV_Multicast (const vec3_t origin, int to)
|
||||||
mod_brush_t *brush = &sv.worldmodel->brush;
|
mod_brush_t *brush = &sv.worldmodel->brush;
|
||||||
|
|
||||||
vec4f_t org = { VectorExpand (origin), 1 };
|
vec4f_t org = { VectorExpand (origin), 1 };
|
||||||
leaf = Mod_PointInLeaf (org, sv.worldmodel);
|
leaf = Mod_PointInLeaf (org, &sv.worldmodel->brush);
|
||||||
if (!leaf)
|
if (!leaf)
|
||||||
leafnum = 0;
|
leafnum = 0;
|
||||||
else
|
else
|
||||||
|
@ -347,7 +347,7 @@ SV_Multicast (const vec3_t origin, int to)
|
||||||
}
|
}
|
||||||
|
|
||||||
org = (vec4f_t) {VectorExpand (SVvector (client->edict, origin)), 1};
|
org = (vec4f_t) {VectorExpand (SVvector (client->edict, origin)), 1};
|
||||||
leaf = Mod_PointInLeaf (org, sv.worldmodel);
|
leaf = Mod_PointInLeaf (org, &sv.worldmodel->brush);
|
||||||
if (leaf) {
|
if (leaf) {
|
||||||
// -1 is because pvs rows are 1 based, not 0 based like leafs
|
// -1 is because pvs rows are 1 based, not 0 based like leafs
|
||||||
leafnum = leaf - brush->leafs - 1;
|
leafnum = leaf - brush->leafs - 1;
|
||||||
|
|
Loading…
Reference in a new issue