diff --git a/src/common/models/model.h b/src/common/models/model.h index 6084e54075..dc4d644764 100644 --- a/src/common/models/model.h +++ b/src/common/models/model.h @@ -77,7 +77,7 @@ public: virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) = 0; virtual float getAspectFactor(float vscale) { return 1.f; } virtual const TArray* AttachAnimationData() { return nullptr; }; - virtual const TArray CalculateBones(int frame1, int frame2, double inter, const TArray& animationData, DBoneComponents* bones, int index) { return {}; }; + virtual const TArray CalculateBones(int frame1, int frame2, double inter, const TArray* animationData, DBoneComponents* bones, int index) { return {}; }; void SetVertexBuffer(int type, IModelVertexBuffer *buffer) { mVBuf[type] = buffer; } IModelVertexBuffer *GetVertexBuffer(int type) const { return mVBuf[type]; } diff --git a/src/common/models/model_iqm.h b/src/common/models/model_iqm.h index cd87a78f32..3ab9566895 100644 --- a/src/common/models/model_iqm.h +++ b/src/common/models/model_iqm.h @@ -116,7 +116,7 @@ public: void BuildVertexBuffer(FModelRenderer* renderer) override; void AddSkins(uint8_t* hitlist, const FTextureID* surfaceskinids) override; const TArray* AttachAnimationData() override; - const TArray CalculateBones(int frame1, int frame2, double inter, const TArray& animationData, DBoneComponents* bones, int index) override; + const TArray CalculateBones(int frame1, int frame2, double inter, const TArray* animationData, DBoneComponents* bones, int index) override; private: void LoadGeometry(); diff --git a/src/common/models/models_iqm.cpp b/src/common/models/models_iqm.cpp index 514fb2833c..d61ad9e672 100644 --- a/src/common/models/models_iqm.cpp +++ b/src/common/models/models_iqm.cpp @@ -514,9 +514,9 @@ const TArray* IQMModel::AttachAnimationData() return &TRSData; } -const TArray IQMModel::CalculateBones(int frame1, int frame2, double inter, const TArray& animationData, DBoneComponents* boneComponentData, int index) +const TArray IQMModel::CalculateBones(int frame1, int frame2, double inter, const TArray* animationData, DBoneComponents* boneComponentData, int index) { - const TArray& animationFrames = &animationData ? animationData : TRSData; + const TArray& animationFrames = animationData ? *animationData : TRSData; if (Joints.Size() > 0) { int numbones = Joints.Size(); @@ -604,4 +604,4 @@ const TArray IQMModel::CalculateBones(int frame1, int frame2, double i return bones; } return {}; -} \ No newline at end of file +} diff --git a/src/r_data/models.cpp b/src/r_data/models.cpp index fd1fa27a09..8ed3e57f2c 100644 --- a/src/r_data/models.cpp +++ b/src/r_data/models.cpp @@ -365,7 +365,6 @@ void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpr auto& ssids = surfaceskinids.Size() > 0 ? surfaceskinids : smf->surfaceskinIDs; auto ssidp = (unsigned)(i * MD3_MAX_SURFACES) < ssids.Size() ? &ssids[i * MD3_MAX_SURFACES] : nullptr; - const TArray* animationData = nullptr; bool nextFrame = smfNext && modelframe != modelframenext; @@ -381,11 +380,11 @@ void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpr if (animationid >= 0) { FModel* animation = Models[animationid]; - animationData = animation->AttachAnimationData(); + const TArray* animationData = animation->AttachAnimationData(); if (!(smf->flags & MDL_MODELSAREATTACHMENTS) || evaluatedSingle == false) { - boneData = animation->CalculateBones(modelframe, nextFrame ? modelframenext : modelframe, nextFrame ? inter : 0.f, *animationData, actor->boneComponentData, i); + boneData = animation->CalculateBones(modelframe, nextFrame ? modelframenext : modelframe, nextFrame ? inter : 0.f, animationData, actor->boneComponentData, i); boneStartingPosition = renderer->SetupFrame(animation, 0, 0, 0, boneData, -1); evaluatedSingle = true; } @@ -394,7 +393,7 @@ void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpr { if (!(smf->flags & MDL_MODELSAREATTACHMENTS) || evaluatedSingle == false) { - boneData = mdl->CalculateBones(modelframe, nextFrame ? modelframenext : modelframe, nextFrame ? inter : 0.f, *animationData, actor->boneComponentData, i); + boneData = mdl->CalculateBones(modelframe, nextFrame ? modelframenext : modelframe, nextFrame ? inter : 0.f, nullptr, actor->boneComponentData, i); boneStartingPosition = renderer->SetupFrame(mdl, 0, 0, 0, boneData, -1); evaluatedSingle = true; }