mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-24 15:11:35 +00:00
Support additional animation sources not only for 2 letter extensions
If extension is not 2 letters length (e.g. not .kf), replacing last 3 last charaters leads to weird results like: "meshes/basicplayer.dae" -> "animations/basicplayer./" According to the doc this should be "animations/basicplayer/".
This commit is contained in:
parent
a6e075499b
commit
5532bc61c1
2 changed files with 19 additions and 10 deletions
|
@ -658,16 +658,24 @@ namespace MWRender
|
||||||
return mKeyframes->mTextKeys;
|
return mKeyframes->mTextKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::loadAllAnimationsInFolder(const std::string& model, const std::string& baseModel)
|
void Animation::loadAdditionalAnimations(VFS::Path::NormalizedView model, const std::string& baseModel)
|
||||||
{
|
{
|
||||||
std::string animationPath = model;
|
constexpr VFS::Path::NormalizedView meshes("meshes/");
|
||||||
if (animationPath.find("meshes") == 0)
|
if (!model.value().starts_with(meshes.value()))
|
||||||
{
|
return;
|
||||||
animationPath.replace(0, 6, "animations");
|
|
||||||
}
|
|
||||||
animationPath.replace(animationPath.size() - 3, 3, "/");
|
|
||||||
|
|
||||||
for (const auto& name : mResourceSystem->getVFS()->getRecursiveDirectoryIterator(animationPath))
|
std::string path(model.value());
|
||||||
|
|
||||||
|
constexpr VFS::Path::NormalizedView animations("animations/");
|
||||||
|
path.replace(0, meshes.value().size(), animations.value());
|
||||||
|
|
||||||
|
const std::string::size_type extensionStart = path.find_last_of(VFS::Path::extensionSeparator);
|
||||||
|
if (extensionStart == std::string::npos)
|
||||||
|
return;
|
||||||
|
|
||||||
|
path.replace(extensionStart, path.size() - extensionStart, "/");
|
||||||
|
|
||||||
|
for (const VFS::Path::Normalized& name : mResourceSystem->getVFS()->getRecursiveDirectoryIterator(path))
|
||||||
{
|
{
|
||||||
if (Misc::getFileExtension(name) == "kf")
|
if (Misc::getFileExtension(name) == "kf")
|
||||||
{
|
{
|
||||||
|
@ -686,7 +694,7 @@ namespace MWRender
|
||||||
addSingleAnimSource(kfname, baseModel);
|
addSingleAnimSource(kfname, baseModel);
|
||||||
|
|
||||||
if (Settings::game().mUseAdditionalAnimSources)
|
if (Settings::game().mUseAdditionalAnimSources)
|
||||||
loadAllAnimationsInFolder(kfname, baseModel);
|
loadAdditionalAnimations(kfname, baseModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Animation::AnimSource> Animation::addSingleAnimSource(
|
std::shared_ptr<Animation::AnimSource> Animation::addSingleAnimSource(
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <components/sceneutil/nodecallback.hpp>
|
#include <components/sceneutil/nodecallback.hpp>
|
||||||
#include <components/sceneutil/textkeymap.hpp>
|
#include <components/sceneutil/textkeymap.hpp>
|
||||||
#include <components/sceneutil/util.hpp>
|
#include <components/sceneutil/util.hpp>
|
||||||
|
#include <components/vfs/pathutil.hpp>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <span>
|
#include <span>
|
||||||
|
@ -281,7 +282,7 @@ namespace MWRender
|
||||||
*/
|
*/
|
||||||
void setObjectRoot(const std::string& model, bool forceskeleton, bool baseonly, bool isCreature);
|
void setObjectRoot(const std::string& model, bool forceskeleton, bool baseonly, bool isCreature);
|
||||||
|
|
||||||
void loadAllAnimationsInFolder(const std::string& model, const std::string& baseModel);
|
void loadAdditionalAnimations(VFS::Path::NormalizedView model, const std::string& baseModel);
|
||||||
|
|
||||||
/** Adds the keyframe controllers in the specified model as a new animation source.
|
/** Adds the keyframe controllers in the specified model as a new animation source.
|
||||||
* @note Later added animation sources have the highest priority when it comes to finding a particular
|
* @note Later added animation sources have the highest priority when it comes to finding a particular
|
||||||
|
|
Loading…
Reference in a new issue