Fixed a couple bugs

- MODELSAREATTACHMENTS was basically being applied anyways
- Fixed a crash related to using an animation that never had the vertex buffer drawn because it was never used as a model
This commit is contained in:
Shiny Metagross 2022-08-23 10:21:58 -07:00 committed by Christoph Oelckers
parent be9a671217
commit 6564adf310
2 changed files with 7 additions and 4 deletions

View file

@ -361,7 +361,7 @@ void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpr
FModel* animation = Models[animationid]; FModel* animation = Models[animationid];
animationData = animation->AttachAnimationData(); animationData = animation->AttachAnimationData();
if ((!smf->flags & MDL_MODELSAREATTACHMENTS) || evaluatedSingle == false) if (!(smf->flags & MDL_MODELSAREATTACHMENTS) || evaluatedSingle == false)
{ {
boneData = animation->CalculateBones(modelframe, nextFrame ? modelframenext : modelframe, nextFrame ? inter : 0.f, *animationData); boneData = animation->CalculateBones(modelframe, nextFrame ? modelframenext : modelframe, nextFrame ? inter : 0.f, *animationData);
boneStartingPosition = renderer->SetupFrame(animation, 0, 0, 0, boneData, -1); boneStartingPosition = renderer->SetupFrame(animation, 0, 0, 0, boneData, -1);
@ -370,7 +370,7 @@ void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpr
} }
else else
{ {
if ((!smf->flags & MDL_MODELSAREATTACHMENTS) || evaluatedSingle == false) if (!(smf->flags & MDL_MODELSAREATTACHMENTS) || evaluatedSingle == false)
{ {
boneData = mdl->CalculateBones(modelframe, nextFrame ? modelframenext : modelframe, nextFrame ? inter : 0.f, *animationData); boneData = mdl->CalculateBones(modelframe, nextFrame ? modelframenext : modelframe, nextFrame ? inter : 0.f, *animationData);
boneStartingPosition = renderer->SetupFrame(mdl, 0, 0, 0, boneData, -1); boneStartingPosition = renderer->SetupFrame(mdl, 0, 0, 0, boneData, -1);

View file

@ -141,8 +141,11 @@ int FHWModelRenderer::SetupFrame(FModel *model, unsigned int frame1, unsigned in
auto mdbuff = static_cast<FModelVertexBuffer*>(model->GetVertexBuffer(GetType())); auto mdbuff = static_cast<FModelVertexBuffer*>(model->GetVertexBuffer(GetType()));
boneIndexBase = boneStartIndex >= 0 ? boneStartIndex : screen->mBones->UploadBones(bones); boneIndexBase = boneStartIndex >= 0 ? boneStartIndex : screen->mBones->UploadBones(bones);
state.SetBoneIndexBase(boneIndexBase); state.SetBoneIndexBase(boneIndexBase);
state.SetVertexBuffer(mdbuff->vertexBuffer(), frame1, frame2); if (mdbuff)
if (mdbuff->indexBuffer()) state.SetIndexBuffer(mdbuff->indexBuffer()); {
state.SetVertexBuffer(mdbuff->vertexBuffer(), frame1, frame2);
if (mdbuff->indexBuffer()) state.SetIndexBuffer(mdbuff->indexBuffer());
}
return boneIndexBase; return boneIndexBase;
} }