mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-10 06:02:10 +08:00
engine: handle swapping sequence files in LoadCacheFile for games with external StudioModelRenderer
This commit is contained in:
@@ -191,6 +191,7 @@ void Mod_StudioGetAttachment( const edict_t *e, int iAttachment, float *org, flo
|
||||
void Mod_GetBonePosition( const edict_t *e, int iBone, float *org, float *ang );
|
||||
hull_t *Mod_HullForStudio( model_t *m, float frame, int seq, vec3_t ang, vec3_t org, vec3_t size, byte *pcnt, byte *pbl, int *hitboxes, edict_t *ed );
|
||||
void *R_StudioGetAnim( studiohdr_t *m_pStudioHeader, model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc );
|
||||
void Mod_SwapStudioSeqGroupAnims( studiohdr_t *phdr, mstudioseqdesc_t *pseq, byte *buf );
|
||||
int Mod_HitgroupForStudioHull( int index );
|
||||
void Mod_ClearStudioCache( void );
|
||||
|
||||
|
||||
@@ -550,7 +550,7 @@ static void Mod_StudioCalcRotations( int boneused[], int numbones, const byte *p
|
||||
}
|
||||
|
||||
|
||||
static void Mod_SwapStudioSeqGroupAnims( studiohdr_t *phdr, mstudioseqdesc_t *pseq, byte *buf )
|
||||
void Mod_SwapStudioSeqGroupAnims( studiohdr_t *phdr, mstudioseqdesc_t *pseq, byte *buf )
|
||||
{
|
||||
mstudioanim_t *panim = (mstudioanim_t *)( buf + pseq->animindex );
|
||||
int numanims = pseq->numblends * phdr->numbones;
|
||||
|
||||
@@ -608,6 +608,31 @@ void GAME_EXPORT Mod_LoadCacheFile( const char *filename, cache_user_t *cu )
|
||||
cu->data = Mem_Malloc( com_studiocache, size );
|
||||
memcpy( cu->data, buf, size );
|
||||
Mem_Free( buf );
|
||||
|
||||
// this handles when studio model renderer tries to load sequence files on it's own
|
||||
// which is what they always do in HLSDK
|
||||
#if XASH_BIG_ENDIAN
|
||||
if( size >= sizeof( int ) && LittleLong( IDSEQGRPHEADER ) == *(uint *)cu->data )
|
||||
{
|
||||
studiohdr_t *phdr = (studiohdr_t *)(intptr_t)REF_GET_PARM( PARM_GET_STUDIO_HDR, 0 );
|
||||
if( !phdr )
|
||||
return;
|
||||
|
||||
mstudioseqdesc_t *pseq = (mstudioseqdesc_t *)((byte *)phdr + phdr->seqindex );
|
||||
|
||||
for( int i = 0; i < phdr->numseq; i++ )
|
||||
{
|
||||
if( pseq[i].seqgroup == 0 )
|
||||
continue;
|
||||
|
||||
mstudioseqgroup_t *pgrp = (mstudioseqgroup_t *)((byte *)phdr + phdr->seqgroupindex ) + pseq[i].seqgroup;
|
||||
|
||||
// assuming filename passes seqgroup's name
|
||||
if( !Q_stricmp( pgrp->name, filename ))
|
||||
Mod_SwapStudioSeqGroupAnims( phdr, &pseq[i], (byte *)cu->data );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -342,6 +342,7 @@ typedef enum
|
||||
PARM_GET_LIGHTSTYLES_PTR = -20,
|
||||
PARM_GET_DLIGHTS_PTR = -21,
|
||||
PARM_GET_ELIGHTS_PTR = -22,
|
||||
PARM_GET_STUDIO_HDR = -23, // current m_pStudioHeader in renderer
|
||||
|
||||
// implemented by ref_dll
|
||||
|
||||
|
||||
Reference in New Issue
Block a user