1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-01 15:15:33 +00:00

Improve const-correctness in Animation

This commit is contained in:
scrawl 2016-05-19 22:30:14 +02:00
parent 3749821809
commit 0efbdb25ee
4 changed files with 17 additions and 17 deletions

View file

@ -227,7 +227,7 @@ public:
{ return weap.type == type; } { return weap.type == type; }
}; };
std::string CharacterController::chooseRandomGroup (const std::string& prefix, int* num) std::string CharacterController::chooseRandomGroup (const std::string& prefix, int* num) const
{ {
int numAnims=0; int numAnims=0;
while (mAnimation->hasAnimation(prefix + toString(numAnims+1))) while (mAnimation->hasAnimation(prefix + toString(numAnims+1)))
@ -629,7 +629,7 @@ void CharacterController::playDeath(float startpoint, CharacterState death)
false, 1.0f, "start", "stop", startpoint, 0); false, 1.0f, "start", "stop", startpoint, 0);
} }
CharacterState CharacterController::chooseRandomDeathState() CharacterState CharacterController::chooseRandomDeathState() const
{ {
int selected=0; int selected=0;
chooseRandomGroup("death", &selected); chooseRandomGroup("death", &selected);

View file

@ -207,12 +207,12 @@ class CharacterController : public MWRender::Animation::TextKeyListener
void updateMagicEffects(); void updateMagicEffects();
void playDeath(float startpoint, CharacterState death); void playDeath(float startpoint, CharacterState death);
CharacterState chooseRandomDeathState(); CharacterState chooseRandomDeathState() const;
void playRandomDeath(float startpoint = 0.0f); void playRandomDeath(float startpoint = 0.0f);
/// choose a random animation group with \a prefix and numeric suffix /// choose a random animation group with \a prefix and numeric suffix
/// @param num if non-NULL, the chosen animation number will be written here /// @param num if non-NULL, the chosen animation number will be written here
std::string chooseRandomGroup (const std::string& prefix, int* num = NULL); std::string chooseRandomGroup (const std::string& prefix, int* num = NULL) const;
bool updateCarriedLeftVisible(WeaponType weaptype) const; bool updateCarriedLeftVisible(WeaponType weaptype) const;

View file

@ -259,7 +259,7 @@ namespace MWRender
ControllerMap mControllerMap[Animation::sNumBlendMasks]; ControllerMap mControllerMap[Animation::sNumBlendMasks];
const std::multimap<float, std::string>& getTextKeys(); const std::multimap<float, std::string>& getTextKeys() const;
}; };
class ResetAccumRootCallback : public osg::NodeCallback class ResetAccumRootCallback : public osg::NodeCallback
@ -314,7 +314,7 @@ namespace MWRender
mInsert->removeChild(mObjectRoot); mInsert->removeChild(mObjectRoot);
} }
MWWorld::Ptr Animation::getPtr() MWWorld::ConstPtr Animation::getPtr() const
{ {
return mPtr; return mPtr;
} }
@ -338,7 +338,7 @@ namespace MWRender
mResetAccumRootCallback->setAccumulate(mAccumulate); mResetAccumRootCallback->setAccumulate(mAccumulate);
} }
size_t Animation::detectBlendMask(osg::Node* node) size_t Animation::detectBlendMask(const osg::Node* node) const
{ {
static const char sBlendMaskRoots[sNumBlendMasks][32] = { static const char sBlendMaskRoots[sNumBlendMasks][32] = {
"", /* Lower body / character root */ "", /* Lower body / character root */
@ -364,7 +364,7 @@ namespace MWRender
return 0; return 0;
} }
const std::multimap<float, std::string> &Animation::AnimSource::getTextKeys() const std::multimap<float, std::string> &Animation::AnimSource::getTextKeys() const
{ {
return mKeyframes->mTextKeys; return mKeyframes->mTextKeys;
} }
@ -441,7 +441,7 @@ namespace MWRender
mAnimSources.clear(); mAnimSources.clear();
} }
bool Animation::hasAnimation(const std::string &anim) bool Animation::hasAnimation(const std::string &anim) const
{ {
AnimSourceList::const_iterator iter(mAnimSources.begin()); AnimSourceList::const_iterator iter(mAnimSources.begin());
for(;iter != mAnimSources.end();++iter) for(;iter != mAnimSources.end();++iter)
@ -1098,7 +1098,7 @@ namespace MWRender
} }
// TODO: Should not be here // TODO: Should not be here
osg::Vec4f Animation::getEnchantmentColor(MWWorld::Ptr item) osg::Vec4f Animation::getEnchantmentColor(const MWWorld::ConstPtr& item) const
{ {
osg::Vec4f result(1,1,1,1); osg::Vec4f result(1,1,1,1);
std::string enchantmentName = item.getClass().getEnchantment(item); std::string enchantmentName = item.getClass().getEnchantment(item);
@ -1198,9 +1198,9 @@ namespace MWRender
} }
} }
void Animation::getLoopingEffects(std::vector<int> &out) void Animation::getLoopingEffects(std::vector<int> &out) const
{ {
for (std::vector<EffectParams>::iterator it = mEffects.begin(); it != mEffects.end(); ++it) for (std::vector<EffectParams>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it)
{ {
if (it->mLoop) if (it->mLoop)
out.push_back(it->mEffectId); out.push_back(it->mEffectId);

View file

@ -270,7 +270,7 @@ protected:
*/ */
void resetActiveGroups(); void resetActiveGroups();
size_t detectBlendMask(osg::Node* node); size_t detectBlendMask(const osg::Node* node) const;
/* Updates the position of the accum root node for the given time, and /* Updates the position of the accum root node for the given time, and
* returns the wanted movement vector from the previous time. */ * returns the wanted movement vector from the previous time. */
@ -315,7 +315,7 @@ protected:
*/ */
virtual void addControllers(); virtual void addControllers();
osg::Vec4f getEnchantmentColor(MWWorld::Ptr item); osg::Vec4f getEnchantmentColor(const MWWorld::ConstPtr& item) const;
void addGlow(osg::ref_ptr<osg::Node> node, osg::Vec4f glowColor); void addGlow(osg::ref_ptr<osg::Node> node, osg::Vec4f glowColor);
@ -327,7 +327,7 @@ public:
Animation(const MWWorld::Ptr &ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem); Animation(const MWWorld::Ptr &ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem);
virtual ~Animation(); virtual ~Animation();
MWWorld::Ptr getPtr(); MWWorld::ConstPtr getPtr() const;
/// Set active flag on the object skeleton, if one exists. /// Set active flag on the object skeleton, if one exists.
/// @see SceneUtil::Skeleton::setActive /// @see SceneUtil::Skeleton::setActive
@ -349,11 +349,11 @@ public:
*/ */
void addEffect (const std::string& model, int effectId, bool loop = false, const std::string& bonename = "", std::string texture = ""); void addEffect (const std::string& model, int effectId, bool loop = false, const std::string& bonename = "", std::string texture = "");
void removeEffect (int effectId); void removeEffect (int effectId);
void getLoopingEffects (std::vector<int>& out); void getLoopingEffects (std::vector<int>& out) const;
virtual void updatePtr(const MWWorld::Ptr &ptr); virtual void updatePtr(const MWWorld::Ptr &ptr);
bool hasAnimation(const std::string &anim); bool hasAnimation(const std::string &anim) const;
// Specifies the axis' to accumulate on. Non-accumulated axis will just // Specifies the axis' to accumulate on. Non-accumulated axis will just
// move visually, but not affect the actual movement. Each x/y/z value // move visually, but not affect the actual movement. Each x/y/z value