renders: share R_CullAliasMeshModel

This commit is contained in:
Denis Pauk 2023-12-29 01:20:43 +02:00
parent f9a2fee5b3
commit 057087b7dc
8 changed files with 199 additions and 553 deletions

View file

@ -61,3 +61,139 @@ R_LerpVerts(qboolean powerUpEffect, int nverts, dxtrivertx_t *v, dxtrivertx_t *o
}
}
}
qboolean
R_CullAliasMeshModel(dmdx_t *paliashdr, cplane_t *frustum, int frame, int oldframe, vec3_t e_angles,
vec3_t e_origin, vec3_t bbox[8])
{
int i;
vec3_t mins, maxs;
vec3_t vectors[3];
vec3_t thismins, oldmins, thismaxs, oldmaxs;
daliasxframe_t *pframe, *poldframe;
vec3_t angles;
pframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
frame * paliashdr->framesize);
poldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
oldframe * paliashdr->framesize);
/* compute axially aligned mins and maxs */
if (pframe == poldframe)
{
for (i = 0; i < 3; i++)
{
mins[i] = pframe->translate[i];
maxs[i] = mins[i] + pframe->scale[i] * 0xFFFF;
}
}
else
{
for (i = 0; i < 3; i++)
{
thismins[i] = pframe->translate[i];
thismaxs[i] = thismins[i] + pframe->scale[i] * 0xFFFF;
oldmins[i] = poldframe->translate[i];
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 0xFFFF;
if (thismins[i] < oldmins[i])
{
mins[i] = thismins[i];
}
else
{
mins[i] = oldmins[i];
}
if (thismaxs[i] > oldmaxs[i])
{
maxs[i] = thismaxs[i];
}
else
{
maxs[i] = oldmaxs[i];
}
}
}
/* compute a full bounding box */
for (i = 0; i < 8; i++)
{
vec3_t tmp;
if (i & 1)
{
tmp[0] = mins[0];
}
else
{
tmp[0] = maxs[0];
}
if (i & 2)
{
tmp[1] = mins[1];
}
else
{
tmp[1] = maxs[1];
}
if (i & 4)
{
tmp[2] = mins[2];
}
else
{
tmp[2] = maxs[2];
}
VectorCopy(tmp, bbox[i]);
}
/* rotate the bounding box */
VectorCopy(e_angles, angles);
angles[YAW] = -angles[YAW];
AngleVectors(angles, vectors[0], vectors[1], vectors[2]);
for (i = 0; i < 8; i++)
{
vec3_t tmp;
VectorCopy(bbox[i], tmp);
bbox[i][0] = DotProduct(vectors[0], tmp);
bbox[i][1] = -DotProduct(vectors[1], tmp);
bbox[i][2] = DotProduct(vectors[2], tmp);
VectorAdd(e_origin, bbox[i], bbox[i]);
}
int p, f, aggregatemask = ~0;
for (p = 0; p < 8; p++)
{
int mask = 0;
for (f = 0; f < 4; f++)
{
float dp = DotProduct(frustum[f].normal, bbox[p]);
if ((dp - frustum[f].dist) < 0)
{
mask |= (1 << f);
}
}
aggregatemask &= mask;
}
if (aggregatemask)
{
return true;
}
return false;
}

View file

@ -34,7 +34,6 @@ static float r_avertexnormal_dots[SHADEDOT_QUANT][256] = {
#include "../constants/anormtab.h"
};
typedef float vec4_t[4];
static vec4_t s_lerped[MAX_VERTS];
vec3_t shadevector;
float shadelight[3];
@ -231,10 +230,7 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp)
for (i = 0; i < 3; i++)
{
move[i] = backlerp * move[i] + frontlerp * frame->translate[i];
}
for (i = 0; i < 3; i++)
{
frontv[i] = frontlerp * frame->scale[i];
backv[i] = backlerp * oldframe->scale[i];
}
@ -385,13 +381,7 @@ R_DrawAliasShadow(entity_t *currententity, dmdx_t *paliashdr, int posenum)
static qboolean
R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
{
int i;
vec3_t mins, maxs;
dmdx_t *paliashdr;
vec3_t vectors[3];
vec3_t thismins, oldmins, thismaxs, oldmaxs;
daliasxframe_t *pframe, *poldframe;
vec3_t angles;
paliashdr = (dmdx_t *)currentmodel->extradata;
if (!paliashdr)
@ -415,129 +405,8 @@ R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
e->oldframe = 0;
}
pframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
e->frame * paliashdr->framesize);
poldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
e->oldframe * paliashdr->framesize);
/* compute axially aligned mins and maxs */
if (pframe == poldframe)
{
for (i = 0; i < 3; i++)
{
mins[i] = pframe->translate[i];
maxs[i] = mins[i] + pframe->scale[i] * 0xFFFF;
}
}
else
{
for (i = 0; i < 3; i++)
{
thismins[i] = pframe->translate[i];
thismaxs[i] = thismins[i] + pframe->scale[i] * 0xFFFF;
oldmins[i] = poldframe->translate[i];
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 0xFFFF;
if (thismins[i] < oldmins[i])
{
mins[i] = thismins[i];
}
else
{
mins[i] = oldmins[i];
}
if (thismaxs[i] > oldmaxs[i])
{
maxs[i] = thismaxs[i];
}
else
{
maxs[i] = oldmaxs[i];
}
}
}
/* compute a full bounding box */
for (i = 0; i < 8; i++)
{
vec3_t tmp;
if (i & 1)
{
tmp[0] = mins[0];
}
else
{
tmp[0] = maxs[0];
}
if (i & 2)
{
tmp[1] = mins[1];
}
else
{
tmp[1] = maxs[1];
}
if (i & 4)
{
tmp[2] = mins[2];
}
else
{
tmp[2] = maxs[2];
}
VectorCopy(tmp, bbox[i]);
}
/* rotate the bounding box */
VectorCopy(e->angles, angles);
angles[YAW] = -angles[YAW];
AngleVectors(angles, vectors[0], vectors[1], vectors[2]);
for (i = 0; i < 8; i++)
{
vec3_t tmp;
VectorCopy(bbox[i], tmp);
bbox[i][0] = DotProduct(vectors[0], tmp);
bbox[i][1] = -DotProduct(vectors[1], tmp);
bbox[i][2] = DotProduct(vectors[2], tmp);
VectorAdd(e->origin, bbox[i], bbox[i]);
}
int p, f, aggregatemask = ~0;
for (p = 0; p < 8; p++)
{
int mask = 0;
for (f = 0; f < 4; f++)
{
float dp = DotProduct(frustum[f].normal, bbox[p]);
if ((dp - frustum[f].dist) < 0)
{
mask |= (1 << f);
}
}
aggregatemask &= mask;
}
if (aggregatemask)
{
return true;
}
return false;
return R_CullAliasMeshModel(paliashdr, frustum, e->frame, e->oldframe,
e->angles, e->origin, bbox);
}
void

View file

@ -37,7 +37,6 @@ static float r_avertexnormal_dots[SHADEDOT_QUANT][256] = {
#include "../constants/anormtab.h"
};
typedef float vec4_t[4];
static vec4_t s_lerped[MAX_VERTS];
typedef struct gl3_shadowinfo_s {
@ -492,13 +491,7 @@ DrawAliasShadow(gl3_shadowinfo_t* shadowInfo)
static qboolean
CullAliasModel(vec3_t bbox[8], entity_t *e)
{
int i;
vec3_t mins, maxs;
dmdx_t *paliashdr;
vec3_t vectors[3];
vec3_t thismins, oldmins, thismaxs, oldmaxs;
daliasxframe_t *pframe, *poldframe;
vec3_t angles;
gl3model_t* model = e->model;
@ -506,141 +499,20 @@ CullAliasModel(vec3_t bbox[8], entity_t *e)
if ((e->frame >= paliashdr->num_frames) || (e->frame < 0))
{
R_Printf(PRINT_DEVELOPER, "R_CullAliasModel %s: no such frame %d\n",
model->name, e->frame);
R_Printf(PRINT_DEVELOPER, "%s %s: no such frame %d\n",
__func__, model->name, e->frame);
e->frame = 0;
}
if ((e->oldframe >= paliashdr->num_frames) || (e->oldframe < 0))
{
R_Printf(PRINT_DEVELOPER, "R_CullAliasModel %s: no such oldframe %d\n",
model->name, e->oldframe);
R_Printf(PRINT_DEVELOPER, "%s %s: no such oldframe %d\n",
__func__, model->name, e->oldframe);
e->oldframe = 0;
}
pframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
e->frame * paliashdr->framesize);
poldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
e->oldframe * paliashdr->framesize);
/* compute axially aligned mins and maxs */
if (pframe == poldframe)
{
for (i = 0; i < 3; i++)
{
mins[i] = pframe->translate[i];
maxs[i] = mins[i] + pframe->scale[i] * 0xFFFF;
}
}
else
{
for (i = 0; i < 3; i++)
{
thismins[i] = pframe->translate[i];
thismaxs[i] = thismins[i] + pframe->scale[i] * 0xFFFF;
oldmins[i] = poldframe->translate[i];
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 0xFFFF;
if (thismins[i] < oldmins[i])
{
mins[i] = thismins[i];
}
else
{
mins[i] = oldmins[i];
}
if (thismaxs[i] > oldmaxs[i])
{
maxs[i] = thismaxs[i];
}
else
{
maxs[i] = oldmaxs[i];
}
}
}
/* compute a full bounding box */
for (i = 0; i < 8; i++)
{
vec3_t tmp;
if (i & 1)
{
tmp[0] = mins[0];
}
else
{
tmp[0] = maxs[0];
}
if (i & 2)
{
tmp[1] = mins[1];
}
else
{
tmp[1] = maxs[1];
}
if (i & 4)
{
tmp[2] = mins[2];
}
else
{
tmp[2] = maxs[2];
}
VectorCopy(tmp, bbox[i]);
}
/* rotate the bounding box */
VectorCopy(e->angles, angles);
angles[YAW] = -angles[YAW];
AngleVectors(angles, vectors[0], vectors[1], vectors[2]);
for (i = 0; i < 8; i++)
{
vec3_t tmp;
VectorCopy(bbox[i], tmp);
bbox[i][0] = DotProduct(vectors[0], tmp);
bbox[i][1] = -DotProduct(vectors[1], tmp);
bbox[i][2] = DotProduct(vectors[2], tmp);
VectorAdd(e->origin, bbox[i], bbox[i]);
}
int p, f, aggregatemask = ~0;
for (p = 0; p < 8; p++)
{
int mask = 0;
for (f = 0; f < 4; f++)
{
float dp = DotProduct(frustum[f].normal, bbox[p]);
if ((dp - frustum[f].dist) < 0)
{
mask |= (1 << f);
}
}
aggregatemask &= mask;
}
if (aggregatemask)
{
return true;
}
return false;
return R_CullAliasMeshModel(paliashdr, frustum, e->frame, e->oldframe,
e->angles, e->origin, bbox);
}
void
@ -1008,4 +880,3 @@ void GL3_DrawAliasShadows(void)
gl3state.uni3DData.transModelMat4 = oldMat;
GL3_UpdateUBO3D();
}

View file

@ -37,7 +37,6 @@ static float r_avertexnormal_dots[SHADEDOT_QUANT][256] = {
#include "../constants/anormtab.h"
};
typedef float vec4_t[4];
static vec4_t s_lerped[MAX_VERTS];
typedef struct gl4_shadowinfo_s {
@ -73,12 +72,9 @@ GL4_ShutdownMeshes(void)
static void
DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
{
GLenum type;
float l;
daliasxframe_t *frame, *oldframe;
dxtrivertx_t *v, *ov, *verts;
int *order;
int count;
float alpha;
vec3_t move, delta, vectors[3];
vec3_t frontv, backv;
@ -168,6 +164,8 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
while (1)
{
GLushort nextVtxIdx = da_count(vtxBuf);
GLenum type;
int count;
/* get the vertex count and primitive type */
count = *order++;
@ -213,8 +211,11 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
int i;
for(i=0; i<count; ++i)
{
int j=0;
gl4_alias_vtx_t* cur = &buf[i];
int index_xyz;
int j = 0;
float l;
/* texture coordinates come from the draw list */
cur->texCoord[0] = ((float *) order)[0];
cur->texCoord[1] = ((float *) order)[1];
@ -293,7 +294,6 @@ DrawAliasShadow(gl4_shadowinfo_t* shadowInfo)
{
GLenum type;
int *order;
vec3_t point;
float height = 0, lheight;
int count;
@ -384,6 +384,8 @@ DrawAliasShadow(gl4_shadowinfo_t* shadowInfo)
for(i=0; i<count; ++i)
{
vec3_t point;
/* normals and vertexes come from the frame list */
VectorCopy(s_lerped[order[2]], point);
@ -452,13 +454,7 @@ DrawAliasShadow(gl4_shadowinfo_t* shadowInfo)
static qboolean
CullAliasModel(vec3_t bbox[8], entity_t *e)
{
int i;
vec3_t mins, maxs;
dmdx_t *paliashdr;
vec3_t vectors[3];
vec3_t thismins, oldmins, thismaxs, oldmaxs;
daliasxframe_t *pframe, *poldframe;
vec3_t angles;
gl4model_t* model = e->model;
@ -466,141 +462,20 @@ CullAliasModel(vec3_t bbox[8], entity_t *e)
if ((e->frame >= paliashdr->num_frames) || (e->frame < 0))
{
R_Printf(PRINT_DEVELOPER, "R_CullAliasModel %s: no such frame %d\n",
model->name, e->frame);
R_Printf(PRINT_DEVELOPER, "%s %s: no such frame %d\n",
__func__, model->name, e->frame);
e->frame = 0;
}
if ((e->oldframe >= paliashdr->num_frames) || (e->oldframe < 0))
{
R_Printf(PRINT_DEVELOPER, "R_CullAliasModel %s: no such oldframe %d\n",
model->name, e->oldframe);
R_Printf(PRINT_DEVELOPER, "%s %s: no such oldframe %d\n",
__func__, model->name, e->oldframe);
e->oldframe = 0;
}
pframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
e->frame * paliashdr->framesize);
poldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
e->oldframe * paliashdr->framesize);
/* compute axially aligned mins and maxs */
if (pframe == poldframe)
{
for (i = 0; i < 3; i++)
{
mins[i] = pframe->translate[i];
maxs[i] = mins[i] + pframe->scale[i] * 0xFFFF;
}
}
else
{
for (i = 0; i < 3; i++)
{
thismins[i] = pframe->translate[i];
thismaxs[i] = thismins[i] + pframe->scale[i] * 0xFFFF;
oldmins[i] = poldframe->translate[i];
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 0xFFFF;
if (thismins[i] < oldmins[i])
{
mins[i] = thismins[i];
}
else
{
mins[i] = oldmins[i];
}
if (thismaxs[i] > oldmaxs[i])
{
maxs[i] = thismaxs[i];
}
else
{
maxs[i] = oldmaxs[i];
}
}
}
/* compute a full bounding box */
for (i = 0; i < 8; i++)
{
vec3_t tmp;
if (i & 1)
{
tmp[0] = mins[0];
}
else
{
tmp[0] = maxs[0];
}
if (i & 2)
{
tmp[1] = mins[1];
}
else
{
tmp[1] = maxs[1];
}
if (i & 4)
{
tmp[2] = mins[2];
}
else
{
tmp[2] = maxs[2];
}
VectorCopy(tmp, bbox[i]);
}
/* rotate the bounding box */
VectorCopy(e->angles, angles);
angles[YAW] = -angles[YAW];
AngleVectors(angles, vectors[0], vectors[1], vectors[2]);
for (i = 0; i < 8; i++)
{
vec3_t tmp;
VectorCopy(bbox[i], tmp);
bbox[i][0] = DotProduct(vectors[0], tmp);
bbox[i][1] = -DotProduct(vectors[1], tmp);
bbox[i][2] = DotProduct(vectors[2], tmp);
VectorAdd(e->origin, bbox[i], bbox[i]);
}
int p, f, aggregatemask = ~0;
for (p = 0; p < 8; p++)
{
int mask = 0;
for (f = 0; f < 4; f++)
{
float dp = DotProduct(frustum[f].normal, bbox[p]);
if ((dp - frustum[f].dist) < 0)
{
mask |= (1 << f);
}
}
aggregatemask &= mask;
}
if (aggregatemask)
{
return true;
}
return false;
return R_CullAliasMeshModel(paliashdr, frustum, e->frame, e->oldframe,
e->angles, e->origin, bbox);
}
void
@ -743,12 +618,13 @@ GL4_DrawAliasModel(entity_t *entity)
{
/* bonus items will pulse with time */
float scale;
float min;
scale = 0.1 * sin(gl4_newrefdef.time * 7);
for (i = 0; i < 3; i++)
{
float min;
min = shadelight[i] * 0.8;
shadelight[i] += scale;
@ -967,4 +843,3 @@ void GL4_DrawAliasShadows(void)
gl4state.uni3DData.transModelMat4 = oldMat;
GL4_UpdateUBO3D();
}

View file

@ -377,6 +377,8 @@ extern void R_SubdivideSurface(int *surfedges, mvertex_t *vertexes, medge_t *edg
msurface_t *fa);
/* Mesh logic */
extern qboolean R_CullAliasMeshModel(dmdx_t *paliashdr, cplane_t *frustum,
int frame, int oldframe, vec3_t e_angles, vec3_t e_origin, vec3_t bbox[8]);
extern void R_LerpVerts(qboolean powerUpEffect, int nverts, dxtrivertx_t *v, dxtrivertx_t *ov,
dxtrivertx_t *verts, float *lerp, const float move[3],
const float frontv[3], const float backv[3]);

View file

@ -78,9 +78,11 @@ R_AliasCheckBBox
#define BBOX_TRIVIAL_REJECT 8
/*
** R_AliasCheckFrameBBox
**
** Checks a specific alias frame bounding box
* R_AliasCheckFrameBBox
*
* Checks a specific alias frame bounding box
*
* TODO: Combine with R_CullAliasMeshModel
*/
static unsigned long
R_AliasCheckFrameBBox( daliasxframe_t *frame, float worldxf[3][4] )
@ -99,7 +101,7 @@ R_AliasCheckFrameBBox( daliasxframe_t *frame, float worldxf[3][4] )
for (i=0 ; i<3 ; i++)
{
mins[i] = frame->translate[i];
maxs[i] = mins[i] + frame->scale[i]*255;
maxs[i] = mins[i] + frame->scale[i] * 0xFFFF;
}
/*
@ -109,9 +111,14 @@ R_AliasCheckFrameBBox( daliasxframe_t *frame, float worldxf[3][4] )
R_AliasTransformVector( maxs, transformed_max, aliastransform );
if ( transformed_min[2] >= ALIAS_Z_CLIP_PLANE )
{
zfullyclipped = false;
}
if ( transformed_max[2] >= ALIAS_Z_CLIP_PLANE )
{
zfullyclipped = false;
}
if ( zfullyclipped )
{
@ -128,19 +135,31 @@ R_AliasCheckFrameBBox( daliasxframe_t *frame, float worldxf[3][4] )
unsigned long clipcode = 0;
if ( i & 1 )
{
tmp[0] = mins[0];
}
else
{
tmp[0] = maxs[0];
}
if ( i & 2 )
{
tmp[1] = mins[1];
}
else
{
tmp[1] = maxs[1];
}
if ( i & 4 )
{
tmp[2] = mins[2];
}
else
{
tmp[2] = maxs[2];
}
R_AliasTransformVector( tmp, transformed, worldxf );
@ -149,7 +168,9 @@ R_AliasCheckFrameBBox( daliasxframe_t *frame, float worldxf[3][4] )
float dp = DotProduct( transformed, view_clipplanes[j].normal );
if ( ( dp - view_clipplanes[j].dist ) < 0.0F )
{
clipcode |= 1 << j;
}
}
aggregate_and_clipcode &= clipcode;
@ -392,12 +413,17 @@ R_AliasSetUpTransform(const entity_t *currententity)
/*
================
R_AliasTransformFinalVerts
TODO: Combine with R_LerpVerts
================
*/
static void
R_AliasTransformFinalVerts(const entity_t *currententity, int numpoints, finalvert_t *fv, dxtrivertx_t *oldv, dxtrivertx_t *newv )
{
int i;
qboolean colorOnly = 0 != (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE |
RF_SHELL_HALF_DAM));
for ( i = 0; i < numpoints; i++, fv++, oldv++, newv++ )
{
@ -405,14 +431,14 @@ R_AliasTransformFinalVerts(const entity_t *currententity, int numpoints, finalve
const float *plightnormal;
vec3_t lerped_vert;
lerped_vert[0] = r_lerp_move[0] + oldv->v[0]*r_lerp_backv[0] + newv->v[0]*r_lerp_frontv[0];
lerped_vert[1] = r_lerp_move[1] + oldv->v[1]*r_lerp_backv[1] + newv->v[1]*r_lerp_frontv[1];
lerped_vert[2] = r_lerp_move[2] + oldv->v[2]*r_lerp_backv[2] + newv->v[2]*r_lerp_frontv[2];
lerped_vert[0] = r_lerp_move[0] + oldv->v[0] * r_lerp_backv[0] + newv->v[0] * r_lerp_frontv[0];
lerped_vert[1] = r_lerp_move[1] + oldv->v[1] * r_lerp_backv[1] + newv->v[1] * r_lerp_frontv[1];
lerped_vert[2] = r_lerp_move[2] + oldv->v[2] * r_lerp_backv[2] + newv->v[2] * r_lerp_frontv[2];
plightnormal = r_avertexnormals[newv->lightnormalindex];
// added double damage shell
if ( currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM) )
if ( colorOnly )
{
lerped_vert[0] += plightnormal[0] * POWERSUIT_SCALE;
lerped_vert[1] += plightnormal[1] * POWERSUIT_SCALE;

View file

@ -30,8 +30,6 @@
#define NUMVERTEXNORMALS 162
#define SHADEDOT_QUANT 16
typedef float vec4_t[4];
enum {
TRIANGLE_STRIP = 0,
TRIANGLE_FAN = 1
@ -466,10 +464,7 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp
for (i = 0; i < 3; i++)
{
move[i] = backlerp * move[i] + frontlerp * frame->translate[i];
}
for (i = 0; i < 3; i++)
{
frontv[i] = frontlerp * frame->scale[i];
backv[i] = backlerp * oldframe->scale[i];
}
@ -594,13 +589,7 @@ Vk_DrawAliasShadow(int *order, int *order_end, int posenum,
static qboolean
R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
{
int i;
vec3_t mins, maxs;
dmdx_t *paliashdr;
vec3_t vectors[3];
vec3_t thismins, oldmins, thismaxs, oldmaxs;
daliasxframe_t *pframe, *poldframe;
vec3_t angles;
paliashdr = (dmdx_t *)currentmodel->extradata;
if (!paliashdr)
@ -624,131 +613,8 @@ R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
e->oldframe = 0;
}
pframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
e->frame * paliashdr->framesize);
poldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
e->oldframe * paliashdr->framesize);
/* compute axially aligned mins and maxs */
if (pframe == poldframe)
{
for (i = 0; i < 3; i++)
{
mins[i] = pframe->translate[i];
maxs[i] = mins[i] + pframe->scale[i] * 0xFFFF;
}
}
else
{
for (i = 0; i < 3; i++)
{
thismins[i] = pframe->translate[i];
thismaxs[i] = thismins[i] + pframe->scale[i] * 0xFFFF;
oldmins[i] = poldframe->translate[i];
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 0xFFFF;
if (thismins[i] < oldmins[i])
{
mins[i] = thismins[i];
}
else
{
mins[i] = oldmins[i];
}
if (thismaxs[i] > oldmaxs[i])
{
maxs[i] = thismaxs[i];
}
else
{
maxs[i] = oldmaxs[i];
}
}
}
/* compute a full bounding box */
for (i = 0; i < 8; i++)
{
vec3_t tmp;
if (i & 1)
{
tmp[0] = mins[0];
}
else
{
tmp[0] = maxs[0];
}
if (i & 2)
{
tmp[1] = mins[1];
}
else
{
tmp[1] = maxs[1];
}
if (i & 4)
{
tmp[2] = mins[2];
}
else
{
tmp[2] = maxs[2];
}
VectorCopy(tmp, bbox[i]);
}
/* rotate the bounding box */
VectorCopy(e->angles, angles);
angles[YAW] = -angles[YAW];
AngleVectors(angles, vectors[0], vectors[1], vectors[2]);
for (i = 0; i < 8; i++)
{
vec3_t tmp;
VectorCopy(bbox[i], tmp);
bbox[i][0] = DotProduct(vectors[0], tmp);
bbox[i][1] = -DotProduct(vectors[1], tmp);
bbox[i][2] = DotProduct(vectors[2], tmp);
VectorAdd(e->origin, bbox[i], bbox[i]);
}
{
int p, f, aggregatemask = ~0;
for (p = 0; p < 8; p++)
{
int mask = 0;
for (f = 0; f < 4; f++)
{
float dp = DotProduct( frustum[f].normal, bbox[p] );
if ((dp - frustum[f].dist ) < 0)
{
mask |= (1 << f);
}
}
aggregatemask &= mask;
}
if (aggregatemask)
{
return true;
}
return false;
}
return R_CullAliasMeshModel(paliashdr, frustum, e->frame, e->oldframe,
e->angles, e->origin, bbox);
}
void

View file

@ -214,6 +214,7 @@ typedef enum
typedef float vec_t;
typedef vec_t vec3_t[3];
typedef vec_t vec4_t[4];
typedef vec_t vec5_t[5];
typedef int fixed4_t;