Prepare for supporting controller objects

actorid
Chris Robinson 12 years ago
parent af2a38db38
commit 0631b28646

@ -45,6 +45,7 @@ Animation::~Animation()
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
sceneMgr->destroyEntity(mEntityList.mEntities[i]);
}
mEntityList.mControllers.clear();
mEntityList.mParticles.clear();
mEntityList.mEntities.clear();
mEntityList.mSkelBase = NULL;
@ -129,6 +130,10 @@ void Animation::createEntityList(Ogre::SceneNode *node, const std::string &model
while(boneiter.hasMoreElements())
boneiter.getNext()->setManuallyControlled(true);
}
Ogre::SharedPtr<Ogre::ControllerValue<Ogre::Real> > ctrlval(OGRE_NEW AnimationValue(this));
for(size_t i = 0;i < mEntityList.mControllers.size();i++)
mEntityList.mControllers[i].setSource(ctrlval);
}
@ -457,6 +462,8 @@ Ogre::Vector3 Animation::runAnimation(float timepassed)
if(!handleEvent(time, evt))
break;
}
for(size_t i = 0;i < mEntityList.mControllers.size();i++)
mEntityList.mControllers[i].update();
return movement;
}

@ -16,6 +16,26 @@ namespace MWRender
class Animation
{
protected:
class AnimationValue : public Ogre::ControllerValue<Ogre::Real>
{
private:
Animation *mAnimation;
public:
AnimationValue(Animation *anim) : mAnimation(anim)
{ }
virtual Ogre::Real getValue() const
{
return mAnimation->mCurrentTime;
}
virtual void setValue(Ogre::Real value)
{
mAnimation->mCurrentTime = value;
}
};
MWWorld::Ptr mPtr;
MWMechanics::CharacterController *mController;

@ -367,6 +367,7 @@ void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
sceneMgr->destroyParticleSystem(entities.mParticles[i]);
for(size_t i = 0;i < entities.mEntities.size();i++)
sceneMgr->destroyEntity(entities.mEntities[i]);
entities.mControllers.clear();
entities.mParticles.clear();
entities.mEntities.clear();
entities.mSkelBase = NULL;

@ -45,6 +45,8 @@ struct EntityList {
std::vector<Ogre::ParticleSystem*> mParticles;
std::vector<Ogre::Controller<Ogre::Real> > mControllers;
EntityList() : mSkelBase(0)
{ }
};

Loading…
Cancel
Save