mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Don't store textkeys in user object bindings
It's a bit unwieldy to have them stored in the 'skeleton master' instead of the skeleton instance. And although the text keys are extracted for each created instance now, this shouldn't be much worse than the multimap copying going on before. Plus, proper serialization can help for future optimizations.
This commit is contained in:
parent
2345b5e8b3
commit
a3511c62cf
4 changed files with 18 additions and 22 deletions
|
@ -97,9 +97,9 @@ void Animation::addObjectList(Ogre::SceneNode *node, const std::string &model, b
|
|||
while(boneiter.hasMoreElements())
|
||||
boneiter.getNext()->setManuallyControlled(true);
|
||||
|
||||
Ogre::SkeletonInstance *baseinst = mSkelBase->getSkeleton();
|
||||
if(mSkelBase != objlist.mSkelBase)
|
||||
{
|
||||
Ogre::SkeletonInstance *baseinst = mSkelBase->getSkeleton();
|
||||
for(size_t i = 0;i < objlist.mControllers.size();i++)
|
||||
{
|
||||
NifOgre::NodeTargetValue<Ogre::Real> *dstval;
|
||||
|
@ -114,23 +114,13 @@ void Animation::addObjectList(Ogre::SceneNode *node, const std::string &model, b
|
|||
}
|
||||
}
|
||||
|
||||
Ogre::SkeletonPtr skel = Ogre::SkeletonManager::getSingleton().getByName(skelinst->getName());
|
||||
boneiter = skel->getBoneIterator();
|
||||
while(boneiter.hasMoreElements())
|
||||
if(objlist.mTextKeys.size() > 0)
|
||||
{
|
||||
Ogre::Bone *bone = boneiter.getNext();
|
||||
Ogre::UserObjectBindings &bindings = bone->getUserObjectBindings();
|
||||
const Ogre::Any &data = bindings.getUserAny(NifOgre::sTextKeyExtraDataID);
|
||||
if(data.isEmpty()) continue;
|
||||
|
||||
objlist.mTextKeys[bone->getHandle()] = Ogre::any_cast<NifOgre::TextKeyMap>(data);
|
||||
if(!mNonAccumRoot)
|
||||
{
|
||||
mAccumRoot = mInsert;
|
||||
mNonAccumRoot = mSkelBase->getSkeleton()->getBone(bone->getName());
|
||||
mNonAccumRoot = baseinst->getBone(objlist.mTextKeys.begin()->first);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(size_t i = 0;i < objlist.mControllers.size();i++)
|
||||
|
|
|
@ -649,7 +649,14 @@ class NIFObjectLoader
|
|||
Nif::ExtraPtr e = node->extra;
|
||||
while(!e.empty())
|
||||
{
|
||||
if(e->recType == Nif::RC_NiStringExtraData)
|
||||
if(e->recType == Nif::RC_NiTextKeyExtraData)
|
||||
{
|
||||
const Nif::NiTextKeyExtraData *tk = static_cast<const Nif::NiTextKeyExtraData*>(e.getPtr());
|
||||
|
||||
int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(name, node->recIndex);
|
||||
objectlist.mTextKeys[trgtid] = NIFSkeletonLoader::extractTextKeys(tk);
|
||||
}
|
||||
else if(e->recType == Nif::RC_NiStringExtraData)
|
||||
{
|
||||
const Nif::NiStringExtraData *sd = static_cast<const Nif::NiStringExtraData*>(e.getPtr());
|
||||
// String markers may contain important information
|
||||
|
@ -661,6 +668,7 @@ class NIFObjectLoader
|
|||
flags |= 0x80000000;
|
||||
}
|
||||
}
|
||||
|
||||
e = e->extra;
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,6 @@ 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;
|
||||
}
|
||||
|
@ -287,16 +286,16 @@ Ogre::SkeletonPtr NIFSkeletonLoader::createSkeleton(const std::string &name, con
|
|||
{
|
||||
/* We need to be a little aggressive here, since some NIFs have a crap-ton
|
||||
* of nodes and Ogre only supports 256 bones. We will skip a skeleton if:
|
||||
* There are no bones used for skinning, there are no controllers on non-
|
||||
* NiTriShape nodes, there are no nodes named "AttachLight", and the tree
|
||||
* consists of NiNode, NiTriShape, and RootCollisionNode types only.
|
||||
* There are no bones used for skinning, there are no controllers, there
|
||||
* are no nodes named "AttachLight", and the tree consists of NiNode,
|
||||
* NiTriShape, and RootCollisionNode types only.
|
||||
*/
|
||||
if(!node->boneTrafo)
|
||||
{
|
||||
if(node->recType == Nif::RC_NiTriShape)
|
||||
return Ogre::SkeletonPtr();
|
||||
if(node->controller.empty() && node->name != "AttachLight")
|
||||
{
|
||||
if(node->recType == Nif::RC_NiTriShape)
|
||||
return Ogre::SkeletonPtr();
|
||||
if(node->recType == Nif::RC_NiNode || node->recType == Nif::RC_RootCollisionNode)
|
||||
{
|
||||
const Nif::NiNode *ninode = static_cast<const Nif::NiNode*>(node);
|
||||
|
|
|
@ -37,8 +37,6 @@ class NIFSkeletonLoader : public Ogre::ManualResourceLoader
|
|||
}
|
||||
|
||||
static void buildAnimation(Ogre::Skeleton *skel, const std::string &name, const std::vector<const Nif::NiKeyframeController*> &ctrls, const std::vector<std::string> &targets, float startTime, float stopTime);
|
||||
|
||||
static TextKeyMap extractTextKeys(const Nif::NiTextKeyExtraData *tk);
|
||||
void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, Ogre::Bone *&animroot, TextKeyMap &textkeys, std::vector<Nif::NiKeyframeController const*> &ctrls, Ogre::Bone *parent=NULL);
|
||||
|
||||
// Lookup to retrieve an Ogre bone handle for a given Nif record index
|
||||
|
@ -48,6 +46,7 @@ class NIFSkeletonLoader : public Ogre::ManualResourceLoader
|
|||
static LoaderMap sLoaders;
|
||||
|
||||
public:
|
||||
static TextKeyMap extractTextKeys(const Nif::NiTextKeyExtraData *tk);
|
||||
void loadResource(Ogre::Resource *resource);
|
||||
|
||||
static Ogre::SkeletonPtr createSkeleton(const std::string &name, const std::string &group, const Nif::Node *node);
|
||||
|
|
Loading…
Reference in a new issue