From 6605aa7dec985ad120d3bd8a2ab272e6ea1db84d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 10 May 2013 20:45:09 -0700 Subject: [PATCH] Create three bone groups This still won't work as expected. Currently there is only one priority level, and only one animation state per priority level can be active at a time. It's close, though. --- apps/openmw/mwrender/animation.cpp | 32 +++++++++++++++++++++--------- apps/openmw/mwrender/animation.hpp | 9 ++++++--- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 455273f70..8a4dba521 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -145,17 +145,24 @@ void Animation::setRenderProperties(const NifOgre::ObjectList &objlist, Ogre::ui size_t Animation::detectAnimGroup(const Ogre::Node *node) { + static const char sGroupRoots[sNumGroups][32] = { + "", /* Lower body / character root */ + "Bip01 Spine1", /* Upper body */ + "Bip01 L Clavicle", /* Left arm */ + }; + while(node) { -#if 0 const Ogre::String &name = node->getName(); - if(name == "Bip01 L Clavicle") - return 2; - if(name == "Bip01 Spine1") - return 1; -#endif + for(size_t i = 1;i < sNumGroups;i++) + { + if(name == sGroupRoots[i]) + return i; + } + node = node->getParent(); } + return 0; } @@ -482,14 +489,21 @@ bool Animation::play(const std::string &groupname, Priority priority, int groups if(groupname.empty()) return resetActiveGroups(); - AnimStateMap::iterator stateiter = mStates.find(groupname); + AnimStateMap::iterator stateiter = mStates.begin(); + while(stateiter != mStates.end()) + { + if(stateiter->second.mPriority == priority) + mStates.erase(stateiter++); + else + stateiter++; + } + + stateiter = mStates.find(groupname); if(stateiter != mStates.end()) { stateiter->second.mPriority = priority; return resetActiveGroups(); } - // HACK: Don't clear all active animations - mStates.clear(); /* Look in reverse; last-inserted source has priority. */ AnimSourceList::reverse_iterator iter(mAnimSources.rbegin()); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index e1e5079e8..747db0fe5 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -23,12 +23,15 @@ public: }; enum Group { - Group_Default = 1<<0, - Group_All = Group_Default + Group_LowerBody = 1<<0, + Group_UpperBody = 1<<1, + Group_LeftArm = 1<<2, + + Group_All = Group_LowerBody | Group_UpperBody | Group_LeftArm }; protected: - static const size_t sNumGroups = 1; + static const size_t sNumGroups = 3; class AnimationValue : public Ogre::ControllerValue {