Use an enum to specify the NPC's view mode (normal, head only)

This commit is contained in:
Chris Robinson 2013-04-09 09:07:05 -07:00
parent 973fdeb2e0
commit 9f9d978b0f
3 changed files with 16 additions and 10 deletions

View file

@ -59,8 +59,8 @@ namespace MWRender
mNode = renderRoot->createChildSceneNode(); mNode = renderRoot->createChildSceneNode();
mAnimation = new NpcAnimation(mCharacter, mNode, mAnimation = new NpcAnimation(mCharacter, mNode, MWWorld::Class::get(mCharacter).getInventoryStore(mCharacter),
MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), 0, renderHeadOnly()); 0, (renderHeadOnly() ? NpcAnimation::VM_HeadOnly : NpcAnimation::VM_Normal));
mNode->setVisible (false); mNode->setVisible (false);
@ -101,8 +101,8 @@ namespace MWRender
assert(mAnimation); assert(mAnimation);
delete mAnimation; delete mAnimation;
mAnimation = new NpcAnimation(mCharacter, mNode, mAnimation = new NpcAnimation(mCharacter, mNode, MWWorld::Class::get(mCharacter).getInventoryStore(mCharacter),
MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), 0, renderHeadOnly()); 0, (renderHeadOnly() ? NpcAnimation::VM_HeadOnly : NpcAnimation::VM_Normal));
float scale=1.f; float scale=1.f;
MWWorld::Class::get(mCharacter).adjustScale(mCharacter, scale); MWWorld::Class::get(mCharacter).adjustScale(mCharacter, scale);

View file

@ -56,7 +56,7 @@ NpcAnimation::~NpcAnimation()
} }
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags, bool headOnly) NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags, ViewMode viewMode)
: Animation(ptr), : Animation(ptr),
mStateID(-1), mStateID(-1),
mTimeToChange(0), mTimeToChange(0),
@ -73,7 +73,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
mGloveL(inv.end()), mGloveL(inv.end()),
mGloveR(inv.end()), mGloveR(inv.end()),
mSkirtIter(inv.end()), mSkirtIter(inv.end()),
mHeadOnly(headOnly) mViewMode(viewMode)
{ {
mNpc = mPtr.get<ESM::NPC>()->mBase; mNpc = mPtr.get<ESM::NPC>()->mBase;
@ -222,7 +222,7 @@ void NpcAnimation::updateParts(bool forceupdate)
if(!forceupdate) if(!forceupdate)
return; return;
for(size_t i = 0;i < slotlistsize && !mHeadOnly;i++) for(size_t i = 0;i < slotlistsize && mViewMode != VM_HeadOnly;i++)
{ {
MWWorld::ContainerStoreIterator iter = inv.getSlot(slotlist[i].slot); MWWorld::ContainerStoreIterator iter = inv.getSlot(slotlist[i].slot);
@ -259,7 +259,7 @@ void NpcAnimation::updateParts(bool forceupdate)
if(mPartPriorities[ESM::PRT_Hair] < 1 && mPartPriorities[ESM::PRT_Head] <= 1) if(mPartPriorities[ESM::PRT_Hair] < 1 && mPartPriorities[ESM::PRT_Head] <= 1)
addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1, mHairModel); addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1, mHairModel);
if (mHeadOnly) if(mViewMode == VM_HeadOnly)
return; return;
static const struct { static const struct {

View file

@ -26,6 +26,11 @@ struct PartInfo {
const char name[32]; const char name[32];
}; };
enum ViewMode {
VM_Normal,
VM_HeadOnly
};
private: private:
static const size_t sPartListSize = 27; static const size_t sPartListSize = 27;
static const PartInfo sPartList[sPartListSize]; static const PartInfo sPartList[sPartListSize];
@ -39,7 +44,7 @@ private:
std::string mHeadModel; std::string mHeadModel;
std::string mHairModel; std::string mHairModel;
std::string mBodyPrefix; std::string mBodyPrefix;
bool mHeadOnly; ViewMode mViewMode;
float mTimeToChange; float mTimeToChange;
MWWorld::ContainerStoreIterator mRobe; MWWorld::ContainerStoreIterator mRobe;
@ -73,7 +78,8 @@ private:
public: public:
NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node,
MWWorld::InventoryStore& inv, int visibilityFlags, bool headOnly=false); MWWorld::InventoryStore& inv, int visibilityFlags,
ViewMode viewMode=VM_Normal);
virtual ~NpcAnimation(); virtual ~NpcAnimation();
virtual Ogre::Vector3 runAnimation(float timepassed); virtual Ogre::Vector3 runAnimation(float timepassed);