From fb51b281b210f95c6bcb88de263073effad7394d Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Fri, 24 Feb 2012 01:16:30 -0500 Subject: [PATCH 1/7] Slightly better performance on animation --- apps/openmw/mwrender/animation.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 63855f3b8..1318710ee 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -443,31 +443,31 @@ namespace MWRender{ Ogre::Quaternion r; bool bTrans = translist1.size() > 0; - if(bTrans){ - Ogre::Vector3 v1 = translist1[tindexI[slot]]; - Ogre::Vector3 v2 = translist1[tindexJ]; - t = (v1 + (v2 - v1) * x); - - } + bool bQuats = quats.size() > 0; - if(bQuats){ - r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true); - } - skel = base->getSkeleton(); + if(skel->hasBone(iter->getBonename())){ Ogre::Bone* bone = skel->getBone(iter->getBonename()); - if(bTrans) + if(bTrans){ + Ogre::Vector3 v1 = translist1[tindexI[slot]]; + Ogre::Vector3 v2 = translist1[tindexJ]; + t = (v1 + (v2 - v1) * x); bone->setPosition(t); - if(bQuats) + + } + if(bQuats){ + r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true); bone->setOrientation(r); + } - skel->_updateTransforms(); - base->getAllAnimationStates()->_notifyDirty(); + } + skel->_updateTransforms(); + base->getAllAnimationStates()->_notifyDirty(); slot++; } From 08f3ecf9350e06b090de8198a2a6cb3d5c91ee8c Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Fri, 24 Feb 2012 01:30:17 -0500 Subject: [PATCH 2/7] Slightly better performance on animation2 --- apps/openmw/mwrender/animation.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 1318710ee..c5b67ffc9 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -466,11 +466,12 @@ namespace MWRender{ } - skel->_updateTransforms(); - base->getAllAnimationStates()->_notifyDirty(); + slot++; } + skel->_updateTransforms(); + base->getAllAnimationStates()->_notifyDirty(); } } From 8d7a5f469b43f0ec1d3e5678867421cd45b78659 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 26 Feb 2012 21:27:54 -0500 Subject: [PATCH 3/7] a few changes --- apps/openmw/mwrender/animation.cpp | 26 +++++++++++++++----------- apps/openmw/mwrender/animation.hpp | 6 ++++-- apps/openmw/mwrender/npcanimation.cpp | 1 + components/nifogre/ogre_nif_loader.cpp | 3 ++- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index c5b67ffc9..c30579b0f 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -276,6 +276,7 @@ namespace MWRender{ rotmult = bonePtr->getOrientation(); scale = bonePtr->getScale().x; boneSequenceIter++; + std::cout << "Entering\n"; for(; boneSequenceIter != boneSequence.end(); boneSequenceIter++) { if(creaturemodel->getSkeleton()->hasBone(*boneSequenceIter)){ @@ -330,7 +331,7 @@ namespace MWRender{ } } - bool Animation::timeIndex( float time, std::vector times, int & i, int & j, float & x ){ + bool Animation::timeIndex( float time, std::vector& times, int & i, int & j, float & x ){ int count; if ( (count = times.size()) > 0 ) { @@ -388,6 +389,8 @@ namespace MWRender{ } void Animation::handleAnimationTransforms(){ + + Ogre::SkeletonInstance* skel = base->getSkeleton(); @@ -404,10 +407,10 @@ namespace MWRender{ for(unsigned int i = 0; i < entityparts.size(); i++){ //Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton(); - Ogre::Bone* b = skel->getRootBone(); - b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick + //Ogre::Bone* b = skel->getRootBone(); + //b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick - entityparts[i]->getAllAnimationStates()->_notifyDirty(); + //entityparts[i]->getAllAnimationStates()->_notifyDirty(); } @@ -424,18 +427,19 @@ namespace MWRender{ float x; float x2; - std::vector quats = iter->getQuat(); + std::vector& quats = iter->getQuat(); - std::vector ttime = iter->gettTime(); - std::vector::iterator ttimeiter = ttime.begin(); + std::vector& ttime = iter->gettTime(); + - std::vector rtime = iter->getrTime(); - int rindexJ = 0; + std::vector& rtime = iter->getrTime(); + int rindexJ = rindexI[slot]; + timeIndex(time, rtime, rindexI[slot], rindexJ, x2); - int tindexJ = 0; + int tindexJ = tindexI[slot]; - std::vector translist1 = iter->getTranslist1(); + std::vector& translist1 = iter->getTranslist1(); timeIndex(time, ttime, tindexI[slot], tindexJ, x); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index bad7eca15..63ca3da2d 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -28,6 +28,8 @@ class Animation{ MWWorld::Environment& mEnvironment; std::map vecRotPos; static std::map mUniqueIDs; + float oldHund; + bool samePlace; std::vector* > shapeparts; //All the NiTriShape data that we need for animating an npc @@ -55,11 +57,11 @@ class Animation{ Ogre::Entity* base; void handleShapes(std::vector* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel); void handleAnimationTransforms(); - bool timeIndex( float time, std::vector times, int & i, int & j, float & x ); + bool timeIndex( float time, std::vector& times, int & i, int & j, float & x ); std::string getUniqueID(std::string mesh); public: - Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env), animate(0){}; + Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env), animate(0), oldHund(0){}; virtual void runAnimation(float timepassed) = 0; void startScript(std::string groupname, int mode, int loops); void stopScript(); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 4c9c0e466..0ceb0a4c3 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -276,6 +276,7 @@ void NpcAnimation::runAnimation(float timepassed){ shapepartsiter++; entitypartsiter++; } + } } diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 8b5540019..62dbc29df 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -1328,7 +1328,8 @@ void NIFLoader::loadResource(Resource *resource) (*iter)->addBoneAssignment(vba); } - mesh->_notifySkeleton(mSkel); + if(triname == "") + mesh->_notifySkeleton(mSkel); } } From 36e93228309b37ccf2019b530148b401e84ed73a Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 26 Feb 2012 21:43:04 -0500 Subject: [PATCH 4/7] a few changes2 --- apps/openmw/mwrender/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index c30579b0f..999d85414 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -276,7 +276,7 @@ namespace MWRender{ rotmult = bonePtr->getOrientation(); scale = bonePtr->getScale().x; boneSequenceIter++; - std::cout << "Entering\n"; + for(; boneSequenceIter != boneSequence.end(); boneSequenceIter++) { if(creaturemodel->getSkeleton()->hasBone(*boneSequenceIter)){ From a81ecb5f659e1d28b37e1d60d09270ef2597fb17 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 3 Mar 2012 18:26:11 -0500 Subject: [PATCH 5/7] Bug 210 fix --- apps/openmw/mwrender/npcanimation.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 0ceb0a4c3..c6fe023d6 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -42,6 +42,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2); bool female = tolower(secondtolast) == 'f'; + std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower); bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; /*std::cout << "Race: " << ref->base->race ; From 9848b6717432883683a34d0f6f2efaaf5bb2711b Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Mon, 5 Mar 2012 17:46:29 -0500 Subject: [PATCH 6/7] Fixing errors --- apps/openmw/mwrender/animation.cpp | 10 +++++----- apps/openmw/mwrender/animation.hpp | 7 +++---- components/nifogre/ogre_nif_loader.cpp | 2 ++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 999d85414..4972654fc 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -331,7 +331,7 @@ namespace MWRender{ } } - bool Animation::timeIndex( float time, std::vector& times, int & i, int & j, float & x ){ + bool Animation::timeIndex( float time, std::vector & times, int & i, int & j, float & x ){ int count; if ( (count = times.size()) > 0 ) { @@ -427,19 +427,19 @@ namespace MWRender{ float x; float x2; - std::vector& quats = iter->getQuat(); + std::vector & quats = iter->getQuat(); - std::vector& ttime = iter->gettTime(); + std::vector & ttime = iter->gettTime(); - std::vector& rtime = iter->getrTime(); + std::vector & rtime = iter->getrTime(); int rindexJ = rindexI[slot]; timeIndex(time, rtime, rindexI[slot], rindexJ, x2); int tindexJ = tindexI[slot]; - std::vector& translist1 = iter->getTranslist1(); + std::vector & translist1 = iter->getTranslist1(); timeIndex(time, ttime, tindexI[slot], tindexJ, x); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 63ca3da2d..8e3f54315 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -28,8 +28,7 @@ class Animation{ MWWorld::Environment& mEnvironment; std::map vecRotPos; static std::map mUniqueIDs; - float oldHund; - bool samePlace; + std::vector* > shapeparts; //All the NiTriShape data that we need for animating an npc @@ -57,11 +56,11 @@ class Animation{ Ogre::Entity* base; void handleShapes(std::vector* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel); void handleAnimationTransforms(); - bool timeIndex( float time, std::vector& times, int & i, int & j, float & x ); + bool timeIndex( float time, std::vector & times, int & i, int & j, float & x ); std::string getUniqueID(std::string mesh); public: - Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env), animate(0), oldHund(0){}; + Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env), animate(0){}; virtual void runAnimation(float timepassed) = 0; void startScript(std::string groupname, int mode, int loops); void stopScript(); diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 62dbc29df..cb626acbe 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -1328,6 +1328,8 @@ void NIFLoader::loadResource(Resource *resource) (*iter)->addBoneAssignment(vba); } + //Don't link on npc parts to eliminate redundant skeletons + //Will have to be changed later slightly for robes/skirts if(triname == "") mesh->_notifySkeleton(mSkel); } From 39ff8d6a01bd0486402aa137bb668dc649860612 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Tue, 6 Mar 2012 18:28:41 -0500 Subject: [PATCH 7/7] Compile error retry --- apps/openmw/mwrender/animation.cpp | 10 +++++----- apps/openmw/mwrender/animation.hpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 4972654fc..9df987dc1 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -331,7 +331,7 @@ namespace MWRender{ } } - bool Animation::timeIndex( float time, std::vector & times, int & i, int & j, float & x ){ + bool Animation::timeIndex( float time, const std::vector & times, int & i, int & j, float & x ){ int count; if ( (count = times.size()) > 0 ) { @@ -427,19 +427,19 @@ namespace MWRender{ float x; float x2; - std::vector & quats = iter->getQuat(); + const std::vector & quats = iter->getQuat(); - std::vector & ttime = iter->gettTime(); + const std::vector & ttime = iter->gettTime(); - std::vector & rtime = iter->getrTime(); + const std::vector & rtime = iter->getrTime(); int rindexJ = rindexI[slot]; timeIndex(time, rtime, rindexI[slot], rindexJ, x2); int tindexJ = tindexI[slot]; - std::vector & translist1 = iter->getTranslist1(); + const std::vector & translist1 = iter->getTranslist1(); timeIndex(time, ttime, tindexI[slot], tindexJ, x); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 8e3f54315..e08b86e8d 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -56,7 +56,7 @@ class Animation{ Ogre::Entity* base; void handleShapes(std::vector* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel); void handleAnimationTransforms(); - bool timeIndex( float time, std::vector & times, int & i, int & j, float & x ); + bool timeIndex( float time, const std::vector & times, int & i, int & j, float & x ); std::string getUniqueID(std::string mesh); public: