From 752b67c5a7d28300fd0c2855aec8f1fd9e8078ce Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 9 Nov 2023 22:39:55 +0100 Subject: [PATCH] use FTranslationID in the model code. --- source/common/models/model.h | 3 ++- source/common/models/model_iqm.h | 2 +- source/common/models/model_kvx.h | 2 +- source/common/models/model_md2.h | 2 +- source/common/models/model_md3.h | 2 +- source/common/models/model_obj.h | 2 +- source/common/models/model_ue1.h | 2 +- source/common/models/modelrenderer.h | 2 +- source/common/models/models_iqm.cpp | 2 +- source/common/models/models_md2.cpp | 2 +- source/common/models/models_md3.cpp | 2 +- source/common/models/models_obj.cpp | 2 +- source/common/models/models_ue1.cpp | 2 +- source/common/models/models_voxel.cpp | 2 +- source/core/rendering/hw_models.cpp | 4 ++-- source/core/rendering/hw_models.h | 2 +- source/core/rendering/scene/hw_sprites.cpp | 2 +- 17 files changed, 19 insertions(+), 18 deletions(-) diff --git a/source/common/models/model.h b/source/common/models/model.h index dc4d644764b..69b947ae189 100644 --- a/source/common/models/model.h +++ b/source/common/models/model.h @@ -4,6 +4,7 @@ #include "textureid.h" #include "i_modelvertexbuffer.h" #include "matrix.h" +#include "palettecontainer.h" #include "TRS.h" class DBoneComponents; @@ -72,7 +73,7 @@ class FModel virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 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, const TArray& boneData, int boneStartPosition) = 0; + virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) = 0; virtual void BuildVertexBuffer(FModelRenderer *renderer) = 0; virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) = 0; virtual float getAspectFactor(float vscale) { return 1.f; } diff --git a/source/common/models/model_iqm.h b/source/common/models/model_iqm.h index 3ab9566895b..701c1e79374 100644 --- a/source/common/models/model_iqm.h +++ b/source/common/models/model_iqm.h @@ -112,7 +112,7 @@ class IQMModel : public FModel bool Load(const char* fn, int lumpnum, const char* buffer, int length) 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, const TArray& boneData, int boneStartPosition) override; + void RenderFrame(FModelRenderer* renderer, FGameTexture* skin, int frame, int frame2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) override; void BuildVertexBuffer(FModelRenderer* renderer) override; void AddSkins(uint8_t* hitlist, const FTextureID* surfaceskinids) override; const TArray* AttachAnimationData() override; diff --git a/source/common/models/model_kvx.h b/source/common/models/model_kvx.h index c801e5c010f..2175bcbca73 100644 --- a/source/common/models/model_kvx.h +++ b/source/common/models/model_kvx.h @@ -59,7 +59,7 @@ class FVoxelModel : public FModel bool Load(const char * fn, int lumpnum, const char * buffer, int length) override; void Initialize(); 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, const TArray& boneData, int boneStartPosition) override; + virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) override; virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) override; FTextureID GetPaletteTexture() const { return mPalette; } void BuildVertexBuffer(FModelRenderer *renderer) override; diff --git a/source/common/models/model_md2.h b/source/common/models/model_md2.h index 9ead5e60be5..fd1646dc9bc 100644 --- a/source/common/models/model_md2.h +++ b/source/common/models/model_md2.h @@ -113,7 +113,7 @@ class FDMDModel : public FModel virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) 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, const TArray& boneData, int boneStartPosition) override; + virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) 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 b53cd3ebb37..045b1cc3b72 100644 --- a/source/common/models/model_md3.h +++ b/source/common/models/model_md3.h @@ -67,7 +67,7 @@ class FMD3Model : public FModel virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) 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, const TArray& boneData, int boneStartPosition) override; + virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) override; void LoadGeometry(); void BuildVertexBuffer(FModelRenderer *renderer); virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) override; diff --git a/source/common/models/model_obj.h b/source/common/models/model_obj.h index fa41ec0fc87..4fc977c05f4 100644 --- a/source/common/models/model_obj.h +++ b/source/common/models/model_obj.h @@ -98,7 +98,7 @@ class FOBJModel : public FModel ~FOBJModel(); bool Load(const char* fn, int lumpnum, const char* buffer, int length) 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, const TArray& boneData, int boneStartPosition) override; + void RenderFrame(FModelRenderer* renderer, FGameTexture* skin, int frame, int frame2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) 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 4163dd2ba8d..579002f8958 100644 --- a/source/common/models/model_ue1.h +++ b/source/common/models/model_ue1.h @@ -26,7 +26,7 @@ class FUE1Model : public FModel bool Load(const char * fn, int lumpnum, const char * buffer, int length) 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, const TArray& boneData, int boneStartPosition) override; + void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) override; void BuildVertexBuffer(FModelRenderer *renderer) override; void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) override; void LoadGeometry(); diff --git a/source/common/models/modelrenderer.h b/source/common/models/modelrenderer.h index d921e7100fb..3a8388e7236 100644 --- a/source/common/models/modelrenderer.h +++ b/source/common/models/modelrenderer.h @@ -21,7 +21,7 @@ class FModelRenderer virtual void EndDrawHUDModel(FRenderStyle style, FSpriteModelFrame *smf) = 0; virtual void SetInterpolation(double interpolation) = 0; - virtual void SetMaterial(FGameTexture *skin, bool clampNoFilter, int translation) = 0; + virtual void SetMaterial(FGameTexture *skin, bool clampNoFilter, FTranslationID translation) = 0; virtual void DrawArrays(int start, int count) = 0; virtual void DrawElements(int numIndices, size_t offset) = 0; virtual int SetupFrame(FModel* model, unsigned int frame1, unsigned int frame2, unsigned int size, const TArray& bones, int boneStartIndex) { return -1; }; diff --git a/source/common/models/models_iqm.cpp b/source/common/models/models_iqm.cpp index a2bc656a1a5..df65a61d6aa 100644 --- a/source/common/models/models_iqm.cpp +++ b/source/common/models/models_iqm.cpp @@ -445,7 +445,7 @@ int IQMModel::FindFrame(const char* name, bool nodefault) return FErr_NotFound; } -void IQMModel::RenderFrame(FModelRenderer* renderer, FGameTexture* skin, int frame1, int frame2, double inter, int translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) +void IQMModel::RenderFrame(FModelRenderer* renderer, FGameTexture* skin, int frame1, int frame2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) { renderer->SetupFrame(this, 0, 0, NumVertices, boneData, boneStartPosition); diff --git a/source/common/models/models_md2.cpp b/source/common/models/models_md2.cpp index d56d1e7c5cb..3ba364c0332 100644 --- a/source/common/models/models_md2.cpp +++ b/source/common/models/models_md2.cpp @@ -364,7 +364,7 @@ int FDMDModel::FindFrame(const char* name, bool nodefault) // //=========================================================================== -void FDMDModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, int translation, const FTextureID*, const TArray& boneData, int boneStartPosition) +void FDMDModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, FTranslationID translation, const FTextureID*, const TArray& boneData, int boneStartPosition) { if (frameno >= info.numFrames || frameno2 >= info.numFrames) return; diff --git a/source/common/models/models_md3.cpp b/source/common/models/models_md3.cpp index 65948d809e8..5330611fca3 100644 --- a/source/common/models/models_md3.cpp +++ b/source/common/models/models_md3.cpp @@ -345,7 +345,7 @@ int FMD3Model::FindFrame(const char* name, bool nodefault) // //=========================================================================== -void FMD3Model::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, int translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) +void FMD3Model::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) { if ((unsigned)frameno >= Frames.Size() || (unsigned)frameno2 >= Frames.Size()) return; diff --git a/source/common/models/models_obj.cpp b/source/common/models/models_obj.cpp index 087fe0d3add..43e89b1d218 100644 --- a/source/common/models/models_obj.cpp +++ b/source/common/models/models_obj.cpp @@ -630,7 +630,7 @@ int FOBJModel::FindFrame(const char* name, bool nodefault) * @param inter The amount to interpolate the two frames. * @param translation The translation for the skin */ -void FOBJModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, int translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) +void FOBJModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) { // Prevent the model from rendering if the frame number is < 0 if (frameno < 0 || frameno2 < 0) return; diff --git a/source/common/models/models_ue1.cpp b/source/common/models/models_ue1.cpp index 4088601853c..c2f6929eb2f 100644 --- a/source/common/models/models_ue1.cpp +++ b/source/common/models/models_ue1.cpp @@ -232,7 +232,7 @@ int FUE1Model::FindFrame(const char* name, bool nodefault) return index; } -void FUE1Model::RenderFrame( FModelRenderer *renderer, FGameTexture *skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) +void FUE1Model::RenderFrame( FModelRenderer *renderer, FGameTexture *skin, int frame, int frame2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray& boneData, int boneStartPosition) { // the moment of magic if ( (frame < 0) || (frame2 < 0) || (frame >= numFrames) || (frame2 >= numFrames) ) return; diff --git a/source/common/models/models_voxel.cpp b/source/common/models/models_voxel.cpp index 5fb749b5e4b..e6cd5f8373d 100644 --- a/source/common/models/models_voxel.cpp +++ b/source/common/models/models_voxel.cpp @@ -400,7 +400,7 @@ float FVoxelModel::getAspectFactor(float stretch) // //=========================================================================== -void FVoxelModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation, const FTextureID*, const TArray& boneData, int boneStartPosition) +void FVoxelModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, FTranslationID translation, const FTextureID*, const TArray& boneData, int boneStartPosition) { renderer->SetMaterial(skin, true, translation); renderer->SetupFrame(this, 0, 0, 0, {}, -1); diff --git a/source/core/rendering/hw_models.cpp b/source/core/rendering/hw_models.cpp index c4746b7fe19..46e5656ec9c 100644 --- a/source/core/rendering/hw_models.cpp +++ b/source/core/rendering/hw_models.cpp @@ -87,9 +87,9 @@ void FHWModelRenderer::SetInterpolation(double inter) state.SetInterpolationFactor((float)inter); } -void FHWModelRenderer::SetMaterial(FGameTexture *skin, bool clampNoFilter, int translation) +void FHWModelRenderer::SetMaterial(FGameTexture *skin, bool clampNoFilter, FTranslationID translation) { - state.SetMaterial(skin, UF_Skin, 0, clampNoFilter ? CLAMP_NOFILTER : CLAMP_NONE, translation, -1); + state.SetMaterial(skin, UF_Skin, 0, clampNoFilter ? CLAMP_NOFILTER : CLAMP_NONE, translation.index(), -1); state.SetLightIndex(modellightindex); } diff --git a/source/core/rendering/hw_models.h b/source/core/rendering/hw_models.h index 7773d75502e..1ed49886e45 100644 --- a/source/core/rendering/hw_models.h +++ b/source/core/rendering/hw_models.h @@ -49,7 +49,7 @@ class FHWModelRenderer : public FModelRenderer void BeginDrawHUDModel(FRenderStyle style, const VSMatrix &objectToWorldMatrix, bool mirrored, FSpriteModelFrame* smf) override; void EndDrawHUDModel(FRenderStyle style, FSpriteModelFrame* smf) override; void SetInterpolation(double interpolation) override; - void SetMaterial(FGameTexture *skin, bool clampNoFilter, int translation) override; + void SetMaterial(FGameTexture *skin, bool clampNoFilter, FTranslationID translation) override; void DrawArrays(int start, int count) override; void DrawElements(int numIndices, size_t offset) override; int SetupFrame(FModel* model, unsigned int frame1, unsigned int frame2, unsigned int size, const TArray& bones, int boneStartIndex) override; diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index 3e47683bd18..5f220450867 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -157,7 +157,7 @@ void HWSprite::DrawSprite(HWDrawInfo* di, FRenderState& state, bool translucent) mr.BeginDrawModel(RenderStyle, nullptr, rotmat, mirrored); TArray a; mr.SetupFrame(model, 0, 0, 0, a, 0); - model->RenderFrame(&mr, TexMan.GetGameTexture(model->GetPaletteTexture()), 0, 0, 0.f, TRANSLATION(Translation_Remap + curbasepal, palette).index(), nullptr, a, 0); + model->RenderFrame(&mr, TexMan.GetGameTexture(model->GetPaletteTexture()), 0, 0, 0.f, TRANSLATION(Translation_Remap + curbasepal, palette), nullptr, a, 0); mr.EndDrawModel(RenderStyle, nullptr); state.SetDepthFunc(DF_Less); state.SetVertexBuffer(screen->mVertexData);