mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 21:56:41 +00:00 
			
		
		
		
	Merge branch 'optimizeosgaloops' into 'master'
Optimize osganimation for-loops See merge request OpenMW/openmw!460
This commit is contained in:
		
						commit
						3a10c6ae91
					
				
					 3 changed files with 8 additions and 8 deletions
				
			
		|  | @ -10,7 +10,7 @@ namespace Resource | |||
|         mStartTime(0.0f) | ||||
|     { | ||||
|         const osgAnimation::ChannelList& channels = anim.getChannels(); | ||||
|         for (const osg::ref_ptr<osgAnimation::Channel> channel: channels) | ||||
|         for (const auto& channel: channels) | ||||
|             addChannel(channel.get()->clone()); | ||||
|     } | ||||
| 
 | ||||
|  | @ -31,7 +31,7 @@ namespace Resource | |||
| 
 | ||||
|     bool Animation::update (double time) | ||||
|     { | ||||
|         for (const osg::ref_ptr<osgAnimation::Channel> channel: mChannels) | ||||
|         for (const auto& channel: mChannels) | ||||
|         { | ||||
|             channel->update(time, 1.0f, 0); | ||||
|         } | ||||
|  |  | |||
|  | @ -44,7 +44,7 @@ namespace Resource | |||
|                         std::string loopstop = animationName + std::string(": loop stop"); | ||||
| 
 | ||||
|                         const osgAnimation::ChannelList& channels = animation->getChannels(); | ||||
|                         for (const osg::ref_ptr<osgAnimation::Channel> channel: channels) | ||||
|                         for (const auto& channel: channels) | ||||
|                         { | ||||
|                             mergedAnimationTrack->addChannel(channel.get()->clone()); // is ->clone needed?
 | ||||
|                         } | ||||
|  |  | |||
|  | @ -31,7 +31,7 @@ namespace SceneUtil | |||
|     void LinkVisitor::link(osgAnimation::UpdateMatrixTransform* umt) | ||||
|     { | ||||
|         const osgAnimation::ChannelList& channels = mAnimation->getChannels(); | ||||
|         for (const osg::ref_ptr<osgAnimation::Channel> channel: channels) | ||||
|         for (const auto& channel: channels) | ||||
|         { | ||||
|             const std::string& channelName = channel->getName(); | ||||
|             const std::string& channelTargetName = channel->getTargetName(); | ||||
|  | @ -125,13 +125,13 @@ namespace SceneUtil | |||
|         } | ||||
| 
 | ||||
|         //Find the root transform track in animation
 | ||||
|         for (const osg::ref_ptr<Resource::Animation> mergedAnimationTrack : mMergedAnimationTracks) | ||||
|         for (const auto& mergedAnimationTrack : mMergedAnimationTracks) | ||||
|         { | ||||
|             if (mergedAnimationTrack->getName() != animationName) continue; | ||||
| 
 | ||||
|             const osgAnimation::ChannelList& channels = mergedAnimationTrack->getChannels(); | ||||
| 
 | ||||
|             for (const osg::ref_ptr<osgAnimation::Channel> channel: channels) | ||||
|             for (const auto& channel: channels) | ||||
|             { | ||||
|                 if (channel->getTargetName() != "root" || channel->getName() != "transform") continue; | ||||
| 
 | ||||
|  | @ -150,7 +150,7 @@ namespace SceneUtil | |||
| 
 | ||||
|     void OsgAnimationController::update(float time, std::string animationName) | ||||
|     { | ||||
|         for (const osg::ref_ptr<Resource::Animation> mergedAnimationTrack : mMergedAnimationTracks) | ||||
|         for (const auto& mergedAnimationTrack : mMergedAnimationTracks) | ||||
|         { | ||||
|             if (mergedAnimationTrack->getName() == animationName) mergedAnimationTrack->update(time); | ||||
|         } | ||||
|  | @ -162,7 +162,7 @@ namespace SceneUtil | |||
|         { | ||||
|             if (mNeedToLink) | ||||
|             { | ||||
|                 for (const osg::ref_ptr<Resource::Animation> mergedAnimationTrack : mMergedAnimationTracks) | ||||
|                 for (const auto& mergedAnimationTrack : mMergedAnimationTracks) | ||||
|                 { | ||||
|                     if (!mLinker.valid()) mLinker = new LinkVisitor(); | ||||
|                     mLinker->setAnimation(mergedAnimationTrack); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue