mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-29 21:45:33 +00:00
Reduce include dependency for land records
This commit is contained in:
parent
53c3f95ac8
commit
bda29819cf
10 changed files with 90 additions and 48 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <components/sceneutil/workqueue.hpp>
|
||||
|
||||
#include <components/esm3/globalmap.hpp>
|
||||
#include <components/esm3/loadland.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "terrainstorage.hpp"
|
||||
|
||||
#include <components/esm3/loadland.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm3/loadcell.hpp>
|
||||
#include <components/loadinglistener/reporter.hpp>
|
||||
#include <components/misc/constants.hpp>
|
||||
#include <components/misc/resourcehelpers.hpp>
|
||||
#include <components/misc/strings/lower.hpp>
|
||||
#include <components/resource/bulletshapemanager.hpp>
|
||||
|
@ -394,7 +395,7 @@ namespace MWWorld
|
|||
|
||||
void CellPreloader::abortTerrainPreloadExcept(const CellPreloader::PositionCellGrid* exceptPos)
|
||||
{
|
||||
if (exceptPos && contains(mTerrainPreloadPositions, std::array{ *exceptPos }, ESM::Land::REAL_SIZE))
|
||||
if (exceptPos && contains(mTerrainPreloadPositions, std::array{ *exceptPos }, Constants::CellSizeInUnits))
|
||||
return;
|
||||
if (mTerrainPreloadItem && !mTerrainPreloadItem->isDone())
|
||||
{
|
||||
|
@ -437,7 +438,7 @@ namespace MWWorld
|
|||
bool CellPreloader::isTerrainLoaded(const CellPreloader::PositionCellGrid& position, double referenceTime) const
|
||||
{
|
||||
return mLoadedTerrainTimestamp + mResourceSystem->getSceneManager()->getExpiryDelay() > referenceTime
|
||||
&& contains(mLoadedTerrainPositions, std::array{ position }, ESM::Land::REAL_SIZE);
|
||||
&& contains(mLoadedTerrainPositions, std::array{ position }, Constants::CellSizeInUnits);
|
||||
}
|
||||
|
||||
void CellPreloader::setTerrain(Terrain::World* terrain)
|
||||
|
|
|
@ -37,11 +37,6 @@ namespace ESM
|
|||
class ESMWriter;
|
||||
}
|
||||
|
||||
namespace ESM4
|
||||
{
|
||||
struct Land;
|
||||
}
|
||||
|
||||
namespace Loading
|
||||
{
|
||||
class Listener;
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
#include <components/misc/constants.hpp>
|
||||
|
||||
#include "esmterrain.hpp"
|
||||
|
||||
#include <components/esm3/loadland.hpp>
|
||||
#include <components/esm4/loadland.hpp>
|
||||
#include <components/misc/constants.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr std::uint16_t textures[ESM::Land::LAND_NUM_TEXTURES]{ 0 };
|
||||
constexpr std::uint16_t textures[ESM::LandRecordData::sLandNumTextures]{ 0 };
|
||||
|
||||
std::unique_ptr<const ESM::Land::LandData> loadData(const ESM::Land& land, int loadFlags)
|
||||
std::unique_ptr<const ESM::LandRecordData> loadData(const ESM::Land& land, int loadFlags)
|
||||
{
|
||||
std::unique_ptr<ESM::Land::LandData> result = std::make_unique<ESM::Land::LandData>();
|
||||
std::unique_ptr<ESM::LandRecordData> result = std::make_unique<ESM::LandRecordData>();
|
||||
land.loadData(loadFlags, *result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
LandData::LandData() = default;
|
||||
}
|
||||
|
||||
ESM::LandData::LandData(const ESM::Land& land, int loadFlags)
|
||||
: mData(loadData(land, loadFlags))
|
||||
, mLoadFlags(mData->mDataLoaded)
|
||||
|
@ -63,3 +70,8 @@ ESM::LandData::LandData(const ESM4::Land& land, int /*loadFlags*/)
|
|||
|
||||
mHeights = mHeightsData;
|
||||
}
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
LandData::~LandData() = default;
|
||||
}
|
||||
|
|
|
@ -6,19 +6,25 @@
|
|||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
#include <components/esm3/loadland.hpp>
|
||||
#include <components/esm4/loadland.hpp>
|
||||
namespace ESM4
|
||||
{
|
||||
struct Land;
|
||||
}
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct Land;
|
||||
struct LandRecordData;
|
||||
|
||||
class LandData
|
||||
{
|
||||
public:
|
||||
~LandData() = default;
|
||||
LandData() = default;
|
||||
LandData();
|
||||
LandData(const ESM::Land& Land, int loadFlags);
|
||||
LandData(const ESM4::Land& Land, int loadFlags);
|
||||
|
||||
~LandData();
|
||||
|
||||
std::span<const float> getHeights() const { return mHeights; }
|
||||
std::span<const std::int8_t> getNormals() const { return mNormals; }
|
||||
std::span<const std::uint8_t> getColors() const { return mColors; }
|
||||
|
@ -31,7 +37,7 @@ namespace ESM
|
|||
int getPlugin() const { return mPlugin; }
|
||||
|
||||
private:
|
||||
std::unique_ptr<const ESM::Land::LandData> mData;
|
||||
std::unique_ptr<const ESM::LandRecordData> mData;
|
||||
int mLoadFlags = 0;
|
||||
std::vector<float> mHeightsData;
|
||||
float mMinHeight = 0.f;
|
||||
|
|
48
components/esm3/landrecorddata.hpp
Normal file
48
components/esm3/landrecorddata.hpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#ifndef OPENMW_COMPONENTS_ESM3_LANDRECORDDATA_H
|
||||
#define OPENMW_COMPONENTS_ESM3_LANDRECORDDATA_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct LandRecordData
|
||||
{
|
||||
// number of vertices per side
|
||||
static constexpr unsigned sLandSize = 65;
|
||||
|
||||
// total number of vertices
|
||||
static constexpr unsigned sLandNumVerts = sLandSize * sLandSize;
|
||||
|
||||
// number of textures per side of land
|
||||
static constexpr unsigned sLandTextureSize = 16;
|
||||
|
||||
// total number of textures per land
|
||||
static constexpr unsigned sLandNumTextures = sLandTextureSize * sLandTextureSize;
|
||||
|
||||
// Initial reference height for the first vertex, only needed for filling mHeights
|
||||
float mHeightOffset = 0;
|
||||
// Height in world space for each vertex
|
||||
float mHeights[sLandNumVerts];
|
||||
float mMinHeight = 0;
|
||||
float mMaxHeight = 0;
|
||||
|
||||
// 24-bit normals, these aren't always correct though. Edge and corner normals may be garbage.
|
||||
std::int8_t mNormals[sLandNumVerts * 3];
|
||||
|
||||
// 2D array of texture indices. An index can be used to look up an LandTexture,
|
||||
// but to do so you must subtract 1 from the index first!
|
||||
// An index of 0 indicates the default texture.
|
||||
std::uint16_t mTextures[sLandNumTextures];
|
||||
|
||||
// 24-bit RGB color for each vertex
|
||||
std::uint8_t mColours[3 * sLandNumVerts];
|
||||
|
||||
// ???
|
||||
std::uint16_t mUnk1 = 0;
|
||||
std::uint8_t mUnk2 = 0;
|
||||
|
||||
int mDataLoaded = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -10,6 +10,8 @@
|
|||
#include "components/esm/defs.hpp"
|
||||
#include "components/esm/esmcommon.hpp"
|
||||
|
||||
#include "landrecorddata.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
||||
|
@ -68,21 +70,21 @@ namespace ESM
|
|||
static constexpr int DEFAULT_HEIGHT = -2048;
|
||||
|
||||
// number of vertices per side
|
||||
static constexpr int LAND_SIZE = 65;
|
||||
static constexpr int LAND_SIZE = LandRecordData::sLandSize;
|
||||
|
||||
// cell terrain size in world coords
|
||||
static constexpr int REAL_SIZE = Constants::CellSizeInUnits;
|
||||
|
||||
// total number of vertices
|
||||
static constexpr int LAND_NUM_VERTS = LAND_SIZE * LAND_SIZE;
|
||||
static constexpr int LAND_NUM_VERTS = LandRecordData::sLandNumVerts;
|
||||
|
||||
static constexpr int HEIGHT_SCALE = 8;
|
||||
|
||||
// number of textures per side of land
|
||||
static constexpr int LAND_TEXTURE_SIZE = 16;
|
||||
static constexpr int LAND_TEXTURE_SIZE = LandRecordData::sLandTextureSize;
|
||||
|
||||
// total number of textures per land
|
||||
static constexpr int LAND_NUM_TEXTURES = LAND_TEXTURE_SIZE * LAND_TEXTURE_SIZE;
|
||||
static constexpr int LAND_NUM_TEXTURES = LandRecordData::sLandNumTextures;
|
||||
|
||||
static constexpr int LAND_GLOBAL_MAP_LOD_SIZE = 81;
|
||||
|
||||
|
@ -98,32 +100,7 @@ namespace ESM
|
|||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct LandData
|
||||
{
|
||||
// Initial reference height for the first vertex, only needed for filling mHeights
|
||||
float mHeightOffset = 0;
|
||||
// Height in world space for each vertex
|
||||
float mHeights[LAND_NUM_VERTS];
|
||||
float mMinHeight = 0;
|
||||
float mMaxHeight = 0;
|
||||
|
||||
// 24-bit normals, these aren't always correct though. Edge and corner normals may be garbage.
|
||||
std::int8_t mNormals[LAND_NUM_VERTS * 3];
|
||||
|
||||
// 2D array of texture indices. An index can be used to look up an LandTexture,
|
||||
// but to do so you must subtract 1 from the index first!
|
||||
// An index of 0 indicates the default texture.
|
||||
std::uint16_t mTextures[LAND_NUM_TEXTURES];
|
||||
|
||||
// 24-bit RGB color for each vertex
|
||||
std::uint8_t mColours[3 * LAND_NUM_VERTS];
|
||||
|
||||
// ???
|
||||
std::uint16_t mUnk1 = 0;
|
||||
std::uint8_t mUnk2 = 0;
|
||||
|
||||
int mDataLoaded = 0;
|
||||
};
|
||||
using LandData = ESM::LandRecordData;
|
||||
|
||||
// low-LOD heightmap (used for rendering the global map)
|
||||
std::array<std::int8_t, LAND_GLOBAL_MAP_LOD_SIZE> mWnam;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/esmterrain.hpp>
|
||||
#include <components/esm3/loadland.hpp>
|
||||
#include <components/esm4/loadland.hpp>
|
||||
#include <components/misc/resourcehelpers.hpp>
|
||||
#include <components/misc/strings/algorithm.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include <components/esm/esmterrain.hpp>
|
||||
#include <components/esm/util.hpp>
|
||||
#include <components/esm3/loadland.hpp>
|
||||
#include <components/esm3/loadltex.hpp>
|
||||
|
||||
namespace ESM4
|
||||
|
|
Loading…
Reference in a new issue