- changed CalculateBones to receive the bone component data directly instead of the owning actor.

Since the backend also gets used by Raze it may not access Doom game data.
This commit is contained in:
Christoph Oelckers 2022-11-06 10:25:37 +01:00
parent 3e405c5215
commit 0e111ae151
3 changed files with 12 additions and 13 deletions

View file

@ -5,7 +5,6 @@
#include "i_modelvertexbuffer.h"
#include "matrix.h"
#include "TRS.h"
#include "d_player.h"
class FModelRenderer;
class FGameTexture;
@ -77,7 +76,7 @@ public:
virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) = 0;
virtual float getAspectFactor(float vscale) { return 1.f; }
virtual const TArray<TRS>* AttachAnimationData() { return nullptr; };
virtual const TArray<VSMatrix> CalculateBones(int frame1, int frame2, double inter, const TArray<TRS>& animationData, AActor* actor, int index) { return {}; };
virtual const TArray<VSMatrix> CalculateBones(int frame1, int frame2, double inter, const TArray<TRS>& animationData, DBoneComponents* bones, int index) { return {}; };
void SetVertexBuffer(int type, IModelVertexBuffer *buffer) { mVBuf[type] = buffer; }
IModelVertexBuffer *GetVertexBuffer(int type) const { return mVBuf[type]; }

View file

@ -113,7 +113,7 @@ public:
void BuildVertexBuffer(FModelRenderer* renderer) override;
void AddSkins(uint8_t* hitlist, const FTextureID* surfaceskinids) override;
const TArray<TRS>* AttachAnimationData() override;
const TArray<VSMatrix> CalculateBones(int frame1, int frame2, double inter, const TArray<TRS>& animationData, AActor* actor, int index) override;
const TArray<VSMatrix> CalculateBones(int frame1, int frame2, double inter, const TArray<TRS>& animationData, DBoneComponents* bones, int index) override;
private:
void LoadGeometry();

View file

@ -510,17 +510,17 @@ const TArray<TRS>* IQMModel::AttachAnimationData()
return &TRSData;
}
const TArray<VSMatrix> IQMModel::CalculateBones(int frame1, int frame2, double inter, const TArray<TRS>& animationData, AActor* actor, int index)
const TArray<VSMatrix> IQMModel::CalculateBones(int frame1, int frame2, double inter, const TArray<TRS>& animationData, DBoneComponents* boneComponentData, int index)
{
const TArray<TRS>& animationFrames = &animationData ? animationData : TRSData;
if (Joints.Size() > 0)
{
int numbones = Joints.Size();
if (actor->boneComponentData->trscomponents[index].Size() != numbones)
actor->boneComponentData->trscomponents[index].Resize(numbones);
if (actor->boneComponentData->trsmatrix[index].Size() != numbones)
actor->boneComponentData->trsmatrix[index].Resize(numbones);
if (boneComponentData->trscomponents[index].Size() != numbones)
boneComponentData->trscomponents[index].Resize(numbones);
if (boneComponentData->trsmatrix[index].Size() != numbones)
boneComponentData->trsmatrix[index].Resize(numbones);
frame1 = clamp(frame1, 0, ((int)animationFrames.Size() - 1) / numbones);
frame2 = clamp(frame2, 0, ((int)animationFrames.Size() - 1) / numbones);
@ -556,18 +556,18 @@ const TArray<VSMatrix> IQMModel::CalculateBones(int frame1, int frame2, double i
if (Joints[i].Parent >= 0 && modifiedBone[Joints[i].Parent])
{
actor->boneComponentData->trscomponents[index][i] = bone;
boneComponentData->trscomponents[index][i] = bone;
modifiedBone[i] = true;
}
else if (actor->boneComponentData->trscomponents[index][i].Equals(bone))
else if (boneComponentData->trscomponents[index][i].Equals(bone))
{
bones[i] = actor->boneComponentData->trsmatrix[index][i];
bones[i] = boneComponentData->trsmatrix[index][i];
modifiedBone[i] = false;
continue;
}
else
{
actor->boneComponentData->trscomponents[index][i] = bone;
boneComponentData->trscomponents[index][i] = bone;
modifiedBone[i] = true;
}
@ -595,7 +595,7 @@ const TArray<VSMatrix> IQMModel::CalculateBones(int frame1, int frame2, double i
result.multMatrix(swapYZ);
}
actor->boneComponentData->trsmatrix[index] = bones;
boneComponentData->trsmatrix[index] = bones;
return bones;
}