Merge branch 'models_for_the_model_god' into 'master'

Implement TestModels/T3D

Closes #7058

See merge request OpenMW/openmw!2506
iwyu_full
Alexei Kotov 2 years ago
commit cdd6a8c007

@ -34,6 +34,7 @@
Feature #6979: Add support of loading and displaying LOD assets purely based on their filename extension
Feature #6983: PCVisionBonus script functions
Feature #6995: Localize the "show effect duration" option
Feature #7058: Implement TestModels (T3D) console command
0.48.0
------

@ -484,5 +484,6 @@ op 0x2000321: ReloadLua
op 0x2000322: GetPCVisionBonus
op 0x2000323: SetPCVisionBonus
op 0x2000324: ModPCVisionBonus
op 0x2000325: TestModels, T3D
opcodes 0x2000325-0x3ffffff unused
opcodes 0x2000326-0x3ffffff unused

@ -19,11 +19,28 @@
#include <components/misc/rng.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/esm3/loadacti.hpp>
#include <components/esm3/loadalch.hpp>
#include <components/esm3/loadappa.hpp>
#include <components/esm3/loadarmo.hpp>
#include <components/esm3/loadbody.hpp>
#include <components/esm3/loadbook.hpp>
#include <components/esm3/loadclot.hpp>
#include <components/esm3/loadcont.hpp>
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/loaddoor.hpp>
#include <components/esm3/loadingr.hpp>
#include <components/esm3/loadlevlist.hpp>
#include <components/esm3/loadligh.hpp>
#include <components/esm3/loadlock.hpp>
#include <components/esm3/loadmgef.hpp>
#include <components/esm3/loadmisc.hpp>
#include <components/esm3/loadprob.hpp>
#include <components/esm3/loadrepa.hpp>
#include <components/esm3/loadstat.hpp>
#include <components/esm3/loadweap.hpp>
#include <components/files/conversion.hpp>
#include <components/vfs/manager.hpp>
@ -1580,6 +1597,61 @@ namespace MWScript
}
};
class OpTestModels : public Interpreter::Opcode0
{
template <class T>
void test(int& count) const
{
Resource::SceneManager* sceneManager
= MWBase::Environment::get().getResourceSystem()->getSceneManager();
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
for (const T& record : store.get<T>())
{
MWWorld::ManualRef ref(store, record.mId);
std::string model = ref.getPtr().getClass().getModel(ref.getPtr());
if (!model.empty())
{
sceneManager->getTemplate(model);
++count;
}
}
}
public:
void execute(Interpreter::Runtime& runtime) override
{
Resource::SceneManager* sceneManager
= MWBase::Environment::get().getResourceSystem()->getSceneManager();
double delay = sceneManager->getExpiryDelay();
sceneManager->setExpiryDelay(0.0);
int count = 0;
test<ESM::Activator>(count);
test<ESM::Apparatus>(count);
test<ESM::Armor>(count);
test<ESM::Potion>(count);
test<ESM::BodyPart>(count);
test<ESM::Book>(count);
test<ESM::Clothing>(count);
test<ESM::Container>(count);
test<ESM::Creature>(count);
test<ESM::Door>(count);
test<ESM::Ingredient>(count);
test<ESM::Light>(count);
test<ESM::Lockpick>(count);
test<ESM::Miscellaneous>(count);
test<ESM::Probe>(count);
test<ESM::Repair>(count);
test<ESM::Static>(count);
test<ESM::Weapon>(count);
sceneManager->setExpiryDelay(delay);
std::stringstream message;
message << "Attempted to load models for " << count << " objects. Check the log for details.";
runtime.getContext().report(message.str());
}
};
void installOpcodes(Interpreter::Interpreter& interpreter)
{
interpreter.installSegment5<OpMenuMode>(Compiler::Misc::opcodeMenuMode);
@ -1705,6 +1777,7 @@ namespace MWScript
interpreter.installSegment5<OpToggleRecastMesh>(Compiler::Misc::opcodeToggleRecastMesh);
interpreter.installSegment5<OpHelp>(Compiler::Misc::opcodeHelp);
interpreter.installSegment5<OpReloadLua>(Compiler::Misc::opcodeReloadLua);
interpreter.installSegment5<OpTestModels>(Compiler::Misc::opcodeTestModels);
}
}
}

@ -325,6 +325,8 @@ namespace Compiler
extensions.registerInstruction("togglerecastmesh", "", opcodeToggleRecastMesh);
extensions.registerInstruction("help", "", opcodeHelp);
extensions.registerInstruction("reloadlua", "", opcodeReloadLua);
extensions.registerInstruction("testmodels", "", opcodeTestModels);
extensions.registerInstruction("t3d", "", opcodeTestModels);
}
}

@ -320,6 +320,7 @@ namespace Compiler
const int opcodeStartScriptExplicit = 0x200031d;
const int opcodeHelp = 0x2000320;
const int opcodeReloadLua = 0x2000321;
const int opcodeTestModels = 0x2000325;
}
namespace Sky

@ -60,7 +60,7 @@ namespace Resource
/// How long to keep objects in cache after no longer being referenced.
void setExpiryDelay(double expiryDelay) override { mExpiryDelay = expiryDelay; }
float getExpiryDelay() const { return mExpiryDelay; }
double getExpiryDelay() const { return mExpiryDelay; }
const VFS::Manager* getVFS() const { return mVFS; }

Loading…
Cancel
Save