models,renders: remove MAX_VERTS limit

This commit is contained in:
Denis Pauk 2024-02-06 21:57:00 +02:00
parent 3039fe723d
commit b3a84afcfa
11 changed files with 155 additions and 85 deletions

View file

@ -30,6 +30,52 @@ static const float r_avertexnormals[NUMVERTEXNORMALS][3] = {
#include "../constants/anorms.h"
};
static vec4_t *lerpbuff = NULL;
static int lerpbuffnum = 0;
vec4_t *
R_VertBufferRealloc(int num)
{
void *ptr;
if (num < lerpbuffnum)
{
return lerpbuff;
}
lerpbuffnum = num * 2;
ptr = realloc(lerpbuff, lerpbuffnum * sizeof(vec4_t));
if (!ptr)
{
Com_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
return NULL;
}
lerpbuff = ptr;
return lerpbuff;
}
void
R_VertBufferInit(void)
{
lerpbuff = NULL;
lerpbuffnum = 0;
R_VertBufferRealloc(MAX_VERTS);
}
void
R_VertBufferFree(void)
{
if (lerpbuff)
{
free(lerpbuff);
lerpbuff = NULL;
}
lerpbuffnum = 0;
}
/* compressed vertex normals used by mdl and md2 model formats */
byte
R_CompressNormalMDL(const float *normal)
@ -61,9 +107,10 @@ R_CompressNormalMDL(const float *normal)
}
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])
R_LerpVerts(qboolean powerUpEffect, int nverts,
const dxtrivertx_t *v, const dxtrivertx_t *ov,
const dxtrivertx_t *verts, float *lerp,
const float move[3], const float frontv[3], const float backv[3])
{
int i;

View file

@ -376,7 +376,6 @@ Mod_LoadModel_MDL(const char *mod_name, const void *buffer, int modfilelen,
{
R_Printf(PRINT_ALL, "%s: model %s has too many vertices",
__func__, mod_name);
return NULL;
}
if (num_tris <= 0)
@ -672,11 +671,11 @@ Mod_LoadModel_MD3(const char *mod_name, const void *buffer, int modfilelen,
}
int num_xyz = 0, num_tris = 0, num_glcmds = 0, num_skins = 0;
int meshofs = pinmodel.ofs_meshes;
byte * meshofs = (byte*)buffer + pinmodel.ofs_meshes;
for (i = 0; i < pinmodel.num_meshes; i++)
{
const md3_mesh_t *md3_mesh = (md3_mesh_t*)meshofs;
const md3_mesh_t *md3_mesh = (md3_mesh_t*)((byte*)buffer + meshofs);
num_xyz += LittleLong(md3_mesh->num_xyz);
num_tris += LittleLong(md3_mesh->num_tris);
@ -737,17 +736,17 @@ Mod_LoadModel_MD3(const char *mod_name, const void *buffer, int modfilelen,
dmdx_vert_t * vertx = malloc(pinmodel.num_frames * pheader->num_xyz * sizeof(dmdx_vert_t));
char *skin = (char *)pheader + pheader->ofs_skins;
meshofs = (byte*)buffer + pinmodel.ofs_meshes;
meshofs = pinmodel.ofs_meshes;
for (i = 0; i < pinmodel.num_meshes; i++)
{
const md3_mesh_t *md3_mesh = (md3_mesh_t*)meshofs;
const float *fst = (const float*)(meshofs + md3_mesh->ofs_st);
const md3_mesh_t *md3_mesh = (md3_mesh_t*)((byte*)buffer + meshofs);
const float *fst = (const float*)((byte*)buffer + meshofs + md3_mesh->ofs_st);
int j;
/* load shaders */
for (j = 0; j < md3_mesh->num_shaders; j++)
{
const md3_shader_t *md3_shader = (md3_shader_t*)(meshofs + md3_mesh->ofs_shaders) + j;
const md3_shader_t *md3_shader = (md3_shader_t*)((byte*)buffer + meshofs + md3_mesh->ofs_shaders) + j;
strncpy(skin, md3_shader->name, MAX_SKINNAME - 1);
skin += MAX_SKINNAME;
@ -760,7 +759,7 @@ Mod_LoadModel_MD3(const char *mod_name, const void *buffer, int modfilelen,
}
/* load triangles */
const int *p = (const int*)(meshofs + md3_mesh->ofs_tris);
const int *p = (const int*)((byte*)buffer + meshofs + md3_mesh->ofs_tris);
mesh_nodes[i].start = pglcmds - baseglcmds;
@ -796,7 +795,7 @@ Mod_LoadModel_MD3(const char *mod_name, const void *buffer, int modfilelen,
mesh_nodes[i].num = pglcmds - baseglcmds - mesh_nodes[i].start;
md3_vertex_t *md3_vertex = (md3_vertex_t*)(meshofs + md3_mesh->ofs_verts);
md3_vertex_t *md3_vertex = (md3_vertex_t*)((byte*)buffer + meshofs + md3_mesh->ofs_verts);
int k;
for (k = 0; k < pinmodel.num_frames; k ++)
@ -964,7 +963,6 @@ Mod_LoadModel_MD2(const char *mod_name, const void *buffer, int modfilelen,
{
R_Printf(PRINT_ALL, "%s: model %s has too many vertices",
__func__, mod_name);
return NULL;
}
if (pheader->num_st <= 0)
@ -1161,7 +1159,6 @@ Mod_LoadModel_Flex(const char *mod_name, const void *buffer, int modfilelen,
{
R_Printf(PRINT_ALL, "%s: model %s has too many vertices",
__func__, mod_name);
return NULL;
}
if (dmdxheader.num_st <= 0)

View file

@ -1576,6 +1576,7 @@ RI_Init(void)
R_SetDefaultState();
R_VertBufferInit();
R_InitImages();
Mod_Init();
R_InitParticleTexture();
@ -1596,6 +1597,8 @@ RI_Shutdown(void)
R_ShutdownImages();
R_VertBufferFree();
/* shutdown OS specific OpenGL stuff like contexts, etc. */
RI_ShutdownContext();

View file

@ -34,14 +34,13 @@ static float r_avertexnormal_dots[SHADEDOT_QUANT][256] = {
#include "../constants/anormtab.h"
};
static vec4_t s_lerped[MAX_VERTS];
vec3_t shadevector;
float shadelight[3];
float *shadedots = r_avertexnormal_dots[0];
static void
R_DrawAliasDrawCommands(entity_t *currententity, int *order, int *order_end,
float alpha, dxtrivertx_t *verts)
float alpha, dxtrivertx_t *verts, vec4_t *s_lerped)
{
#ifdef _MSC_VER // workaround for lack of VLAs (=> our workaround uses alloca() which is bad in loops)
int maxCount = 0;
@ -174,7 +173,8 @@ R_DrawAliasDrawCommands(entity_t *currententity, int *order, int *order_end,
* Interpolates between two frames and origins
*/
static void
R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp)
R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp,
vec4_t *s_lerped)
{
daliasxframe_t *frame, *oldframe;
dxtrivertx_t *v, *ov, *verts;
@ -248,7 +248,7 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp)
order + mesh_nodes[i].start,
order + Q_min(paliashdr->num_glcmds,
mesh_nodes[i].start + mesh_nodes[i].num),
alpha, verts);
alpha, verts, s_lerped);
}
if (colorOnly)
@ -259,7 +259,7 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp)
static void
R_DrawAliasShadowCommand(entity_t *currententity, int *order, int *order_end,
float height, float lheight)
float height, float lheight, vec4_t *s_lerped)
{
unsigned short total;
vec3_t point;
@ -341,7 +341,8 @@ R_DrawAliasShadowCommand(entity_t *currententity, int *order, int *order_end,
}
static void
R_DrawAliasShadow(entity_t *currententity, dmdx_t *paliashdr, int posenum)
R_DrawAliasShadow(entity_t *currententity, dmdx_t *paliashdr, int posenum,
vec4_t *s_lerped)
{
int *order, i, num_mesh_nodes;
float height = 0, lheight;
@ -368,7 +369,7 @@ R_DrawAliasShadow(entity_t *currententity, dmdx_t *paliashdr, int posenum)
order + mesh_nodes[i].start,
order + Q_min(paliashdr->num_glcmds,
mesh_nodes[i].start + mesh_nodes[i].num),
height, lheight);
height, lheight, s_lerped);
}
/* stencilbuffer shadows */
@ -417,6 +418,7 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
float an;
vec3_t bbox[8];
image_t *skin = NULL;
vec4_t *s_lerped;
if (!(currententity->flags & RF_WEAPONMODEL))
{
@ -692,7 +694,11 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
currententity->backlerp = 0;
}
R_DrawAliasFrameLerp(currententity, paliashdr, currententity->backlerp);
/* buffer for scalled vert from frame */
s_lerped = R_VertBufferRealloc(paliashdr->num_xyz);
R_DrawAliasFrameLerp(currententity, paliashdr, currententity->backlerp,
s_lerped);
R_TexEnv(GL_REPLACE);
glShadeModel(GL_FLAT);
@ -748,7 +754,8 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glColor4f(0, 0, 0, 0.5f);
R_DrawAliasShadow(currententity, paliashdr, currententity->frame);
R_DrawAliasShadow(currententity, paliashdr, currententity->frame,
s_lerped);
glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glPopMatrix();

View file

@ -25,7 +25,6 @@
* =======================================================================
*/
#include "../ref_shared.h"
#include "header/local.h"
@ -638,6 +637,8 @@ GL3_Init(void)
registration_sequence = 1; // from R_InitImages() (everything else from there shouldn't be needed anymore)
R_VertBufferInit();
GL3_Mod_Init();
GL3_InitParticleTexture();
@ -670,6 +671,7 @@ GL3_Shutdown(void)
GL3_Mod_FreeAll();
GL3_ShutdownMeshes();
GL3_ShutdownImages();
R_VertBufferFree();
GL3_SurfShutdown();
GL3_Draw_ShutdownLocal();
GL3_ShutdownShaders();
@ -1170,7 +1172,6 @@ GL3_DrawEntitiesOnList(void)
GL3_DrawAliasShadows();
glDepthMask(1); /* back to writing */
}
static void
@ -1671,8 +1672,10 @@ GL3_RenderView(refdef_t *fd)
if (r_speeds->value)
{
R_Printf(PRINT_ALL, "%4i wpoly %4i epoly %i tex %i lmaps\n",
c_brush_polys, c_alias_polys, c_visible_textures,
c_visible_lightmaps);
c_brush_polys,
c_alias_polys,
c_visible_textures,
c_visible_lightmaps);
}
#if 0 // TODO: stereo stuff
@ -1834,6 +1837,7 @@ GL3_BeginFrame(float camera_separation)
{
#if 0 // TODO: stereo stuff
gl_state.camera_separation = camera_separation;
// force a vid_restart if gl1_stereo has been modified.
if ( gl_state.stereo_mode != gl1_stereo->value ) {
// If we've gone from one mode to another with the same special buffer requirements there's no need to restart.
@ -2028,9 +2032,9 @@ GetRefAPI(refimport_t imp)
re.EndWorldRenderpass = GL3_EndWorldRenderpass;
re.EndFrame = GL3_EndFrame;
// Tell the client that we're unsing the
// Tell the client that we're unsing the
// new renderer restart API.
ri.Vid_RequestRestart(RESTART_NO);
ri.Vid_RequestRestart(RESTART_NO);
return re;
}

View file

@ -37,8 +37,6 @@ static float r_avertexnormal_dots[SHADEDOT_QUANT][256] = {
#include "../constants/anormtab.h"
};
static vec4_t s_lerped[MAX_VERTS];
typedef struct gl3_shadowinfo_s {
vec3_t lightspot;
vec3_t shadevector;
@ -69,7 +67,7 @@ GL3_ShutdownMeshes(void)
static void
DrawAliasFrameLerpCommands(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight,
int *order, int *order_end, float* shadedots, float alpha, qboolean colorOnly,
dxtrivertx_t *verts)
dxtrivertx_t *verts, vec4_t *s_lerped)
{
// all the triangle fans and triangle strips of this model will be converted to
// just triangles: the vertices stay the same and are batched in vtxBuf,
@ -229,6 +227,8 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
float *lerp;
int num_mesh_nodes;
dmdxmesh_t *mesh_nodes;
vec4_t *s_lerped;
// draw without texture? used for quad damage effect etc, I think
qboolean colorOnly = 0 != (entity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE |
@ -290,6 +290,9 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
backv[i] = backlerp * oldframe->scale[i];
}
/* buffer for scalled vert from frame */
s_lerped = R_VertBufferRealloc(paliashdr->num_xyz);
lerp = s_lerped[0];
R_LerpVerts(colorOnly, paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
@ -305,13 +308,13 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
order + mesh_nodes[i].start,
order + Q_min(paliashdr->num_glcmds,
mesh_nodes[i].start + mesh_nodes[i].num),
shadedots, alpha, colorOnly, verts);
shadedots, alpha, colorOnly, verts, s_lerped);
}
}
static void
DrawAliasShadowCommands(int *order, int *order_end, vec3_t shadevector,
float height, float lheight)
float height, float lheight, vec4_t *s_lerped)
{
// GL1 uses alpha 0.5, but in GL3 0.3 looks better
GLfloat color[4] = {0, 0, 0, 0.3};
@ -424,6 +427,7 @@ DrawAliasShadow(gl3_shadowinfo_t* shadowInfo)
float height = 0, lheight;
int num_mesh_nodes;
dmdxmesh_t *mesh_nodes;
vec4_t *s_lerped;
dmdx_t* paliashdr = shadowInfo->paliashdr;
entity_t* entity = shadowInfo->entity;
@ -431,6 +435,9 @@ DrawAliasShadow(gl3_shadowinfo_t* shadowInfo)
vec3_t shadevector;
VectorCopy(shadowInfo->shadevector, shadevector);
/* buffer for scalled vert from frame */
s_lerped = R_VertBufferRealloc(paliashdr->num_xyz);
// all in this scope is to set s_lerped
{
daliasxframe_t *frame, *oldframe;
@ -484,7 +491,7 @@ DrawAliasShadow(gl3_shadowinfo_t* shadowInfo)
order + mesh_nodes[i].start,
order + Q_min(paliashdr->num_glcmds,
mesh_nodes[i].start + mesh_nodes[i].num),
shadevector, height, lheight);
shadevector, height, lheight, s_lerped);
}
}
@ -733,7 +740,6 @@ GL3_DrawAliasModel(entity_t *entity)
gl3state.uni3DData.transProjViewMat4 = HMM_MultiplyMat4(projMat, gl3state.viewMat3D);
}
//glPushMatrix();
origModelMat = gl3state.uni3DData.transModelMat4;
@ -741,7 +747,6 @@ GL3_DrawAliasModel(entity_t *entity)
GL3_RotateForEntity(entity);
entity->angles[PITCH] = -entity->angles[PITCH];
/* select skin */
if (entity->skin)
{
@ -827,12 +832,14 @@ GL3_DrawAliasModel(entity_t *entity)
}
}
void GL3_ResetShadowAliasModels(void)
void
GL3_ResetShadowAliasModels(void)
{
da_clear(shadowModels);
}
void GL3_DrawAliasShadows(void)
void
GL3_DrawAliasShadows(void)
{
size_t numShadowModels = da_count(shadowModels);
if(numShadowModels == 0)

View file

@ -25,7 +25,6 @@
* =======================================================================
*/
#include "../ref_shared.h"
#include "header/local.h"
@ -621,6 +620,8 @@ GL4_Init(void)
registration_sequence = 1; // from R_InitImages() (everything else from there shouldn't be needed anymore)
R_VertBufferInit();
GL4_Mod_Init();
GL4_InitParticleTexture();
@ -653,6 +654,7 @@ GL4_Shutdown(void)
GL4_Mod_FreeAll();
GL4_ShutdownMeshes();
GL4_ShutdownImages();
R_VertBufferFree();
GL4_SurfShutdown();
GL4_Draw_ShutdownLocal();
GL4_ShutdownShaders();

View file

@ -37,8 +37,6 @@ static float r_avertexnormal_dots[SHADEDOT_QUANT][256] = {
#include "../constants/anormtab.h"
};
static vec4_t s_lerped[MAX_VERTS];
typedef struct gl4_shadowinfo_s {
vec3_t lightspot;
vec3_t shadevector;
@ -83,6 +81,8 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
float backlerp = entity->backlerp;
float frontlerp = 1.0 - backlerp;
float *lerp;
vec4_t *s_lerped;
// draw without texture? used for quad damage effect etc, I think
qboolean colorOnly = 0 != (entity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE |
@ -144,6 +144,9 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
backv[i] = backlerp * oldframe->scale[i];
}
/* buffer for scalled vert from frame */
s_lerped = R_VertBufferRealloc(paliashdr->num_xyz);
lerp = s_lerped[0];
R_LerpVerts(colorOnly, paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
@ -296,6 +299,7 @@ DrawAliasShadow(gl4_shadowinfo_t* shadowInfo)
int *order;
float height = 0, lheight;
int count;
vec4_t *s_lerped;
dmdx_t* paliashdr = shadowInfo->paliashdr;
entity_t* entity = shadowInfo->entity;
@ -303,6 +307,9 @@ DrawAliasShadow(gl4_shadowinfo_t* shadowInfo)
vec3_t shadevector;
VectorCopy(shadowInfo->shadevector, shadevector);
/* buffer for scalled vert from frame */
s_lerped = R_VertBufferRealloc(paliashdr->num_xyz);
// all in this scope is to set s_lerped
{
daliasxframe_t *frame, *oldframe;
@ -696,7 +703,6 @@ GL4_DrawAliasModel(entity_t *entity)
gl4state.uni3DData.transProjViewMat4 = HMM_MultiplyMat4(projMat, gl4state.viewMat3D);
}
//glPushMatrix();
origModelMat = gl4state.uni3DData.transModelMat4;
@ -704,7 +710,6 @@ GL4_DrawAliasModel(entity_t *entity)
GL4_RotateForEntity(entity);
entity->angles[PITCH] = -entity->angles[PITCH];
/* select skin */
if (entity->skin)
{

View file

@ -380,10 +380,14 @@ extern void R_SubdivideSurface(const int *surfedges, mvertex_t *vertexes, medge_
/* 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],
extern void R_LerpVerts(qboolean powerUpEffect, int nverts,
const dxtrivertx_t *v, const dxtrivertx_t *ov,
const dxtrivertx_t *verts, float *lerp, const float move[3],
const float frontv[3], const float backv[3]);
extern byte R_CompressNormalMDL(const float *normal);
extern vec4_t *R_VertBufferRealloc(int num);
extern void R_VertBufferInit(void);
extern void R_VertBufferFree(void);
/* Lights logic */
extern bspxlightgrid_t *Mod_LoadBSPXLightGrid(const bspx_header_t *bspx_header, const byte *mod_base);

View file

@ -1699,6 +1699,7 @@ void QVk_WaitAndShutdownAll (void)
Mod_FreeModelsKnown();
Vk_ShutdownImages();
Mesh_Free();
R_VertBufferFree();
QVk_Shutdown();
vk_frameStarted = false;
@ -1716,6 +1717,7 @@ void QVk_Restart(void)
void QVk_PostInit(void)
{
R_VertBufferInit();
Mesh_Init();
Vk_InitImages();
Mod_Init();

View file

@ -57,7 +57,6 @@ static float r_avertexnormal_dots[SHADEDOT_QUANT][256] = {
#include "../constants/anormtab.h"
};
static vec4_t *s_lerped = NULL;
vec3_t shadevector;
float shadelight[3];
float *shadedots = r_avertexnormal_dots[0];
@ -82,13 +81,6 @@ Mesh_VertsRealloc(int count)
verts_count = ROUNDUP(count * 2, 256);
ptr = realloc(s_lerped, verts_count * sizeof(vec4_t));
if (!ptr)
{
return -1;
}
s_lerped = ptr;
ptr = realloc(shadowverts, verts_count * sizeof(vec3_t));
if (!ptr)
{
@ -139,9 +131,9 @@ Mesh_VertsRealloc(int count)
Mesh_Init
===============
*/
void Mesh_Init (void)
void
Mesh_Init(void)
{
s_lerped = NULL;
shadowverts = NULL;
verts_buffer = NULL;
vertList[0] = NULL;
@ -162,7 +154,8 @@ void Mesh_Init (void)
Mesh_Free
================
*/
void Mesh_Free (void)
void
Mesh_Free(void)
{
if (r_validation->value > 1)
{
@ -177,12 +170,6 @@ void Mesh_Free (void)
}
shadowverts = NULL;
if (s_lerped)
{
free(s_lerped);
}
s_lerped = NULL;
if (verts_buffer)
{
free(verts_buffer);
@ -215,13 +202,13 @@ void Mesh_Free (void)
static void
Vk_DrawAliasFrameLerpCommands (entity_t *currententity, int *order, int *order_end,
float alpha, image_t *skin, float *modelMatrix, int leftHandOffset, int translucentIdx,
dxtrivertx_t *verts)
dxtrivertx_t *verts, vec4_t *s_lerped, int verts_count)
{
int vertCounts[2] = { 0, 0 };
int pipeCounters[2] = { 0, 0 };
VkDeviceSize maxTriangleFanIdxCnt = 0;
if (Mesh_VertsRealloc(1))
if (Mesh_VertsRealloc(verts_count))
{
Com_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
@ -287,7 +274,7 @@ Vk_DrawAliasFrameLerpCommands (entity_t *currententity, int *order, int *order_e
vertList[pipelineIdx][vertIdx].color[2] = shadelight[2];
vertList[pipelineIdx][vertIdx].color[3] = alpha;
if (verts_count < index_xyz)
if (verts_count <= index_xyz)
{
R_Printf(PRINT_ALL, "%s: Model has issues with lerped index\n", __func__);
return;
@ -327,7 +314,7 @@ Vk_DrawAliasFrameLerpCommands (entity_t *currententity, int *order, int *order_e
vertList[pipelineIdx][vertIdx].color[2] = l * shadelight[2];
vertList[pipelineIdx][vertIdx].color[3] = alpha;
if (verts_count < index_xyz)
if (verts_count <= index_xyz)
{
R_Printf(PRINT_ALL, "%s: Model has issues with lerped index\n", __func__);
return;
@ -413,7 +400,7 @@ FIXME: batch lerp all vertexes
*/
static void
Vk_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp, image_t *skin,
float *modelMatrix, int leftHandOffset, int translucentIdx)
float *modelMatrix, int leftHandOffset, int translucentIdx, vec4_t *s_lerped)
{
daliasxframe_t *frame, *oldframe;
dxtrivertx_t *v, *ov, *verts;
@ -423,7 +410,6 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp
vec3_t move, delta, vectors[3];
vec3_t frontv, backv;
int i;
float *lerp;
int num_mesh_nodes;
dmdxmesh_t *mesh_nodes;
qboolean colorOnly = 0 != (currententity->flags &
@ -469,14 +455,8 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp
backv[i] = backlerp * oldframe->scale[i];
}
if (Mesh_VertsRealloc(paliashdr->num_xyz))
{
Com_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
lerp = s_lerped[0];
R_LerpVerts(colorOnly, paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv);
R_LerpVerts(colorOnly, paliashdr->num_xyz, v, ov, verts, (float*)s_lerped,
move, frontv, backv);
num_mesh_nodes = paliashdr->num_meshes;
mesh_nodes = (dmdxmesh_t *)((char*)paliashdr + paliashdr->ofs_meshes);
@ -488,13 +468,14 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp
order + Q_min(paliashdr->num_glcmds,
mesh_nodes[i].start + mesh_nodes[i].num),
alpha, skin,
modelMatrix, leftHandOffset, translucentIdx, verts);
modelMatrix, leftHandOffset, translucentIdx, verts,
s_lerped, paliashdr->num_xyz);
}
}
static void
Vk_DrawAliasShadow(int *order, int *order_end, int posenum,
float *modelMatrix, entity_t *currententity)
float *modelMatrix, entity_t *currententity, vec4_t *s_lerped)
{
vec3_t point;
float height, lheight;
@ -620,11 +601,10 @@ R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
void
R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
{
int i;
int leftHandOffset = 0;
int leftHandOffset = 0, i;
float prev_viewproj[16], an;
dmdx_t *paliashdr;
float an;
float prev_viewproj[16];
vec4_t *s_lerped;
if (!(currententity->flags & RF_WEAPONMODEL))
{
@ -821,6 +801,9 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
}
currententity->angles[PITCH] = -currententity->angles[PITCH]; // sigh.
/* buffer for scalled vert from frame */
s_lerped = R_VertBufferRealloc(paliashdr->num_xyz);
{
float model[16];
image_t *skin = NULL;
@ -846,8 +829,11 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
skin = currentmodel->skins[0];
}
}
if (!skin)
{
skin = r_notexture; // fallback...
}
// draw it
if ( (currententity->frame >= paliashdr->num_frames)
@ -869,8 +855,13 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
}
if ( !r_lerpmodels->value )
{
currententity->backlerp = 0;
Vk_DrawAliasFrameLerp(currententity, paliashdr, currententity->backlerp, skin, model, leftHandOffset, (currententity->flags & RF_TRANSLUCENT) ? 1 : 0);
}
Vk_DrawAliasFrameLerp(currententity, paliashdr, currententity->backlerp,
skin, model, leftHandOffset, (currententity->flags & RF_TRANSLUCENT) ? 1 : 0,
s_lerped);
}
if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
@ -906,7 +897,8 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
order + mesh_nodes[i].start,
order + Q_min(paliashdr->num_glcmds,
mesh_nodes[i].start + mesh_nodes[i].num),
currententity->frame, model, currententity);
currententity->frame, model, currententity,
s_lerped);
}
}
}