1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-01 07:09:41 +00:00

Use the pattern according to the esm version

This commit is contained in:
Cédric Mocquillon 2022-09-03 18:50:38 +02:00
parent 160cbfa04e
commit 83ee25711e
10 changed files with 42 additions and 25 deletions

View file

@ -160,6 +160,8 @@ namespace MWBase
virtual const MWWorld::ESMStore& getStore() const = 0; virtual const MWWorld::ESMStore& getStore() const = 0;
virtual const std::vector<int>& getESMVersions() const = 0;
virtual MWWorld::LocalScripts& getLocalScripts() = 0; virtual MWWorld::LocalScripts& getLocalScripts() = 0;
virtual bool hasCellChanged() const = 0; virtual bool hasCellChanged() const = 0;

View file

@ -421,7 +421,8 @@ namespace MWRender
std::map<ESM::RefNum, ESM::CellRef> refs; std::map<ESM::RefNum, ESM::CellRef> refs;
ESM::ReadersCache readers; ESM::ReadersCache readers;
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const auto& world = MWBase::Environment::get().getWorld();
const auto& store = world->getStore();
for (int cellX = startCell.x(); cellX < startCell.x() + size; ++cellX) for (int cellX = startCell.x(); cellX < startCell.x() + size; ++cellX)
{ {
@ -557,7 +558,7 @@ namespace MWRender
if (found != mLODNameCache.end() && found->first == key) if (found != mLODNameCache.end() && found->first == key)
model = found->second; model = found->second;
else else
model = mLODNameCache.insert(found, { key, Misc::ResourceHelpers::getLODMeshName(model, mSceneManager->getVFS(), lod) })->second; model = mLODNameCache.insert(found, { key, Misc::ResourceHelpers::getLODMeshName(world->getESMVersions()[ref.mRefNum.mContentFile], model, mSceneManager->getVFS(), lod) })->second;
} }
osg::ref_ptr<const osg::Node> cnode = mSceneManager->getTemplate(model, false); osg::ref_ptr<const osg::Node> cnode = mSceneManager->getTemplate(model, false);

View file

@ -7,11 +7,12 @@
namespace MWWorld namespace MWWorld
{ {
EsmLoader::EsmLoader(MWWorld::ESMStore& store, ESM::ReadersCache& readers, ToUTF8::Utf8Encoder* encoder) EsmLoader::EsmLoader(MWWorld::ESMStore& store, ESM::ReadersCache& readers, ToUTF8::Utf8Encoder* encoder, std::vector<int>& esmVersions)
: mReaders(readers) : mReaders(readers)
, mStore(store) , mStore(store)
, mEncoder(encoder) , mEncoder(encoder)
, mDialogue(nullptr) // A content file containing INFO records without a DIAL record appends them to the previous file's dialogue , mDialogue(nullptr) // A content file containing INFO records without a DIAL record appends them to the previous file's dialogue
, mESMVersions(esmVersions)
{ {
} }
@ -32,6 +33,7 @@ void EsmLoader::load(const boost::filesystem::path& filepath, int& index, Loadin
+ ", but it is not available or has been loaded in the wrong order. " + ", but it is not available or has been loaded in the wrong order. "
"Please run the launcher to fix this issue."); "Please run the launcher to fix this issue.");
mESMVersions[index] = reader->getVer();
mStore.load(*reader, listener, mDialogue); mStore.load(*reader, listener, mDialogue);
if (!mMasterFileFormat.has_value() && (Misc::StringUtils::ciEndsWith(reader->getName(), ".esm") if (!mMasterFileFormat.has_value() && (Misc::StringUtils::ciEndsWith(reader->getName(), ".esm")

View file

@ -23,7 +23,7 @@ class ESMStore;
struct EsmLoader : public ContentLoader struct EsmLoader : public ContentLoader
{ {
explicit EsmLoader(MWWorld::ESMStore& store, ESM::ReadersCache& readers, ToUTF8::Utf8Encoder* encoder); explicit EsmLoader(MWWorld::ESMStore& store, ESM::ReadersCache& readers, ToUTF8::Utf8Encoder* encoder, std::vector<int>& esmVersions);
std::optional<int> getMasterFileFormat() const { return mMasterFileFormat; } std::optional<int> getMasterFileFormat() const { return mMasterFileFormat; }
@ -35,6 +35,7 @@ struct EsmLoader : public ContentLoader
ToUTF8::Utf8Encoder* mEncoder; ToUTF8::Utf8Encoder* mEncoder;
ESM::Dialogue* mDialogue; ESM::Dialogue* mDialogue;
std::optional<int> mMasterFileFormat; std::optional<int> mMasterFileFormat;
std::vector<int>& mESMVersions;
}; };
} /* namespace MWWorld */ } /* namespace MWWorld */

View file

@ -162,6 +162,7 @@ namespace MWWorld
mLevitationEnabled(true), mGoToJail(false), mDaysInPrison(0), mLevitationEnabled(true), mGoToJail(false), mDaysInPrison(0),
mPlayerTraveling(false), mPlayerInJail(false), mSpellPreloadTimer(0.f) mPlayerTraveling(false), mPlayerInJail(false), mSpellPreloadTimer(0.f)
{ {
mESMVersions.resize(mContentFiles.size(), -1);
Loading::Listener* listener = MWBase::Environment::get().getWindowManager()->getLoadingScreen(); Loading::Listener* listener = MWBase::Environment::get().getWindowManager()->getLoadingScreen();
listener->loadingOn(); listener->loadingOn();
@ -620,6 +621,11 @@ namespace MWWorld
return *mPlayer; return *mPlayer;
} }
const std::vector<int>& World::getESMVersions() const
{
return mESMVersions;
}
const MWWorld::ESMStore& World::getStore() const const MWWorld::ESMStore& World::getStore() const
{ {
return mStore; return mStore;
@ -2933,7 +2939,7 @@ namespace MWWorld
ToUTF8::Utf8Encoder* encoder, Loading::Listener* listener) ToUTF8::Utf8Encoder* encoder, Loading::Listener* listener)
{ {
GameContentLoader gameContentLoader; GameContentLoader gameContentLoader;
EsmLoader esmLoader(mStore, mReaders, encoder); EsmLoader esmLoader(mStore, mReaders, encoder, mESMVersions);
gameContentLoader.addLoader(".esm", esmLoader); gameContentLoader.addLoader(".esm", esmLoader);
gameContentLoader.addLoader(".esp", esmLoader); gameContentLoader.addLoader(".esp", esmLoader);

View file

@ -138,6 +138,8 @@ namespace MWWorld
float mSimulationTimeScale = 1.0; float mSimulationTimeScale = 1.0;
std::vector<int> mESMVersions; //the versions of esm files
// not implemented // not implemented
World (const World&); World (const World&);
World& operator= (const World&); World& operator= (const World&);
@ -249,6 +251,8 @@ namespace MWWorld
const MWWorld::ESMStore& getStore() const override; const MWWorld::ESMStore& getStore() const override;
const std::vector<int>& getESMVersions() const override;
LocalScripts& getLocalScripts() override; LocalScripts& getLocalScripts() override;
bool hasCellChanged() const override; bool hasCellChanged() const override;

View file

@ -4,6 +4,8 @@
#include <string_view> #include <string_view>
#include <algorithm> #include <algorithm>
#include <components/esm/common.hpp>
#include <components/misc/pathhelpers.hpp> #include <components/misc/pathhelpers.hpp>
#include <components/misc/strings/lower.hpp> #include <components/misc/strings/lower.hpp>
#include <components/misc/strings/algorithm.hpp> #include <components/misc/strings/algorithm.hpp>
@ -184,18 +186,29 @@ std::string getBestLODMeshName(std::string const& resPath, const VFS::Manager* v
} }
} }
std::string Misc::ResourceHelpers::getLODMeshName(std::string resPath, const VFS::Manager* vfs, unsigned char lod) std::string Misc::ResourceHelpers::getLODMeshName(int esmVersion, std::string resPath, const VFS::Manager* vfs, unsigned char lod)
{ {
static const std::string distantMeshPattern = Settings::Manager::getString("distant mesh pattern", "Terrain"); const std::string distantMeshPattern = [&esmVersion] {
std::string meshName = getBestLODMeshName(resPath, vfs, distantMeshPattern + "_" + std::to_string(lod)); switch (esmVersion)
if (meshName != resPath) {
return meshName; case ESM::VER_120:
case ESM::VER_130:
return "_dist";
case ESM::VER_080:
case ESM::VER_100:
return "_far";
case ESM::VER_094:
case ESM::VER_170:
return "_lod";
default:
return "";
}
}();
for (char l = lod; l >= 0; --l) for (char l = lod; l >= 0; --l)
{ {
std::stringstream patern; std::stringstream patern;
patern << distantMeshPattern << "_" << int(l); patern << distantMeshPattern << "_" << int(l);
meshName = getBestLODMeshName(resPath, vfs, patern.str()); std::string const meshName = getBestLODMeshName(resPath, vfs, patern.str());
if (meshName != resPath) if (meshName != resPath)
return meshName; return meshName;
} }

View file

@ -30,7 +30,7 @@ namespace Misc
/// marker objects that have a hardcoded function in the game logic, should be hidden from the player /// marker objects that have a hardcoded function in the game logic, should be hidden from the player
bool isHiddenMarker(std::string_view id); bool isHiddenMarker(std::string_view id);
std::string getLODMeshName(std::string resPath, const VFS::Manager* vfs, unsigned char lod = 0); std::string getLODMeshName(int esmVersion, std::string resPath, const VFS::Manager* vfs, unsigned char lod = 0);
} }
} }

View file

@ -205,12 +205,3 @@ object paging min size cost multiplier
This setting adjusts the calculated cost of merging an object used in the mentioned functionality. This setting adjusts the calculated cost of merging an object used in the mentioned functionality.
The larger this value is, the less expensive objects can be before they are discarded. The larger this value is, the less expensive objects can be before they are discarded.
See the formula above to figure out the math. See the formula above to figure out the math.
distant mesh pattern
------------------
:Type: string
:Range:
:Default: _dist
The mesh filename pattern to look for when detecting distant meshes (it will replace original mesh outside active grid)

View file

@ -119,9 +119,6 @@ object paging min size merge factor = 0.3
# Controls how inexpensive an object needs to be to utilize 'min size merge factor'. # Controls how inexpensive an object needs to be to utilize 'min size merge factor'.
object paging min size cost multiplier = 25 object paging min size cost multiplier = 25
# The mesh filename pattern to look for when detecting distant meshes (it will replace original mesh outside active grid)
distant mesh pattern = _dist
[Fog] [Fog]
# If true, use extended fog parameters for distant terrain not controlled by # If true, use extended fog parameters for distant terrain not controlled by