mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-25 11:26:37 +00:00 
			
		
		
		
	Merge branch 'master' into sdl_input
This commit is contained in:
		
						commit
						d26e33eb26
					
				
					 15 changed files with 80 additions and 72 deletions
				
			
		|  | @ -342,16 +342,13 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) | ||||||
|     // cursor replacer (converts the cursor from the bsa so they can be used by mygui)
 |     // cursor replacer (converts the cursor from the bsa so they can be used by mygui)
 | ||||||
|     MWGui::CursorReplace replacer; |     MWGui::CursorReplace replacer; | ||||||
| 
 | 
 | ||||||
|     // Create encoder
 |  | ||||||
|     ToUTF8::Utf8Encoder encoder (mEncoding); |  | ||||||
| 
 |  | ||||||
|     // Create the world
 |     // Create the world
 | ||||||
|     mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster, |     mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster, | ||||||
|         mResDir, mCfgMgr.getCachePath(), mNewGame, &encoder, mFallbackMap, |         mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoder, mFallbackMap, | ||||||
|         mActivationDistanceOverride)); |         mActivationDistanceOverride)); | ||||||
| 
 | 
 | ||||||
|     //Load translation data
 |     //Load translation data
 | ||||||
|     mTranslationDataStorage.setEncoder(&encoder); |     mTranslationDataStorage.setEncoder(mEncoder); | ||||||
|     mTranslationDataStorage.loadTranslationData(mFileCollections, mMaster); |     mTranslationDataStorage.loadTranslationData(mFileCollections, mMaster); | ||||||
| 
 | 
 | ||||||
|     // Create window manager - this manages all the MW-specific GUI windows
 |     // Create window manager - this manages all the MW-specific GUI windows
 | ||||||
|  | @ -436,6 +433,10 @@ void OMW::Engine::go() | ||||||
| 
 | 
 | ||||||
|     settingspath = loadSettings (settings); |     settingspath = loadSettings (settings); | ||||||
| 
 | 
 | ||||||
|  |     // Create encoder
 | ||||||
|  |     ToUTF8::Utf8Encoder encoder (mEncoding); | ||||||
|  |     mEncoder = &encoder; | ||||||
|  | 
 | ||||||
|     prepareEngine (settings); |     prepareEngine (settings); | ||||||
| 
 | 
 | ||||||
|     // Play some good 'ol tunes
 |     // Play some good 'ol tunes
 | ||||||
|  |  | ||||||
|  | @ -62,6 +62,7 @@ namespace OMW | ||||||
|     { |     { | ||||||
|             MWBase::Environment mEnvironment; |             MWBase::Environment mEnvironment; | ||||||
|             ToUTF8::FromType mEncoding; |             ToUTF8::FromType mEncoding; | ||||||
|  |             ToUTF8::Utf8Encoder* mEncoder; | ||||||
|             Files::PathContainer mDataDirs; |             Files::PathContainer mDataDirs; | ||||||
|             boost::filesystem::path mResDir; |             boost::filesystem::path mResDir; | ||||||
|             OEngine::Render::OgreRenderer *mOgre; |             OEngine::Render::OgreRenderer *mOgre; | ||||||
|  |  | ||||||
|  | @ -440,7 +440,7 @@ namespace MWGui | ||||||
| 
 | 
 | ||||||
|         for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it) |         for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it) | ||||||
|         { |         { | ||||||
|             spellList.push_back(*it); |             spellList.push_back (it->first); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const MWWorld::ESMStore &esmStore = |         const MWWorld::ESMStore &esmStore = | ||||||
|  |  | ||||||
|  | @ -102,7 +102,7 @@ namespace MWGui | ||||||
|         for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter) |         for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter) | ||||||
|         { |         { | ||||||
|             const ESM::Spell* spell = |             const ESM::Spell* spell = | ||||||
|                 MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); |                 MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (iter->first); | ||||||
| 
 | 
 | ||||||
|             if (spell->mData.mType!=ESM::Spell::ST_Spell) |             if (spell->mData.mType!=ESM::Spell::ST_Spell) | ||||||
|                 continue; // don't try to sell diseases, curses or powers
 |                 continue; // don't try to sell diseases, curses or powers
 | ||||||
|  | @ -110,7 +110,7 @@ namespace MWGui | ||||||
|             if (std::find (playerSpells.begin(), playerSpells.end(), *iter)!=playerSpells.end()) |             if (std::find (playerSpells.begin(), playerSpells.end(), *iter)!=playerSpells.end()) | ||||||
|                 continue; // we have that spell already
 |                 continue; // we have that spell already
 | ||||||
| 
 | 
 | ||||||
|             addSpell (*iter); |             addSpell (iter->first); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         updateLabels(); |         updateLabels(); | ||||||
|  |  | ||||||
|  | @ -436,7 +436,7 @@ namespace MWGui | ||||||
|         for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it) |         for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it) | ||||||
|         { |         { | ||||||
|             const ESM::Spell* spell = |             const ESM::Spell* spell = | ||||||
|                 MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(*it); |                 MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (it->first); | ||||||
| 
 | 
 | ||||||
|             // only normal spells count
 |             // only normal spells count
 | ||||||
|             if (spell->mData.mType != ESM::Spell::ST_Spell) |             if (spell->mData.mType != ESM::Spell::ST_Spell) | ||||||
|  |  | ||||||
|  | @ -139,7 +139,7 @@ namespace MWGui | ||||||
| 
 | 
 | ||||||
|         for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it) |         for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it) | ||||||
|         { |         { | ||||||
|             spellList.push_back(*it); |             spellList.push_back (it->first); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const MWWorld::ESMStore &esmStore = |         const MWWorld::ESMStore &esmStore = | ||||||
|  |  | ||||||
|  | @ -68,7 +68,7 @@ namespace MWMechanics | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void MagicEffects::add (const ESM::EffectList& list) |     void MagicEffects::add (const ESM::EffectList& list, float magnitude) | ||||||
|     { |     { | ||||||
|         for (std::vector<ESM::ENAMstruct>::const_iterator iter (list.mList.begin()); iter!=list.mList.end(); |         for (std::vector<ESM::ENAMstruct>::const_iterator iter (list.mList.begin()); iter!=list.mList.end(); | ||||||
|             ++iter) |             ++iter) | ||||||
|  | @ -78,9 +78,13 @@ namespace MWMechanics | ||||||
|             if (iter->mMagnMin>=iter->mMagnMax) |             if (iter->mMagnMin>=iter->mMagnMax) | ||||||
|                 param.mMagnitude = iter->mMagnMin; |                 param.mMagnitude = iter->mMagnMin; | ||||||
|             else |             else | ||||||
|  |             { | ||||||
|  |                 if (magnitude==-1) | ||||||
|  |                     magnitude = static_cast<float> (std::rand()) / RAND_MAX; | ||||||
|  | 
 | ||||||
|                 param.mMagnitude = static_cast<int> ( |                 param.mMagnitude = static_cast<int> ( | ||||||
|                     (iter->mMagnMax-iter->mMagnMin+1)* |                     (iter->mMagnMax-iter->mMagnMin+1)*magnitude + iter->mMagnMin); | ||||||
|                     (static_cast<float> (std::rand()) / RAND_MAX) + iter->mMagnMin); |             } | ||||||
| 
 | 
 | ||||||
|             add (*iter, param); |             add (*iter, param); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -67,7 +67,8 @@ namespace MWMechanics | ||||||
| 
 | 
 | ||||||
|             void add (const EffectKey& key, const EffectParam& param); |             void add (const EffectKey& key, const EffectParam& param); | ||||||
| 
 | 
 | ||||||
|             void add (const ESM::EffectList& list); |             void add (const ESM::EffectList& list, float magnitude = -1); | ||||||
|  |             ///< \param magnitude normalised magnitude (-1: random)
 | ||||||
| 
 | 
 | ||||||
|             MagicEffects& operator+= (const MagicEffects& effects); |             MagicEffects& operator+= (const MagicEffects& effects); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,22 +1,19 @@ | ||||||
| 
 | 
 | ||||||
| #include "spells.hpp" | #include "spells.hpp" | ||||||
| 
 | 
 | ||||||
| #include "../mwworld/esmstore.hpp" | #include <cstdlib> | ||||||
| 
 | 
 | ||||||
| #include <components/esm/loadspel.hpp> | #include <components/esm/loadspel.hpp> | ||||||
| 
 | 
 | ||||||
| #include "../mwbase/environment.hpp" | #include "../mwbase/environment.hpp" | ||||||
| #include "../mwbase/world.hpp" | #include "../mwbase/world.hpp" | ||||||
| 
 | 
 | ||||||
|  | #include "../mwworld/esmstore.hpp" | ||||||
|  | 
 | ||||||
| #include "magiceffects.hpp" | #include "magiceffects.hpp" | ||||||
| 
 | 
 | ||||||
| namespace MWMechanics | namespace MWMechanics | ||||||
| { | { | ||||||
|     void Spells::addSpell (const ESM::Spell *spell, MagicEffects& effects) const |  | ||||||
|     { |  | ||||||
|         effects.add (spell->mEffects); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     Spells::TIterator Spells::begin() const |     Spells::TIterator Spells::begin() const | ||||||
|     { |     { | ||||||
|         return mSpells.begin(); |         return mSpells.begin(); | ||||||
|  | @ -29,13 +26,13 @@ namespace MWMechanics | ||||||
| 
 | 
 | ||||||
|     void Spells::add (const std::string& spellId) |     void Spells::add (const std::string& spellId) | ||||||
|     { |     { | ||||||
|         if (std::find (mSpells.begin(), mSpells.end(), spellId)==mSpells.end()) |         if (mSpells.find (spellId)==mSpells.end()) | ||||||
|             mSpells.push_back (spellId); |             mSpells.insert (std::make_pair (spellId, static_cast<float> (std::rand()) / RAND_MAX)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void Spells::remove (const std::string& spellId) |     void Spells::remove (const std::string& spellId) | ||||||
|     { |     { | ||||||
|         TContainer::iterator iter = std::find (mSpells.begin(), mSpells.end(), spellId); |         TContainer::iterator iter = mSpells.find (spellId); | ||||||
| 
 | 
 | ||||||
|         if (iter!=mSpells.end()) |         if (iter!=mSpells.end()) | ||||||
|             mSpells.erase (iter); |             mSpells.erase (iter); | ||||||
|  | @ -51,11 +48,11 @@ namespace MWMechanics | ||||||
|         for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) |         for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) | ||||||
|         { |         { | ||||||
|             const ESM::Spell *spell = |             const ESM::Spell *spell = | ||||||
|                 MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); |                 MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (iter->first); | ||||||
| 
 | 
 | ||||||
|             if (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight || |             if (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight || | ||||||
|                 spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse) |                 spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse) | ||||||
|                 addSpell (spell, effects); |                 effects.add (spell->mEffects, iter->second); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return effects; |         return effects; | ||||||
|  | @ -81,7 +78,7 @@ namespace MWMechanics | ||||||
|         for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) |         for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) | ||||||
|         { |         { | ||||||
|             const ESM::Spell *spell = |             const ESM::Spell *spell = | ||||||
|                 MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); |                 MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (iter->first); | ||||||
| 
 | 
 | ||||||
|             if (spell->mData.mFlags & ESM::Spell::ST_Disease) |             if (spell->mData.mFlags & ESM::Spell::ST_Disease) | ||||||
|                 return true; |                 return true; | ||||||
|  | @ -95,7 +92,7 @@ namespace MWMechanics | ||||||
|         for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) |         for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) | ||||||
|         { |         { | ||||||
|             const ESM::Spell *spell = |             const ESM::Spell *spell = | ||||||
|                 MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); |                 MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (iter->first); | ||||||
| 
 | 
 | ||||||
|             if (spell->mData.mFlags & ESM::Spell::ST_Blight) |             if (spell->mData.mFlags & ESM::Spell::ST_Blight) | ||||||
|                 return true; |                 return true; | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #ifndef GAME_MWMECHANICS_SPELLS_H | #ifndef GAME_MWMECHANICS_SPELLS_H | ||||||
| #define GAME_MWMECHANICS_SPELLS_H | #define GAME_MWMECHANICS_SPELLS_H | ||||||
| 
 | 
 | ||||||
| #include <vector> | #include <map> | ||||||
| #include <string> | #include <string> | ||||||
| 
 | 
 | ||||||
| namespace ESM | namespace ESM | ||||||
|  | @ -21,16 +21,14 @@ namespace MWMechanics | ||||||
|     { |     { | ||||||
|         public: |         public: | ||||||
| 
 | 
 | ||||||
|             typedef std::vector<std::string> TContainer; |             typedef std::map<std::string, float> TContainer; // ID, normalised magnitude
 | ||||||
|             typedef TContainer::const_iterator TIterator; |             typedef TContainer::const_iterator TIterator; | ||||||
| 
 | 
 | ||||||
|         private: |         private: | ||||||
| 
 | 
 | ||||||
|             std::vector<std::string> mSpells; |             TContainer mSpells; | ||||||
|             std::string mSelectedSpell; |             std::string mSelectedSpell; | ||||||
| 
 | 
 | ||||||
|             void addSpell (const ESM::Spell *, MagicEffects& effects) const; |  | ||||||
| 
 |  | ||||||
|         public: |         public: | ||||||
| 
 | 
 | ||||||
|             TIterator begin() const; |             TIterator begin() const; | ||||||
|  |  | ||||||
|  | @ -485,7 +485,7 @@ namespace MWScript | ||||||
|                     for (MWMechanics::Spells::TIterator iter ( |                     for (MWMechanics::Spells::TIterator iter ( | ||||||
|                         MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().begin()); |                         MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().begin()); | ||||||
|                         iter!=MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().end(); ++iter) |                         iter!=MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().end(); ++iter) | ||||||
|                         if (*iter==id) |                         if (iter->first==id) | ||||||
|                         { |                         { | ||||||
|                             value = 1; |                             value = 1; | ||||||
|                             break; |                             break; | ||||||
|  |  | ||||||
|  | @ -39,9 +39,8 @@ | ||||||
| //#include <boost/mutex.hpp>
 | //#include <boost/mutex.hpp>
 | ||||||
| //#include <boost/thread/locks.hpp>
 | //#include <boost/thread/locks.hpp>
 | ||||||
| 
 | 
 | ||||||
| using namespace std; | namespace Nif | ||||||
| using namespace Nif; | { | ||||||
| using namespace Misc; |  | ||||||
| 
 | 
 | ||||||
| class NIFFile::LoadedCache | class NIFFile::LoadedCache | ||||||
| { | { | ||||||
|  | @ -177,6 +176,8 @@ NIFFile::NIFFile(const std::string &name, psudo_private_modifier) | ||||||
| { | { | ||||||
|     inp = Ogre::ResourceGroupManager::getSingleton().openResource(name); |     inp = Ogre::ResourceGroupManager::getSingleton().openResource(name); | ||||||
|     parse(); |     parse(); | ||||||
|  |     // Make sure to close the file after it was loaded into memory
 | ||||||
|  |     inp.setNull(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| NIFFile::~NIFFile() | NIFFile::~NIFFile() | ||||||
|  | @ -205,7 +206,7 @@ void NIFFile::parse() | ||||||
|     fail("Unsupported NIF version"); |     fail("Unsupported NIF version"); | ||||||
| 
 | 
 | ||||||
|   // Number of records
 |   // Number of records
 | ||||||
|   int recNum = getInt(); |   size_t recNum = getInt(); | ||||||
|   records.resize(recNum); |   records.resize(recNum); | ||||||
| 
 | 
 | ||||||
|   /* The format for 10.0.1.0 seems to be a bit different. After the
 |   /* The format for 10.0.1.0 seems to be a bit different. After the
 | ||||||
|  | @ -217,7 +218,7 @@ void NIFFile::parse() | ||||||
|      we do not support or plan to support other versions yet. |      we do not support or plan to support other versions yet. | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
|   for(int i=0;i<recNum;i++) |   for(size_t i = 0;i < recNum;i++) | ||||||
|     { |     { | ||||||
|       std::string rec = getString(); |       std::string rec = getString(); | ||||||
|       //cout << i << ": " << rec.toString() << endl;
 |       //cout << i << ": " << rec.toString() << endl;
 | ||||||
|  | @ -309,6 +310,7 @@ void NIFFile::parse() | ||||||
|       assert(r != NULL); |       assert(r != NULL); | ||||||
|       assert(r->recType != RC_MISSING); |       assert(r->recType != RC_MISSING); | ||||||
|       r->recName = rec; |       r->recName = rec; | ||||||
|  |       r->recIndex = i; | ||||||
|       records[i] = r; |       records[i] = r; | ||||||
|       r->read(this); |       r->read(this); | ||||||
| 
 | 
 | ||||||
|  | @ -327,11 +329,8 @@ void NIFFile::parse() | ||||||
|      tree, but for the moment we ignore it. |      tree, but for the moment we ignore it. | ||||||
|    */ |    */ | ||||||
| 
 | 
 | ||||||
|   // TODO: Set up kf file here first, if applicable. It needs its own
 |  | ||||||
|   // code to link it up with the main NIF structure.
 |  | ||||||
| 
 |  | ||||||
|   // Once parsing is done, do post-processing.
 |   // Once parsing is done, do post-processing.
 | ||||||
|   for(int i=0; i<recNum; i++) |   for(size_t i=0; i<recNum; i++) | ||||||
|     records[i]->post(this); |     records[i]->post(this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -373,3 +372,5 @@ Ogre::Matrix4 Node::getWorldTransform() const | ||||||
|         return parent->getWorldTransform() * getLocalTransform(); |         return parent->getWorldTransform() * getLocalTransform(); | ||||||
|     return getLocalTransform(); |     return getLocalTransform(); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -146,7 +146,7 @@ public: | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// Number of records
 |     /// Number of records
 | ||||||
|     int numRecords() { return records.size(); } |     size_t numRecords() { return records.size(); } | ||||||
| 
 | 
 | ||||||
|     /*************************************************
 |     /*************************************************
 | ||||||
|                Parser functions |                Parser functions | ||||||
|  |  | ||||||
|  | @ -91,8 +91,9 @@ struct Record | ||||||
|     // Record type and type name
 |     // Record type and type name
 | ||||||
|     int recType; |     int recType; | ||||||
|     std::string recName; |     std::string recName; | ||||||
|  |     size_t recIndex; | ||||||
| 
 | 
 | ||||||
|     Record() : recType(RC_MISSING) {} |     Record() : recType(RC_MISSING), recIndex(~(size_t)0) {} | ||||||
| 
 | 
 | ||||||
|     /// Parses the record from file
 |     /// Parses the record from file
 | ||||||
|     virtual void read(NIFFile *nif) = 0; |     virtual void read(NIFFile *nif) = 0; | ||||||
|  |  | ||||||
|  | @ -695,9 +695,10 @@ class NIFMeshLoader : Ogre::ManualResourceLoader | ||||||
| { | { | ||||||
|     std::string mName; |     std::string mName; | ||||||
|     std::string mGroup; |     std::string mGroup; | ||||||
|     std::string mShapeName; |     size_t mShapeIndex; | ||||||
|     std::string mMaterialName; |  | ||||||
|     std::string mSkelName; |     std::string mSkelName; | ||||||
|  |     std::string mMaterialName; | ||||||
|  |     std::string mShapeName; | ||||||
| 
 | 
 | ||||||
|     void warn(const std::string &msg) |     void warn(const std::string &msg) | ||||||
|     { |     { | ||||||
|  | @ -805,7 +806,8 @@ class NIFMeshLoader : Ogre::ManualResourceLoader | ||||||
|         Ogre::VertexDeclaration *decl; |         Ogre::VertexDeclaration *decl; | ||||||
|         int nextBuf = 0; |         int nextBuf = 0; | ||||||
| 
 | 
 | ||||||
|         Ogre::SubMesh *sub = mesh->createSubMesh(shape->name); |         Ogre::SubMesh *sub = ((mShapeName.length() > 0) ? mesh->createSubMesh(mShapeName) : | ||||||
|  |                                                           mesh->createSubMesh()); | ||||||
| 
 | 
 | ||||||
|         // Add vertices
 |         // Add vertices
 | ||||||
|         sub->useSharedVertices = false; |         sub->useSharedVertices = false; | ||||||
|  | @ -912,13 +914,13 @@ class NIFMeshLoader : Ogre::ManualResourceLoader | ||||||
| 
 | 
 | ||||||
|     bool findTriShape(Ogre::Mesh *mesh, Nif::Node const *node) |     bool findTriShape(Ogre::Mesh *mesh, Nif::Node const *node) | ||||||
|     { |     { | ||||||
|         if(node->recType == Nif::RC_NiTriShape && mShapeName == node->name) |         if(node->recType == Nif::RC_NiTriShape && mShapeIndex == node->recIndex) | ||||||
|         { |         { | ||||||
|             handleNiTriShape(mesh, dynamic_cast<Nif::NiTriShape const *>(node)); |             handleNiTriShape(mesh, dynamic_cast<const Nif::NiTriShape*>(node)); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         Nif::NiNode const *ninode = dynamic_cast<Nif::NiNode const *>(node); |         const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(node); | ||||||
|         if(ninode) |         if(ninode) | ||||||
|         { |         { | ||||||
|             Nif::NodeList const &children = ninode->children; |             Nif::NodeList const &children = ninode->children; | ||||||
|  | @ -942,7 +944,7 @@ public: | ||||||
|     NIFMeshLoader() |     NIFMeshLoader() | ||||||
|     { } |     { } | ||||||
|     NIFMeshLoader(const std::string &name, const std::string &group, const std::string skelName) |     NIFMeshLoader(const std::string &name, const std::string &group, const std::string skelName) | ||||||
|       : mName(name), mGroup(group), mSkelName(skelName) |       : mName(name), mGroup(group), mShapeIndex(~(size_t)0), mSkelName(skelName) | ||||||
|     { } |     { } | ||||||
| 
 | 
 | ||||||
|     virtual void loadResource(Ogre::Resource *resource) |     virtual void loadResource(Ogre::Resource *resource) | ||||||
|  | @ -950,15 +952,14 @@ public: | ||||||
|         Ogre::Mesh *mesh = dynamic_cast<Ogre::Mesh*>(resource); |         Ogre::Mesh *mesh = dynamic_cast<Ogre::Mesh*>(resource); | ||||||
|         assert(mesh && "Attempting to load a mesh into a non-mesh resource!"); |         assert(mesh && "Attempting to load a mesh into a non-mesh resource!"); | ||||||
| 
 | 
 | ||||||
|         if(!mShapeName.length()) |         Nif::NIFFile::ptr nif = Nif::NIFFile::create(mName); | ||||||
|  |         if(mShapeIndex >= nif->numRecords()) | ||||||
|         { |         { | ||||||
|             if(mSkelName.length() > 0) |             mesh->setSkeletonName(mSkelName); | ||||||
|                 mesh->setSkeletonName(mSkelName); |  | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         Nif::NIFFile::ptr nif = Nif::NIFFile::create (mName); |         Nif::Node const *node = dynamic_cast<const Nif::Node*>(nif->getRecord(mShapeIndex)); | ||||||
|         Nif::Node const *node = dynamic_cast<Nif::Node const *>(nif->getRecord(0)); |  | ||||||
|         findTriShape(mesh, node); |         findTriShape(mesh, node); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -999,9 +1000,12 @@ public: | ||||||
|         if(node->recType == Nif::RC_NiTriShape) |         if(node->recType == Nif::RC_NiTriShape) | ||||||
|         { |         { | ||||||
|             const Nif::NiTriShape *shape = dynamic_cast<const Nif::NiTriShape*>(node); |             const Nif::NiTriShape *shape = dynamic_cast<const Nif::NiTriShape*>(node); | ||||||
|  |             mShapeName = shape->name; | ||||||
| 
 | 
 | ||||||
|             Ogre::MeshManager &meshMgr = Ogre::MeshManager::getSingleton(); |             Ogre::MeshManager &meshMgr = Ogre::MeshManager::getSingleton(); | ||||||
|             std::string fullname = mName+"@shape="+shape->name; |             std::string fullname = mName+"@index="+Ogre::StringConverter::toString(shape->recIndex); | ||||||
|  |             if(mShapeName.length() > 0) | ||||||
|  |                 fullname += "@shape="+mShapeName; | ||||||
|             if(mSkelName.length() > 0 && mName != mSkelName) |             if(mSkelName.length() > 0 && mName != mSkelName) | ||||||
|                 fullname += "@skel="+mSkelName; |                 fullname += "@skel="+mSkelName; | ||||||
| 
 | 
 | ||||||
|  | @ -1013,7 +1017,7 @@ public: | ||||||
|                 *loader = *this; |                 *loader = *this; | ||||||
|                 if(!(flags&0x01)) // Not hidden
 |                 if(!(flags&0x01)) // Not hidden
 | ||||||
|                 { |                 { | ||||||
|                     loader->mShapeName = shape->name; |                     loader->mShapeIndex = shape->recIndex; | ||||||
|                     loader->mMaterialName = NIFMaterialLoader::getMaterial(shape, fullname, mGroup); |                     loader->mMaterialName = NIFMaterialLoader::getMaterial(shape, fullname, mGroup); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue