mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-29 03:26:38 +00:00 
			
		
		
		
	Add methods to disable and get info for a layer
This commit is contained in:
		
							parent
							
								
									24f1eba902
								
							
						
					
					
						commit
						09fc50948b
					
				
					 2 changed files with 55 additions and 15 deletions
				
			
		|  | @ -225,6 +225,8 @@ void Animation::updateActiveControllers() | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |         if(ctrls == NULL) | ||||||
|  |             continue; | ||||||
| 
 | 
 | ||||||
|         /* Check if any objectlists are active on subsequent layers. Include
 |         /* Check if any objectlists are active on subsequent layers. Include
 | ||||||
|          * those layers if not. |          * those layers if not. | ||||||
|  | @ -239,7 +241,6 @@ void Animation::updateActiveControllers() | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         assert(ctrls != NULL); |  | ||||||
|         std::vector<Ogre::Controller<Ogre::Real> >::const_iterator ctrl(ctrls->begin()); |         std::vector<Ogre::Controller<Ogre::Real> >::const_iterator ctrl(ctrls->begin()); | ||||||
|         for(;ctrl != ctrls->end();ctrl++) |         for(;ctrl != ctrls->end();ctrl++) | ||||||
|         { |         { | ||||||
|  | @ -525,21 +526,9 @@ bool Animation::play(const std::string &groupname, const std::string &start, con | ||||||
| 
 | 
 | ||||||
|     bool movinganim = false; |     bool movinganim = false; | ||||||
|     bool foundanim = false; |     bool foundanim = false; | ||||||
|     if(groupname.empty()) |  | ||||||
|     { |  | ||||||
|         // Do not allow layer 0 to be disabled
 |  | ||||||
|         assert(layeridx != 0); |  | ||||||
| 
 | 
 | ||||||
|         mLayer[layeridx].mGroupName.clear(); |  | ||||||
|         mLayer[layeridx].mTextKeys = NULL; |  | ||||||
|         mLayer[layeridx].mControllers = NULL; |  | ||||||
|         mLayer[layeridx].mLoopCount = 0; |  | ||||||
|         mLayer[layeridx].mPlaying = false; |  | ||||||
| 
 |  | ||||||
|         foundanim = true; |  | ||||||
|     } |  | ||||||
|     /* Look in reverse; last-inserted source has priority. */ |     /* Look in reverse; last-inserted source has priority. */ | ||||||
|     else for(std::vector<ObjectInfo>::reverse_iterator iter(mObjects.rbegin());iter != mObjects.rend();iter++) |     for(std::vector<ObjectInfo>::reverse_iterator iter(mObjects.rbegin());iter != mObjects.rend();iter++) | ||||||
|     { |     { | ||||||
|         NifOgre::ObjectList &objlist = iter->mObjectList; |         NifOgre::ObjectList &objlist = iter->mObjectList; | ||||||
|         if(objlist.mTextKeys.size() == 0) |         if(objlist.mTextKeys.size() == 0) | ||||||
|  | @ -602,6 +591,43 @@ bool Animation::play(const std::string &groupname, const std::string &start, con | ||||||
|     return movinganim; |     return movinganim; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void Animation::disable(size_t layeridx) | ||||||
|  | { | ||||||
|  |     if(mLayer[layeridx].mGroupName.empty()) | ||||||
|  |         return; | ||||||
|  | 
 | ||||||
|  |     for(std::vector<ObjectInfo>::iterator iter(mObjects.begin());iter != mObjects.end();iter++) | ||||||
|  |         iter->mActiveLayers &= ~(1<<layeridx); | ||||||
|  | 
 | ||||||
|  |     mLayer[layeridx].mGroupName.clear(); | ||||||
|  |     mLayer[layeridx].mTextKeys = NULL; | ||||||
|  |     mLayer[layeridx].mControllers = NULL; | ||||||
|  |     mLayer[layeridx].mLoopCount = 0; | ||||||
|  |     mLayer[layeridx].mPlaying = false; | ||||||
|  | 
 | ||||||
|  |     updateActiveControllers(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool Animation::getInfo(size_t layeridx, float *complete, std::string *groupname, std::string *start, std::string *stop) const | ||||||
|  | { | ||||||
|  |     if(mLayer[layeridx].mGroupName.empty()) | ||||||
|  |     { | ||||||
|  |         if(complete) *complete = 0.0f; | ||||||
|  |         if(groupname) *groupname = ""; | ||||||
|  |         if(start) *start = ""; | ||||||
|  |         if(stop) *stop = ""; | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if(complete) *complete = (mLayer[layeridx].mTime - mLayer[layeridx].mStartKey->first) / | ||||||
|  |                              (mLayer[layeridx].mStopKey->first - mLayer[layeridx].mStartKey->first); | ||||||
|  |     if(groupname) *groupname = mLayer[layeridx].mGroupName; | ||||||
|  |     if(start) *start = mLayer[layeridx].mStartKey->second.substr(mLayer[layeridx].mGroupName.size()+2); | ||||||
|  |     if(stop) *stop = mLayer[layeridx].mStopKey->second.substr(mLayer[layeridx].mGroupName.size()+2); | ||||||
|  |     return true; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| Ogre::Vector3 Animation::runAnimation(float duration) | Ogre::Vector3 Animation::runAnimation(float duration) | ||||||
| { | { | ||||||
|     Ogre::Vector3 movement(0.0f); |     Ogre::Vector3 movement(0.0f); | ||||||
|  |  | ||||||
|  | @ -141,8 +141,22 @@ public: | ||||||
|      */ |      */ | ||||||
|     bool play(const std::string &groupname, const std::string &start, const std::string &stop, float startpoint, size_t loops); |     bool play(const std::string &groupname, const std::string &start, const std::string &stop, float startpoint, size_t loops); | ||||||
| 
 | 
 | ||||||
|     virtual Ogre::Vector3 runAnimation(float timepassed); |     /** Stops and removes the animation from the given layer. */ | ||||||
|  |     void disable(size_t layeridx); | ||||||
| 
 | 
 | ||||||
|  |     /** Gets info about the given animation layer.
 | ||||||
|  |      * \param layeridx Layer index to get info about. | ||||||
|  |      * \param complete Stores completion amount (0 = at start key, 0.5 = half way between start and stop keys), etc. | ||||||
|  |      * \param groupname Stores animation group being played. | ||||||
|  |      * \param start Stores the start key | ||||||
|  |      * \param stop Stores the stop key | ||||||
|  |      * \return True if an animation is active on the layer, false otherwise. | ||||||
|  |      */ | ||||||
|  |     bool getInfo(size_t layeridx, float *complete=NULL, std::string *groupname=NULL, std::string *start=NULL, std::string *stop=NULL) const; | ||||||
|  | 
 | ||||||
|  |     virtual Ogre::Vector3 runAnimation(float duration); | ||||||
|  | 
 | ||||||
|  |     /* Returns if there's an animation playing on the given layer. */ | ||||||
|     bool isPlaying(size_t layeridx) const |     bool isPlaying(size_t layeridx) const | ||||||
|     { return mLayer[layeridx].mPlaying; } |     { return mLayer[layeridx].mPlaying; } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue