mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
- rewrote the model storage code.
Using proper C++ containers now.
This commit is contained in:
parent
8bc34f3dac
commit
a4dd5bb4ce
29 changed files with 401 additions and 1374 deletions
|
@ -576,6 +576,7 @@ file( GLOB HEADER_FILES
|
|||
core/input/*.h
|
||||
core/rendering/*.h
|
||||
core/rendering/scene/*.h
|
||||
core/models/*.h
|
||||
|
||||
common/audio/sound/thirdparty/*.h
|
||||
common/audio/sound/*.h
|
||||
|
@ -630,6 +631,7 @@ file( GLOB HEADER_FILES
|
|||
thirdparty/include/*.hpp
|
||||
thirdparty/imgui/*.h
|
||||
core/textures/*.h
|
||||
core/models/*.h
|
||||
core/textures/formats/*.h
|
||||
)
|
||||
|
||||
|
@ -1028,6 +1030,7 @@ set (PCH_SOURCES
|
|||
core/rendering/scene/hw_lighting.cpp
|
||||
|
||||
core/r_data/gldefs.cpp
|
||||
core/models/modeldata.cpp
|
||||
|
||||
core/console/c_notifybuffer.cpp
|
||||
core/console/d_event.cpp
|
||||
|
@ -1501,6 +1504,7 @@ source_group("Core\\2D" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/2d
|
|||
source_group("Core\\Console" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/console/.+")
|
||||
source_group("Core\\DObject" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/dobject/.+")
|
||||
source_group("Core\\Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/menu/.+")
|
||||
source_group("Core\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/models/.+")
|
||||
source_group("Core\\Rendering" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/rendering/.+")
|
||||
source_group("Core\\Rendering\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/rendering/scene/.+")
|
||||
source_group("Platform" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/platform/.+")
|
||||
|
|
|
@ -25,11 +25,8 @@ typedef int64_t coord_t;
|
|||
|
||||
enum
|
||||
{
|
||||
MAXVOXMIPS = 5,
|
||||
|
||||
MAXWALLSB = 6144,
|
||||
|
||||
MAXVOXELS = 1024,
|
||||
// Maximum number of component tiles in a multi-psky:
|
||||
MAXUNIQHUDID = 256, //Extra slots so HUD models can store animation state without messing game sprites
|
||||
|
||||
|
@ -102,8 +99,6 @@ inline int32_t randomseed;
|
|||
inline uint8_t paletteloaded;
|
||||
inline int32_t g_visibility = 512, g_relvisibility = 0;
|
||||
inline int32_t enginecompatibility_mode;
|
||||
inline int32_t nextvoxid;
|
||||
inline FixedBitArray<MAXVOXELS>voxreserve;
|
||||
|
||||
|
||||
void setVideoMode();
|
||||
|
@ -142,62 +137,9 @@ extern bool hw_int_useindexedcolortextures;
|
|||
EXTERN_CVAR(Bool, hw_useindexedcolortextures)
|
||||
EXTERN_CVAR(Bool, r_voxels)
|
||||
|
||||
extern int32_t mdtims, omdtims;
|
||||
extern int32_t r_rorphase;
|
||||
|
||||
// flags bitset: 1 = don't compress
|
||||
int32_t Ptile2tile(int32_t tile, int32_t palette) ATTRIBUTE((pure));
|
||||
int32_t md_loadmodel(const char *fn);
|
||||
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags);
|
||||
// int32_t md_tilehasmodel(int32_t tilenume, int32_t pal);
|
||||
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
// TODO: dynamically allocate this
|
||||
|
||||
typedef struct { FVector3 add; int16_t angadd, flags, fov; } hudtyp;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// maps build tiles to particular animation frames of a model
|
||||
int16_t modelid;
|
||||
int16_t framenum; // calculate the number from the name when declaring
|
||||
int16_t nexttile;
|
||||
uint16_t smoothduration;
|
||||
hudtyp hudmem[2];
|
||||
int8_t skinnum;
|
||||
uint8_t pal;
|
||||
} tile2model_t;
|
||||
|
||||
# define EXTRATILES (MAXTILES/8)
|
||||
|
||||
inline int32_t mdinited;
|
||||
inline tile2model_t tile2model[MAXTILES+EXTRATILES];
|
||||
|
||||
inline int32_t md_tilehasmodel(int32_t const tilenume, int32_t const pal)
|
||||
{
|
||||
return mdinited ? tile2model[Ptile2tile(tilenume,pal)].modelid : -1;
|
||||
}
|
||||
#endif // defined USE_OPENGL
|
||||
|
||||
int tilehasmodelorvoxel(int const tilenume, int pal);
|
||||
|
||||
int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume,
|
||||
int32_t skinnum, float smoothduration, int32_t pal);
|
||||
int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *frameend,
|
||||
int32_t fps, int32_t flags);
|
||||
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum,
|
||||
int32_t surfnum, float param, float specpower, float specfactor, int32_t flags);
|
||||
int32_t md_definehud (int32_t modelid, int32_t tilex, FVector3 add,
|
||||
int32_t angadd, int32_t flags, int32_t fov);
|
||||
int32_t md_undefinetile(int32_t tile);
|
||||
int32_t md_undefinemodel(int32_t modelid);
|
||||
|
||||
static inline int64_t compat_maybe_truncate_to_int32(int64_t val)
|
||||
{
|
||||
return enginecompatibility_mode != ENGINECOMPATIBILITY_NONE ? (int32_t)val : val;
|
||||
}
|
||||
|
||||
void updateModelInterpolation();
|
||||
|
||||
#endif // build_h_
|
||||
|
|
|
@ -1,200 +0,0 @@
|
|||
#ifndef mdsprite_h_
|
||||
# define mdsprite_h_
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
#include "palette.h"
|
||||
#include "gl_hwtexture.h"
|
||||
#include "model_kvx.h"
|
||||
|
||||
#if defined(_M_IX86) || defined(_M_AMD64) || defined(__i386) || defined(__x86_64)
|
||||
#define SHIFTMOD32(a) (a)
|
||||
#else
|
||||
#define SHIFTMOD32(a) ((a)&31)
|
||||
#endif
|
||||
|
||||
#define IDP2_MAGIC 0x32504449
|
||||
#define IDP3_MAGIC 0x33504449
|
||||
|
||||
class FGameTexture;
|
||||
|
||||
struct mdmodel_t
|
||||
{
|
||||
|
||||
int32_t mdnum, shadeoff;
|
||||
float scale, bscale, zadd, yoffset;
|
||||
FGameTexture *texture;
|
||||
|
||||
int32_t flags;
|
||||
};
|
||||
|
||||
struct mdanim_t
|
||||
{
|
||||
int32_t startframe, endframe;
|
||||
int32_t fpssc, flags;
|
||||
mdanim_t* next;
|
||||
};
|
||||
|
||||
struct mdskinmap_t
|
||||
{
|
||||
uint8_t palette, flags, filler[2]; // Build palette number, flags the same as hightiles
|
||||
int32_t skinnum, surfnum; // Skin identifier, surface number
|
||||
FTextureID texture;
|
||||
mdskinmap_t* next;
|
||||
float param, specpower, specfactor;
|
||||
};
|
||||
|
||||
struct idmodel_t : public mdmodel_t
|
||||
{
|
||||
int32_t numframes, cframe, nframe, fpssc, usesalpha;
|
||||
float oldtime, curtime, interpol;
|
||||
mdanim_t *animations;
|
||||
mdskinmap_t *skinmap;
|
||||
int32_t numskins, skinloaded;
|
||||
};
|
||||
|
||||
#define MDANIM_LOOP 0
|
||||
#define MDANIM_ONESHOT 1
|
||||
|
||||
|
||||
|
||||
//This MD2 code is based on the source code from David Henry (tfc_duke(at)hotmail.com)
|
||||
// Was at http://tfc.duke.free.fr/us/tutorials/models/md2.htm
|
||||
// Available from http://web.archive.org/web/20030816010242/http://tfc.duke.free.fr/us/tutorials/models/md2.htm
|
||||
// Now at http://tfc.duke.free.fr/coding/md2.html (in French)
|
||||
//He probably wouldn't recognize it if he looked at it though :)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t id, vers, skinxsiz, skinysiz, framebytes; //id:"IPD2", vers:8
|
||||
int32_t numskins, numverts, numuv, numtris, numglcmds, numframes;
|
||||
int32_t ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each)
|
||||
} md2head_t;
|
||||
|
||||
typedef struct { uint8_t v[3], ni; } md2vert_t; //compressed vertex coords (x,y,z)
|
||||
typedef struct
|
||||
{
|
||||
FVector3 mul, add; //scale&translation vector
|
||||
char name[16]; //frame name
|
||||
md2vert_t verts[1]; //first vertex of this frame
|
||||
} md2frame_t;
|
||||
|
||||
typedef struct { int16_t u, v; } md2uv_t;
|
||||
typedef struct
|
||||
{
|
||||
uint16_t v[3];
|
||||
uint16_t u[3];
|
||||
} md2tri_t;
|
||||
|
||||
struct md2model_t : public idmodel_t
|
||||
{
|
||||
//MD2 specific stuff:
|
||||
int32_t numverts, numglcmds, framebytes, *glcmds;
|
||||
char *frames;
|
||||
char *basepath; // pointer to string of base path
|
||||
char *skinfn; // pointer to first of numskins 64-char strings
|
||||
md2uv_t *uv;
|
||||
md2tri_t* tris;
|
||||
};
|
||||
|
||||
|
||||
typedef struct { char nam[64]; int32_t i; } md3shader_t; //ascz path of shader, shader index
|
||||
typedef struct { int32_t i[3]; } md3tri_t; //indices of tri
|
||||
typedef struct { float u, v; } md3uv_t;
|
||||
typedef struct { int16_t x, y, z; uint8_t nlat, nlng; } md3xyzn_t; //xyz are [10:6] ints
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FVector3 min, max, cen; //bounding box&origin
|
||||
float r; //radius of bounding sphere
|
||||
char nam[16]; //ascz frame name
|
||||
} md3frame_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char nam[64]; //ascz tag name
|
||||
FVector3 p, x, y, z; //tag object pos&orient
|
||||
} md3tag_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t id; //IDP3(0x33806873)
|
||||
char nam[64]; //ascz surface name
|
||||
int32_t flags; //?
|
||||
int32_t numframes, numshaders, numverts, numtris; //numframes same as md3head,max shade=~256,vert=~4096,tri=~8192
|
||||
int32_t ofstris;
|
||||
int32_t ofsshaders;
|
||||
int32_t ofsuv;
|
||||
int32_t ofsxyzn;
|
||||
int32_t ofsend;
|
||||
// DO NOT read directly to this structure
|
||||
// the following block is NOT in the file format
|
||||
// be sure to use the SIZEOF_MD3SURF_T macro
|
||||
md3tri_t *tris;
|
||||
md3shader_t *shaders;
|
||||
md3uv_t *uv;
|
||||
md3xyzn_t *xyzn;
|
||||
float *geometry; // used by Polymer
|
||||
} md3surf_t;
|
||||
|
||||
#define SIZEOF_MD3SURF_T (11*sizeof(int32_t) + 64*sizeof(char))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t id, vers; //id=IDP3(0x33806873), vers=15
|
||||
char nam[64]; //ascz path in PK3
|
||||
int32_t flags; //?
|
||||
int32_t numframes, numtags, numsurfs, numskins; //max=~1024,~16,~32,numskins=artifact of MD2; use shader field instead
|
||||
int32_t ofsframes;
|
||||
int32_t ofstags;
|
||||
int32_t ofssurfs;
|
||||
int32_t eof;
|
||||
// DO NOT read directly to this structure
|
||||
// the following block is NOT in the file format
|
||||
// be sure to use the SIZEOF_MD3HEAD_T macro
|
||||
md3frame_t *frames;
|
||||
md3tag_t *tags;
|
||||
md3surf_t *surfs;
|
||||
} md3head_t;
|
||||
|
||||
#define SIZEOF_MD3HEAD_T (sizeof(md3head_t)-3*sizeof(void*))
|
||||
|
||||
struct md3model_t : public idmodel_t
|
||||
{
|
||||
|
||||
//MD3 specific
|
||||
md3head_t head;
|
||||
FVector3 *muladdframes;
|
||||
|
||||
uint16_t *indexes;
|
||||
uint16_t *vindexes;
|
||||
|
||||
float *maxdepths;
|
||||
// polymer VBO names after that, allocated per surface
|
||||
/*
|
||||
GLuint *indices;
|
||||
GLuint *texcoords;
|
||||
GLuint *geometry;
|
||||
*/
|
||||
};
|
||||
|
||||
inline mdmodel_t **models;
|
||||
|
||||
FGameTexture* mdloadskin(idmodel_t* m, int32_t number, int32_t pal, int32_t surf, bool* exact);
|
||||
void mdinit(void);
|
||||
void freeallmodels(void);
|
||||
int32_t polymost_mddraw(tspritetype* tspr);
|
||||
void md3_vox_calcmat_common(tspritetype* tspr, const FVector3 *a0, float f, float mat[16]);
|
||||
|
||||
inline int32_t mdpause;
|
||||
inline int32_t nextmodelid;
|
||||
|
||||
#endif // defined USE_OPENGL
|
||||
|
||||
enum {
|
||||
HUDFLAG_HIDE = 1,
|
||||
HUDFLAG_NOBOB = 2,
|
||||
HUDFLAG_FLIPPED = 4,
|
||||
HUDFLAG_NODEPTH = 8,
|
||||
};
|
||||
|
||||
#endif // !mdsprite_h_
|
File diff suppressed because it is too large
Load diff
|
@ -151,7 +151,7 @@ int ModelFrameHash(FSpriteModelFrame * smf)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
unsigned FindModel(const char * path, const char * modelfile)
|
||||
unsigned FindModel(const char * path, const char * modelfile, bool silent)
|
||||
{
|
||||
FModel * model = nullptr;
|
||||
FString fullname;
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
IModelVertexBuffer *GetVertexBuffer(int type) const { return mVBuf[type]; }
|
||||
void DestroyVertexBuffer();
|
||||
|
||||
bool hasSurfaces = false;
|
||||
FString mFileName;
|
||||
|
||||
private:
|
||||
|
@ -88,5 +89,5 @@ private:
|
|||
};
|
||||
|
||||
int ModelFrameHash(FSpriteModelFrame* smf);
|
||||
unsigned FindModel(const char* path, const char* modelfile);
|
||||
unsigned FindModel(const char* path, const char* modelfile, bool silent = false);
|
||||
|
||||
|
|
|
@ -133,6 +133,7 @@ bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int le
|
|||
|
||||
auto numFrames = LittleLong(hdr->Num_Frames);
|
||||
auto numSurfaces = LittleLong(hdr->Num_Surfaces);
|
||||
hasSurfaces = numSurfaces > 1;
|
||||
|
||||
numTags = LittleLong(hdr->Num_Tags);
|
||||
|
||||
|
|
|
@ -222,6 +222,8 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length
|
|||
curSurface->faceStart = aggSurfFaceCount;
|
||||
surfaces.Push(*curSurface);
|
||||
delete curSurface;
|
||||
hasSurfaces = surfaces.Size() > 1;
|
||||
|
||||
|
||||
if (uvs.Size() == 0)
|
||||
{ // Needed so that OBJs without UVs can work
|
||||
|
|
|
@ -48,6 +48,7 @@ float unpackuvert( uint32_t n, int c )
|
|||
bool FUE1Model::Load( const char *filename, int lumpnum, const char *buffer, int length )
|
||||
{
|
||||
int lumpnum2;
|
||||
hasSurfaces = true;
|
||||
FString realfilename = fileSystem.GetFileFullName(lumpnum);
|
||||
if ( (size_t)realfilename.IndexOf("_d.3d") == realfilename.Len()-5 )
|
||||
{
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
#include <stdint.h>
|
||||
// [RH] Voxels from Build
|
||||
|
||||
#define MAXVOXMIPS 5
|
||||
enum
|
||||
{
|
||||
MAXVOXMIPS = 5,
|
||||
};
|
||||
|
||||
struct kvxslab_t
|
||||
{
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "mapinfo.h"
|
||||
#include "hw_voxels.h"
|
||||
#include "psky.h"
|
||||
#include "models/modeldata.h"
|
||||
|
||||
int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, bool indexed = false);
|
||||
int tileSetSkybox(int picnum, int palnum, FString* facenames, bool indexed = false);
|
||||
|
@ -1655,14 +1656,14 @@ void parseDefineModel(FScanner& sc, FScriptPosition& pos)
|
|||
if (!sc.GetFloat(scale, true)) return;
|
||||
if (!sc.GetNumber(shadeoffs, true)) return;
|
||||
|
||||
mdglobal.lastmodelid = md_loadmodel(modelfn);
|
||||
mdglobal.lastmodelid = modelManager.LoadModel(modelfn);
|
||||
if (mdglobal.lastmodelid < 0)
|
||||
{
|
||||
pos.Message(MSG_WARNING, "definemodel: unable to load model file '%s'", modelfn.GetChars());
|
||||
}
|
||||
else
|
||||
{
|
||||
md_setmisc(mdglobal.lastmodelid, (float)scale, shadeoffs, 0.0, 0.0, 0);
|
||||
modelManager.SetMisc(mdglobal.lastmodelid, (float)scale, shadeoffs, 0.0, 0.0, 0);
|
||||
mdglobal.modelskin = mdglobal.lastmodelskin = 0;
|
||||
mdglobal.seenframe = 0;
|
||||
}
|
||||
|
@ -1693,7 +1694,7 @@ void parseDefineModelFrame(FScanner& sc, FScriptPosition& pos)
|
|||
}
|
||||
for (int i = firsttile; i <= lasttile && ok; i++)
|
||||
{
|
||||
int err = (md_defineframe(mdglobal.lastmodelid, framename, i, max(0, mdglobal.modelskin), 0.0f, 0));
|
||||
int err = (modelManager.DefineFrame(mdglobal.lastmodelid, framename, i, max(0, mdglobal.modelskin), 0.0f, 0));
|
||||
if (err < 0) ok = false;
|
||||
if (err == -2) pos.Message(MSG_ERROR, "Invalid tile number %d", i);
|
||||
else if (err == -3) pos.Message(MSG_ERROR, "Invalid frame name '%s'", framename.GetChars());
|
||||
|
@ -1723,7 +1724,7 @@ void parseDefineModelAnim(FScanner& sc, FScriptPosition& pos)
|
|||
pos.Message(MSG_WARNING, "definemodelframe: Ignoring animation definition outside model.");
|
||||
return;
|
||||
}
|
||||
int err = (md_defineanimation(mdglobal.lastmodelid, startframe, endframe, (int32_t)(dfps * (65536.0 * .001)), flags));
|
||||
int err = (modelManager.DefineAnimation(mdglobal.lastmodelid, startframe, endframe, (int32_t)(dfps * (65536.0 * .001)), flags));
|
||||
if (err == -2) pos.Message(MSG_ERROR, "Invalid start frame name %s", startframe.GetChars());
|
||||
else if (err == -3) pos.Message(MSG_ERROR, "Invalid end frame name %s", endframe.GetChars());
|
||||
}
|
||||
|
@ -1747,7 +1748,7 @@ void parseDefineModelSkin(FScanner& sc, FScriptPosition& pos)
|
|||
|
||||
if (!fileSystem.FileExists(skinfn)) return;
|
||||
|
||||
int err = (md_defineskin(mdglobal.lastmodelid, skinfn, palnum, max(0, mdglobal.modelskin), 0, 0.0f, 1.0f, 1.0f, 0));
|
||||
int err = (modelManager.DefineSkin(mdglobal.lastmodelid, skinfn, palnum, max(0, mdglobal.modelskin), 0, 0.0f, 1.0f, 1.0f, 0));
|
||||
if (err == -2) pos.Message(MSG_ERROR, "Invalid skin file name %s", skinfn.GetChars());
|
||||
else if (err == -3) pos.Message(MSG_ERROR, "Invalid palette %d", palnum);
|
||||
}
|
||||
|
@ -1775,7 +1776,7 @@ void parseUndefModel(FScanner& sc, FScriptPosition& pos)
|
|||
int tile;
|
||||
if (!sc.GetNumber(tile, true)) return;
|
||||
if (!ValidateTilenum("undefmodel", tile, pos)) return;
|
||||
md_undefinetile(tile);
|
||||
modelManager.UndefineTile(tile);
|
||||
}
|
||||
|
||||
void parseUndefModelRange(FScanner& sc, FScriptPosition& pos)
|
||||
|
@ -1785,7 +1786,7 @@ void parseUndefModelRange(FScanner& sc, FScriptPosition& pos)
|
|||
if (!sc.GetNumber(start, true)) return;
|
||||
if (!sc.GetNumber(end, true)) return;
|
||||
if (!ValidateTileRange("undefmodel", start, end, pos)) return;
|
||||
for (int i = start; i <= end; i++) md_undefinetile(i);
|
||||
for (int i = start; i <= end; i++) modelManager.UndefineTile(i);
|
||||
}
|
||||
|
||||
void parseUndefModelOf(FScanner& sc, FScriptPosition& pos)
|
||||
|
@ -1834,7 +1835,7 @@ static bool parseModelFrameBlock(FScanner& sc, FixedBitArray<1024>& usedframes)
|
|||
}
|
||||
for (int i = starttile; i <= endtile && ok; i++)
|
||||
{
|
||||
int res = md_defineframe(mdglobal.lastmodelid, framename, i, max(0, mdglobal.modelskin), smoothduration, pal);
|
||||
int res = modelManager.DefineFrame(mdglobal.lastmodelid, framename, i, max(0, mdglobal.modelskin), smoothduration, pal);
|
||||
if (res < 0)
|
||||
{
|
||||
ok = false;
|
||||
|
@ -1877,7 +1878,7 @@ static bool parseModelAnimBlock(FScanner& sc)
|
|||
return false;
|
||||
}
|
||||
|
||||
int res = md_defineanimation(mdglobal.lastmodelid, startframe, endframe, (int)(fps * (65536.0 * .001)), flags);
|
||||
int res = modelManager.DefineAnimation(mdglobal.lastmodelid, startframe, endframe, (int)(fps * (65536.0 * .001)), flags);
|
||||
if (res < 0)
|
||||
{
|
||||
if (res == -2) pos.Message(MSG_ERROR, "Invalid start frame name %s", startframe.GetChars());
|
||||
|
@ -1927,7 +1928,7 @@ static bool parseModelSkinBlock(FScanner& sc, int pal)
|
|||
}
|
||||
|
||||
if (pal == DETAILPAL) param = 1.f / param;
|
||||
int res = md_defineskin(mdglobal.lastmodelid, filename, pal, max(0, mdglobal.modelskin), surface, param, specpower, specfactor, flags);
|
||||
int res = modelManager.DefineSkin(mdglobal.lastmodelid, filename, pal, max(0, mdglobal.modelskin), surface, param, specpower, specfactor, flags);
|
||||
if (res < 0)
|
||||
{
|
||||
if (res == -2) pos.Message(MSG_ERROR, "Invalid skin filename %s", filename.GetChars());
|
||||
|
@ -1968,7 +1969,7 @@ static bool parseModelHudBlock(FScanner& sc)
|
|||
for (int i = starttile; i <= endtile; i++)
|
||||
{
|
||||
FVector3 addf = { (float)add.X, (float)add.Y, (float)add.Z };
|
||||
int res = md_definehud(mdglobal.lastmodelid, i, addf, angadd, flags, fov);
|
||||
int res = modelManager.DefineHud(mdglobal.lastmodelid, i, addf, angadd, flags, fov);
|
||||
if (res < 0)
|
||||
{
|
||||
if (res == -2) pos.Message(MSG_ERROR, "Invalid tile number %d", i);
|
||||
|
@ -1995,7 +1996,7 @@ void parseModel(FScanner& sc, FScriptPosition& pos)
|
|||
|
||||
if (sc.StartBraces(&blockend)) return;
|
||||
|
||||
mdglobal.lastmodelid = md_loadmodel(modelfn);
|
||||
mdglobal.lastmodelid = modelManager.LoadModel(modelfn);
|
||||
if (mdglobal.lastmodelid < 0)
|
||||
{
|
||||
pos.Message(MSG_WARNING, "Unable to load model file '%s'", modelfn.GetChars());
|
||||
|
@ -2028,13 +2029,12 @@ void parseModel(FScanner& sc, FScriptPosition& pos)
|
|||
if (mdglobal.lastmodelid >= 0)
|
||||
{
|
||||
pos.Message(MSG_ERROR, "Removing model %d due to errors.", mdglobal.lastmodelid);
|
||||
md_undefinemodel(mdglobal.lastmodelid);
|
||||
nextmodelid--;
|
||||
modelManager.UndefineModel(mdglobal.lastmodelid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
md_setmisc(mdglobal.lastmodelid, (float)scale, shadeoffs, (float)mzadd, (float)myoffset, flags);
|
||||
modelManager.SetMisc(mdglobal.lastmodelid, (float)scale, shadeoffs, (float)mzadd, (float)myoffset, flags);
|
||||
mdglobal.modelskin = mdglobal.lastmodelskin = 0;
|
||||
mdglobal.seenframe = 0;
|
||||
}
|
||||
|
|
|
@ -631,7 +631,6 @@ int GameMain()
|
|||
TexMan.DeleteAll();
|
||||
TileFiles.CloseAll(); // delete the texture data before shutting down graphics.
|
||||
I_ShutdownGraphics();
|
||||
freeallmodels();
|
||||
if (gi)
|
||||
{
|
||||
delete gi;
|
||||
|
@ -940,7 +939,6 @@ static void InitTextures()
|
|||
TexMan.Init();
|
||||
TexMan.AddTextures([]() {}, [](BuildInfo&) {});
|
||||
StartWindow->Progress();
|
||||
mdinit();
|
||||
|
||||
TileFiles.Init();
|
||||
TileFiles.LoadArtSet("tiles%03d.art"); // it's the same for all games.
|
||||
|
|
|
@ -1251,19 +1251,6 @@ tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor)
|
|||
return tspr;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int tilehasmodelorvoxel(int const tilenume, int pal)
|
||||
{
|
||||
return
|
||||
(mdinited && hw_models && tile2model[Ptile2tile(tilenume, pal)].modelid != -1) ||
|
||||
(r_voxels && tiletovox[tilenume] != -1);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// vector serializers
|
||||
|
|
|
@ -438,7 +438,7 @@ void Display()
|
|||
screen->FrameTime = I_msTimeFS();
|
||||
screen->BeginFrame();
|
||||
screen->SetSceneRenderTarget(gl_ssao != 0);
|
||||
updateModelInterpolation();
|
||||
//updateModelInterpolation();
|
||||
gi->Render();
|
||||
DrawFullscreenBlends();
|
||||
drawMapTitle();
|
||||
|
|
243
source/core/models/modeldata.cpp
Normal file
243
source/core/models/modeldata.cpp
Normal file
|
@ -0,0 +1,243 @@
|
|||
#include "basics.h"
|
||||
#include "model.h"
|
||||
#include "modeldata.h"
|
||||
#include "texturemanager.h"
|
||||
#include "hw_voxels.h"
|
||||
|
||||
#include "build.h"
|
||||
|
||||
|
||||
int ModelManager::LoadModel(const char* fn)
|
||||
{
|
||||
unsigned modelid = FindModel(nullptr, fn, true);
|
||||
|
||||
if (modelid == ~0u)
|
||||
return -1;
|
||||
|
||||
// Note that the descriptor table may contain the same model multiple times!
|
||||
|
||||
int mdid = modelDescs.Reserve(1);
|
||||
modelDescs.Last() = {};
|
||||
modelDescs.Last().modelID = modelid;
|
||||
return mdid;
|
||||
}
|
||||
|
||||
int ModelManager::SetMisc(int modelid, float scale, int shadeoff, float zadd, float yoffset, int flags)
|
||||
{
|
||||
if ((unsigned)modelid >= modelDescs.Size()) return -1;
|
||||
|
||||
auto md = &modelDescs[modelid];
|
||||
md->bscale = scale;
|
||||
md->shadeoff = shadeoff;
|
||||
md->zadd = zadd;
|
||||
md->yoffset = yoffset;
|
||||
md->flags = flags;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ModelManager::DefineFrame(int modelid, const char* framename, int tilenum, int skinnum, float smoothduration, int pal)
|
||||
{
|
||||
if ((unsigned)modelid >= modelDescs.Size()) return -1;
|
||||
if ((uint32_t)tilenum >= MAXTILES) return -2;
|
||||
if (!framename) return -3;
|
||||
|
||||
ModelTileFrame mframe;
|
||||
|
||||
auto mdesc = &modelDescs[modelid];
|
||||
auto model = Models[mdesc->modelID];
|
||||
|
||||
auto frm = model->FindFrame(framename, true);
|
||||
if (frm == FErr_NotFound) return -3;
|
||||
if (frm == FErr_Voxel) skinnum = 0;
|
||||
if (frm < 0) frm = 0;
|
||||
|
||||
mframe.modelid = modelid;
|
||||
mframe.framenum = frm;
|
||||
mframe.skinnum = skinnum;
|
||||
mframe.smoothduration = smoothduration;
|
||||
auto key = FrameMapKey(tilenum, pal);
|
||||
frameMap.Insert(key, mframe);
|
||||
return key;
|
||||
}
|
||||
|
||||
int ModelManager::DefineAnimation(int modelid, const char* framestart, const char* frameend, int fpssc, int flags)
|
||||
{
|
||||
if ((unsigned)modelid >= modelDescs.Size()) return -1;
|
||||
if (!framestart) return -2;
|
||||
if (!frameend) return -3;
|
||||
|
||||
auto mdesc = &modelDescs[modelid];
|
||||
auto model = Models[mdesc->modelID];
|
||||
|
||||
auto frm = model->FindFrame(framestart, true);
|
||||
if (frm == FErr_NotFound) return -2;
|
||||
if (frm < 0) frm = 0;
|
||||
|
||||
auto frme = model->FindFrame(frameend, true);
|
||||
if (frme == FErr_NotFound) return -3;
|
||||
if (frme < 0) frme = 0;
|
||||
|
||||
ModelAnimation anm;
|
||||
|
||||
anm.startframe = frm;
|
||||
anm.endframe = frme;
|
||||
anm.fpssc = fpssc;
|
||||
anm.flags = flags;
|
||||
mdesc->anims.Push(anm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ModelManager::DefineSkin(int modelid, const char* skinfn, int palnum, int skinnum, int surfnum, float param, float specpower, float specfactor, int flags)
|
||||
{
|
||||
if ((unsigned)modelid >= modelDescs.Size()) return -1;
|
||||
if (!skinfn) return -2;
|
||||
if ((unsigned)palnum >= (unsigned)MAXPALOOKUPS) return -3;
|
||||
|
||||
auto mdesc = &modelDescs[modelid];
|
||||
auto model = Models[mdesc->modelID];
|
||||
|
||||
if (model->FindFrame("", true) == FErr_Voxel)
|
||||
return 0;
|
||||
|
||||
if (!model->hasSurfaces) surfnum = 0;
|
||||
|
||||
ModelSkinDef* skdef = nullptr;
|
||||
|
||||
for (auto& sk : mdesc->skins)
|
||||
{
|
||||
if (sk.palette == (uint8_t)palnum && skinnum == sk.skinnum && surfnum == sk.surfnum)
|
||||
{
|
||||
skdef = &sk;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (skdef == nullptr)
|
||||
{
|
||||
mdesc->skins.Reserve(1);
|
||||
skdef = &mdesc->skins.Last();
|
||||
}
|
||||
|
||||
skdef->palette = (uint8_t)palnum;
|
||||
skdef->flags = (uint8_t)flags;
|
||||
skdef->skinnum = skinnum;
|
||||
skdef->surfnum = surfnum;
|
||||
skdef->param = param;
|
||||
skdef->specpower = specpower;
|
||||
skdef->specfactor = specfactor;
|
||||
skdef->texture = TexMan.CheckForTexture(skinfn, ETextureType::Any);
|
||||
if (!skdef->texture.isValid()) return -2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ModelManager::DefineHud(int modelid, int tilex, FVector3 add, int angadd, int flags, int fov)
|
||||
{
|
||||
if ((unsigned)modelid >= modelDescs.Size()) return -1;
|
||||
if ((unsigned)tilex >= (unsigned)MAXTILES) return -1;
|
||||
|
||||
auto mdesc = &modelDescs[modelid];
|
||||
auto model = Models[mdesc->modelID];
|
||||
|
||||
// not implemented yet
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ModelManager::UndefineTile(int tile)
|
||||
{
|
||||
if ((unsigned)tile >= (unsigned)MAXTILES) return -1;
|
||||
|
||||
// delete all entries from the map that reference this tile
|
||||
for (int i = 0; i < MAXPALOOKUPS; i++)
|
||||
{
|
||||
frameMap.Remove(FrameMapKey(tile, i));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ModelManager::UndefineModel(int modelid)
|
||||
{
|
||||
if ((unsigned)modelid >= modelDescs.Size()) return -1;
|
||||
|
||||
auto mdesc = &modelDescs[modelid];
|
||||
mdesc->deleted = true;
|
||||
mdesc->anims.Reset();
|
||||
mdesc->skins.Reset();
|
||||
if (modelid == (int)modelDescs.Size() - 1)
|
||||
modelDescs.Pop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0 // kept as reminders for later. We still need the prioritization code in mdloadskin, the rest needs to be redone
|
||||
|
||||
FGameTexture* mdloadskin(idmodel_t* m, int32_t number, int32_t pal, int32_t surf, bool* exact)
|
||||
{
|
||||
int32_t i;
|
||||
mdskinmap_t* sk, * skzero = NULL;
|
||||
|
||||
if (m->mdnum == 2)
|
||||
surf = 0;
|
||||
|
||||
if ((unsigned)pal >= (unsigned)MAXPALOOKUPS)
|
||||
return 0;
|
||||
|
||||
i = -1;
|
||||
for (sk = m->skinmap; sk; sk = sk->next)
|
||||
{
|
||||
if (sk->palette == pal && sk->skinnum == number && sk->surfnum == surf)
|
||||
{
|
||||
if (exact) *exact = true;
|
||||
//Printf("Using exact match skin (pal=%d,skinnum=%d,surfnum=%d) %s\n",pal,number,surf,skinfile);
|
||||
return TexMan.GetGameTexture(sk->texture);
|
||||
}
|
||||
//If no match, give highest priority to number, then pal.. (Parkar's request, 02/27/2005)
|
||||
else if ((sk->palette == 0) && (sk->skinnum == number) && (sk->surfnum == surf) && (i < 5)) { i = 5; skzero = sk; }
|
||||
else if ((sk->palette == pal) && (sk->skinnum == 0) && (sk->surfnum == surf) && (i < 4)) { i = 4; skzero = sk; }
|
||||
else if ((sk->palette == 0) && (sk->skinnum == 0) && (sk->surfnum == surf) && (i < 3)) { i = 3; skzero = sk; }
|
||||
else if ((sk->palette == 0) && (sk->skinnum == number) && (i < 2)) { i = 2; skzero = sk; }
|
||||
else if ((sk->palette == pal) && (sk->skinnum == 0) && (i < 1)) { i = 1; skzero = sk; }
|
||||
else if ((sk->palette == 0) && (sk->skinnum == 0) && (i < 0)) { i = 0; skzero = sk; }
|
||||
}
|
||||
|
||||
// Special palettes do not get replacements
|
||||
if (pal >= (MAXPALOOKUPS - RESERVEDPALS))
|
||||
return 0;
|
||||
|
||||
if (skzero)
|
||||
{
|
||||
//Printf("Using def skin 0,0 as fallback, pal=%d\n", pal);
|
||||
if (exact) *exact = false;
|
||||
return TexMan.GetGameTexture(skzero->texture);
|
||||
}
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void updateModelInterpolation()
|
||||
{
|
||||
// this never worked - only left as a reference to sprext stuff.
|
||||
omdtims = mdtims;
|
||||
mdtims = I_msTime();
|
||||
|
||||
TSpriteIterator<DCoreActor> it;
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
if ((mdpause && actor->sprext.mdanimtims) || (actor->sprext.renderflags & SPREXT_NOMDANIM))
|
||||
actor->sprext.mdanimtims += mdtims - omdtims;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int tilehasmodelorvoxel(int const tilenume, int pal)
|
||||
{
|
||||
return
|
||||
(hw_models && modelManager.CheckModel(tilenume, pal)) ||
|
||||
(r_voxels && tiletovox[tilenume] != -1);
|
||||
}
|
||||
|
85
source/core/models/modeldata.h
Normal file
85
source/core/models/modeldata.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include "vectors.h"
|
||||
|
||||
enum {
|
||||
HUDFLAG_HIDE = 1,
|
||||
HUDFLAG_NOBOB = 2,
|
||||
HUDFLAG_FLIPPED = 4,
|
||||
HUDFLAG_NODEPTH = 8,
|
||||
};
|
||||
|
||||
struct ModelAnimation
|
||||
{
|
||||
int startframe, endframe;
|
||||
int fpssc, flags;
|
||||
};
|
||||
|
||||
struct ModelSkinDef
|
||||
{
|
||||
uint8_t palette, flags;
|
||||
int32_t skinnum, surfnum; // Skin identifier, surface number
|
||||
FTextureID texture;
|
||||
float param, specpower, specfactor;
|
||||
};
|
||||
|
||||
|
||||
struct ModelDescriptor
|
||||
{
|
||||
unsigned modelID;
|
||||
|
||||
// stuff that can get set from .DEF so we need to keep it.
|
||||
int shadeoff;
|
||||
int flags;
|
||||
float scale, bscale, zadd, yoffset;
|
||||
bool deleted;
|
||||
FGameTexture* texture;
|
||||
TArray<ModelAnimation> anims;
|
||||
TArray<ModelSkinDef> skins;
|
||||
};
|
||||
|
||||
struct ModelTileFrame
|
||||
{
|
||||
// maps build tiles to particular animation frames of a model
|
||||
int modelid;
|
||||
int framenum;
|
||||
float smoothduration;
|
||||
int skinnum;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct ModelManager
|
||||
{
|
||||
TArray<ModelDescriptor> modelDescs;
|
||||
TMap<unsigned, ModelTileFrame> frameMap;
|
||||
|
||||
unsigned FrameMapKey(unsigned tilenum, unsigned palette)
|
||||
{
|
||||
return tilenum + (palette < 16); // good enough for now - should later be redirected to the underlying texture ID.
|
||||
}
|
||||
|
||||
// Interface for the .def parser
|
||||
int LoadModel(const char* fn);
|
||||
int SetMisc(int modelid, float scale, int shadeoff, float zadd, float yoffset, int flags);
|
||||
int DefineFrame(int modelid, const char* framename, int tilenum, int skinnum, float smoothduration, int pal);
|
||||
int DefineAnimation(int modelid, const char* framestart, const char* frameend, int fpssc, int flags);
|
||||
int DefineSkin(int modelid, const char* skinfn, int palnum, int skinnum, int surfnum, float param, float specpower, float specfactor, int flags);
|
||||
int DefineHud(int modelid, int tilex, FVector3 add, int angadd, int flags, int fov);
|
||||
int UndefineTile(int tile);
|
||||
int UndefineModel(int modelid);
|
||||
bool CheckModel(int tilenum, int pal)
|
||||
{
|
||||
return frameMap.CheckKey(FrameMapKey(tilenum, pal)) != nullptr;
|
||||
}
|
||||
ModelTileFrame* GetModel(int tilenum, int pal)
|
||||
{
|
||||
return frameMap.CheckKey(FrameMapKey(tilenum, pal));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int tilehasmodelorvoxel(int const tilenume, int pal);
|
||||
inline ModelManager modelManager;
|
|
@ -43,6 +43,7 @@
|
|||
#include "hw_models.h"
|
||||
#include "hw_voxels.h"
|
||||
#include "mapinfo.h"
|
||||
#include "models/modeldata.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
extern short voxelIndex[MAXTILES];
|
||||
|
@ -68,9 +69,9 @@ static void doprecache(int picnum, int palette)
|
|||
|
||||
if (!hw_models) return;
|
||||
|
||||
int const mid = md_tilehasmodel(picnum, palette);
|
||||
int const mid = modelManager.CheckModel(picnum, palette);
|
||||
|
||||
if (mid < 0 || models[mid]->mdnum < 2)
|
||||
if (mid < 0)
|
||||
{
|
||||
if (r_voxels)
|
||||
{
|
||||
|
@ -86,6 +87,7 @@ static void doprecache(int picnum, int palette)
|
|||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int const surfaces = (models[mid]->mdnum == 3) ? ((md3model_t *)models[mid])->head.numsurfs : 0;
|
||||
|
||||
for (int i = 0; i <= surfaces; i++)
|
||||
|
@ -94,6 +96,7 @@ static void doprecache(int picnum, int palette)
|
|||
int paletteid = TRANSLATION(Translation_Remap + curbasepal, palette);
|
||||
if (skintex) PrecacheTex(skintex, paletteid);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ static voxmodel_t* voxload(int lumpnum)
|
|||
voxmodel_t* vm = new voxmodel_t;
|
||||
*vm = {};
|
||||
auto pivot = voxel->Mips[0].Pivot;
|
||||
vm->mdnum = 1; //VOXel model id
|
||||
//vm->mdnum = 1; //VOXel model id
|
||||
vm->scale = vm->bscale = 1.f;
|
||||
vm->piv.X = float(pivot.X);
|
||||
vm->piv.Y = float(pivot.Y);
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "mdsprite.h"
|
||||
#include "model.h"
|
||||
#include "model_kvx.h"
|
||||
#include "intvec.h"
|
||||
|
||||
// We still need the relation to mdmodel_t as long as the model code hasn't been redone.
|
||||
struct voxmodel_t : public mdmodel_t
|
||||
constexpr int MAXVOXELS = 1024;
|
||||
|
||||
struct voxmodel_t // : public mdmodel_t
|
||||
{
|
||||
FVoxelModel* model = nullptr;
|
||||
float scale, bscale, zadd, yoffset;
|
||||
vec3_t siz;
|
||||
FVector3 piv;
|
||||
int32_t is8bit;
|
||||
|
@ -19,6 +23,9 @@ extern float voxscale[];
|
|||
extern voxmodel_t* voxmodels[MAXVOXELS];
|
||||
extern FixedBitArray<MAXVOXELS> voxrotate;
|
||||
|
||||
inline int32_t nextvoxid;
|
||||
inline FixedBitArray<MAXVOXELS>voxreserve;
|
||||
|
||||
void voxInit();
|
||||
void voxClear();
|
||||
int voxDefine(int voxindex, const char* filename);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "build.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "hw_drawinfo.h"
|
||||
//#include "models.h"
|
||||
#include "models/modeldata.h"
|
||||
#include "hw_clock.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "hw_viewpointbuffer.h"
|
||||
|
@ -290,8 +290,8 @@ void HWDrawInfo::DispatchSprites()
|
|||
|
||||
if (!(actor->sprext.renderflags & SPREXT_NOTMD))
|
||||
{
|
||||
int pt = Ptile2tile(tilenum, tspr->pal);
|
||||
if (hw_models && tile2model[pt].modelid >= 0 && tile2model[pt].framenum >= 0)
|
||||
auto pt = modelManager.GetModel(tilenum, tspr->pal);
|
||||
if (hw_models && pt && pt->modelid >= 0 && pt->framenum >= 0)
|
||||
{
|
||||
//HWSprite hwsprite;
|
||||
//if (hwsprite.ProcessModel(pt, tspr)) continue;
|
||||
|
|
|
@ -479,12 +479,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, spritetype &c, spritet
|
|||
|
||||
FSerializer& Serialize(FSerializer& arc, const char* key, spriteext_t& c, spriteext_t* def)
|
||||
{
|
||||
if (arc.isWriting() && c.mdanimtims)
|
||||
{
|
||||
c.mdanimtims -= mdtims;
|
||||
if (c.mdanimtims == 0) c.mdanimtims++;
|
||||
}
|
||||
|
||||
def = &zspx; // always delta against 0
|
||||
if (arc.BeginObject(key))
|
||||
{
|
||||
|
@ -498,7 +492,6 @@ FSerializer& Serialize(FSerializer& arc, const char* key, spriteext_t& c, sprite
|
|||
.EndObject();
|
||||
}
|
||||
|
||||
if (c.mdanimtims) c.mdanimtims += mdtims;
|
||||
return arc;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "sc_man.h"
|
||||
#include "gamestruct.h"
|
||||
#include "hw_voxels.h"
|
||||
#include "models/modeldata.h"
|
||||
|
||||
#include "hw_renderstate.h"
|
||||
|
||||
|
@ -661,7 +662,7 @@ void tileDelete(int tile)
|
|||
TileFiles.tiledata[tile].texture = TileFiles.tiledata[tile].backup = TexMan.GameByIndex(0);
|
||||
TileFiles.tiledata[tile].replacement = ReplacementType::Art; // whatever this was, now it isn't anymore. (SW tries to nuke camera textures with this, :( )
|
||||
tiletovox[tile] = -1; // clear the link but don't clear the voxel. It may be in use for another tile.
|
||||
md_undefinetile(tile);
|
||||
modelManager.UndefineTile(tile);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "v_font.h"
|
||||
#include "hw_voxels.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "models/modeldata.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
|
@ -628,7 +629,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
|
|||
case 6:
|
||||
case 7:
|
||||
{
|
||||
if (hw_models && md_tilehasmodel(pTSprite->picnum, pTSprite->pal) >= 0 && !(owneractor->sprext.renderflags & SPREXT_NOTMD))
|
||||
if (hw_models && modelManager.CheckModel(pTSprite->picnum, pTSprite->pal) && !(owneractor->sprext.renderflags & SPREXT_NOTMD))
|
||||
break;
|
||||
|
||||
// Can be overridden by def script
|
||||
|
@ -678,9 +679,9 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
|
|||
{
|
||||
int const nRootTile = pTSprite->picnum;
|
||||
int nAnimTile = pTSprite->picnum + tileAnimateOfs(pTSprite->picnum, (pTSprite->ownerActor->GetIndex() & 16383));
|
||||
auto pt = modelManager.GetModel(nAnimTile, pTSprite->pal);
|
||||
|
||||
if (tile2model[Ptile2tile(nAnimTile, pTSprite->pal)].modelid >= 0 &&
|
||||
tile2model[Ptile2tile(nAnimTile, pTSprite->pal)].framenum >= 0)
|
||||
if (pt && pt->modelid >= 0 && pt->framenum >= 0)
|
||||
{
|
||||
pTSprite->yoffset += tileTopOffset(nAnimTile);
|
||||
pTSprite->xoffset += tileLeftOffset(nAnimTile);
|
||||
|
|
|
@ -42,7 +42,6 @@ enum
|
|||
kMaxTiles = MAXTILES,
|
||||
kMaxStatus = MAXSTATUS,
|
||||
kMaxPlayers = 8,
|
||||
kMaxVoxels = MAXVOXELS,
|
||||
|
||||
kTicRate = 120,
|
||||
kTicsPerFrame = 4,
|
||||
|
|
|
@ -71,7 +71,7 @@ void GameInterface::LoadGameTextures()
|
|||
}
|
||||
for (int i = 0; i < kMaxTiles; i++)
|
||||
{
|
||||
if (voxelIndex[i] >= 0 && voxelIndex[i] < kMaxVoxels)
|
||||
if (voxelIndex[i] >= 0 && voxelIndex[i] < MAXVOXELS)
|
||||
voxreserve.Set(voxelIndex[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ source as it is released.
|
|||
#include "names_d.h"
|
||||
#include "dukeactor.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "models/modeldata.h"
|
||||
|
||||
EXTERN_CVAR(Bool, wt_commentary)
|
||||
|
||||
|
@ -79,7 +80,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
t->xrepeat = t->yrepeat = 0;
|
||||
continue;
|
||||
case CHAIR3:
|
||||
if (hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0)
|
||||
if (hw_models && modelManager.CheckModel(t->picnum, t->pal))
|
||||
{
|
||||
t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
break;
|
||||
|
@ -256,7 +257,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
t->picnum = GROWSPARK + ((PlayClock >> 4) & 3);
|
||||
break;
|
||||
case RPG:
|
||||
if (hw_models && md_tilehasmodel(h->spr.picnum, h->spr.pal) >= 0)
|
||||
if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal))
|
||||
{
|
||||
t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
break;
|
||||
|
@ -274,7 +275,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
break;
|
||||
|
||||
case RECON:
|
||||
if (hw_models && md_tilehasmodel(h->spr.picnum, h->spr.pal) >= 0)
|
||||
if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal))
|
||||
{
|
||||
t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
break;
|
||||
|
@ -363,7 +364,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
|
||||
if (!h->GetOwner())
|
||||
{
|
||||
if (hw_models && md_tilehasmodel(h->spr.picnum, h->spr.pal) >= 0)
|
||||
if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal))
|
||||
{
|
||||
k = 0;
|
||||
t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
|
@ -485,7 +486,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
{
|
||||
l = ScriptCode[t4 + 2];
|
||||
|
||||
if (hw_models && md_tilehasmodel(h->spr.picnum, h->spr.pal) >= 0)
|
||||
if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal))
|
||||
{
|
||||
k = 0;
|
||||
t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
|
@ -582,7 +583,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
shadowspr->pos.Z = floorz;
|
||||
shadowspr->pal = 4;
|
||||
|
||||
if (hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0)
|
||||
if (hw_models && modelManager.CheckModel(t->picnum, t->pal))
|
||||
{
|
||||
shadowspr->yrepeat = 0;
|
||||
// 512:trans reverse
|
||||
|
@ -652,7 +653,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
t->picnum += (h->spr.shade >> 1);
|
||||
break;
|
||||
case PLAYERONWATER:
|
||||
if (hw_models && md_tilehasmodel(h->spr.picnum, h->spr.pal) >= 0)
|
||||
if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal))
|
||||
{
|
||||
k = 0;
|
||||
t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
|
@ -710,7 +711,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
|
||||
case CAMERA1:
|
||||
case RAT:
|
||||
if (hw_models && md_tilehasmodel(h->spr.picnum, h->spr.pal) >= 0)
|
||||
if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal))
|
||||
{
|
||||
t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
break;
|
||||
|
|
|
@ -33,6 +33,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
|||
#include "prediction.h"
|
||||
#include "dukeactor.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "models/modeldata.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
@ -408,7 +409,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
|
||||
if (!h->GetOwner())
|
||||
{
|
||||
if (hw_models && md_tilehasmodel(h->spr.picnum, h->spr.pal) >= 0)
|
||||
if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal))
|
||||
{
|
||||
k = 0;
|
||||
t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
|
@ -618,7 +619,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
{
|
||||
l = ScriptCode[t4 + 2];
|
||||
|
||||
if (hw_models && md_tilehasmodel(h->spr.picnum, h->spr.pal) >= 0)
|
||||
if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal))
|
||||
{
|
||||
k = 0;
|
||||
t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
|
@ -738,7 +739,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
shadowspr->pos.Z = floorz;
|
||||
shadowspr->pal = 4;
|
||||
|
||||
if (hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0)
|
||||
if (hw_models && modelManager.CheckModel(t->picnum, t->pal))
|
||||
{
|
||||
shadowspr->yrepeat = 0;
|
||||
// 512:trans reverse
|
||||
|
|
|
@ -56,6 +56,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
#include "v_draw.h"
|
||||
#include "render.h"
|
||||
#include "razefont.h"
|
||||
#include "models/modeldata.h"
|
||||
|
||||
extern DCoreActor* wall_to_sprite_actors[8];
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
#include "parent.h"
|
||||
#include "v_video.h"
|
||||
#include "render.h"
|
||||
#include "models/modeldata.h"
|
||||
|
||||
BEGIN_SW_NS
|
||||
|
||||
|
@ -812,7 +813,7 @@ void JAnalyzeSprites(tspritetype* tspr)
|
|||
// Take care of autosizing
|
||||
DoAutoSize(tspr);
|
||||
|
||||
if (md_tilehasmodel(tspr->picnum, 0) >= 0 && hw_models) return;
|
||||
if (hw_models && modelManager.CheckModel(tspr->picnum, 0)) return;
|
||||
|
||||
// Check for voxels
|
||||
//if (bVoxelsOn)
|
||||
|
|
Loading…
Reference in a new issue