|
|
|
@ -545,9 +545,9 @@ namespace Resource
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
osg::ref_ptr<osg::Node> loadNonNif(
|
|
|
|
|
const std::string& normalizedFilename, std::istream& model, Resource::ImageManager* imageManager)
|
|
|
|
|
VFS::Path::NormalizedView normalizedFilename, std::istream& model, Resource::ImageManager* imageManager)
|
|
|
|
|
{
|
|
|
|
|
auto ext = Misc::getFileExtension(normalizedFilename);
|
|
|
|
|
const std::string_view ext = Misc::getFileExtension(normalizedFilename.value());
|
|
|
|
|
osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension(std::string(ext));
|
|
|
|
|
if (!reader)
|
|
|
|
|
{
|
|
|
|
@ -566,7 +566,7 @@ namespace Resource
|
|
|
|
|
if (ext == "dae")
|
|
|
|
|
options->setOptionString("daeUseSequencedTextureUnits");
|
|
|
|
|
|
|
|
|
|
const std::array<std::uint64_t, 2> fileHash = Files::getHash(normalizedFilename, model);
|
|
|
|
|
const std::array<std::uint64_t, 2> fileHash = Files::getHash(normalizedFilename.value(), model);
|
|
|
|
|
|
|
|
|
|
osgDB::ReaderWriter::ReadResult result = reader->readNode(model, options);
|
|
|
|
|
if (!result.success())
|
|
|
|
@ -721,10 +721,10 @@ namespace Resource
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Node> load(const std::string& normalizedFilename, const VFS::Manager* vfs,
|
|
|
|
|
osg::ref_ptr<osg::Node> load(VFS::Path::NormalizedView normalizedFilename, const VFS::Manager* vfs,
|
|
|
|
|
Resource::ImageManager* imageManager, Resource::NifFileManager* nifFileManager)
|
|
|
|
|
{
|
|
|
|
|
auto ext = Misc::getFileExtension(normalizedFilename);
|
|
|
|
|
const std::string_view ext = Misc::getFileExtension(normalizedFilename.value());
|
|
|
|
|
if (ext == "nif")
|
|
|
|
|
return NifOsg::Loader::load(*nifFileManager->get(normalizedFilename), imageManager);
|
|
|
|
|
else if (ext == "spt")
|
|
|
|
@ -778,12 +778,12 @@ namespace Resource
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool canOptimize(const std::string& filename)
|
|
|
|
|
static bool canOptimize(std::string_view filename)
|
|
|
|
|
{
|
|
|
|
|
size_t slashpos = filename.find_last_of("\\/");
|
|
|
|
|
if (slashpos != std::string::npos && slashpos + 1 < filename.size())
|
|
|
|
|
const std::string_view::size_type slashpos = filename.find_last_of('/');
|
|
|
|
|
if (slashpos != std::string_view::npos && slashpos + 1 < filename.size())
|
|
|
|
|
{
|
|
|
|
|
std::string basename = filename.substr(slashpos + 1);
|
|
|
|
|
const std::string_view basename = filename.substr(slashpos + 1);
|
|
|
|
|
// xmesh.nif can not be optimized because there are keyframes added in post
|
|
|
|
|
if (!basename.empty() && basename[0] == 'x')
|
|
|
|
|
return false;
|
|
|
|
@ -796,7 +796,7 @@ namespace Resource
|
|
|
|
|
|
|
|
|
|
// For spell VFX, DummyXX nodes must remain intact. Not adding those to reservedNames to avoid being overly
|
|
|
|
|
// cautious - instead, decide on filename
|
|
|
|
|
if (filename.find("vfx_pattern") != std::string::npos)
|
|
|
|
|
if (filename.find("vfx_pattern") != std::string_view::npos)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -843,11 +843,12 @@ namespace Resource
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
VFS::Path::Normalized path("meshes/marker_error.****");
|
|
|
|
|
for (const auto meshType : { "nif", "osg", "osgt", "osgb", "osgx", "osg2", "dae" })
|
|
|
|
|
{
|
|
|
|
|
const std::string normalized = "meshes/marker_error." + std::string(meshType);
|
|
|
|
|
if (mVFS->exists(normalized))
|
|
|
|
|
return load(normalized, mVFS, mImageManager, mNifFileManager);
|
|
|
|
|
path.changeExtension(meshType);
|
|
|
|
|
if (mVFS->exists(path))
|
|
|
|
|
return load(path, mVFS, mImageManager, mNifFileManager);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const std::exception& e)
|
|
|
|
@ -869,7 +870,7 @@ namespace Resource
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<const osg::Node> SceneManager::getTemplate(std::string_view name, bool compile)
|
|
|
|
|
{
|
|
|
|
|
std::string normalized = VFS::Path::normalizeFilename(name);
|
|
|
|
|
const VFS::Path::Normalized normalized(name);
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(normalized);
|
|
|
|
|
if (obj)
|
|
|
|
|