mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 12:30:32 +00:00
- move modeldef parsing to its own function (ParseModelDefLump)
- rename gl_InitModels to InitModels - add commented out support for #include in modeldefs (blocked by gene tech having broken #include statements in its modeldef files)
This commit is contained in:
parent
31abe3df7e
commit
91aec1689e
2 changed files with 322 additions and 309 deletions
|
@ -469,21 +469,14 @@ static unsigned FindModel(const char * path, const char * modelfile)
|
|||
|
||||
//===========================================================================
|
||||
//
|
||||
// gl_InitModels
|
||||
// InitModels
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void gl_InitModels()
|
||||
void ParseModelDefLump(int Lump);
|
||||
|
||||
void InitModels()
|
||||
{
|
||||
int Lump, lastLump;
|
||||
FString path;
|
||||
int index, surface;
|
||||
int i;
|
||||
|
||||
FSpriteModelFrame smf;
|
||||
|
||||
lastLump = 0;
|
||||
|
||||
for (unsigned i = 0; i < Models.Size(); i++)
|
||||
{
|
||||
delete Models[i];
|
||||
|
@ -502,6 +495,7 @@ void gl_InitModels()
|
|||
for (unsigned i = 0; i < VoxelDefs.Size(); i++)
|
||||
{
|
||||
FVoxelModel *md = (FVoxelModel*)Models[VoxelDefs[i]->Voxel->VoxelIndex];
|
||||
FSpriteModelFrame smf;
|
||||
memset(&smf, 0, sizeof(smf));
|
||||
smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1;
|
||||
smf.modelIDs[0] = VoxelDefs[i]->Voxel->VoxelIndex;
|
||||
|
@ -533,17 +527,39 @@ void gl_InitModels()
|
|||
}
|
||||
}
|
||||
|
||||
memset(&smf, 0, sizeof(smf));
|
||||
smf.modelIDs[0] = smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1;
|
||||
int Lump;
|
||||
int lastLump = 0;
|
||||
while ((Lump = Wads.FindLump("MODELDEF", &lastLump)) != -1)
|
||||
{
|
||||
ParseModelDefLump(Lump);
|
||||
}
|
||||
|
||||
// create a hash table for quick access
|
||||
SpriteModelHash = new int[SpriteModelFrames.Size ()];
|
||||
atterm(DeleteModelHash);
|
||||
memset(SpriteModelHash, 0xff, SpriteModelFrames.Size () * sizeof(int));
|
||||
|
||||
for (unsigned int i = 0; i < SpriteModelFrames.Size (); i++)
|
||||
{
|
||||
int j = ModelFrameHash(&SpriteModelFrames[i]) % SpriteModelFrames.Size ();
|
||||
|
||||
SpriteModelFrames[i].hashnext = SpriteModelHash[j];
|
||||
SpriteModelHash[j]=i;
|
||||
}
|
||||
}
|
||||
|
||||
static void ParseModelDefLump(int Lump)
|
||||
{
|
||||
FScanner sc(Lump);
|
||||
while (sc.GetString())
|
||||
{
|
||||
if (sc.Compare("model"))
|
||||
{
|
||||
path = "";
|
||||
int index, surface;
|
||||
FString path = "";
|
||||
sc.MustGetString();
|
||||
|
||||
FSpriteModelFrame smf;
|
||||
memset(&smf, 0, sizeof(smf));
|
||||
smf.modelIDs[0] = smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1;
|
||||
smf.xscale=smf.yscale=smf.zscale=1.f;
|
||||
|
@ -752,7 +768,7 @@ void gl_InitModels()
|
|||
|
||||
sc.MustGetString();
|
||||
smf.sprite = -1;
|
||||
for (i = 0; i < (int)sprites.Size (); ++i)
|
||||
for (int i = 0; i < (int)sprites.Size (); ++i)
|
||||
{
|
||||
if (strnicmp (sprites[i].name, sc.String, 4) == 0)
|
||||
{
|
||||
|
@ -795,7 +811,7 @@ void gl_InitModels()
|
|||
smf.modelframes[index] = sc.Number;
|
||||
}
|
||||
|
||||
for(i=0; framechars[i]>0; i++)
|
||||
for(int i=0; framechars[i]>0; i++)
|
||||
{
|
||||
char map[29]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
int c = toupper(framechars[i])-'A';
|
||||
|
@ -828,20 +844,17 @@ void gl_InitModels()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// create a hash table for quick access
|
||||
SpriteModelHash = new int[SpriteModelFrames.Size ()];
|
||||
atterm(DeleteModelHash);
|
||||
memset(SpriteModelHash, 0xff, SpriteModelFrames.Size () * sizeof(int));
|
||||
|
||||
for (i = 0; i < (int)SpriteModelFrames.Size (); i++)
|
||||
// This code is commented out because Gene Tech has broken include statements that blocks this feature..
|
||||
/*else if (sc.Compare("#include"))
|
||||
{
|
||||
int j = ModelFrameHash(&SpriteModelFrames[i]) % SpriteModelFrames.Size ();
|
||||
|
||||
SpriteModelFrames[i].hashnext = SpriteModelHash[j];
|
||||
SpriteModelHash[j]=i;
|
||||
sc.MustGetString();
|
||||
// This is not using sc.Open because it can print a more useful error message when done here
|
||||
int includelump = Wads.CheckNumForFullName(sc.String, true);
|
||||
if (includelump == -1)
|
||||
sc.ScriptError("Lump '%s' not found", sc.String);
|
||||
else
|
||||
ParseModelDefLump(includelump);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "r_data/voxels.h"
|
||||
#include "vm.h"
|
||||
|
||||
void gl_InitModels();
|
||||
void InitModels();
|
||||
|
||||
// variables used to look up
|
||||
// and range check thing_t sprites patches
|
||||
|
@ -1048,7 +1048,7 @@ void R_InitSprites ()
|
|||
// [RH] Sort the skins, but leave base as skin 0
|
||||
//qsort (&skins[PlayerClasses.Size ()], numskins-PlayerClasses.Size (), sizeof(FPlayerSkin), skinsorter);
|
||||
|
||||
gl_InitModels();
|
||||
InitModels();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue