mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 23:45:35 +00:00
Merge branch 'cast-fix' into 'master'
Fix bad cast of loop count in animation bindings. See merge request OpenMW/openmw!3819
This commit is contained in:
commit
c86ca0ef01
17 changed files with 49 additions and 47 deletions
|
@ -64,7 +64,7 @@ namespace MWBase
|
|||
virtual void animationTextKey(const MWWorld::Ptr& actor, const std::string& key) = 0;
|
||||
virtual void playAnimation(const MWWorld::Ptr& object, const std::string& groupname,
|
||||
const MWRender::AnimPriority& priority, int blendMask, bool autodisable, float speedmult,
|
||||
std::string_view start, std::string_view stop, float startpoint, size_t loops, bool loopfallback)
|
||||
std::string_view start, std::string_view stop, float startpoint, uint32_t loops, bool loopfallback)
|
||||
= 0;
|
||||
virtual void exteriorCreated(MWWorld::CellStore& cell) = 0;
|
||||
virtual void actorDied(const MWWorld::Ptr& actor) = 0;
|
||||
|
|
|
@ -171,7 +171,7 @@ namespace MWBase
|
|||
///< Forces an object to refresh its animation state.
|
||||
|
||||
virtual bool playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number = 1, bool scripted = false)
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, uint32_t number = 1, bool scripted = false)
|
||||
= 0;
|
||||
///< Run animation for a MW-reference. Calls to this function for references that are currently not
|
||||
/// in the scene should be ignored.
|
||||
|
@ -180,8 +180,8 @@ namespace MWBase
|
|||
/// \param number How many times the animation should be run
|
||||
/// \param scripted Whether the animation should be treated as a scripted animation.
|
||||
/// \return Success or error
|
||||
virtual bool playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, int loops, float speed,
|
||||
std::string_view startKey, std::string_view stopKey, bool forceLoop)
|
||||
virtual bool playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, uint32_t loops,
|
||||
float speed, std::string_view startKey, std::string_view stopKey, bool forceLoop)
|
||||
= 0;
|
||||
///< Lua variant of playAnimationGroup. The mode parameter is omitted
|
||||
/// and forced to 0. modes 1 and 2 can be emulated by doing clearAnimationQueue() and
|
||||
|
|
|
@ -249,7 +249,7 @@ namespace MWLua
|
|||
// Extended variant of MWScript's PlayGroup and LoopGroup
|
||||
api["playQueued"] = sol::overload(
|
||||
[mechanics](const sol::object& object, const std::string& groupname, const sol::table& options) {
|
||||
int numberOfLoops = options.get_or("loops", std::numeric_limits<int>::max());
|
||||
uint32_t numberOfLoops = options.get_or("loops", std::numeric_limits<uint32_t>::max());
|
||||
float speed = options.get_or("speed", 1.f);
|
||||
std::string startKey = options.get_or<std::string>("startkey", "start");
|
||||
std::string stopKey = options.get_or<std::string>("stopkey", "stop");
|
||||
|
@ -265,7 +265,7 @@ namespace MWLua
|
|||
});
|
||||
|
||||
api["playBlended"] = [](const sol::object& object, std::string_view groupname, const sol::table& options) {
|
||||
int loops = options.get_or("loops", 0);
|
||||
uint32_t loops = options.get_or("loops", 0u);
|
||||
MWRender::Animation::AnimPriority priority = getPriorityArgument(options);
|
||||
BlendMask blendMask = options.get_or("blendmask", BlendMask::BlendMask_All);
|
||||
bool autoDisable = options.get_or("autodisable", true);
|
||||
|
|
|
@ -373,7 +373,7 @@ namespace MWLua
|
|||
|
||||
void LuaManager::playAnimation(const MWWorld::Ptr& actor, const std::string& groupname,
|
||||
const MWRender::AnimPriority& priority, int blendMask, bool autodisable, float speedmult,
|
||||
std::string_view start, std::string_view stop, float startpoint, size_t loops, bool loopfallback)
|
||||
std::string_view start, std::string_view stop, float startpoint, uint32_t loops, bool loopfallback)
|
||||
{
|
||||
sol::table options = mLua.newTable();
|
||||
options["blendmask"] = blendMask;
|
||||
|
|
|
@ -82,7 +82,8 @@ namespace MWLua
|
|||
void animationTextKey(const MWWorld::Ptr& actor, const std::string& key) override;
|
||||
void playAnimation(const MWWorld::Ptr& actor, const std::string& groupname,
|
||||
const MWRender::AnimPriority& priority, int blendMask, bool autodisable, float speedmult,
|
||||
std::string_view start, std::string_view stop, float startpoint, size_t loops, bool loopfallback) override;
|
||||
std::string_view start, std::string_view stop, float startpoint, uint32_t loops,
|
||||
bool loopfallback) override;
|
||||
void exteriorCreated(MWWorld::CellStore& cell) override
|
||||
{
|
||||
mEngineEvents.addToQueue(EngineEvents::OnNewExterior{ cell });
|
||||
|
|
|
@ -2005,7 +2005,7 @@ namespace MWMechanics
|
|||
}
|
||||
|
||||
bool Actors::playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted) const
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, uint32_t number, bool scripted) const
|
||||
{
|
||||
const auto iter = mIndex.find(ptr.mRef);
|
||||
if (iter != mIndex.end())
|
||||
|
@ -2020,7 +2020,7 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
bool Actors::playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, int loops, float speed,
|
||||
bool Actors::playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, uint32_t loops, float speed,
|
||||
std::string_view startKey, std::string_view stopKey, bool forceLoop)
|
||||
{
|
||||
const auto iter = mIndex.find(ptr.mRef);
|
||||
|
|
|
@ -112,9 +112,9 @@ namespace MWMechanics
|
|||
|
||||
void forceStateUpdate(const MWWorld::Ptr& ptr) const;
|
||||
|
||||
bool playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted = false) const;
|
||||
bool playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, int loops, float speed,
|
||||
bool playAnimationGroup(const MWWorld::Ptr& ptr, std::string_view groupName, int mode, uint32_t number,
|
||||
bool scripted = false) const;
|
||||
bool playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, uint32_t loops, float speed,
|
||||
std::string_view startKey, std::string_view stopKey, bool forceLoop);
|
||||
void enableLuaAnimations(const MWWorld::Ptr& ptr, bool enable);
|
||||
void skipAnimation(const MWWorld::Ptr& ptr) const;
|
||||
|
|
|
@ -483,7 +483,8 @@ namespace MWMechanics
|
|||
return;
|
||||
}
|
||||
|
||||
playBlendedAnimation(mCurrentHit, priority, MWRender::BlendMask_All, true, 1, startKey, stopKey, 0.0f, ~0ul);
|
||||
playBlendedAnimation(mCurrentHit, priority, MWRender::BlendMask_All, true, 1, startKey, stopKey, 0.0f,
|
||||
std::numeric_limits<uint32_t>::max());
|
||||
}
|
||||
|
||||
void CharacterController::refreshJumpAnims(JumpingState jump, bool force)
|
||||
|
@ -521,7 +522,7 @@ namespace MWMechanics
|
|||
mCurrentJump = jumpAnimName;
|
||||
if (mJumpState == JumpState_InAir)
|
||||
playBlendedAnimation(jumpAnimName, Priority_Jump, jumpmask, false, 1.0f,
|
||||
startAtLoop ? "loop start" : "start", "stop", 0.f, ~0ul);
|
||||
startAtLoop ? "loop start" : "start", "stop", 0.f, std::numeric_limits<uint32_t>::max());
|
||||
else if (mJumpState == JumpState_Landing)
|
||||
playBlendedAnimation(jumpAnimName, Priority_Jump, jumpmask, true, 1.0f, "loop stop", "stop", 0.0f, 0);
|
||||
}
|
||||
|
@ -749,8 +750,8 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
playBlendedAnimation(
|
||||
mCurrentMovement, Priority_Movement, movemask, false, 1.f, "start", "stop", startpoint, ~0ul, true);
|
||||
playBlendedAnimation(mCurrentMovement, Priority_Movement, movemask, false, 1.f, "start", "stop", startpoint,
|
||||
std::numeric_limits<uint32_t>::max(), true);
|
||||
}
|
||||
|
||||
void CharacterController::refreshIdleAnims(CharacterState idle, bool force)
|
||||
|
@ -778,7 +779,7 @@ namespace MWMechanics
|
|||
}
|
||||
|
||||
MWRender::Animation::AnimPriority priority = getIdlePriority(mIdleState);
|
||||
size_t numLoops = std::numeric_limits<size_t>::max();
|
||||
size_t numLoops = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
// Only play "idleswim" or "idlesneak" if they exist. Otherwise, fallback to
|
||||
// "idle"+weapon or "idle".
|
||||
|
@ -1192,8 +1193,8 @@ namespace MWMechanics
|
|||
if (!animPlaying)
|
||||
{
|
||||
int mask = MWRender::BlendMask_Torso | MWRender::BlendMask_RightArm;
|
||||
playBlendedAnimation(
|
||||
"idlestorm", Priority_Storm, mask, true, 1.0f, "start", "stop", 0.0f, ~0ul, true);
|
||||
playBlendedAnimation("idlestorm", Priority_Storm, mask, true, 1.0f, "start", "stop", 0.0f,
|
||||
std::numeric_limits<uint32_t>::max(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1326,7 +1327,7 @@ namespace MWMechanics
|
|||
mAnimation->disable("shield");
|
||||
|
||||
playBlendedAnimation("torch", Priority_Torch, MWRender::BlendMask_LeftArm, false, 1.0f, "start", "stop",
|
||||
0.0f, std::numeric_limits<size_t>::max(), true);
|
||||
0.0f, std::numeric_limits<uint32_t>::max(), true);
|
||||
}
|
||||
else if (mAnimation->isPlaying("torch"))
|
||||
{
|
||||
|
@ -2515,7 +2516,8 @@ namespace MWMechanics
|
|||
{
|
||||
AnimationQueueEntry entry;
|
||||
entry.mGroup = iter->mGroup;
|
||||
entry.mLoopCount = iter->mLoopCount;
|
||||
entry.mLoopCount
|
||||
= static_cast<uint32_t>(std::min<uint64_t>(iter->mLoopCount, std::numeric_limits<uint32_t>::max()));
|
||||
entry.mLooping = mAnimation->isLoopingAnimation(entry.mGroup);
|
||||
entry.mStartKey = "start";
|
||||
entry.mStopKey = "stop";
|
||||
|
@ -2538,7 +2540,7 @@ namespace MWMechanics
|
|||
|
||||
void CharacterController::playBlendedAnimation(const std::string& groupname, const MWRender::AnimPriority& priority,
|
||||
int blendMask, bool autodisable, float speedmult, std::string_view start, std::string_view stop,
|
||||
float startpoint, size_t loops, bool loopfallback) const
|
||||
float startpoint, uint32_t loops, bool loopfallback) const
|
||||
{
|
||||
if (mLuaAnimations)
|
||||
MWBase::Environment::get().getLuaManager()->playAnimation(mPtr, groupname, priority, blendMask, autodisable,
|
||||
|
@ -2548,7 +2550,7 @@ namespace MWMechanics
|
|||
groupname, priority, blendMask, autodisable, speedmult, start, stop, startpoint, loops, loopfallback);
|
||||
}
|
||||
|
||||
bool CharacterController::playGroup(std::string_view groupname, int mode, int count, bool scripted)
|
||||
bool CharacterController::playGroup(std::string_view groupname, int mode, uint32_t count, bool scripted)
|
||||
{
|
||||
if (!mAnimation || !mAnimation->hasAnimation(groupname))
|
||||
return false;
|
||||
|
@ -2583,9 +2585,8 @@ namespace MWMechanics
|
|||
// if played with a count of 0, all objects play exactly once from start to stop.
|
||||
// But if the count is x > 0, actors and non-actors behave differently. actors will loop
|
||||
// exactly x times, while non-actors will loop x+1 instead.
|
||||
if (mPtr.getClass().isActor())
|
||||
if (mPtr.getClass().isActor() && count > 0)
|
||||
count--;
|
||||
count = std::max(count, 0);
|
||||
|
||||
AnimationQueueEntry entry;
|
||||
entry.mGroup = groupname;
|
||||
|
@ -2620,7 +2621,7 @@ namespace MWMechanics
|
|||
}
|
||||
|
||||
bool CharacterController::playGroupLua(std::string_view groupname, float speed, std::string_view startKey,
|
||||
std::string_view stopKey, int loops, bool forceLoop)
|
||||
std::string_view stopKey, uint32_t loops, bool forceLoop)
|
||||
{
|
||||
// Note: In mwscript, "idle" is a special case used to clear the anim queue.
|
||||
// In lua we offer an explicit clear method instead so this method does not treat "idle" special.
|
||||
|
@ -2632,7 +2633,7 @@ namespace MWMechanics
|
|||
entry.mGroup = groupname;
|
||||
// Note: MWScript gives one less loop to actors than non-actors.
|
||||
// But this is the Lua version. We don't need to reproduce this weirdness here.
|
||||
entry.mLoopCount = std::max(loops, 0);
|
||||
entry.mLoopCount = loops;
|
||||
entry.mStartKey = startKey;
|
||||
entry.mStopKey = stopKey;
|
||||
entry.mLooping = mAnimation->isLoopingAnimation(groupname) || forceLoop;
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace MWMechanics
|
|||
struct AnimationQueueEntry
|
||||
{
|
||||
std::string mGroup;
|
||||
size_t mLoopCount;
|
||||
uint32_t mLoopCount;
|
||||
float mTime;
|
||||
bool mLooping;
|
||||
bool mScripted;
|
||||
|
@ -276,10 +276,10 @@ namespace MWMechanics
|
|||
|
||||
void playBlendedAnimation(const std::string& groupname, const MWRender::AnimPriority& priority, int blendMask,
|
||||
bool autodisable, float speedmult, std::string_view start, std::string_view stop, float startpoint,
|
||||
size_t loops, bool loopfallback = false) const;
|
||||
bool playGroup(std::string_view groupname, int mode, int count, bool scripted = false);
|
||||
uint32_t loops, bool loopfallback = false) const;
|
||||
bool playGroup(std::string_view groupname, int mode, uint32_t count, bool scripted = false);
|
||||
bool playGroupLua(std::string_view groupname, float speed, std::string_view startKey, std::string_view stopKey,
|
||||
int loops, bool forceLoop);
|
||||
uint32_t loops, bool forceLoop);
|
||||
void enableLuaAnimations(bool enable);
|
||||
void skipAnim();
|
||||
bool isAnimPlaying(std::string_view groupName) const;
|
||||
|
|
|
@ -749,14 +749,14 @@ namespace MWMechanics
|
|||
}
|
||||
|
||||
bool MechanicsManager::playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted)
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, uint32_t number, bool scripted)
|
||||
{
|
||||
if (ptr.getClass().isActor())
|
||||
return mActors.playAnimationGroup(ptr, groupName, mode, number, scripted);
|
||||
else
|
||||
return mObjects.playAnimationGroup(ptr, groupName, mode, number, scripted);
|
||||
}
|
||||
bool MechanicsManager::playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, int loops,
|
||||
bool MechanicsManager::playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, uint32_t loops,
|
||||
float speed, std::string_view startKey, std::string_view stopKey, bool forceLoop)
|
||||
{
|
||||
if (ptr.getClass().isActor())
|
||||
|
|
|
@ -141,9 +141,9 @@ namespace MWMechanics
|
|||
|
||||
/// Attempt to play an animation group
|
||||
/// @return Success or error
|
||||
bool playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted = false) override;
|
||||
bool playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, int loops, float speed,
|
||||
bool playAnimationGroup(const MWWorld::Ptr& ptr, std::string_view groupName, int mode, uint32_t number,
|
||||
bool scripted = false) override;
|
||||
bool playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, uint32_t loops, float speed,
|
||||
std::string_view startKey, std::string_view stopKey, bool forceLoop) override;
|
||||
void enableLuaAnimations(const MWWorld::Ptr& ptr, bool enable) override;
|
||||
void skipAnimation(const MWWorld::Ptr& ptr) override;
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace MWMechanics
|
|||
}
|
||||
|
||||
bool Objects::playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted)
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, uint32_t number, bool scripted)
|
||||
{
|
||||
const auto iter = mIndex.find(ptr.mRef);
|
||||
if (iter != mIndex.end())
|
||||
|
@ -114,8 +114,8 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
bool Objects::playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, int loops, float speed,
|
||||
std::string_view startKey, std::string_view stopKey, bool forceLoop)
|
||||
bool Objects::playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, uint32_t loops,
|
||||
float speed, std::string_view startKey, std::string_view stopKey, bool forceLoop)
|
||||
{
|
||||
const auto iter = mIndex.find(ptr.mRef);
|
||||
if (iter != mIndex.end())
|
||||
|
|
|
@ -46,8 +46,8 @@ namespace MWMechanics
|
|||
void onClose(const MWWorld::Ptr& ptr);
|
||||
|
||||
bool playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted = false);
|
||||
bool playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, int loops, float speed,
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, uint32_t number, bool scripted = false);
|
||||
bool playAnimationGroupLua(const MWWorld::Ptr& ptr, std::string_view groupName, uint32_t loops, float speed,
|
||||
std::string_view startKey, std::string_view stopKey, bool forceLoop);
|
||||
void enableLuaAnimations(const MWWorld::Ptr& ptr, bool enable);
|
||||
void skipAnimation(const MWWorld::Ptr& ptr);
|
||||
|
|
|
@ -805,7 +805,7 @@ namespace MWRender
|
|||
}
|
||||
|
||||
void Animation::play(std::string_view groupname, const AnimPriority& priority, int blendMask, bool autodisable,
|
||||
float speedmult, std::string_view start, std::string_view stop, float startpoint, size_t loops,
|
||||
float speedmult, std::string_view start, std::string_view stop, float startpoint, uint32_t loops,
|
||||
bool loopfallback)
|
||||
{
|
||||
if (!mObjectRoot || mAnimSources.empty())
|
||||
|
|
|
@ -153,7 +153,7 @@ namespace MWRender
|
|||
|
||||
bool mPlaying;
|
||||
bool mLoopingEnabled;
|
||||
size_t mLoopCount;
|
||||
uint32_t mLoopCount;
|
||||
|
||||
AnimPriority mPriority;
|
||||
int mBlendMask;
|
||||
|
@ -379,7 +379,7 @@ namespace MWRender
|
|||
* the "start" and "stop" keys for looping?
|
||||
*/
|
||||
void play(std::string_view groupname, const AnimPriority& priority, int blendMask, bool autodisable,
|
||||
float speedmult, std::string_view start, std::string_view stop, float startpoint, size_t loops,
|
||||
float speedmult, std::string_view start, std::string_view stop, float startpoint, uint32_t loops,
|
||||
bool loopfallback = false);
|
||||
|
||||
/** Adjust the speed multiplier of an already playing animation.
|
||||
|
|
|
@ -464,7 +464,7 @@ namespace MWRender
|
|||
{
|
||||
if (!mAnimation->getInfo("torch"))
|
||||
mAnimation->play(
|
||||
"torch", 2, BlendMask::BlendMask_LeftArm, false, 1.0f, "start", "stop", 0.0f, ~0ul, true);
|
||||
"torch", 2, BlendMask::BlendMask_LeftArm, false, 1.0f, "start", "stop", 0.0f, std::numeric_limits<uint32_t>::max(), true);
|
||||
}
|
||||
else if (mAnimation->getInfo("torch"))
|
||||
mAnimation->disable("torch");
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace MWScript
|
|||
}
|
||||
|
||||
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(
|
||||
ptr, group, mode, std::numeric_limits<int>::max(), true);
|
||||
ptr, group, mode, std::numeric_limits<uint32_t>::max(), true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue