gl1,gl3,gl4,vk: sync R_LerpVerts

This commit is contained in:
Denis Pauk 2023-12-26 14:14:31 +02:00
parent 06ee407efa
commit 2a8e84ccd8
8 changed files with 95 additions and 163 deletions

View File

@ -1038,6 +1038,7 @@ REFGL1_OBJS_ := \
src/client/refresh/gl1/gl1_surf.o \
src/client/refresh/gl1/gl1_warp.o \
src/client/refresh/gl1/gl1_sdl.o \
src/client/refresh/files/mesh.o \
src/client/refresh/files/light.o \
src/client/refresh/files/surf.o \
src/client/refresh/files/models.o \
@ -1074,6 +1075,7 @@ REFGL3_OBJS_ := \
src/client/refresh/gl3/gl3_surf.o \
src/client/refresh/gl3/gl3_warp.o \
src/client/refresh/gl3/gl3_shaders.o \
src/client/refresh/files/mesh.o \
src/client/refresh/files/light.o \
src/client/refresh/files/surf.o \
src/client/refresh/files/models.o \
@ -1116,6 +1118,7 @@ REFGL4_OBJS_ := \
src/client/refresh/gl4/gl4_surf.o \
src/client/refresh/gl4/gl4_warp.o \
src/client/refresh/gl4/gl4_shaders.o \
src/client/refresh/files/mesh.o \
src/client/refresh/files/light.o \
src/client/refresh/files/surf.o \
src/client/refresh/files/models.o \
@ -1160,6 +1163,7 @@ REFSOFT_OBJS_ := \
src/client/refresh/soft/sw_sprite.o \
src/client/refresh/soft/sw_surf.o \
src/client/refresh/soft/sw_warp.o \
src/client/refresh/files/mesh.o \
src/client/refresh/files/light.o \
src/client/refresh/files/surf.o \
src/client/refresh/files/models.o \
@ -1203,6 +1207,7 @@ REFVK_OBJS_ := \
src/client/refresh/vk/vk_warp.o \
src/client/refresh/vk/vk_util.o \
src/client/refresh/vk/volk/volk.o \
src/client/refresh/files/mesh.o \
src/client/refresh/files/light.o \
src/client/refresh/files/surf.o \
src/client/refresh/files/models.o \

View File

@ -0,0 +1,63 @@
/*
* Copyright (C) 1997-2001 Id Software, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* Mesh logic
*
* =======================================================================
*/
#include "../ref_shared.h"
static float r_avertexnormals[NUMVERTEXNORMALS][3] = {
#include "../constants/anorms.h"
};
void
R_LerpVerts(qboolean powerUpEffect, int nverts, dtrivertx_t *v, dtrivertx_t *ov,
dtrivertx_t *verts, float *lerp, const float move[3],
const float frontv[3], const float backv[3])
{
int i;
if (powerUpEffect)
{
for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
float *normal = r_avertexnormals[verts[i].lightnormalindex];
lerp[0] = move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0] +
normal[0] * POWERSUIT_SCALE;
lerp[1] = move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1] +
normal[1] * POWERSUIT_SCALE;
lerp[2] = move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2] +
normal[2] * POWERSUIT_SCALE;
}
}
else
{
for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
lerp[0] = move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0];
lerp[1] = move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1];
lerp[2] = move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2];
}
}
}

View File

@ -41,10 +41,14 @@ R_TextureAnimation(const entity_t *currententity, const mtexinfo_t *tex)
int c;
if (!tex->next)
{
return tex->image;
}
if (!currententity)
{
return tex->image;
}
c = currententity->frame % tex->numframes;
while (c && tex)
@ -63,12 +67,16 @@ R_AreaVisible(const byte *areabits, mleaf_t *pleaf)
// check for door connected areas
if (!areabits)
{
return true;
}
area = pleaf->area;
if ((areabits[area >> 3] & (1 << (area & 7))))
{
return true;
}
return false; // not visible
}

View File

