The two TArrays of type FTextureID skinIDs and surfaceskinIDs no longer have any null elements. These elements will have a textureid (FTextureID.texnum) of 0.

Re-worded error messages which were unprecise or unfitting before (model index below 0 was not acknowledged at all, or grouped together with a "too many models" message).

modelIDs are given a default value of -1.

Important: A MODELDEF's FrameIndex lines can no longer refer to model indices that are beyond the number of models of that MODELDEF entry. There is in fact a check to avoid going beyond the number of an actor's models which would abort program operation at startup, but it never caught any such occurances.

surfaceSkinIDs was two-dimensional and is now a one-dimensional TArray as well, elements are accessed via [Row + Column * NumRows], in this case surfaceIndex + modelIndex * MD3_MAX_SURFACES]
Used TArray.Alloc to make TArrays have the correct size depending on the number of models.

Also removed MAX_MODELS_PER_FRAME.
Edited skinSurfaceIDs access for one-dimensional TArray

Added MD3_MODELS_MIN
To ensure compatibility with mods, all model-related TArrays (four in total) have a minimum size of 4, defined by MD3_MODELS_MIN.
This commit is contained in:
Chernoskill 2021-02-09 14:48:43 +01:00 committed by Cherno
commit fa2058004b
6 changed files with 87 additions and 29 deletions

View file

@ -242,8 +242,9 @@ void FUE1Model::RenderFrame( FModelRenderer *renderer, FGameTexture *skin, int f
FGameTexture *sskin = skin;
if ( !sskin )
{
if ( curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum].isValid() )
sskin = TexMan.GetGameTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum], true);
int ssIndex = groups[i].texNum + curMDLIndex * MD3_MAX_SURFACES;
if (curSpriteMDLFrame->surfaceskinIDs[ssIndex].isValid())
sskin = TexMan.GetGameTexture(curSpriteMDLFrame->surfaceskinIDs[ssIndex], true);
if ( !sskin )
{
vofs += vsize;
@ -302,9 +303,12 @@ void FUE1Model::BuildVertexBuffer( FModelRenderer *renderer )
void FUE1Model::AddSkins( uint8_t *hitlist )
{
for ( int i=0; i<numGroups; i++ )
if ( curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum].isValid() )
hitlist[curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum].GetIndex()] |= FTextureManager::HIT_Flat;
for (int i = 0; i < numGroups; i++)
{
int ssIndex = groups[i].texNum + curMDLIndex * MD3_MAX_SURFACES;
if (curSpriteMDLFrame->surfaceskinIDs[ssIndex].isValid())
hitlist[curSpriteMDLFrame->surfaceskinIDs[ssIndex].GetIndex()] |= FTextureManager::HIT_Flat;
}
}
FUE1Model::~FUE1Model()