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