ref: replace model (un)loading by Mod_ProcessRenderData
This commit is contained in:
parent
8339096ad8
commit
297ca08e81
9 changed files with 81 additions and 57 deletions
|
@ -1310,9 +1310,7 @@ void CL_EmitEntities( void )
|
||||||
// set client ideal pitch when mlook is disabled
|
// set client ideal pitch when mlook is disabled
|
||||||
CL_SetIdealPitch ();
|
CL_SetIdealPitch ();
|
||||||
|
|
||||||
// clear the scene befor start new frame
|
ref.dllFuncs.R_ClearScene ();
|
||||||
if( clgame.drawFuncs.R_ClearScene != NULL )
|
|
||||||
clgame.drawFuncs.R_ClearScene();
|
|
||||||
|
|
||||||
// link all the visible clients first
|
// link all the visible clients first
|
||||||
CL_LinkPlayers ( &cl.frames[cl.parsecountmod] );
|
CL_LinkPlayers ( &cl.frames[cl.parsecountmod] );
|
||||||
|
|
|
@ -1135,20 +1135,12 @@ void CL_InitEdicts( void )
|
||||||
clgame.remap_info = (remap_info_t **)Mem_Calloc( clgame.mempool, sizeof( remap_info_t* ) * clgame.maxRemapInfos );
|
clgame.remap_info = (remap_info_t **)Mem_Calloc( clgame.mempool, sizeof( remap_info_t* ) * clgame.maxRemapInfos );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( clgame.drawFuncs.R_ProcessEntData != NULL )
|
ref.dllFuncs.R_ProcessEntData( true );
|
||||||
{
|
|
||||||
// let the client.dll free custom data
|
|
||||||
clgame.drawFuncs.R_ProcessEntData( true );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CL_FreeEdicts( void )
|
void CL_FreeEdicts( void )
|
||||||
{
|
{
|
||||||
if( clgame.drawFuncs.R_ProcessEntData != NULL )
|
ref.dllFuncs.R_ProcessEntData( false );
|
||||||
{
|
|
||||||
// let the client.dll free custom data
|
|
||||||
clgame.drawFuncs.R_ProcessEntData( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( clgame.entities )
|
if( clgame.entities )
|
||||||
Mem_Free( clgame.entities );
|
Mem_Free( clgame.entities );
|
||||||
|
@ -1236,7 +1228,11 @@ static qboolean CL_LoadHudSprite( const char *szSpriteName, model_t *m_pSprite,
|
||||||
|
|
||||||
if( type == SPR_MAPSPRITE )
|
if( type == SPR_MAPSPRITE )
|
||||||
ref.dllFuncs.Mod_LoadMapSprite( m_pSprite, buf, size, &loaded );
|
ref.dllFuncs.Mod_LoadMapSprite( m_pSprite, buf, size, &loaded );
|
||||||
else Mod_LoadSpriteModel( m_pSprite, buf, &loaded, texFlags );
|
else
|
||||||
|
{
|
||||||
|
Mod_LoadSpriteModel( m_pSprite, buf, &loaded, texFlags );
|
||||||
|
ref.dllFuncs.Mod_ProcessRenderData( m_pSprite, true, buf );
|
||||||
|
}
|
||||||
|
|
||||||
Mem_Free( buf );
|
Mem_Free( buf );
|
||||||
|
|
||||||
|
|
|
@ -1554,9 +1554,6 @@ void CL_RegisterResources( sizebuf_t *msg )
|
||||||
|
|
||||||
CL_SetupOverviewParams();
|
CL_SetupOverviewParams();
|
||||||
|
|
||||||
if( clgame.drawFuncs.R_NewMap != NULL )
|
|
||||||
clgame.drawFuncs.R_NewMap();
|
|
||||||
|
|
||||||
// release unused SpriteTextures
|
// release unused SpriteTextures
|
||||||
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
|
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
|
||||||
{
|
{
|
||||||
|
@ -3138,9 +3135,6 @@ void CL_LegacyPrecache_f( void )
|
||||||
|
|
||||||
CL_SetupOverviewParams();
|
CL_SetupOverviewParams();
|
||||||
|
|
||||||
if( clgame.drawFuncs.R_NewMap != NULL )
|
|
||||||
clgame.drawFuncs.R_NewMap();
|
|
||||||
|
|
||||||
// release unused SpriteTextures
|
// release unused SpriteTextures
|
||||||
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
|
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
|
||||||
{
|
{
|
||||||
|
|
|
@ -99,17 +99,13 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
|
||||||
mod->mins[2] = -pinhl->bounds[1] * 0.5f;
|
mod->mins[2] = -pinhl->bounds[1] * 0.5f;
|
||||||
mod->maxs[2] = pinhl->bounds[1] * 0.5f;
|
mod->maxs[2] = pinhl->bounds[1] * 0.5f;
|
||||||
}
|
}
|
||||||
|
if( loaded ) *loaded = true; // done
|
||||||
|
|
||||||
if( Host_IsDedicated() )
|
if( Host_IsDedicated() )
|
||||||
{
|
{
|
||||||
// skip frames loading
|
// skip frames loading
|
||||||
if( loaded ) *loaded = true; // done
|
|
||||||
psprite->numframes = 0;
|
psprite->numframes = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// continue loading frames
|
|
||||||
#ifndef XASH_DEDICATED
|
|
||||||
ref.dllFuncs.Mod_LoadModel( mod_sprite, mod, buffer, loaded, texFlags );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,11 +88,7 @@ static void Mod_FreeUserData( model_t *mod )
|
||||||
#ifndef XASH_DEDICATED
|
#ifndef XASH_DEDICATED
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( clgame.drawFuncs.Mod_ProcessUserData != NULL )
|
ref.dllFuncs.Mod_ProcessRenderData( mod, false, NULL );
|
||||||
{
|
|
||||||
// let the client.dll free custom data
|
|
||||||
clgame.drawFuncs.Mod_ProcessUserData( mod, false, NULL );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -111,9 +107,6 @@ void Mod_FreeModel( model_t *mod )
|
||||||
if( mod->type != mod_brush || mod->name[0] != '*' )
|
if( mod->type != mod_brush || mod->name[0] != '*' )
|
||||||
{
|
{
|
||||||
Mod_FreeUserData( mod );
|
Mod_FreeUserData( mod );
|
||||||
#ifndef XASH_DEDICATED
|
|
||||||
ref.dllFuncs.Mod_UnloadTextures( mod );
|
|
||||||
#endif
|
|
||||||
Mem_FreePool( &mod->mempool );
|
Mem_FreePool( &mod->mempool );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,8 +288,8 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
|
||||||
Mod_LoadSpriteModel( mod, buf, &loaded, 0 );
|
Mod_LoadSpriteModel( mod, buf, &loaded, 0 );
|
||||||
break;
|
break;
|
||||||
case IDALIASHEADER:
|
case IDALIASHEADER:
|
||||||
// REFTODO: move alias loader to engine
|
// REFTODO: move server-related code here
|
||||||
ref.dllFuncs.Mod_LoadModel( mod_alias, mod, buf, &loaded, 0 );
|
loaded = true;
|
||||||
break;
|
break;
|
||||||
case Q1BSP_VERSION:
|
case Q1BSP_VERSION:
|
||||||
case HLBSP_VERSION:
|
case HLBSP_VERSION:
|
||||||
|
@ -310,18 +303,7 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
|
||||||
else Con_Printf( S_ERROR "%s has unknown format\n", tempname );
|
else Con_Printf( S_ERROR "%s has unknown format\n", tempname );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if( loaded )
|
||||||
if( !loaded )
|
|
||||||
{
|
|
||||||
Mod_FreeModel( mod );
|
|
||||||
Mem_Free( buf );
|
|
||||||
|
|
||||||
if( crash ) Host_Error( "Could not load model %s\n", tempname );
|
|
||||||
else Con_Printf( S_ERROR "Could not load model %s\n", tempname );
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if( world.loading )
|
if( world.loading )
|
||||||
SetBits( mod->flags, MODEL_WORLD ); // mark worldmodel
|
SetBits( mod->flags, MODEL_WORLD ); // mark worldmodel
|
||||||
|
@ -337,15 +319,22 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
|
||||||
#ifndef XASH_DEDICATED
|
#ifndef XASH_DEDICATED
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( clgame.drawFuncs.Mod_ProcessUserData != NULL )
|
loaded = ref.dllFuncs.Mod_ProcessRenderData( mod, true, buf );
|
||||||
{
|
|
||||||
// let the client.dll load custom data
|
|
||||||
clgame.drawFuncs.Mod_ProcessUserData( mod, true, buf );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !loaded )
|
||||||
|
{
|
||||||
|
Mod_FreeModel( mod );
|
||||||
|
Mem_Free( buf );
|
||||||
|
|
||||||
|
if( crash ) Host_Error( "Could not load model %s\n", tempname );
|
||||||
|
else Con_Printf( S_ERROR "Could not load model %s\n", tempname );
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
p = &mod_crcinfo[mod - mod_known];
|
p = &mod_crcinfo[mod - mod_known];
|
||||||
mod->needload = NL_PRESENT;
|
mod->needload = NL_PRESENT;
|
||||||
|
|
||||||
|
|
|
@ -460,6 +460,7 @@ typedef struct ref_interface_s
|
||||||
|
|
||||||
qboolean (*R_AddEntity)( struct cl_entity_s *clent, int type );
|
qboolean (*R_AddEntity)( struct cl_entity_s *clent, int type );
|
||||||
void (*CL_AddCustomBeam)( cl_entity_t *pEnvBeam );
|
void (*CL_AddCustomBeam)( cl_entity_t *pEnvBeam );
|
||||||
|
void (*R_ProcessEntData)( qboolean allocate );
|
||||||
|
|
||||||
// view info
|
// view info
|
||||||
qboolean (*IsNormalPass)( void );
|
qboolean (*IsNormalPass)( void );
|
||||||
|
@ -518,9 +519,8 @@ typedef struct ref_interface_s
|
||||||
|
|
||||||
// model management
|
// model management
|
||||||
// flags ignored for everything except spritemodels
|
// flags ignored for everything except spritemodels
|
||||||
void (*Mod_LoadModel)( modtype_t desiredType, model_t *mod, const byte *buf, qboolean *loaded, int flags );
|
|
||||||
void (*Mod_LoadMapSprite)( struct model_s *mod, const void *buffer, size_t size, qboolean *loaded );
|
void (*Mod_LoadMapSprite)( struct model_s *mod, const void *buffer, size_t size, qboolean *loaded );
|
||||||
void (*Mod_UnloadTextures)( model_t *mod );
|
qboolean (*Mod_ProcessRenderData)( model_t *mod, qboolean create, const byte *buffer );
|
||||||
void (*Mod_StudioLoadTextures)( model_t *mod, void *data );
|
void (*Mod_StudioLoadTextures)( model_t *mod, void *data );
|
||||||
|
|
||||||
// efx implementation
|
// efx implementation
|
||||||
|
|
|
@ -164,6 +164,42 @@ static void Mod_LoadModel( modtype_t desiredType, model_t *mod, const byte *buf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qboolean Mod_ProcessRenderData( model_t *mod, qboolean create, const byte *buf )
|
||||||
|
{
|
||||||
|
qboolean loaded = true;
|
||||||
|
|
||||||
|
if( create )
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
switch( mod->type )
|
||||||
|
{
|
||||||
|
case mod_studio:
|
||||||
|
// Mod_LoadStudioModel( mod, buf, loaded );
|
||||||
|
break;
|
||||||
|
case mod_sprite:
|
||||||
|
Mod_LoadSpriteModel( mod, buf, &loaded, mod->numtexinfo );
|
||||||
|
break;
|
||||||
|
case mod_alias:
|
||||||
|
Mod_LoadAliasModel( mod, buf, &loaded );
|
||||||
|
break;
|
||||||
|
case mod_brush:
|
||||||
|
// Mod_LoadBrushModel( mod, buf, loaded );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: gEngfuncs.Host_Error( "Mod_LoadModel: unsupported type %d\n", mod->type );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( loaded && gEngfuncs.drawFuncs->Mod_ProcessUserData )
|
||||||
|
gEngfuncs.drawFuncs->Mod_ProcessUserData( mod, create, buf );
|
||||||
|
|
||||||
|
if( !create )
|
||||||
|
Mod_UnloadTextures( mod );
|
||||||
|
|
||||||
|
return loaded;
|
||||||
|
}
|
||||||
|
|
||||||
static int GL_RenderGetParm( int parm, int arg )
|
static int GL_RenderGetParm( int parm, int arg )
|
||||||
{
|
{
|
||||||
gl_texture_t *glt;
|
gl_texture_t *glt;
|
||||||
|
@ -339,6 +375,12 @@ void Mod_UnloadTextures( model_t *mod )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void R_ProcessEntData( qboolean allocate )
|
||||||
|
{
|
||||||
|
if( gEngfuncs.drawFuncs->R_ProcessEntData )
|
||||||
|
gEngfuncs.drawFuncs->R_ProcessEntData( allocate );
|
||||||
|
}
|
||||||
|
|
||||||
ref_interface_t gReffuncs =
|
ref_interface_t gReffuncs =
|
||||||
{
|
{
|
||||||
R_Init,
|
R_Init,
|
||||||
|
@ -363,6 +405,7 @@ ref_interface_t gReffuncs =
|
||||||
|
|
||||||
R_AddEntity,
|
R_AddEntity,
|
||||||
CL_AddCustomBeam,
|
CL_AddCustomBeam,
|
||||||
|
R_ProcessEntData,
|
||||||
|
|
||||||
IsNormalPass,
|
IsNormalPass,
|
||||||
|
|
||||||
|
@ -407,9 +450,8 @@ ref_interface_t gReffuncs =
|
||||||
|
|
||||||
R_GetSpriteParms,
|
R_GetSpriteParms,
|
||||||
|
|
||||||
Mod_LoadModel,
|
|
||||||
Mod_LoadMapSprite,
|
Mod_LoadMapSprite,
|
||||||
Mod_UnloadTextures,
|
Mod_ProcessRenderData,
|
||||||
Mod_StudioLoadTextures,
|
Mod_StudioLoadTextures,
|
||||||
|
|
||||||
CL_DrawParticles,
|
CL_DrawParticles,
|
||||||
|
|
|
@ -223,6 +223,11 @@ void R_ClearScene( void )
|
||||||
tr.draw_list->num_solid_entities = 0;
|
tr.draw_list->num_solid_entities = 0;
|
||||||
tr.draw_list->num_trans_entities = 0;
|
tr.draw_list->num_trans_entities = 0;
|
||||||
tr.draw_list->num_beam_entities = 0;
|
tr.draw_list->num_beam_entities = 0;
|
||||||
|
|
||||||
|
// clear the scene befor start new frame
|
||||||
|
if( gEngfuncs.drawFuncs->R_ClearScene != NULL )
|
||||||
|
gEngfuncs.drawFuncs->R_ClearScene();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -178,4 +178,8 @@ void R_NewMap( void )
|
||||||
|
|
||||||
GL_BuildLightmaps ();
|
GL_BuildLightmaps ();
|
||||||
R_GenerateVBO();
|
R_GenerateVBO();
|
||||||
|
|
||||||
|
if( gEngfuncs.drawFuncs->R_NewMap != NULL )
|
||||||
|
gEngfuncs.drawFuncs->R_NewMap();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue