more misc animation fixes
This commit is contained in:
parent
9d1f7f1bff
commit
3f4c66681e
2 changed files with 43 additions and 34 deletions
|
|
@ -5159,9 +5159,34 @@ void SetAnimationInternal(AActor * self, FName animName, double framerate, int s
|
|||
tic += ticFrac;
|
||||
}
|
||||
|
||||
FModel * mdl = Models[(self->modelData->models.Size() > 0 && self->modelData->models[0].modelID >= 0) ? self->modelData->models[0].modelID : BaseSpriteModelFrames[self->GetClass()].modelIDs[0]];
|
||||
int animID = -1;
|
||||
|
||||
|
||||
if(self->modelData->animationIDs.Size() > 0 && self->modelData->animationIDs[0] >= 0)
|
||||
{
|
||||
animID = self->modelData->animationIDs[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
animID = BaseSpriteModelFrames[self->GetClass()].animationIDs[0];
|
||||
}
|
||||
|
||||
FModel * animation = nullptr;
|
||||
if (animID >= 0 && animID < Models.Size())
|
||||
{
|
||||
animation = Models[animID];
|
||||
}
|
||||
else if(self->modelData->models.Size() && self->modelData->models[0].modelID >= 0 && self->modelData->models[0].modelID < Models.Size())
|
||||
{
|
||||
animation = Models[self->modelData->models[0].modelID];
|
||||
}
|
||||
else
|
||||
{
|
||||
animation = Models[BaseSpriteModelFrames[self->GetClass()].modelIDs[0]];
|
||||
}
|
||||
|
||||
int animStart = animation->FindFirstFrame(animName);
|
||||
|
||||
int animStart = mdl->FindFirstFrame(animName);
|
||||
if(animStart == FErr_NotFound)
|
||||
{
|
||||
self->modelData->curAnim.flags = MODELANIM_NONE;
|
||||
|
|
@ -5186,28 +5211,7 @@ void SetAnimationInternal(AActor * self, FName animName, double framerate, int s
|
|||
|
||||
calcFrames(self->modelData->curAnim, tic, to, inter);
|
||||
|
||||
const TArray<TRS>* animationData = nullptr;
|
||||
|
||||
int animationid = -1;
|
||||
|
||||
const FSpriteModelFrame * smf = &BaseSpriteModelFrames[self->GetClass()];
|
||||
|
||||
if (self->modelData->animationIDs.Size() > 0 && self->modelData->animationIDs[0] >= 0)
|
||||
{
|
||||
animationid = self->modelData->animationIDs[0];
|
||||
}
|
||||
else if(smf->modelsAmount > 0)
|
||||
{
|
||||
animationid = smf->animationIDs[0];
|
||||
}
|
||||
|
||||
FModel* animation = mdl;
|
||||
|
||||
if (animationid >= 0)
|
||||
{
|
||||
animation = Models[animationid];
|
||||
animationData = animation->AttachAnimationData();
|
||||
}
|
||||
const TArray<TRS>* animationData = animation->AttachAnimationData();
|
||||
|
||||
self->modelData->prevAnim = animation->PrecalculateFrame(self->modelData->prevAnim, to, inter, animationData);
|
||||
}
|
||||
|
|
@ -5224,11 +5228,11 @@ void SetAnimationInternal(AActor * self, FName animName, double framerate, int s
|
|||
self->modelData->prevAnim = nullptr;
|
||||
}
|
||||
|
||||
int animEnd = mdl->FindLastFrame(animName);
|
||||
int animEnd = animation->FindLastFrame(animName);
|
||||
|
||||
if(framerate < 0)
|
||||
{
|
||||
framerate = mdl->FindFramerate(animName);
|
||||
framerate = animation->FindFramerate(animName);
|
||||
}
|
||||
|
||||
int len = animEnd - animStart;
|
||||
|
|
@ -5474,6 +5478,12 @@ void ChangeModelNative(
|
|||
if(generatorindex != -1) mobj->modelData->modelFrameGenerators[modelindex] = generatorindex;
|
||||
}
|
||||
|
||||
if(!(mobj->modelData->curAnim.flags & MODELANIM_NONE) && animationindex == 0 && (mobj->modelData->animationIDs.Size() == 0 || mobj->modelData->animationIDs[0] != queryAnimation))
|
||||
{ // reset current animation if animation file changes
|
||||
mobj->modelData->curAnim.flags |= MODELANIM_NONE;
|
||||
mobj->modelData->prevAnim = nullptr;
|
||||
}
|
||||
|
||||
if(mobj->modelData->animationIDs.Size() == animationindex)
|
||||
{
|
||||
mobj->modelData->animationIDs.Push(queryAnimation);
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ void RenderModel(FModelRenderer *renderer, float x, float y, float z, FSpriteMod
|
|||
// so we make the "undistorted" behavior opt-in
|
||||
if (smf_flags & MDL_CORRECTPIXELSTRETCH)
|
||||
{
|
||||
stretch = (smf->modelIDs[0] != -1 ? Models[smf->modelIDs[0]]->getAspectFactor(actor->Level->info->pixelstretch) : 1.f) / actor->Level->info->pixelstretch;
|
||||
stretch = (smf->modelIDs[0] >= 0 ? Models[smf->modelIDs[0]]->getAspectFactor(actor->Level->info->pixelstretch) : 1.f) / actor->Level->info->pixelstretch;
|
||||
objectToWorldMatrix.scale(1, stretch, 1);
|
||||
}
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ void RenderModel(FModelRenderer *renderer, float x, float y, float z, FSpriteMod
|
|||
|
||||
if (!(smf_flags & MDL_CORRECTPIXELSTRETCH))
|
||||
{
|
||||
stretch = (smf->modelIDs[0] != -1 ? Models[smf->modelIDs[0]]->getAspectFactor(actor->Level->info->pixelstretch) : 1.f) / actor->Level->info->pixelstretch;
|
||||
stretch = (smf->modelIDs[0] >= 0 ? Models[smf->modelIDs[0]]->getAspectFactor(actor->Level->info->pixelstretch) : 1.f) / actor->Level->info->pixelstretch;
|
||||
objectToWorldMatrix.scale(1, stretch, 1);
|
||||
}
|
||||
|
||||
|
|
@ -412,7 +412,6 @@ void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpr
|
|||
|
||||
TArray<FTextureID> surfaceskinids;
|
||||
|
||||
const TArray<VSMatrix> *boneData;
|
||||
int boneStartingPosition = -1;
|
||||
bool evaluatedSingle = false;
|
||||
|
||||
|
|
@ -538,9 +537,11 @@ void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpr
|
|||
|
||||
bool nextFrame = smfNext && modelframe != modelframenext;
|
||||
|
||||
|
||||
// [RL0] while per-model animations aren't done, DECOUPLEDANIMATIONS does the same as MODELSAREATTACHMENTS
|
||||
if(!evaluatedSingle)
|
||||
{
|
||||
const TArray<VSMatrix> *boneData = nullptr;
|
||||
FModel* animation = mdl;
|
||||
const TArray<TRS>* animationData = nullptr;
|
||||
|
||||
|
|
@ -552,7 +553,7 @@ void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpr
|
|||
|
||||
if(is_decoupled)
|
||||
{
|
||||
if(decoupled_frame.frame1 != -1)
|
||||
if(decoupled_frame.frame1 >= 0)
|
||||
{
|
||||
boneData = animation->CalculateBones(actor->modelData->prevAnim, decoupled_frame, inter, animationData);
|
||||
}
|
||||
|
|
@ -567,8 +568,6 @@ void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpr
|
|||
boneStartingPosition = boneData ? renderer->UploadBones(*boneData) : -1;
|
||||
evaluatedSingle = true;
|
||||
}
|
||||
|
||||
boneData = nullptr;
|
||||
}
|
||||
|
||||
mdl->RenderFrame(renderer, tex, modelframe, nextFrame ? modelframenext : modelframe, nextFrame ? inter : -1.f, translation, ssidp, boneStartingPosition, actor);
|
||||
|
|
@ -1002,10 +1001,10 @@ void ParseModelDefLump(int Lump)
|
|||
if (isframe)
|
||||
{
|
||||
sc.MustGetString();
|
||||
if (smf.modelIDs[index] != -1)
|
||||
if (smf.modelIDs[index] >= 0)
|
||||
{
|
||||
FModel *model = Models[smf.modelIDs[index]];
|
||||
if (smf.animationIDs[index] != -1)
|
||||
if (smf.animationIDs[index] >= 0)
|
||||
{
|
||||
model = Models[smf.animationIDs[index]];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue