Skip to content

Commit

Permalink
renders: check min/max on nodes load
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Dec 31, 2024
1 parent 50a0609 commit 1fdb0f8
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 16 deletions.
39 changes: 34 additions & 5 deletions src/client/refresh/files/maps.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ Mod_NumberLeafs(mleaf_t *leafs, mnode_t *node, int *r_leaftovis, int *r_vistolea

static void
Mod_LoadQNodes(const char *name, cplane_t *planes, int numplanes, mleaf_t *leafs,
int numleafs, mnode_t **nodes, int *numnodes, const byte *mod_base,
const lump_t *l)
int numleafs, mnode_t **nodes, int *numnodes, vec3_t mins, vec3_t maxs,
const byte *mod_base, const lump_t *l)
{
dqnode_t *in;
mnode_t *out;
Expand All @@ -101,6 +101,24 @@ Mod_LoadQNodes(const char *name, cplane_t *planes, int numplanes, mleaf_t *leafs
*nodes = out;
*numnodes = count;

/* Set initial min/max */
if (count)
{
for (i = 0; i < 3; i++)
{
mins[i] = in->mins[i];
maxs[i] = in->maxs[i];
}
}
else
{
for (i = 0; i < 3; i++)
{
mins[i] = 0;
maxs[i] = 0;
}
}

for (i = 0; i < count; i++, in++, out++)
{
int j, planenum;
Expand All @@ -109,6 +127,17 @@ Mod_LoadQNodes(const char *name, cplane_t *planes, int numplanes, mleaf_t *leafs
{
out->minmaxs[j] = in->mins[j];
out->minmaxs[3 + j] = in->maxs[j];

/* update min/max */
if (mins[j] > in->mins[j])
{
mins[j] = in->mins[j];
}

if (maxs[j] < in->maxs[j])
{
maxs[j] = in->maxs[j];
}
}

planenum = LittleLong(in->planenum) & 0xFFFFFFFF;
Expand Down Expand Up @@ -156,8 +185,8 @@ Mod_LoadQNodes(const char *name, cplane_t *planes, int numplanes, mleaf_t *leafs

void
Mod_LoadQBSPNodes(const char *name, cplane_t *planes, int numplanes, mleaf_t *leafs,
int numleafs, mnode_t **nodes, int *numnodes, const byte *mod_base,
const lump_t *l, int ident)
int numleafs, mnode_t **nodes, int *numnodes, vec3_t mins, vec3_t maxs,
const byte *mod_base, const lump_t *l, int ident)
{
int *r_leaftovis, *r_vistoleaf;
int numvisleafs;
Expand All @@ -172,7 +201,7 @@ Mod_LoadQBSPNodes(const char *name, cplane_t *planes, int numplanes, mleaf_t *le
}

Mod_LoadQNodes(name, planes, numplanes, leafs, numleafs, nodes, numnodes,
mod_base, l);
mins, maxs, mod_base, l);

Mod_SetParent(*nodes, NULL); /* sets nodes and leafs */

Expand Down
4 changes: 2 additions & 2 deletions src/client/refresh/gl1/gl1_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
mod->marksurfaces, mod->nummarksurfaces, &mod->numclusters,
mod_base, &header->lumps[LUMP_LEAFS]);
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
&header->lumps[LUMP_NODES], header->ident);
mod->numleafs, &mod->nodes, &mod->numnodes, mod->mins, mod->maxs,
mod_base, &header->lumps[LUMP_NODES], header->ident);
Mod_LoadSubmodels(mod, mod_base, &header->lumps[LUMP_MODELS]);
mod->numframes = 2; /* regular and alternate animation */

Expand Down
4 changes: 2 additions & 2 deletions src/client/refresh/gl3/gl3_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
mod->marksurfaces, mod->nummarksurfaces, &mod->numclusters,
mod_base, &header->lumps[LUMP_LEAFS]);
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
&header->lumps[LUMP_NODES], header->ident);
mod->numleafs, &mod->nodes, &mod->numnodes, mod->mins, mod->maxs,
mod_base, &header->lumps[LUMP_NODES], header->ident);
Mod_LoadSubmodels(mod, mod_base, &header->lumps[LUMP_MODELS]);
mod->numframes = 2; /* regular and alternate animation */

Expand Down
4 changes: 2 additions & 2 deletions src/client/refresh/gl4/gl4_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
mod->marksurfaces, mod->nummarksurfaces, &mod->numclusters,
mod_base, &header->lumps[LUMP_LEAFS]);
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
&header->lumps[LUMP_NODES], header->ident);
mod->numleafs, &mod->nodes, &mod->numnodes, mod->mins, mod->maxs,
mod_base, &header->lumps[LUMP_NODES], header->ident);
Mod_LoadSubmodels(mod, mod_base, &header->lumps[LUMP_MODELS]);
mod->numframes = 2; /* regular and alternate animation */

Expand Down
2 changes: 1 addition & 1 deletion src/client/refresh/ref_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ extern void Mod_LoadQBSPMarksurfaces(const char *name, msurface_t ***marksurface
unsigned int *nummarksurfaces, msurface_t *surfaces, int numsurfaces,
const byte *mod_base, const lump_t *lMod_LoadQBSPMarksurfaces);
extern void Mod_LoadQBSPNodes(const char *name, cplane_t *planes, int numplanes,
mleaf_t *leafs, int numleafs, mnode_t **nodes, int *numnodes,
mleaf_t *leafs, int numleafs, mnode_t **nodes, int *numnodes, vec3_t mins, vec3_t maxs,
const byte *mod_base, const lump_t *l, int ident);
extern void Mod_LoadQBSPLeafs(const char *name, mleaf_t **leafs, int *numleafs,
msurface_t **marksurfaces, unsigned int nummarksurfaces,
Expand Down
4 changes: 2 additions & 2 deletions src/client/refresh/soft/sw_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
mod->marksurfaces, mod->nummarksurfaces, &mod->numclusters,
mod_base, &header->lumps[LUMP_LEAFS]);
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
&header->lumps[LUMP_NODES], header->ident);
mod->numleafs, &mod->nodes, &mod->numnodes, mod->mins, mod->maxs,
mod_base, &header->lumps[LUMP_NODES], header->ident);
Mod_LoadSubmodels(mod, mod_base, &header->lumps[LUMP_MODELS]);
mod->numframes = 2; /* regular and alternate animation */

Expand Down
4 changes: 2 additions & 2 deletions src/client/refresh/vk/vk_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
mod->marksurfaces, mod->nummarksurfaces, &mod->numclusters,
mod_base, &header->lumps[LUMP_LEAFS]);
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
&header->lumps[LUMP_NODES], header->ident);
mod->numleafs, &mod->nodes, &mod->numnodes, mod->mins, mod->maxs,
mod_base, &header->lumps[LUMP_NODES], header->ident);
Mod_LoadSubmodels(mod, mod_base, &header->lumps[LUMP_MODELS]);
mod->numframes = 2; /* regular and alternate animation */

Expand Down

0 comments on commit 1fdb0f8

Please sign in to comment.