Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unequip animation during stance switching (bug #4327) #1619

Merged
merged 2 commits into from Jun 8, 2018

Conversation

akortunov
Copy link
Collaborator

@akortunov akortunov commented Mar 1, 2018

Fixes bug #4327 and bug #2835.

Since CharacterController::updateWeaponState() has more than 500 lines of code, I am not able to test all possible cases for my own.
Also I noticed that there is no unequipping sound in Morrowind during weapon->spell switching. Should I add it?

Note: I am not sure if I should show torches and/or shields during stance change.


float complete;
bool animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete);
if (animPlaying && complete < 0.95f)
Copy link
Collaborator Author

@akortunov akortunov Mar 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know how to play two animation groups one by one seamlessly, so I have to use a hack - play the equipping animation if more than 95% of unequipping animation was played.
Is there any better solution?

Nevermind, there is another bug in switching itself, will try to investigate it.

@akortunov akortunov changed the title Add unequip animation during stance switching (bug #4327) [Testing needed] Add unequip animation during stance switching (bug #4327) Mar 1, 2018
@akortunov
Copy link
Collaborator Author

akortunov commented Mar 2, 2018

Also OpenMW misses unequip sound during weapon->hth switch. That's because we do not know in CharacterController::updateWeaponState() which weapon was equipped previously.

UPDATE: added missing sounds for now.

@akortunov akortunov changed the title [Testing needed] Add unequip animation during stance switching (bug #4327) [Testing needed, WIP] Add unequip animation during stance switching (bug #4327) Mar 2, 2018
@akortunov akortunov changed the title [Testing needed, WIP] Add unequip animation during stance switching (bug #4327) [Testing needed] Add unequip animation during stance switching (bug #4327) Mar 3, 2018
@akortunov
Copy link
Collaborator Author

I suppose this PR is ready for review/testing now.

@ghost
Copy link

ghost commented Mar 9, 2018

I do not know how to play two animation groups one by one seamlessly, so I have to use a hack - play the equipping animation if more than 95% on unequipping animation was played.
Is there any better solution?

That's an ongoing issue affecting many other animations, and for attack animations in particular we have an open bug.

In this PR, it seems that the lack of continuity actually causes a visible glitch rather than just delays/stuttering. The 95% number attempts to prevent this, but will not do so with lower frame rates. Maybe you could set the first animation to not auto-disable so that if there is a frame where the first animation is finished but the second is not started yet, we don't glitch to a position that's related to neither of the two animations. When that's done, the 95% 'hack' could be removed.

I just noticed you already made a change to that. I'd still prefer a less hacky one, though.

@akortunov
Copy link
Collaborator Author

I'd still prefer a less hacky one, though.

Can you tell what's wrong? I'll try to rework it.

@ghost
Copy link

ghost commented Mar 9, 2018

I do not like the 'Disable default idle state during weapon [un]equipping to avoid body desync', it looks like a hack and is placed in a totally unrelated section of the code.

My suggestion was to set the 'bool autodisable' of playAnimation to false. Not sure if it's practical, but worth a try.

@akortunov
Copy link
Collaborator Author

My suggestion was to set the 'bool autodisable' of playAnimation to false.

Done.
Note: hands position during unequipping on the run is a quite weird, but I suppose this is a resource bug.
Both OpenMW (with or without this PR) and Morrowind are affected by this bug.

@akortunov akortunov changed the title [Testing needed] Add unequip animation during stance switching (bug #4327) Add unequip animation during stance switching (bug #4327) Mar 19, 2018
@Capostrophic
Copy link
Collaborator

Works well for me.

@psi29a
Copy link
Member

psi29a commented May 24, 2018

@zinnschlag can you cast your eye here. :)

1.0f, "unequip start", "unequip stop", 0.0f, 0);
mUpperBodyState = UpperCharState_UnEquipingWeap;

if(!downSoundId.empty() && !isStillWeapon)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!isStillWeapon is already checked above this.

{
if(stats.getDrawState() == DrawState_Spell)
if(!getRealWeapon && stats.getDrawState() == DrawState_Spell)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'getRealWeapon' parameter seems a bit messy, is there any way to refactor the code so we don't need it?

@@ -152,6 +152,7 @@ struct WeaponInfo;
class CharacterController : public MWRender::Animation::TextKeyListener
{
MWWorld::Ptr mPtr;
MWWorld::Ptr mPreviousWeapon;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think mWeapon would be a better name because this is the up to date weapon more often than it isn't.

@akortunov
Copy link
Collaborator Author

akortunov commented May 28, 2018

I uploaded reworked version (changes, requested by scrawl).

An additional question: should we use weapon unequipping sound during weapon->spell switch?
It is missing in vanilla, but it should be here by common sense.

@akortunov akortunov changed the title Add unequip animation during stance switching (bug #4327) [Do not merge yet] Add unequip animation during stance switching (bug #4327) May 28, 2018
@akortunov akortunov changed the title [Do not merge yet] Add unequip animation during stance switching (bug #4327) Add unequip animation during stance switching (bug #4327) May 28, 2018
@akortunov
Copy link
Collaborator Author

Are there any complaints or suggestions?

@zinnschlag zinnschlag merged commit 6eb531c into OpenMW:master Jun 8, 2018
zinnschlag added a commit that referenced this pull request Jun 8, 2018
@akortunov akortunov deleted the weaponswitch branch June 13, 2018 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants