2014-10-08 17:17:31 +02:00
|
|
|
#ifndef OPENCS_RENDER_TERRAINSTORAGE_H
|
|
|
|
#define OPENCS_RENDER_TERRAINSTORAGE_H
|
|
|
|
|
2019-10-02 14:04:15 +03:00
|
|
|
#include <array>
|
|
|
|
|
2022-01-22 23:52:08 +01:00
|
|
|
#include <components/esm3terrain/storage.hpp>
|
2014-10-08 17:17:31 +02:00
|
|
|
|
|
|
|
#include "../../model/world/data.hpp"
|
|
|
|
|
|
|
|
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 12:59:15 +03:00
|
|
|
void setAlteredHeight(int inCellX, int inCellY, float heightMap);
|
|
|
|
void resetHeights();
|
2019-11-20 13:37:00 +00:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
bool useAlteration() const override { return true; }
|
2019-09-11 12:59:15 +03:00
|
|
|
float getSumOfAlteredAndTrueHeight(int cellX, int cellY, int inCellX, int inCellY);
|
|
|
|
float* getAlteredHeight(int inCellX, int inCellY);
|
|
|
|
|
2014-10-08 17:17:31 +02:00
|
|
|
private:
|
|
|
|
const CSMWorld::Data& mData;
|
2022-01-22 22:44:02 +01:00
|
|
|
std::array<float, ESM::Land::LAND_SIZE * ESM::Land::LAND_SIZE> mAlteredHeight;
|
2014-10-08 17:17:31 +02:00
|
|
|
|
2020-10-22 23:57:53 +02:00
|
|
|
osg::ref_ptr<const ESMTerrain::LandObject> getLand (int cellX, int cellY) override;
|
|
|
|
const ESM::LandTexture* getLandTexture(int index, short plugin) override;
|
2014-10-08 17:17:31 +02:00
|
|
|
|
2020-10-22 23:57:53 +02:00
|
|
|
void getBounds(float& minX, float& maxX, float& minY, float& maxY) override;
|
2019-10-03 12:54:37 +03:00
|
|
|
|
2019-10-03 23:22:19 +03: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;
|
2019-10-07 02:57:09 +03:00
|
|
|
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;
|
2019-10-03 23:22:19 +03:00
|
|
|
|
2020-10-22 23:57:53 +02:00
|
|
|
void adjustColor(int col, int row, const ESM::Land::LandData *heightData, osg::Vec4ub& color) const override;
|
|
|
|
float getAlteredHeight(int col, int row) const override;
|
2014-10-08 17:17:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|