Don't duplicate getFileExtension, use OpenMW's namespaces

pull/593/head
Nelsson Huotari 4 years ago
parent 08dcbe30b3
commit 55dcc6582a

@ -14,7 +14,7 @@
#include "objectcache.hpp"
#include "scenemanager.hpp"
namespace OsgAOpenMW
namespace Resource
{
RetrieveAnimationsVisitor::RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target, osg::ref_ptr<osgAnimation::BasicAnimationManager> animationManager) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), mTarget(target), mAnimationManager(animationManager) {}
@ -23,9 +23,9 @@ namespace OsgAOpenMW
{
if (node.libraryName() == std::string("osgAnimation") && node.className() == std::string("Bone") && node.getName() == std::string("root"))
{
osg::ref_ptr<OsgaController::KeyframeController> callback = new OsgaController::KeyframeController();
osg::ref_ptr<SceneUtil::OsgAnimationController> callback = new SceneUtil::OsgAnimationController();
std::vector<OsgaController::EmulatedAnimation> emulatedAnimations;
std::vector<SceneUtil::EmulatedAnimation> emulatedAnimations;
for (auto animation : mAnimationManager->getAnimationList())
{
@ -63,7 +63,7 @@ namespace OsgAOpenMW
mTarget.mTextKeys.emplace(startTime, std::move(loopstart));
mTarget.mTextKeys.emplace(stopTime, std::move(loopstop));
OsgaController::EmulatedAnimation emulatedAnimation;
SceneUtil::EmulatedAnimation emulatedAnimation;
emulatedAnimation.mStartTime = startTime;
emulatedAnimation.mStopTime = stopTime;
emulatedAnimation.mName = animationName;
@ -76,14 +76,6 @@ namespace OsgAOpenMW
traverse(node);
}
std::string getFileExtension(const std::string& file)
{
size_t extPos = file.find_last_of('.');
if (extPos != std::string::npos && extPos+1 < file.size())
return file.substr(extPos+1);
return std::string();
}
}
namespace Resource
@ -110,7 +102,7 @@ namespace Resource
else
{
osg::ref_ptr<SceneUtil::KeyframeHolder> loaded (new SceneUtil::KeyframeHolder);
std::string ext = OsgAOpenMW::getFileExtension(normalized);
std::string ext = Resource::getFileExtension(normalized);
if (ext == "kf")
{
NifOsg::Loader::loadKf(Nif::NIFFilePtr(new Nif::NIFFile(mVFS->getNormalized(normalized), normalized)), *loaded.get());
@ -121,7 +113,7 @@ namespace Resource
osg::ref_ptr<osgAnimation::BasicAnimationManager> bam = dynamic_cast<osgAnimation::BasicAnimationManager*> (scene->getUpdateCallback());
if (bam)
{
OsgAOpenMW::RetrieveAnimationsVisitor rav(*loaded.get(), bam);
Resource::RetrieveAnimationsVisitor rav(*loaded.get(), bam);
scene->accept(rav);
}
}

@ -9,7 +9,7 @@
#include "resourcemanager.hpp"
namespace OsgAOpenMW
namespace Resource
{
/// @brief extract animations to OpenMW's animation system
class RetrieveAnimationsVisitor : public osg::NodeVisitor
@ -24,8 +24,6 @@ namespace OsgAOpenMW
osg::ref_ptr<osgAnimation::BasicAnimationManager> mAnimationManager;
};
std::string getFileExtension(const std::string& file);
}
namespace Resource

@ -338,17 +338,9 @@ namespace Resource
Resource::ImageManager* mImageManager;
};
std::string getFileExtension(const std::string& file)
{
size_t extPos = file.find_last_of('.');
if (extPos != std::string::npos && extPos+1 < file.size())
return file.substr(extPos+1);
return std::string();
}
osg::ref_ptr<osg::Node> load (Files::IStreamPtr file, const std::string& normalizedFilename, Resource::ImageManager* imageManager, Resource::NifFileManager* nifFileManager)
{
std::string ext = getFileExtension(normalizedFilename);
std::string ext = Resource::getFileExtension(normalizedFilename);
if (ext == "nif")
return NifOsg::Loader::load(nifFileManager->get(normalizedFilename), imageManager);
else
@ -780,4 +772,11 @@ namespace Resource
return shaderVisitor;
}
std::string getFileExtension(const std::string& file)
{
size_t extPos = file.find_last_of('.');
if (extPos != std::string::npos && extPos+1 < file.size())
return file.substr(extPos+1);
return std::string();
}
}

@ -181,6 +181,7 @@ namespace Resource
void operator = (const SceneManager&);
};
std::string getFileExtension(const std::string& file);
}
#endif

@ -21,7 +21,7 @@
#include <components/sceneutil/controller.hpp>
#include <components/sceneutil/keyframe.hpp>
namespace OsgaController
namespace SceneUtil
{
LinkVisitor::LinkVisitor() : osg::NodeVisitor( TRAVERSE_ALL_CHILDREN )
{
@ -101,14 +101,14 @@ namespace OsgaController
apply(static_cast<osg::Node&>(node));
}
KeyframeController::KeyframeController(const KeyframeController &copy, const osg::CopyOp &copyop) : SceneUtil::KeyframeController(copy, copyop)
OsgAnimationController::OsgAnimationController(const OsgAnimationController &copy, const osg::CopyOp &copyop) : SceneUtil::KeyframeController(copy, copyop)
, mMergedAnimationTracks(copy.mMergedAnimationTracks)
, mEmulatedAnimations(copy.mEmulatedAnimations)
{
mLinker = nullptr;
}
osg::Vec3f KeyframeController::getTranslation(float time) const
osg::Vec3f OsgAnimationController::getTranslation(float time) const
{
osg::Vec3f translationValue;
std::string animationName;
@ -148,7 +148,7 @@ namespace OsgaController
return osg::Vec3f();
}
void KeyframeController::update(float time, std::string animationName)
void OsgAnimationController::update(float time, std::string animationName)
{
for (const osg::ref_ptr<Resource::Animation> mergedAnimationTrack : mMergedAnimationTracks)
{
@ -156,7 +156,7 @@ namespace OsgaController
}
}
void KeyframeController::operator() (osg::Node* node, osg::NodeVisitor* nv)
void OsgAnimationController::operator() (osg::Node* node, osg::NodeVisitor* nv)
{
if (hasInput())
{
@ -185,12 +185,12 @@ namespace OsgaController
traverse(node, nv);
}
void KeyframeController::setEmulatedAnimations(std::vector<EmulatedAnimation> emulatedAnimations)
void OsgAnimationController::setEmulatedAnimations(std::vector<EmulatedAnimation> emulatedAnimations)
{
mEmulatedAnimations = emulatedAnimations;
}
void KeyframeController::addMergedAnimationTrack(osg::ref_ptr<Resource::Animation> animationTrack)
void OsgAnimationController::addMergedAnimationTrack(osg::ref_ptr<Resource::Animation> animationTrack)
{
mMergedAnimationTracks.emplace_back(animationTrack);
}

@ -16,7 +16,7 @@
#include <components/sceneutil/keyframe.hpp>
#include <components/resource/animation.hpp>
namespace OsgaController
namespace SceneUtil
{
struct EmulatedAnimation
{
@ -44,15 +44,15 @@ namespace OsgaController
Resource::Animation* mAnimation;
};
class KeyframeController : public SceneUtil::KeyframeController
class OsgAnimationController : public SceneUtil::KeyframeController
{
public:
/// @brief Handles the animation for osgAnimation formats
KeyframeController() {};
OsgAnimationController() {};
KeyframeController(const KeyframeController& copy, const osg::CopyOp& copyop);
OsgAnimationController(const OsgAnimationController& copy, const osg::CopyOp& copyop);
META_Object(OsgaController, KeyframeController)
META_Object(SceneUtil, OsgAnimationController)
/// @brief Handles the location of the instance
osg::Vec3f getTranslation(float time) const override;

Loading…
Cancel
Save