1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 05:53:50 +00:00

Store the base skeleton entity in MWRender::Animation

This commit is contained in:
Chris Robinson 2013-04-14 16:56:35 -07:00
parent 7000a1aa3e
commit f9dee25fd1
3 changed files with 16 additions and 13 deletions

View file

@ -33,6 +33,7 @@ Animation::Animation(const MWWorld::Ptr &ptr)
: mPtr(ptr)
, mController(NULL)
, mInsert(NULL)
, mSkelBase(NULL)
, mAccumRoot(NULL)
, mNonAccumRoot(NULL)
, mAccumulate(Ogre::Vector3::ZERO)
@ -65,7 +66,7 @@ Animation::~Animation()
void Animation::setAnimationSources(const std::vector<std::string> &names)
{
if(!mObjectList.mSkelBase)
if(!mSkelBase)
return;
Ogre::SceneManager *sceneMgr = mInsert->getCreator();
@ -81,7 +82,7 @@ void Animation::setAnimationSources(const std::vector<std::string> &names)
mAnimationSources.clear();
Ogre::SharedPtr<Ogre::ControllerValue<Ogre::Real> > ctrlval(OGRE_NEW AnimationValue(this));
Ogre::SkeletonInstance *skelinst = mObjectList.mSkelBase->getSkeleton();
Ogre::SkeletonInstance *skelinst = mSkelBase->getSkeleton();
std::vector<std::string>::const_iterator nameiter;
for(nameiter = names.begin();nameiter != names.end();nameiter++)
{
@ -127,7 +128,7 @@ void Animation::setAnimationSources(const std::vector<std::string> &names)
if(!mNonAccumRoot)
{
mAccumRoot = mInsert;
mNonAccumRoot = mObjectList.mSkelBase->getSkeleton()->getBone(bone->getName());
mNonAccumRoot = mSkelBase->getSkeleton()->getBone(bone->getName());
}
for(int i = 0;i < skel->getNumAnimations();i++)
@ -152,7 +153,9 @@ void Animation::createObjectList(Ogre::SceneNode *node, const std::string &model
mObjectList = NifOgre::Loader::createObjects(mInsert, model);
if(mObjectList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mObjectList.mSkelBase->getAllAnimationStates();
mSkelBase = mObjectList.mSkelBase;
Ogre::AnimationStateSet *aset = mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator asiter = aset->getAnimationStateIterator();
while(asiter.hasMoreElements())
{
@ -164,7 +167,7 @@ void Animation::createObjectList(Ogre::SceneNode *node, const std::string &model
// Set the bones as manually controlled since we're applying the
// transformations manually (needed if we want to apply an animation
// from one skeleton onto another).
Ogre::SkeletonInstance *skelinst = mObjectList.mSkelBase->getSkeleton();
Ogre::SkeletonInstance *skelinst = mSkelBase->getSkeleton();
Ogre::Skeleton::BoneIterator boneiter = skelinst->getBoneIterator();
while(boneiter.hasMoreElements())
boneiter.getNext()->setManuallyControlled(true);
@ -182,9 +185,9 @@ void Animation::createObjectList(Ogre::SceneNode *node, const std::string &model
Ogre::Node *Animation::getNode(const std::string &name)
{
if(mObjectList.mSkelBase)
if(mSkelBase)
{
Ogre::SkeletonInstance *skel = mObjectList.mSkelBase->getSkeleton();
Ogre::SkeletonInstance *skel = mSkelBase->getSkeleton();
if(skel->hasBone(name))
return skel->getBone(name);
}
@ -508,11 +511,11 @@ Ogre::Vector3 Animation::runAnimation(float timepassed)
for(size_t i = 0;i < mCurrentControllers->size();i++)
(*mCurrentControllers)[i].update();
if(mObjectList.mSkelBase)
if(mSkelBase)
{
// HACK: Dirty the animation state set so that Ogre will apply the
// transformations to entities this skeleton instance is shared with.
mObjectList.mSkelBase->getAllAnimationStates()->_notifyDirty();
mSkelBase->getAllAnimationStates()->_notifyDirty();
}
return movement;

View file

@ -43,6 +43,7 @@ protected:
MWMechanics::CharacterController *mController;
Ogre::SceneNode *mInsert;
Ogre::Entity *mSkelBase;
NifOgre::ObjectList mObjectList;
std::map<std::string,NifOgre::TextKeyMap> mTextKeys;
Ogre::Node *mAccumRoot;

View file

@ -359,8 +359,7 @@ void NpcAnimation::updateParts(bool forceupdate)
NifOgre::ObjectList NpcAnimation::insertBoundedPart(const std::string &model, int group, const std::string &bonename)
{
NifOgre::ObjectList objects = NifOgre::Loader::createObjects(mObjectList.mSkelBase, bonename,
mInsert, model);
NifOgre::ObjectList objects = NifOgre::Loader::createObjects(mSkelBase, bonename, mInsert, model);
for(size_t i = 0;i < objects.mEntities.size();i++)
{
objects.mEntities[i]->getUserObjectBindings().setUserAny(Ogre::Any(group));
@ -408,7 +407,7 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
mTimeToChange -= timepassed;
Ogre::Vector3 ret = Animation::runAnimation(timepassed);
const Ogre::SkeletonInstance *skelsrc = mObjectList.mSkelBase->getSkeleton();
const Ogre::SkeletonInstance *skelsrc = mSkelBase->getSkeleton();
for(size_t i = 0;i < sPartListSize;i++)
{
Ogre::Entity *ent = mObjectParts[i].mSkelBase;