From 297898182b3b448ca2c2286d528ee6336db3ba66 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 28 Aug 2020 15:28:26 +0400 Subject: [PATCH] Reset attached arrow in the beginning of unequipping animation --- apps/openmw/mwmechanics/character.cpp | 2 ++ apps/openmw/mwrender/animation.hpp | 1 + apps/openmw/mwrender/creatureanimation.cpp | 6 ++++++ apps/openmw/mwrender/creatureanimation.hpp | 1 + apps/openmw/mwrender/npcanimation.cpp | 6 ++++++ apps/openmw/mwrender/npcanimation.hpp | 1 + apps/openmw/mwrender/weaponanimation.cpp | 5 +++++ apps/openmw/mwrender/weaponanimation.hpp | 2 ++ 8 files changed, 24 insertions(+) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 5d102f69ea..0abf478077 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1306,6 +1306,8 @@ bool CharacterController::updateWeaponState(CharacterState& idle) 1.0f, "unequip start", "unequip stop", 0.0f, 0); mUpperBodyState = UpperCharState_UnEquipingWeap; + mAnimation->detachArrow(); + // If we do not have the "unequip detach" key, hide weapon manually. if (mAnimation->getTextKeyTime(weapgroup+": unequip detach") < 0) mAnimation->showWeapons(false); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index a04a3f999b..8a1719db43 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -474,6 +474,7 @@ public: void setAlpha(float alpha); virtual void setPitchFactor(float factor) {} virtual void attachArrow() {} + virtual void detachArrow() {} virtual void releaseArrow(float attackStrength) {} virtual void enableHeadAnimation(bool enable) {} // TODO: move outside of this class diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index 489a7a9871..4a832c60c1 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -208,6 +208,12 @@ bool CreatureWeaponAnimation::isArrowAttached() const return mAmmunition != nullptr; } +void CreatureWeaponAnimation::detachArrow() +{ + WeaponAnimation::detachArrow(mPtr); + updateQuiver(); +} + void CreatureWeaponAnimation::attachArrow() { WeaponAnimation::attachArrow(mPtr); diff --git a/apps/openmw/mwrender/creatureanimation.hpp b/apps/openmw/mwrender/creatureanimation.hpp index cdcdafe248..071500d743 100644 --- a/apps/openmw/mwrender/creatureanimation.hpp +++ b/apps/openmw/mwrender/creatureanimation.hpp @@ -40,6 +40,7 @@ namespace MWRender void updatePart(PartHolderPtr& scene, int slot); virtual void attachArrow(); + virtual void detachArrow(); virtual void releaseArrow(float attackStrength); // WeaponAnimation virtual osg::Group* getArrowBone(); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 468938d22d..617a0a4ba7 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -1051,6 +1051,12 @@ void NpcAnimation::attachArrow() updateQuiver(); } +void NpcAnimation::detachArrow() +{ + WeaponAnimation::detachArrow(mPtr); + updateQuiver(); +} + void NpcAnimation::releaseArrow(float attackStrength) { WeaponAnimation::releaseArrow(mPtr, attackStrength); diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 7edf35a5cd..cf695c8786 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -142,6 +142,7 @@ public: virtual void showCarriedLeft(bool show); virtual void attachArrow(); + virtual void detachArrow(); virtual void releaseArrow(float attackStrength); virtual osg::Group* getArrowBone(); diff --git a/apps/openmw/mwrender/weaponanimation.cpp b/apps/openmw/mwrender/weaponanimation.cpp index 2af5fdb41b..0c2a11466b 100644 --- a/apps/openmw/mwrender/weaponanimation.cpp +++ b/apps/openmw/mwrender/weaponanimation.cpp @@ -98,6 +98,11 @@ void WeaponAnimation::attachArrow(MWWorld::Ptr actor) } } +void WeaponAnimation::detachArrow(MWWorld::Ptr actor) +{ + mAmmunition.reset(); +} + void WeaponAnimation::releaseArrow(MWWorld::Ptr actor, float attackStrength) { MWWorld::InventoryStore& inv = actor.getClass().getInventoryStore(actor); diff --git a/apps/openmw/mwrender/weaponanimation.hpp b/apps/openmw/mwrender/weaponanimation.hpp index a1988703c5..dac1b663d0 100644 --- a/apps/openmw/mwrender/weaponanimation.hpp +++ b/apps/openmw/mwrender/weaponanimation.hpp @@ -36,6 +36,8 @@ namespace MWRender /// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op. void attachArrow(MWWorld::Ptr actor); + void detachArrow(MWWorld::Ptr actor); + /// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op. void releaseArrow(MWWorld::Ptr actor, float attackStrength);