2014-10-08 15:17:31 +00:00
|
|
|
#ifndef OPENCS_RENDER_TERRAINSTORAGE_H
|
|
|
|
#define OPENCS_RENDER_TERRAINSTORAGE_H
|
|
|
|
|
2019-10-02 11:04:15 +00:00
|
|
|
#include <array>
|
|
|
|
|
2022-10-09 10:39:43 +00:00
|
|
|
#include <components/esm3/loadland.hpp>
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <components/esm3/loadltex.hpp>
|
2022-01-22 22:52:08 +00:00
|
|
|
#include <components/esm3terrain/storage.hpp>
|
2022-10-09 10:39:43 +00:00
|
|
|
#include <osg/ref_ptr>
|
2014-10-08 15:17:31 +00:00
|
|
|
|
2022-10-09 10:39:43 +00:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class Data;
|
|
|
|
}
|
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Vec4ub;
|
|
|
|
}
|
2014-10-08 15:17:31 +00:00
|
|
|
|
|
|
|
namespace CSVRender
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @brief A bridge between the terrain component and OpenCS's terrain data storage.
|
|
|
|
*/
|
|
|
|
class TerrainStorage : public ESMTerrain::Storage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TerrainStorage(const CSMWorld::Data& data);
|
2019-09-11 09:59:15 +00:00
|
|
|
void setAlteredHeight(int inCellX, int inCellY, float heightMap);
|
|
|
|
void resetHeights();
|
2019-11-20 13:37:00 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
bool useAlteration() const override { return true; }
|
2019-09-11 09:59:15 +00:00
|
|
|
float getSumOfAlteredAndTrueHeight(int cellX, int cellY, int inCellX, int inCellY);
|
|
|
|
float* getAlteredHeight(int inCellX, int inCellY);
|
|
|
|
|
2014-10-08 15:17:31 +00:00
|
|
|
private:
|
|
|
|
const CSMWorld::Data& mData;
|
2022-01-22 21:44:02 +00:00
|
|
|
std::array<float, ESM::Land::LAND_SIZE * ESM::Land::LAND_SIZE> mAlteredHeight;
|
2014-10-08 15:17:31 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
osg::ref_ptr<const ESMTerrain::LandObject> getLand(int cellX, int cellY) override;
|
2020-10-22 21:57:53 +00:00
|
|
|
const ESM::LandTexture* getLandTexture(int index, short plugin) override;
|
2014-10-08 15:17:31 +00:00
|
|
|
|
2020-10-22 21:57:53 +00:00
|
|
|
void getBounds(float& minX, float& maxX, float& minY, float& maxY) override;
|
2019-10-03 09:54:37 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
int getThisHeight(int col, int row, const ESM::Land::LandData* heightData) const;
|
|
|
|
int getLeftHeight(int col, int row, const ESM::Land::LandData* heightData) const;
|
|
|
|
int getRightHeight(int col, int row, const ESM::Land::LandData* heightData) const;
|
|
|
|
int getUpHeight(int col, int row, const ESM::Land::LandData* heightData) const;
|
|
|
|
int getDownHeight(int col, int row, const ESM::Land::LandData* heightData) const;
|
|
|
|
int getHeightDifferenceToLeft(int col, int row, const ESM::Land::LandData* heightData) const;
|
|
|
|
int getHeightDifferenceToRight(int col, int row, const ESM::Land::LandData* heightData) const;
|
|
|
|
int getHeightDifferenceToUp(int col, int row, const ESM::Land::LandData* heightData) const;
|
|
|
|
int getHeightDifferenceToDown(int col, int row, const ESM::Land::LandData* heightData) const;
|
|
|
|
bool leftOrUpIsOverTheLimit(
|
|
|
|
int col, int row, int heightWarningLimit, const ESM::Land::LandData* heightData) const;
|
|
|
|
bool rightOrDownIsOverTheLimit(
|
|
|
|
int col, int row, int heightWarningLimit, const ESM::Land::LandData* heightData) const;
|
|
|
|
|
|
|
|
void adjustColor(int col, int row, const ESM::Land::LandData* heightData, osg::Vec4ub& color) const override;
|
2020-10-22 21:57:53 +00:00
|
|
|
float getAlteredHeight(int col, int row) const override;
|
2014-10-08 15:17:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|