Skip to content

Commit

Permalink
- changed CalculateBones to receive the bone component data directly …
Browse files Browse the repository at this point in the history
…instead of the owning actor.

Since the backend also gets used by Raze it may not access Doom game data.
  • Loading branch information
coelckers committed Nov 6, 2022
1 parent 3e405c5 commit 0e111ae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/common/models/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "i_modelvertexbuffer.h"
#include "matrix.h"
#include "TRS.h"
#include "d_player.h"

class FModelRenderer;
class FGameTexture;
Expand Down Expand Up @@ -77,7 +76,7 @@ class FModel
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]; }
Expand Down
2 changes: 1 addition & 1 deletion src/common/models/model_iqm.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class IQMModel : public FModel
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();
Expand Down
20 changes: 10 additions & 10 deletions src/common/models/models_iqm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 0e111ae

Please sign in to comment.