22 Jan 2018

This commit is contained in:
g-cont 2018-01-22 00:00:00 +03:00 committed by Alibek Omarov
parent d2dc072b18
commit 534a248cf7
7 changed files with 56 additions and 19 deletions

View File

@ -225,6 +225,7 @@ typedef struct render_api_s
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
// find in files
char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly );
unsigned int (*pfnFileBufferCRC32)( const void *buffer, const int length );
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 35
} render_api_t;

View File

@ -57,6 +57,7 @@ typedef struct triangleapi_s
void (*LightAtPoint)( float *pos, float *value );
void (*Color4fRendermode)( float r, float g, float b, float a, int rendermode );
void (*FogParams)( float flDensity, int iFogSkybox );
colorVec (*LightVec)( const float *start, const float *end, float *lightspot );
} triangleapi_t;
#endif//TRIANGLEAPI_H

View File

@ -3746,6 +3746,7 @@ triangleapi_t gTriApi =
TriLightAtPoint,
TriColor4fRendermode,
TriFogParams,
R_LightVec,
};
static efx_api_t gEfxApi =

View File

@ -710,7 +710,8 @@ void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, float fr
vLast = fmod( freq * speed, 1 );
scale = scale * length;
w = freq * delta[2];
// clamp the beam width
w = fmod( freq, width ) * delta[2];
// NOTE: we must force the degenerate triangles to be on the edge
for( i = 0; i < segments; i++ )
@ -1913,16 +1914,16 @@ void CL_ParseViewBeam( sizebuf_t *msg, int beamType )
end[2] = MSG_ReadCoord( msg );
modelIndex = MSG_ReadShort( msg );
startFrame = MSG_ReadByte( msg );
frameRate = (float)(MSG_ReadByte( msg ) * 0.1f);
frameRate = (float)(MSG_ReadByte( msg ));
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)MSG_ReadByte( msg );
width = (float)(MSG_ReadByte( msg ) * 0.1f);
noise = (float)(MSG_ReadByte( msg ) * 0.01f);
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
b = (float)MSG_ReadByte( msg ) / 255.0f;
a = (float)MSG_ReadByte( msg ) / 255.0f;
speed = (float)(MSG_ReadByte( msg ) * 0.1f);
R_BeamCirclePoints( beamType, start, end, modelIndex, life, width, noise, a, speed, startFrame, frameRate, r, g, b );
speed = (float)MSG_ReadByte( msg );
R_BeamCirclePoints( beamType, start, end, modelIndex, life, width, noise, a, speed / 10.0f, startFrame, frameRate, r, g, b );
break;
case TE_BEAMFOLLOW:
startEnt = MSG_ReadShort( msg );

View File

@ -363,7 +363,7 @@ colorVec R_LightVec( const vec3_t start, const vec3_t end, vec3_t lspot )
if( r_lighting_extended->value )
maxEnts = clgame.pmove->numphysent;
// check al the bsp-models
// check all the bsp-models
for( i = 0; i < maxEnts; i++ )
{
physent_t *pe = &clgame.pmove->physents[i];

View File

@ -1446,6 +1446,20 @@ static char **pfnGetFilesList( const char *pattern, int *numFiles, int gamediron
if( numFiles ) *numFiles = t->numfilenames;
return t->filenames;
}
static uint pfnFileBufferCRC32( const void *buffer, const int length )
{
uint modelCRC = 0;
if( !buffer || length <= 0 )
return modelCRC;
CRC32_Init( &modelCRC );
CRC32_ProcessBuffer( &modelCRC, buffer, length );
CRC32_Final( &modelCRC );
return modelCRC;
}
static render_api_t gRenderAPI =
{
@ -1503,6 +1517,7 @@ static render_api_t gRenderAPI =
R_Mem_Alloc,
R_Mem_Free,
pfnGetFilesList,
pfnFileBufferCRC32,
};
/*

View File

@ -3791,6 +3791,27 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
}
}
/*
=================
R_StudioLoadTextures
=================
*/
void R_StudioLoadTextures( model_t *mod, studiohdr_t *phdr )
{
mstudiotexture_t *ptexture;
int i;
if( host.type == HOST_DEDICATED )
return;
ptexture = (mstudiotexture_t *)(((byte *)phdr) + phdr->textureindex);
if( phdr->textureindex > 0 && phdr->numtextures <= MAXSTUDIOSKINS )
{
for( i = 0; i < phdr->numtextures; i++ )
R_StudioLoadTexture( mod, phdr, &ptexture[i] );
}
}
/*
=================
R_StudioLoadHeader
@ -3800,7 +3821,6 @@ studiohdr_t *R_StudioLoadHeader( model_t *mod, const void *buffer )
{
byte *pin;
studiohdr_t *phdr;
mstudiotexture_t *ptexture;
int i;
if( !buffer ) return NULL;
@ -3815,16 +3835,6 @@ studiohdr_t *R_StudioLoadHeader( model_t *mod, const void *buffer )
return NULL;
}
if( host.type != HOST_DEDICATED )
{
ptexture = (mstudiotexture_t *)(((byte *)phdr) + phdr->textureindex);
if( phdr->textureindex > 0 && phdr->numtextures <= MAXSTUDIOSKINS )
{
for( i = 0; i < phdr->numtextures; i++ )
R_StudioLoadTexture( mod, phdr, &ptexture[i] );
}
}
return (studiohdr_t *)buffer;
}
@ -3861,6 +3871,8 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
}
else
{
R_StudioLoadTextures( mod, thdr );
// give space for textures and skinrefs
size1 = thdr->numtextures * sizeof( mstudiotexture_t );
size2 = thdr->numskinfamilies * thdr->numskinref * sizeof( short );
@ -3882,9 +3894,15 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
}
else
{
// NOTE: don't modify source buffer because it's used for CRC computing
loadmodel->cache.data = Mem_Alloc( loadmodel->mempool, phdr->length );
memcpy( loadmodel->cache.data, buffer, phdr->length );
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
R_StudioLoadTextures( mod, phdr );
// NOTE: we wan't keep raw textures in memory. just cutoff model pointer above texture base
loadmodel->cache.data = Mem_Alloc( loadmodel->mempool, phdr->texturedataindex );
memcpy( loadmodel->cache.data, buffer, phdr->texturedataindex );
loadmodel->cache.data = Mem_Realloc( loadmodel->mempool, loadmodel->cache.data, phdr->texturedataindex );
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
phdr->length = phdr->texturedataindex; // update model size
}