1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00
OpenMW/apps/openmw/mwclass/classmodel.hpp
elsid ce263af393
Use existing functions and objects to call correctMeshPath etc
Remove WindowManager wrappers.

It's not safe to use WindowManager in all places and it's not required.
Environment stores resource system providing VFS required to call these
functions. In the case of ObjectPaging it's available from the member variable.
Also ObjectPaging::createChunk may access WindowManager when it's already
destructed when exiting the game because it's destructed before CellPreloader
finishes all background jobs. Engine::mResourceSystem is destructed after all
other systems so it's safe to use it.
2022-06-29 00:58:49 +02:00

30 lines
708 B
C++

#ifndef OPENMW_MWCLASS_CLASSMODEL_H
#define OPENMW_MWCLASS_CLASSMODEL_H
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/livecellref.hpp"
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <string>
namespace MWClass
{
template <class Class>
std::string getClassModel(const MWWorld::ConstPtr& ptr)
{
const MWWorld::LiveCellRef<Class> *ref = ptr.get<Class>();
if (!ref->mBase->mModel.empty())
return Misc::ResourceHelpers::correctMeshPath(ref->mBase->mModel,
MWBase::Environment::get().getResourceSystem()->getVFS());
return {};
}
}
#endif