mirror of
https://github.com/yquake2/ref_vk.git
synced 2024-11-10 06:41:45 +00:00
parent
659a5c489a
commit
de9b099995
5 changed files with 50 additions and 35 deletions
|
@ -207,5 +207,6 @@ extern void Mod_LoadPlanes (const char *name, cplane_t **planes, int *numplanes,
|
|||
extern void Mod_LoadSurfedges (const char *name, int **surfedges, int *numsurfedges,
|
||||
const byte *mod_base, const lump_t *l, int extra);
|
||||
extern int Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra);
|
||||
extern mleaf_t *Mod_PointInLeaf(const vec3_t p, mnode_t *node);
|
||||
|
||||
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */
|
||||
|
|
|
@ -750,3 +750,43 @@ Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra)
|
|||
size = (size + 31) & ~31;
|
||||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
Mod_PointInLeaf
|
||||
===============
|
||||
*/
|
||||
mleaf_t *
|
||||
Mod_PointInLeaf(const vec3_t p, mnode_t *node)
|
||||
{
|
||||
if (!node)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: bad node.", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
float d;
|
||||
cplane_t *plane;
|
||||
|
||||
if (node->contents != CONTENTS_NODE)
|
||||
{
|
||||
return (mleaf_t *)node;
|
||||
}
|
||||
|
||||
plane = node->plane;
|
||||
d = DotProduct(p, plane->normal) - plane->dist;
|
||||
|
||||
if (d > 0)
|
||||
{
|
||||
node = node->children[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
node = node->children[1];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL; /* never reached */
|
||||
}
|
||||
|
|
|
@ -168,7 +168,6 @@ typedef struct model_s
|
|||
//============================================================================
|
||||
|
||||
void Mod_Init (void);
|
||||
mleaf_t *Mod_PointInLeaf (const vec3_t p, model_t *model);
|
||||
const byte *Mod_ClusterPVS (int cluster, const model_t *model);
|
||||
|
||||
void Mod_Modellist_f (void);
|
||||
|
|
|
@ -33,37 +33,6 @@ static int models_known_max = 0;
|
|||
|
||||
int registration_sequence;
|
||||
|
||||
/*
|
||||
===============
|
||||
Mod_PointInLeaf
|
||||
===============
|
||||
*/
|
||||
mleaf_t *Mod_PointInLeaf (const vec3_t p, model_t *model)
|
||||
{
|
||||
mnode_t *node;
|
||||
|
||||
if (!model || !model->nodes)
|
||||
ri.Sys_Error (ERR_DROP, "%s: bad model", __func__);
|
||||
|
||||
node = model->nodes;
|
||||
while (1)
|
||||
{
|
||||
cplane_t *plane;
|
||||
float d;
|
||||
|
||||
if (node->contents != CONTENTS_NODE)
|
||||
return (mleaf_t *)node;
|
||||
plane = node->plane;
|
||||
d = DotProduct (p,plane->normal) - plane->dist;
|
||||
if (d > 0)
|
||||
node = node->children[0];
|
||||
else
|
||||
node = node->children[1];
|
||||
}
|
||||
|
||||
return NULL; // never reached
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
|
|
|
@ -698,9 +698,15 @@ R_SetupFrame (void)
|
|||
// current viewcluster
|
||||
if (!(r_newrefdef.rdflags & RDF_NOWORLDMODEL))
|
||||
{
|
||||
if (!r_worldmodel)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: bad world model", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
r_oldviewcluster = r_viewcluster;
|
||||
r_oldviewcluster2 = r_viewcluster2;
|
||||
leaf = Mod_PointInLeaf(r_origin, r_worldmodel);
|
||||
leaf = Mod_PointInLeaf(r_origin, r_worldmodel->nodes);
|
||||
r_viewcluster = r_viewcluster2 = leaf->cluster;
|
||||
|
||||
// check above and below so crossing solid water doesn't draw wrong
|
||||
|
@ -710,7 +716,7 @@ R_SetupFrame (void)
|
|||
|
||||
VectorCopy(r_origin, temp);
|
||||
temp[2] -= 16;
|
||||
leaf = Mod_PointInLeaf(temp, r_worldmodel);
|
||||
leaf = Mod_PointInLeaf(temp, r_worldmodel->nodes);
|
||||
if (!(leaf->contents & CONTENTS_SOLID) &&
|
||||
(leaf->cluster != r_viewcluster2))
|
||||
r_viewcluster2 = leaf->cluster;
|
||||
|
@ -721,7 +727,7 @@ R_SetupFrame (void)
|
|||
|
||||
VectorCopy(r_origin, temp);
|
||||
temp[2] += 16;
|
||||
leaf = Mod_PointInLeaf(temp, r_worldmodel);
|
||||
leaf = Mod_PointInLeaf(temp, r_worldmodel->nodes);
|
||||
if (!(leaf->contents & CONTENTS_SOLID) &&
|
||||
(leaf->cluster != r_viewcluster2))
|
||||
r_viewcluster2 = leaf->cluster;
|
||||
|
|
Loading…
Reference in a new issue