Avoid storing text keys for each animation

actorid
Chris Robinson 12 years ago
parent 7d59340ed6
commit 2345b5e8b3

@ -121,24 +121,15 @@ void Animation::addObjectList(Ogre::SceneNode *node, const std::string &model, b
Ogre::Bone *bone = boneiter.getNext();
Ogre::UserObjectBindings &bindings = bone->getUserObjectBindings();
const Ogre::Any &data = bindings.getUserAny(NifOgre::sTextKeyExtraDataID);
if(data.isEmpty() || !Ogre::any_cast<bool>(data))
continue;
if(data.isEmpty()) continue;
objlist.mTextKeys[bone->getHandle()] = Ogre::any_cast<NifOgre::TextKeyMap>(data);
if(!mNonAccumRoot)
{
mAccumRoot = mInsert;
mNonAccumRoot = mSkelBase->getSkeleton()->getBone(bone->getName());
}
for(int i = 0;i < skel->getNumAnimations();i++)
{
Ogre::Animation *anim = skel->getAnimation(i);
const Ogre::Any &groupdata = bindings.getUserAny(std::string(NifOgre::sTextKeyExtraDataID)+
"@"+anim->getName());
if(!groupdata.isEmpty())
mTextKeys[anim->getName()] = Ogre::any_cast<NifOgre::TextKeyMap>(groupdata);
}
break;
}
}
@ -451,7 +442,7 @@ void Animation::play(const std::string &groupname, const std::string &start, con
{
Ogre::SkeletonInstance *skel = iter->mSkelBase->getSkeleton();
mCurrentAnim = skel->getAnimation(groupname);
mCurrentKeys = &mTextKeys[groupname];
mCurrentKeys = &iter->mTextKeys.begin()->second;
mCurrentGroup = groupname;
mCurrentControllers = &iter->mControllers;

@ -46,7 +46,6 @@ protected:
Ogre::SceneNode *mInsert;
Ogre::Entity *mSkelBase;
std::vector<NifOgre::ObjectList> mObjectLists;
std::map<std::string,NifOgre::TextKeyMap> mTextKeys;
Ogre::Node *mAccumRoot;
Ogre::Bone *mNonAccumRoot;
Ogre::Vector3 mAccumulate;

@ -50,6 +50,8 @@ struct ObjectList {
// bones in the mSkelBase which are NiCamera nodes.
std::vector<Ogre::Bone*> mCameras;
std::map<int,TextKeyMap> mTextKeys;
std::vector<Ogre::Controller<Ogre::Real> > mControllers;
ObjectList() : mSkelBase(0)

@ -193,6 +193,7 @@ void NIFSkeletonLoader::buildBones(Ogre::Skeleton *skel, const Nif::Node *node,
const Nif::NiTextKeyExtraData *tk = static_cast<const Nif::NiTextKeyExtraData*>(e.getPtr());
textkeys = extractTextKeys(tk);
animroot = bone;
bone->getUserObjectBindings().setUserAny(sTextKeyExtraDataID, Ogre::Any(textkeys));
}
e = e->extra;
}
@ -255,9 +256,6 @@ void NIFSkeletonLoader::loadResource(Ogre::Resource *resource)
return;
}
Ogre::UserObjectBindings &bindings = animroot->getUserObjectBindings();
bindings.setUserAny(sTextKeyExtraDataID, Ogre::Any(true));
std::string currentgroup;
TextKeyMap::const_iterator keyiter = textkeys.begin();
for(keyiter = textkeys.begin();keyiter != textkeys.end();keyiter++)
@ -281,9 +279,6 @@ void NIFSkeletonLoader::loadResource(Ogre::Resource *resource)
}
buildAnimation(skel, currentgroup, ctrls, targets, keyiter->first, lastkeyiter->first);
TextKeyMap groupkeys(keyiter, ++lastkeyiter);
bindings.setUserAny(std::string(sTextKeyExtraDataID)+"@"+currentgroup, Ogre::Any(groupkeys));
}
}

Loading…
Cancel
Save