mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:53:52 +00:00
Merge branch 'nif-cleanup' of https://github.com/ChrisKCat/openmw into nif-cleanup
This commit is contained in:
commit
1dbfd60305
6 changed files with 72 additions and 64 deletions
|
@ -16,6 +16,7 @@ Animation::Animation(OEngine::Render::OgreRenderer& _rend)
|
|||
, mRend(_rend)
|
||||
, mTime(0.0f)
|
||||
, mAnimate(0)
|
||||
, mSkipFrame(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -39,7 +40,37 @@ void Animation::playGroup(std::string groupname, int mode, int loops)
|
|||
|
||||
void Animation::skipAnim()
|
||||
{
|
||||
mAnimate = 0;
|
||||
mSkipFrame = true;
|
||||
}
|
||||
|
||||
void Animation::runAnimation(float timepassed)
|
||||
{
|
||||
if(mAnimate != 0 && !mSkipFrame)
|
||||
{
|
||||
mTime += timepassed;
|
||||
|
||||
if(mEntityList.mSkelBase)
|
||||
{
|
||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
||||
while(as.hasMoreElements())
|
||||
{
|
||||
Ogre::AnimationState *state = as.getNext();
|
||||
state->setTimePosition(mTime);
|
||||
if(mTime >= state->getLength())
|
||||
{
|
||||
if(mAnimate != -1)
|
||||
mAnimate--;
|
||||
//std::cout << "Stopping the animation\n";
|
||||
if(mAnimate == 0)
|
||||
mTime = state->getLength();
|
||||
else
|
||||
mTime = mTime - state->getLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mSkipFrame = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ protected:
|
|||
|
||||
float mTime;
|
||||
int mAnimate;
|
||||
bool mSkipFrame;
|
||||
|
||||
NifOgre::EntityList mEntityList;
|
||||
|
||||
|
@ -36,7 +37,7 @@ public:
|
|||
|
||||
void playGroup(std::string groupname, int mode, int loops);
|
||||
void skipAnim();
|
||||
virtual void runAnimation(float timepassed) = 0;
|
||||
virtual void runAnimation(float timepassed);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -69,30 +69,9 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O
|
|||
|
||||
void CreatureAnimation::runAnimation(float timepassed)
|
||||
{
|
||||
if(mAnimate > 0)
|
||||
{
|
||||
mTime += timepassed;
|
||||
// Placeholder
|
||||
|
||||
if(mEntityList.mSkelBase)
|
||||
{
|
||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
||||
while(as.hasMoreElements())
|
||||
{
|
||||
Ogre::AnimationState *state = as.getNext();
|
||||
state->setTimePosition(mTime);
|
||||
if(state->getTimePosition() >= state->getLength())
|
||||
{
|
||||
mAnimate--;
|
||||
//std::cout << "Stopping the animation\n";
|
||||
if(mAnimate == 0)
|
||||
mTime = state->getLength();
|
||||
else
|
||||
mTime = mTime - state->getLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Animation::runAnimation(timepassed);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ void NpcAnimation::updateParts()
|
|||
{ &greaves, MWWorld::InventoryStore::Slot_Greaves },
|
||||
{ &leftpauldron, MWWorld::InventoryStore::Slot_LeftPauldron },
|
||||
{ &rightpauldron, MWWorld::InventoryStore::Slot_RightPauldron },
|
||||
{ &boots, MWWorld::InventoryStore::Slot_Boots }, // !isBeast
|
||||
{ &boots, MWWorld::InventoryStore::Slot_Boots },
|
||||
{ &leftglove, MWWorld::InventoryStore::Slot_LeftGauntlet },
|
||||
{ &rightglove, MWWorld::InventoryStore::Slot_RightGauntlet },
|
||||
{ &shirt, MWWorld::InventoryStore::Slot_Shirt },
|
||||
|
@ -157,9 +157,6 @@ void NpcAnimation::updateParts()
|
|||
};
|
||||
for(size_t i = 0;i < sizeof(slotlist)/sizeof(slotlist[0]);i++)
|
||||
{
|
||||
if(slotlist[i].iter == &boots && isBeast)
|
||||
continue;
|
||||
|
||||
MWWorld::ContainerStoreIterator iter = mInv.getSlot(slotlist[i].slot);
|
||||
if(*slotlist[i].iter != iter)
|
||||
{
|
||||
|
@ -235,7 +232,7 @@ void NpcAnimation::updateParts()
|
|||
std::vector<ESM::PartReference> parts = armor->parts.parts;
|
||||
addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts);
|
||||
}
|
||||
if(!isBeast && boots != mInv.end())
|
||||
if(boots != mInv.end())
|
||||
{
|
||||
if(boots->getTypeName() == typeid(ESM::Clothing).name())
|
||||
{
|
||||
|
@ -373,30 +370,7 @@ void NpcAnimation::runAnimation(float timepassed)
|
|||
}
|
||||
timeToChange += timepassed;
|
||||
|
||||
if(mAnimate > 0)
|
||||
{
|
||||
mTime += timepassed;
|
||||
|
||||
if(mEntityList.mSkelBase)
|
||||
{
|
||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
||||
while(as.hasMoreElements())
|
||||
{
|
||||
Ogre::AnimationState *state = as.getNext();
|
||||
state->setTimePosition(mTime);
|
||||
if(state->getTimePosition() >= state->getLength())
|
||||
{
|
||||
mAnimate--;
|
||||
//std::cout << "Stopping the animation\n";
|
||||
if(mAnimate == 0)
|
||||
mTime = state->getLength();
|
||||
else
|
||||
mTime = mTime - state->getLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Animation::runAnimation(timepassed);
|
||||
}
|
||||
|
||||
void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
|
||||
|
@ -411,7 +385,6 @@ void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
|
|||
}
|
||||
entities.mEntities.clear();
|
||||
entities.mSkelBase = NULL;
|
||||
entities.mRootNode = NULL;
|
||||
}
|
||||
|
||||
void NpcAnimation::removeIndividualPart(int type)
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "ogre_nif_loader.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <OgreMaterialManager.h>
|
||||
#include <OgreMeshManager.h>
|
||||
#include <OgreHardwareBufferManager.h>
|
||||
|
@ -306,10 +308,30 @@ void loadResource(Ogre::Resource *resource)
|
|||
|
||||
Ogre::TransformKeyFrame *kframe;
|
||||
kframe = nodetrack->createNodeKeyFrame(curtime);
|
||||
// FIXME: These should be interpolated since they don't all fall on the same time
|
||||
if(quatiter == quatkeys.mKeys.end() || quatiter == quatkeys.mKeys.begin())
|
||||
kframe->setRotation(curquat);
|
||||
else
|
||||
{
|
||||
QuaternionKeyList::VecType::const_iterator last = quatiter-1;
|
||||
float diff = (curtime-last->mTime) / (quatiter->mTime-last->mTime);
|
||||
kframe->setRotation(Ogre::Quaternion::nlerp(diff, lastquat, curquat));
|
||||
}
|
||||
if(traniter == trankeys.mKeys.end() || traniter == trankeys.mKeys.begin())
|
||||
kframe->setTranslate(curtrans);
|
||||
else
|
||||
{
|
||||
Vector3KeyList::VecType::const_iterator last = traniter-1;
|
||||
float diff = (curtime-last->mTime) / (traniter->mTime-last->mTime);
|
||||
kframe->setTranslate(lasttrans + ((curtrans-lasttrans)*diff));
|
||||
}
|
||||
if(scaleiter == scalekeys.mKeys.end() || scaleiter == scalekeys.mKeys.begin())
|
||||
kframe->setScale(curscale);
|
||||
else
|
||||
{
|
||||
FloatKeyList::VecType::const_iterator last = scaleiter-1;
|
||||
float diff = (curtime-last->mTime) / (scaleiter->mTime-last->mTime);
|
||||
kframe->setScale(lastscale + ((curscale-lastscale)*diff));
|
||||
}
|
||||
}
|
||||
}
|
||||
anim->optimise();
|
||||
|
@ -1027,7 +1049,6 @@ EntityList NIFLoader::createEntities(Ogre::SceneNode *parent, const std::string
|
|||
if(meshes.size() == 0)
|
||||
return entitylist;
|
||||
|
||||
entitylist.mRootNode = parent;
|
||||
Ogre::SceneManager *sceneMgr = parent->getCreator();
|
||||
for(size_t i = 0;i < meshes.size();i++)
|
||||
{
|
||||
|
@ -1061,6 +1082,11 @@ EntityList NIFLoader::createEntities(Ogre::SceneNode *parent, const std::string
|
|||
return entitylist;
|
||||
}
|
||||
|
||||
static bool checklow(const char &a, const char &b)
|
||||
{
|
||||
return ::tolower(a) == ::tolower(b);
|
||||
}
|
||||
|
||||
EntityList NIFLoader::createEntities(Ogre::Entity *parent, const std::string &bonename,
|
||||
Ogre::SceneNode *parentNode,
|
||||
const std::string &name,
|
||||
|
@ -1080,8 +1106,7 @@ EntityList NIFLoader::createEntities(Ogre::Entity *parent, const std::string &bo
|
|||
if(ent->hasSkeleton())
|
||||
{
|
||||
if(meshes[i].second.length() < filter.length() ||
|
||||
!boost::algorithm::lexicographical_compare(meshes[i].second.substr(0, filter.length()),
|
||||
filter, boost::algorithm::is_iequal()))
|
||||
std::mismatch(filter.begin(), filter.end(), meshes[i].second.begin(), checklow).first != filter.end())
|
||||
{
|
||||
sceneMgr->destroyEntity(ent);
|
||||
meshes.erase(meshes.begin()+i);
|
||||
|
|
|
@ -62,9 +62,8 @@ namespace NifOgre
|
|||
struct EntityList {
|
||||
std::vector<Ogre::Entity*> mEntities;
|
||||
Ogre::Entity *mSkelBase;
|
||||
Ogre::SceneNode *mRootNode;
|
||||
|
||||
EntityList() : mSkelBase(0), mRootNode(0)
|
||||
EntityList() : mSkelBase(0)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue