1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00

Add part info for weapons and shields

This commit is contained in:
Chris Robinson 2013-01-06 05:39:39 -08:00
parent 976b042cca
commit 2b1fe7dc44
2 changed files with 20 additions and 24 deletions

View File

@ -17,7 +17,7 @@ using namespace NifOgre;
namespace MWRender namespace MWRender
{ {
const PartInfo NpcAnimation::sPartList[NpcAnimation::sPartListSize] = { const NpcAnimation::PartInfo NpcAnimation::sPartList[NpcAnimation::sPartListSize] = {
{ ESM::PRT_Head, &NpcAnimation::mHead, "Head" }, { ESM::PRT_Head, &NpcAnimation::mHead, "Head" },
{ ESM::PRT_Hair, &NpcAnimation::mHair, "Head" }, { ESM::PRT_Hair, &NpcAnimation::mHair, "Head" },
{ ESM::PRT_Neck, &NpcAnimation::mNeck, "Neck" }, { ESM::PRT_Neck, &NpcAnimation::mNeck, "Neck" },
@ -28,7 +28,7 @@ const PartInfo NpcAnimation::sPartList[NpcAnimation::sPartListSize] = {
{ ESM::PRT_LHand, &NpcAnimation::mHandL, "Left Hand" }, { ESM::PRT_LHand, &NpcAnimation::mHandL, "Left Hand" },
{ ESM::PRT_RWrist, &NpcAnimation::mWristR, "Right Wrist" }, { ESM::PRT_RWrist, &NpcAnimation::mWristR, "Right Wrist" },
{ ESM::PRT_LWrist, &NpcAnimation::mWristL, "Left Wrist" }, { ESM::PRT_LWrist, &NpcAnimation::mWristL, "Left Wrist" },
{ ESM::PRT_Shield, NULL, "" }, { ESM::PRT_Shield, &NpcAnimation::mShield, "Shield" },
{ ESM::PRT_RForearm, &NpcAnimation::mForearmR, "Right Forearm" }, { ESM::PRT_RForearm, &NpcAnimation::mForearmR, "Right Forearm" },
{ ESM::PRT_LForearm, &NpcAnimation::mForearmL, "Left Forearm" }, { ESM::PRT_LForearm, &NpcAnimation::mForearmL, "Left Forearm" },
{ ESM::PRT_RUpperarm, &NpcAnimation::mUpperArmR, "Right Upper Arm" }, { ESM::PRT_RUpperarm, &NpcAnimation::mUpperArmR, "Right Upper Arm" },
@ -43,24 +43,21 @@ const PartInfo NpcAnimation::sPartList[NpcAnimation::sPartListSize] = {
{ ESM::PRT_LLeg, &NpcAnimation::mUpperLegL, "Left Upper Leg" }, { ESM::PRT_LLeg, &NpcAnimation::mUpperLegL, "Left Upper Leg" },
{ ESM::PRT_RPauldron, &NpcAnimation::mClavicleR, "Right Clavicle" }, { ESM::PRT_RPauldron, &NpcAnimation::mClavicleR, "Right Clavicle" },
{ ESM::PRT_LPauldron, &NpcAnimation::mClavicleL, "Left Clavicle" }, { ESM::PRT_LPauldron, &NpcAnimation::mClavicleL, "Left Clavicle" },
{ ESM::PRT_Weapon, NULL, "" }, { ESM::PRT_Weapon, &NpcAnimation::mWeapon, "Weapon" },
{ ESM::PRT_Tail, &NpcAnimation::mTail, "Tail" } { ESM::PRT_Tail, &NpcAnimation::mTail, "Tail" }
}; };
NpcAnimation::~NpcAnimation() NpcAnimation::~NpcAnimation()
{ {
for(size_t i = 0;i < sPartListSize;i++) for(size_t i = 0;i < sPartListSize;i++)
{ removeEntities(this->*sPartList[i].ents);
if(sPartList[i].ents)
removeEntities(this->*sPartList[i].ents);
}
} }
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags) NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags)
: Animation(), : Animation(),
mStateID(-1),
mInv(inv), mInv(inv),
mStateID(-1),
mTimeToChange(0), mTimeToChange(0),
mVisibilityFlags(visibilityFlags), mVisibilityFlags(visibilityFlags),
mRobe(mInv.end()), mRobe(mInv.end()),
@ -78,10 +75,10 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
{ {
mNpc = ptr.get<ESM::NPC>()->mBase; mNpc = ptr.get<ESM::NPC>()->mBase;
for (int init = 0; init < 27; init++) for(size_t i = 0;i < sPartListSize;i++)
{ {
mPartslots[init] = -1; //each slot is empty mPartslots[i] = -1; //each slot is empty
mPartPriorities[init] = 0; mPartPriorities[i] = 0;
} }
const MWWorld::ESMStore &store = const MWWorld::ESMStore &store =
@ -397,8 +394,7 @@ void NpcAnimation::removeIndividualPart(int type)
{ {
if(type == sPartList[i].type) if(type == sPartList[i].type)
{ {
if(sPartList[i].ents) removeEntities(this->*sPartList[i].ents);
removeEntities(this->*sPartList[i].ents);
break; break;
} }
} }
@ -436,8 +432,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority,
{ {
if(type == sPartList[i].type) if(type == sPartList[i].type)
{ {
if(sPartList[i].ents) this->*sPartList[i].ents = insertBoundedPart(mesh, group, sPartList[i].name);
this->*sPartList[i].ents = insertBoundedPart(mesh, group, sPartList[i].name);
break; break;
} }
} }

View File

@ -14,23 +14,22 @@ namespace ESM
namespace MWRender namespace MWRender
{ {
class NpcAnimation; class NpcAnimation : public Animation
{
public:
struct PartInfo { struct PartInfo {
ESM::PartReferenceType type; ESM::PartReferenceType type;
NifOgre::EntityList NpcAnimation::*ents; NifOgre::EntityList NpcAnimation::*ents;
const char name[32]; const char name[32];
}; };
class NpcAnimation : public Animation
{
private: private:
static const size_t sPartListSize = 27;
static const PartInfo sPartList[sPartListSize];
MWWorld::InventoryStore& mInv; MWWorld::InventoryStore& mInv;
int mStateID; int mStateID;
int mPartslots[27]; //Each part slot is taken by clothing, armor, or is empty
int mPartPriorities[27];
//Bounded Parts //Bounded Parts
NifOgre::EntityList mClavicleL; NifOgre::EntityList mClavicleL;
NifOgre::EntityList mClavicleR; NifOgre::EntityList mClavicleR;
@ -54,6 +53,8 @@ private:
NifOgre::EntityList mHair; NifOgre::EntityList mHair;
NifOgre::EntityList mHandL; NifOgre::EntityList mHandL;
NifOgre::EntityList mHandR; NifOgre::EntityList mHandR;
NifOgre::EntityList mShield;
NifOgre::EntityList mWeapon;
NifOgre::EntityList mHead; NifOgre::EntityList mHead;
NifOgre::EntityList mChest; NifOgre::EntityList mChest;
NifOgre::EntityList mTail; NifOgre::EntityList mTail;
@ -79,8 +80,8 @@ private:
int mVisibilityFlags; int mVisibilityFlags;
static const size_t sPartListSize = 27; int mPartslots[sPartListSize]; //Each part slot is taken by clothing, armor, or is empty
static const PartInfo sPartList[sPartListSize]; int mPartPriorities[sPartListSize];
public: public:
NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node,