diff --git a/source/common/models/model.cpp b/source/common/models/model.cpp index 1829ccebb..21f5c9f41 100644 --- a/source/common/models/model.cpp +++ b/source/common/models/model.cpp @@ -155,12 +155,13 @@ unsigned FindModel(const char * path, const char * modelfile) FModel * model = nullptr; FString fullname; - fullname.Format("%s%s", path, modelfile); + if (path) fullname.Format("%s%s", path, modelfile); + else fullname = modelfile; int lump = fileSystem.CheckNumForFullName(fullname); if (lump<0) { - Printf("FindModel: '%s' not found\n", fullname.GetChars()); + Printf(PRINT_HIGH, "FindModel: '%s' not found\n", fullname.GetChars()); return -1; } @@ -226,7 +227,7 @@ unsigned FindModel(const char * path, const char * modelfile) } else { - Printf("LoadModel: Unknown model format in '%s'\n", fullname.GetChars()); + Printf(PRINT_HIGH, "LoadModel: Unknown model format in '%s'\n", fullname.GetChars()); return -1; } } diff --git a/source/common/models/model.h b/source/common/models/model.h index 300661d25..edbcc4841 100644 --- a/source/common/models/model.h +++ b/source/common/models/model.h @@ -53,6 +53,13 @@ enum ModelRendererType NumModelRendererTypes }; +enum EFrameError +{ + FErr_NotFound = -1, + FErr_Voxel = -2, + FErr_Singleframe = -3 +}; + class FModel { public: @@ -60,7 +67,7 @@ public: virtual ~FModel(); virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0; - virtual int FindFrame(const char * name) = 0; + virtual int FindFrame(const char * name, bool nodefault = false) = 0; virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) = 0; virtual void BuildVertexBuffer(FModelRenderer *renderer) = 0; virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) = 0; diff --git a/source/common/models/model_kvx.h b/source/common/models/model_kvx.h index 4c107db5c..2fa82b0ed 100644 --- a/source/common/models/model_kvx.h +++ b/source/common/models/model_kvx.h @@ -58,7 +58,7 @@ public: ~FVoxelModel(); bool Load(const char * fn, int lumpnum, const char * buffer, int length) override; void Initialize(); - virtual int FindFrame(const char * name) override; + virtual int FindFrame(const char * name, bool nodefault) override; virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) override; virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) override; FTextureID GetPaletteTexture() const { return mPalette; } diff --git a/source/common/models/model_md2.h b/source/common/models/model_md2.h index 966a38975..b1feef645 100644 --- a/source/common/models/model_md2.h +++ b/source/common/models/model_md2.h @@ -112,7 +112,7 @@ public: virtual ~FDMDModel(); virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) override; - virtual int FindFrame(const char * name) override; + virtual int FindFrame(const char * name, bool nodefault) override; virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) override; virtual void LoadGeometry(); virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) override; diff --git a/source/common/models/model_md3.h b/source/common/models/model_md3.h index e79a4c98b..3d81cb1c3 100644 --- a/source/common/models/model_md3.h +++ b/source/common/models/model_md3.h @@ -66,7 +66,7 @@ public: FMD3Model() = default; virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) override; - virtual int FindFrame(const char * name) override; + virtual int FindFrame(const char * name, bool nodefault) override; virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) override; void LoadGeometry(); void BuildVertexBuffer(FModelRenderer *renderer); diff --git a/source/common/models/model_obj.h b/source/common/models/model_obj.h index a07090900..55a47363c 100644 --- a/source/common/models/model_obj.h +++ b/source/common/models/model_obj.h @@ -97,7 +97,7 @@ public: FOBJModel(): hasMissingNormals(false), hasSmoothGroups(false), vertFaces(nullptr) {} ~FOBJModel(); bool Load(const char* fn, int lumpnum, const char* buffer, int length) override; - int FindFrame(const char* name) override; + int FindFrame(const char* name, bool nodefault) override; void RenderFrame(FModelRenderer* renderer, FGameTexture* skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) override; void BuildVertexBuffer(FModelRenderer* renderer) override; void AddSkins(uint8_t* hitlist, const FTextureID* surfaceskinids) override; diff --git a/source/common/models/model_ue1.h b/source/common/models/model_ue1.h index 2d29c2eff..f2ed1952c 100644 --- a/source/common/models/model_ue1.h +++ b/source/common/models/model_ue1.h @@ -25,7 +25,7 @@ public: }; bool Load(const char * fn, int lumpnum, const char * buffer, int length) override; - int FindFrame(const char * name) override; + int FindFrame(const char * name, bool nodefault) override; void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) override; void BuildVertexBuffer(FModelRenderer *renderer) override; void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) override; diff --git a/source/common/models/models_md2.cpp b/source/common/models/models_md2.cpp index f38472301..81d1c3666 100644 --- a/source/common/models/models_md2.cpp +++ b/source/common/models/models_md2.cpp @@ -348,13 +348,13 @@ void FDMDModel::AddSkins(uint8_t *hitlist, const FTextureID*) // FDMDModel::FindFrame // //=========================================================================== -int FDMDModel::FindFrame(const char * name) +int FDMDModel::FindFrame(const char * name, bool nodefault) { for (int i=0;i= numFrames) return FErr_NotFound; + return index; } void FUE1Model::RenderFrame( FModelRenderer *renderer, FGameTexture *skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) diff --git a/source/common/models/models_voxel.cpp b/source/common/models/models_voxel.cpp index 6db0c9e5f..41f5e854a 100644 --- a/source/common/models/models_voxel.cpp +++ b/source/common/models/models_voxel.cpp @@ -378,9 +378,9 @@ bool FVoxelModel::Load(const char * fn, int lumpnum, const char * buffer, int le // //=========================================================================== -int FVoxelModel::FindFrame(const char * name) +int FVoxelModel::FindFrame(const char * name, bool nodefault) { - return 0; + return nodefault? FErr_Voxel : 0; // -2, not -1 because voxels are special. } //===========================================================================