GenericObjectCache stored osg::ref_ptr<osg::Object>, so everything cached had to derive from osg::Object whether that meant anything or not: NifFileHolder and BgsmFileHolder existed for no other reason, Resource::BulletShape and ESMTerrain::LandObject carried META_Object and a CopyOp constructor nothing ever called, and every getter paid a static_cast on the way out. The cache and MultiObjectCache now take their value type as a template parameter, ask "is anything else holding this?" through a useCount overload rather than a base class method, and constrain accept and releaseGLObjects so a value type with neither is not an error. Both holders are deleted; BulletShape, BulletShapeInstance and LandObject become plain classes held by std::shared_ptr across physics, pathfinding, navmeshtool and terrain storage; MWPhysics::HeightField's type-erased osg::Object keep-alive becomes the LandObject it was always holding; every remaining manager names the type it actually caches through the NodeResourceManager alias, which removes eight static_casts and stops clang-format wrapping the declarations. The preloader needs two keep-alive sets for now, because the render-owned entries are still osg::Object; they merge once those move behind the render backend.
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#ifndef MWRENDER_TERRAINSTORAGE_H
|
|
#define MWRENDER_TERRAINSTORAGE_H
|
|
|
|
#include <memory>
|
|
|
|
#include <components/esmterrain/storage.hpp>
|
|
|
|
#include <components/resource/resourcesystem.hpp>
|
|
|
|
namespace MWRender
|
|
{
|
|
|
|
class LandManager;
|
|
|
|
/// @brief Connects the ESM Store used in OpenMW with the ESMTerrain storage.
|
|
class TerrainStorage : public ESMTerrain::Storage
|
|
{
|
|
public:
|
|
TerrainStorage(Resource::ResourceSystem* resourceSystem, std::string_view normalMapPattern = {},
|
|
std::string_view normalHeightMapPattern = {}, bool autoUseNormalMaps = false,
|
|
std::string_view specularMapPattern = {}, bool autoUseSpecularMaps = false);
|
|
~TerrainStorage();
|
|
|
|
std::shared_ptr<const ESMTerrain::LandObject> getLand(ESM::ExteriorCellLocation cellLocation) override;
|
|
const VFS::Path::Normalized* getLandTexture(std::uint16_t index, int plugin) override;
|
|
|
|
const ESM4::LandTexture* getEsm4LandTexture(ESM::RefId ltexId) const override;
|
|
const ESM4::TextureSet* getEsm4TextureSet(ESM::RefId txstId) const override;
|
|
|
|
bool hasData(ESM::ExteriorCellLocation cellLocation) override;
|
|
|
|
/// Get bounds of the whole terrain in cell units
|
|
void getBounds(float& minX, float& maxX, float& minY, float& maxY, ESM::RefId worldspace) override;
|
|
|
|
LandManager* getLandManager() const;
|
|
|
|
private:
|
|
std::unique_ptr<LandManager> mLandManager;
|
|
|
|
Resource::ResourceSystem* mResourceSystem;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|