mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 13:15:34 +00:00
Use a multimap for the bodypart map
This commit is contained in:
parent
a5e4faaed2
commit
025fa4e0d5
1 changed files with 34 additions and 31 deletions
|
@ -283,29 +283,30 @@ void NpcAnimation::updateParts(bool forceupdate)
|
||||||
std::pair<std::string, int> thisCombination = std::make_pair(race, flags);
|
std::pair<std::string, int> thisCombination = std::make_pair(race, flags);
|
||||||
if (sRaceMapping.find(thisCombination) == sRaceMapping.end())
|
if (sRaceMapping.find(thisCombination) == sRaceMapping.end())
|
||||||
{
|
{
|
||||||
static std::map<int, int> bodypartMap;
|
typedef std::multimap<ESM::BodyPart::MeshPart,ESM::PartReferenceType> BodyPartMapType;
|
||||||
if(bodypartMap.size() == 0)
|
static BodyPartMapType sBodyPartMap;
|
||||||
|
if(sBodyPartMap.size() == 0)
|
||||||
{
|
{
|
||||||
bodypartMap[ESM::PRT_Neck] = ESM::BodyPart::MP_Neck;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Neck, ESM::PRT_Neck));
|
||||||
bodypartMap[ESM::PRT_Cuirass] = ESM::BodyPart::MP_Chest;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Chest, ESM::PRT_Cuirass));
|
||||||
bodypartMap[ESM::PRT_Groin] = ESM::BodyPart::MP_Groin;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Groin, ESM::PRT_Groin));
|
||||||
bodypartMap[ESM::PRT_RHand] = ESM::BodyPart::MP_Hand;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Hand, ESM::PRT_RHand));
|
||||||
bodypartMap[ESM::PRT_LHand] = ESM::BodyPart::MP_Hand;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Hand, ESM::PRT_LHand));
|
||||||
bodypartMap[ESM::PRT_RWrist] = ESM::BodyPart::MP_Wrist;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Wrist, ESM::PRT_RWrist));
|
||||||
bodypartMap[ESM::PRT_LWrist] = ESM::BodyPart::MP_Wrist;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Wrist, ESM::PRT_LWrist));
|
||||||
bodypartMap[ESM::PRT_RForearm] = ESM::BodyPart::MP_Forearm;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Forearm, ESM::PRT_RForearm));
|
||||||
bodypartMap[ESM::PRT_LForearm] = ESM::BodyPart::MP_Forearm;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Forearm, ESM::PRT_LForearm));
|
||||||
bodypartMap[ESM::PRT_RUpperarm] = ESM::BodyPart::MP_Upperarm;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Upperarm, ESM::PRT_RUpperarm));
|
||||||
bodypartMap[ESM::PRT_LUpperarm] = ESM::BodyPart::MP_Upperarm;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Upperarm, ESM::PRT_LUpperarm));
|
||||||
bodypartMap[ESM::PRT_RFoot] = ESM::BodyPart::MP_Foot;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Foot, ESM::PRT_RFoot));
|
||||||
bodypartMap[ESM::PRT_LFoot] = ESM::BodyPart::MP_Foot;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Foot, ESM::PRT_LFoot));
|
||||||
bodypartMap[ESM::PRT_RAnkle] = ESM::BodyPart::MP_Ankle;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Ankle, ESM::PRT_RAnkle));
|
||||||
bodypartMap[ESM::PRT_LAnkle] = ESM::BodyPart::MP_Ankle;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Ankle, ESM::PRT_LAnkle));
|
||||||
bodypartMap[ESM::PRT_RKnee] = ESM::BodyPart::MP_Knee;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Knee, ESM::PRT_RKnee));
|
||||||
bodypartMap[ESM::PRT_LKnee] = ESM::BodyPart::MP_Knee;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Knee, ESM::PRT_LKnee));
|
||||||
bodypartMap[ESM::PRT_RLeg] = ESM::BodyPart::MP_Upperleg;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Upperleg, ESM::PRT_RLeg));
|
||||||
bodypartMap[ESM::PRT_LLeg] = ESM::BodyPart::MP_Upperleg;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Upperleg, ESM::PRT_LLeg));
|
||||||
bodypartMap[ESM::PRT_Tail] = ESM::BodyPart::MP_Tail;
|
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Tail, ESM::PRT_Tail));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const ESM::BodyPart*> &parts = sRaceMapping[thisCombination];
|
std::vector<const ESM::BodyPart*> &parts = sRaceMapping[thisCombination];
|
||||||
|
@ -337,20 +338,22 @@ void NpcAnimation::updateParts(bool forceupdate)
|
||||||
bodypart.mData.mPart == ESM::BodyPart::MP_Forearm))
|
bodypart.mData.mPart == ESM::BodyPart::MP_Forearm))
|
||||||
{
|
{
|
||||||
/* Allow 3rd person skins as a fallback for the forearms if 1st person is missing. */
|
/* Allow 3rd person skins as a fallback for the forearms if 1st person is missing. */
|
||||||
for(std::map<int,int>::iterator bIt = bodypartMap.begin();bIt != bodypartMap.end();++bIt)
|
BodyPartMapType::const_iterator bIt = sBodyPartMap.lower_bound(BodyPartMapType::key_type(bodypart.mData.mPart));
|
||||||
|
while(bIt != sBodyPartMap.end() && bIt->first == bodypart.mData.mPart)
|
||||||
{
|
{
|
||||||
if(bIt->second == bodypart.mData.mPart)
|
if(!parts[bIt->second])
|
||||||
{
|
parts[bIt->second] = &*it;
|
||||||
if(!parts[bIt->first])
|
bIt++;
|
||||||
parts[bIt->first] = &*it;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for(std::map<int,int>::iterator bIt = bodypartMap.begin();bIt != bodypartMap.end();++bIt)
|
BodyPartMapType::const_iterator bIt = sBodyPartMap.lower_bound(BodyPartMapType::key_type(bodypart.mData.mPart));
|
||||||
if(bIt->second == bodypart.mData.mPart)
|
while(bIt != sBodyPartMap.end() && bIt->first == bodypart.mData.mPart)
|
||||||
parts[bIt->first] = &*it;
|
{
|
||||||
|
parts[bIt->second] = &*it;
|
||||||
|
bIt++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue