forked from teamnwah/openmw-tes3coop
split getStartTime
This commit is contained in:
parent
979128b2c5
commit
d6d9df6cec
4 changed files with 34 additions and 20 deletions
|
@ -785,15 +785,21 @@ void getMinMaxAttackDuration(const MWWorld::Ptr& actor, float (*fMinMaxDurations
|
|||
// get durations for each attack type
|
||||
for (int i = 0; i < (bRangedWeap ? 1 : 3); i++)
|
||||
{
|
||||
float start1 = anim->getStartTime(weapGroup + (bRangedWeap ? attackType[3] : attackType[i]) + textKey, false);
|
||||
float start1 = anim->getTextKeyTime(weapGroup + (bRangedWeap ? attackType[3] : attackType[i]) + textKey);
|
||||
|
||||
if (start1 < 0)
|
||||
{
|
||||
fMinMaxDurations[i][0] = fMinMaxDurations[i][1] = 0.1f;
|
||||
continue;
|
||||
}
|
||||
|
||||
textKey2 = "min attack";
|
||||
float start2 = anim->getStartTime(weapGroup + (bRangedWeap ? attackType[3] : attackType[i]) + textKey2, false);
|
||||
float start2 = anim->getTextKeyTime(weapGroup + (bRangedWeap ? attackType[3] : attackType[i]) + textKey2);
|
||||
|
||||
fMinMaxDurations[i][0] = (start2 - start1) / weapSpeed;
|
||||
|
||||
textKey2 = "max attack";
|
||||
start1 = anim->getStartTime(weapGroup + (bRangedWeap ? attackType[3] : attackType[i]) + textKey2, false);
|
||||
start1 = anim->getTextKeyTime(weapGroup + (bRangedWeap ? attackType[3] : attackType[i]) + textKey2);
|
||||
|
||||
fMinMaxDurations[i][1] = fMinMaxDurations[i][0] + (start1 - start2) / weapSpeed;
|
||||
}
|
||||
|
|
|
@ -903,27 +903,32 @@ bool Animation::getInfo(const std::string &groupname, float *complete, float *sp
|
|||
return true;
|
||||
}
|
||||
|
||||
float Animation::getStartTime(const std::string &groupname, bool onlyGroup) const
|
||||
float Animation::getStartTime(const std::string &groupname) const
|
||||
{
|
||||
AnimSourceList::const_iterator iter(mAnimSources.begin());
|
||||
for(;iter != mAnimSources.end();iter++)
|
||||
for(AnimSourceList::const_iterator iter(mAnimSources.begin()); iter != mAnimSources.end(); ++iter)
|
||||
{
|
||||
const NifOgre::TextKeyMap &keys = (*iter)->mTextKeys;
|
||||
if (onlyGroup)
|
||||
{
|
||||
|
||||
NifOgre::TextKeyMap::const_iterator found = findGroupStart(keys, groupname);
|
||||
if(found != keys.end())
|
||||
return found->first;
|
||||
}
|
||||
else
|
||||
return -1.f;
|
||||
}
|
||||
|
||||
float Animation::getTextKeyTime(const std::string &textKey) const
|
||||
{
|
||||
for(NifOgre::TextKeyMap::const_iterator iter(keys.begin()); iter != keys.end(); ++iter)
|
||||
for(AnimSourceList::const_iterator iter(mAnimSources.begin()); iter != mAnimSources.end(); ++iter)
|
||||
{
|
||||
if(iter->second.compare(0, groupname.size(), groupname) == 0)
|
||||
return iter->first;
|
||||
}
|
||||
const NifOgre::TextKeyMap &keys = (*iter)->mTextKeys;
|
||||
|
||||
for(NifOgre::TextKeyMap::const_iterator iterKey(keys.begin()); iterKey != keys.end(); ++iterKey)
|
||||
{
|
||||
if(iterKey->second.compare(0, textKey.size(), textKey) == 0)
|
||||
return iterKey->first;
|
||||
}
|
||||
}
|
||||
|
||||
return -1.f;
|
||||
}
|
||||
|
||||
|
|
|
@ -275,7 +275,10 @@ public:
|
|||
bool getInfo(const std::string &groupname, float *complete=NULL, float *speedmult=NULL) const;
|
||||
|
||||
/// Get the absolute position in the animation track of the first text key with the given group.
|
||||
float getStartTime(const std::string &groupname, bool onlyGroup) const;
|
||||
float getStartTime(const std::string &groupname) const;
|
||||
|
||||
/// Get the absolute position in the animation track of the text key
|
||||
float getTextKeyTime(const std::string &textKey) const;
|
||||
|
||||
/// Get the current absolute position in the animation track for the animation that is currently playing from the given group.
|
||||
float getCurrentTime(const std::string& groupname) const;
|
||||
|
|
|
@ -32,7 +32,7 @@ float WeaponAnimationTime::getValue() const
|
|||
void WeaponAnimationTime::setGroup(const std::string &group)
|
||||
{
|
||||
mWeaponGroup = group;
|
||||
mStartTime = mAnimation->getStartTime(mWeaponGroup, true);
|
||||
mStartTime = mAnimation->getStartTime(mWeaponGroup);
|
||||
}
|
||||
|
||||
void WeaponAnimationTime::updateStartTime()
|
||||
|
|
Loading…
Reference in a new issue