@ -29,10 +29,6 @@
#define NUMVERTEXNORMALS 162
#define SHADEDOT_QUANT 16
static float r_avertexnormals[NUMVERTEXNORMALS][3] = {
#include "../constants/anorms.h"
};
/* precalculated dot products for quantized angles */
static float r_avertexnormal_dots[SHADEDOT_QUANT][256] = {
#include "../constants/anormtab.h"
@ -44,41 +40,6 @@ vec3_t shadevector;
float shadelight[3];
float *shadedots = r_avertexnormal_dots[0];
static void
R_LerpVerts(entity_t *currententity, int nverts, dtrivertx_t *v, dtrivertx_t *ov,
dtrivertx_t *verts, float *lerp, const float move[3],
const float frontv[3], const float backv[3])
{
int i;
if (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN |
RF_SHELL_BLUE | RF_SHELL_DOUBLE |
RF_SHELL_HALF_DAM))
{
for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
float *normal = r_avertexnormals[verts[i].lightnormalindex];
lerp[0] = move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0] +
normal[0] * POWERSUIT_SCALE;
lerp[1] = move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1] +
normal[1] * POWERSUIT_SCALE;
lerp[2] = move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2] +
normal[2] * POWERSUIT_SCALE;
}
}
else
{
for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
lerp[0] = move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0];
lerp[1] = move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1];
lerp[2] = move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2];
}
}
}
static void
R_DrawAliasDrawCommands(entity_t *currententity, int *order, int *order_end,
float alpha, dtrivertx_t *verts)
@ -227,6 +188,9 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdl_t *paliashdr, float backlerp)
float *lerp;
int num_mesh_nodes;
short *mesh_nodes;
qboolean colorOnly = 0 != (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE |
RF_SHELL_HALF_DAM));
frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
+ currententity->frame * paliashdr->framesize);
@ -247,9 +211,7 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdl_t *paliashdr, float backlerp)
alpha = 1.0;
}
if (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE |
RF_SHELL_HALF_DAM))
if (colorOnly)
{
glDisable(GL_TEXTURE_2D);
}
@ -279,7 +241,7 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdl_t *paliashdr, float backlerp)
lerp = s_lerped[0];
R_LerpVerts(currententity, paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
R_LerpVerts(colorOnly, paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
num_mesh_nodes = (paliashdr->ofs_skins - sizeof(dmdl_t)) / sizeof(short) / 2;
mesh_nodes = (short *)((char*)paliashdr + sizeof(dmdl_t));
@ -303,9 +265,7 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdl_t *paliashdr, float backlerp)
alpha, verts);
}
if (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE |
RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM))
if (colorOnly)
{
glEnable(GL_TEXTURE_2D);
}

View File

@ -32,10 +32,6 @@
#define NUMVERTEXNORMALS 162
#define SHADEDOT_QUANT 16
static float r_avertexnormals[NUMVERTEXNORMALS][3] = {
#include "../constants/anorms.h"
};
/* precalculated dot products for quantized angles */
static float r_avertexnormal_dots[SHADEDOT_QUANT][256] = {
#include "../constants/anormtab.h"
@ -71,38 +67,6 @@ GL3_ShutdownMeshes(void)
da_free(shadowModels);
}
static void
LerpVerts(qboolean powerUpEffect, int nverts, dtrivertx_t *v, dtrivertx_t *ov,
dtrivertx_t *verts, float *lerp, float move[3],
float frontv[3], float backv[3])
{
int i;
if (powerUpEffect)
{
for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
float *normal = r_avertexnormals[verts[i].lightnormalindex];
lerp[0] = move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0] +
normal[0] * POWERSUIT_SCALE;
lerp[1] = move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1] +
normal[1] * POWERSUIT_SCALE;
lerp[2] = move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2] +
normal[2] * POWERSUIT_SCALE;
}
}
else
{
for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
lerp[0] = move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0];
lerp[1] = move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1];
lerp[2] = move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2];
}
}
}
static void
DrawAliasFrameLerpCommands(dmdl_t *paliashdr, entity_t* entity, vec3_t shadelight,
int *order, int *order_end, float* shadedots, float alpha, qboolean colorOnly,
@ -329,7 +293,7 @@ DrawAliasFrameLerp(dmdl_t *paliashdr, entity_t* entity, vec3_t shadelight)
lerp = s_lerped[0];
LerpVerts(colorOnly, paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
R_LerpVerts(colorOnly, paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
YQ2_STATIC_ASSERT(sizeof(gl3_alias_vtx_t) == 9*sizeof(GLfloat), "invalid gl3_alias_vtx_t size");
@ -516,7 +480,7 @@ DrawAliasShadow(gl3_shadowinfo_t* shadowInfo)
// false: don't extrude vertices for powerup - this means the powerup shell
// is not seen in the shadow, only the underlying model..
LerpVerts(false, paliashdr->num_xyz, v, ov, verts, s_lerped[0], move, frontv, backv);
R_LerpVerts(false, paliashdr->num_xyz, v, ov, verts, s_lerped[0], move, frontv, backv);
}
lheight = entity->origin[2] - shadowInfo->lightspot[2];

View File

@ -32,10 +32,6 @@
#define NUMVERTEXNORMALS 162
#define SHADEDOT_QUANT 16
static float r_avertexnormals[NUMVERTEXNORMALS][3] = {
#include "../constants/anorms.h"
};
/* precalculated dot products for quantized angles */
static float r_avertexnormal_dots[SHADEDOT_QUANT][256] = {
#include "../constants/anormtab.h"
@ -71,38 +67,6 @@ GL4_ShutdownMeshes(void)
da_free(shadowModels);
}
static void
LerpVerts(qboolean powerUpEffect, int nverts, dtrivertx_t *v, dtrivertx_t *ov,
dtrivertx_t *verts, float *lerp, float move[3],
float frontv[3], float backv[3])
{
int i;
if (powerUpEffect)
{
for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
float *normal = r_avertexnormals[verts[i].lightnormalindex];
lerp[0] = move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0] +
normal[0] * POWERSUIT_SCALE;
lerp[1] = move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1] +
normal[1] * POWERSUIT_SCALE;
lerp[2] = move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2] +
normal[2] * POWERSUIT_SCALE;
}
}
else
{
for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
lerp[0] = move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0];
lerp[1] = move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1];
lerp[2] = move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2];
}
}
}
/*
* Interpolates between two frames and origins
*/
@ -186,7 +150,7 @@ DrawAliasFrameLerp(dmdl_t *paliashdr, entity_t* entity, vec3_t shadelight)
lerp = s_lerped[0];
LerpVerts(colorOnly, paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
R_LerpVerts(colorOnly, paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
YQ2_STATIC_ASSERT(sizeof(gl4_alias_vtx_t) == 9*sizeof(GLfloat), "invalid gl4_alias_vtx_t size");
@ -377,7 +341,7 @@ DrawAliasShadow(gl4_shadowinfo_t* shadowInfo)
// false: don't extrude vertices for powerup - this means the powerup shell
// is not seen in the shadow, only the underlying model..
LerpVerts(false, paliashdr->num_xyz, v, ov, verts, s_lerped[0], move, frontv, backv);
R_LerpVerts(false, paliashdr->num_xyz, v, ov, verts, s_lerped[0], move, frontv, backv);
}
lheight = entity->origin[2] - shadowInfo->lightspot[2];

View File

@ -376,6 +376,11 @@ extern void R_SetFrustum(vec3_t vup, vec3_t vpn, vec3_t vright, vec3_t r_origin,
extern void R_SubdivideSurface(int *surfedges, mvertex_t *vertexes, medge_t *edges,
msurface_t *fa);
/* Mesh logic */
extern void R_LerpVerts(qboolean powerUpEffect, int nverts, dtrivertx_t *v, dtrivertx_t *ov,
dtrivertx_t *verts, float *lerp, const float move[3],
const float frontv[3], const float backv[3]);
/* Lights logic */
extern bspxlightgrid_t *Mod_LoadBSPXLightGrid(const bspx_header_t *bspx_header, const byte *mod_base);
extern void R_LightPoint(const bspxlightgrid_t *grid, const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,

View File

@ -30,10 +30,6 @@
#define NUMVERTEXNORMALS 162
#define SHADEDOT_QUANT 16
static float r_avertexnormals[NUMVERTEXNORMALS][3] = {
#include "../constants/anorms.h"
};
typedef float vec4_t[4];
enum {
@ -218,42 +214,6 @@ void Mesh_Free (void)
drawInfo[1] = NULL;
}
static void
R_LerpVerts(entity_t *currententity, int nverts, dtrivertx_t *v, dtrivertx_t *ov,
dtrivertx_t *verts, float *lerp, const float move[3],
const float frontv[3], const float backv[3])
{
int i;
if (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN |
RF_SHELL_BLUE | RF_SHELL_DOUBLE |
RF_SHELL_HALF_DAM))
{
for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
float *normal = r_avertexnormals[verts[i].lightnormalindex];
lerp[0] = move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0] +
normal[0] * POWERSUIT_SCALE;
lerp[1] = move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1] +
normal[1] * POWERSUIT_SCALE;
lerp[2] = move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2] +
normal[2] * POWERSUIT_SCALE;
}
}
else
{
for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
lerp[0] = move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0];
lerp[1] = move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1];
lerp[2] = move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2];
}
}
}
static void
Vk_DrawAliasFrameLerpCommands (entity_t *currententity, int *order, int *order_end,
float alpha, image_t *skin, float *modelMatrix, int leftHandOffset, int translucentIdx,
@ -468,6 +428,9 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdl_t *paliashdr, float backlerp
float *lerp;
int num_mesh_nodes;
short *mesh_nodes;
qboolean colorOnly = 0 != (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE |
RF_SHELL_HALF_DAM));
frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
+ currententity->frame * paliashdr->framesize);
@ -518,7 +481,7 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdl_t *paliashdr, float backlerp
lerp = s_lerped[0];
R_LerpVerts(currententity, paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
R_LerpVerts(colorOnly, paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
num_mesh_nodes = (paliashdr->ofs_skins - sizeof(dmdl_t)) / sizeof(short) / 2;
mesh_nodes = (short *)((char*)paliashdr + sizeof(dmdl_t));