5 #ifndef MERCATOR_SEGMENT_H
6 #define MERCATOR_SEGMENT_H
10 #include "BasePoint.h"
11 #include "HeightMap.h"
13 #include <wfmath/vector.h>
14 #include <wfmath/axisbox.h>
63 std::vector<float> m_normals;
74 std::map<long, std::multimap<int, AreaEntry>::iterator> m_areaLookup;
77 std::map<long, const TerrainMod*> m_terrainMods;
79 explicit Segment(
int x,
int z,
int resolution);
118 m_controlPoints(x, z) = bp;
124 return m_controlPoints;
129 return m_controlPoints;
164 return m_normals.data();
169 return m_normals.data();
173 float get(
int x,
int z)
const {
174 return m_heightMap.
get(x, z);
177 void getHeight(
float x,
float y,
float &h)
const;
179 WFMath::Vector<3> &normal)
const;
180 bool clipToSegment(
const WFMath::AxisBox<2> &bbox,
int &lx,
int &hx,
int &lz,
int &hz)
const;
186 void populateHeightMap(
HeightMap& heightMap);
194 WFMath::AxisBox<2>
getRect()
const;
204 const std::map<long, const TerrainMod*>& getMods()
const
205 {
return m_terrainMods; }
207 void updateArea(
long id,
const Area* area,
const Shader* shader);
211 void applyMod(
const TerrainMod *t);
213 void invalidateSurfaces();
Region of terrain surface which is modified.
Point on the fundamental grid that is used as the basis for terrain.
DataType * getData()
Accessor for a pointer to buffer containing data values.
bool isValid() const
Determine if this buffer has valid allocated storage.
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
float getMin() const
Accessor for the minimum height value in this Segment.
float get(int x, int z) const
Get the height at a relative integer position in the Segment.
float getMax() const
Accessor for the maximum height value in this Segment.
A fixed sized array of objects.
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
bool clipToSegment(const WFMath::AxisBox< 2 > &bbox, int &lx, int &hx, int &lz, int &hz) const
Determine the intersection between an axis aligned box and this segment.
int getResolution() const
Accessor for resolution of this segment.
bool isValid() const
Check whether this Segment contains valid point data.
void setCornerPoint(unsigned int x, unsigned int z, const BasePoint &bp)
Set the BasePoint data for one of the four that define this Segment.
const HeightMap & getHeightMap() const
Accessor for height map.
const float * getNormals() const
Accessor for buffer containing surface normals.
void populate()
Populate the Segment with heightfield data.
std::multimap< int, AreaEntry > Areastore
STL multimap of pointers to Area objects affecting this segment.
WFMath::AxisBox< 2 > getRect() const
The 2d area covered by this segment.
void populateNormals()
Populate the Segment with surface normal data.
int getSize() const
Accessor for array size of this segment.
const float * getPoints() const
Accessor for buffer containing height points.
float * getPoints()
Accessor for write access to buffer containing height points.
Matrix< 2, 2, BasePoint > & getControlPoints()
Accessor for modifying 2D matrix of base points.
Segment(int x, int z, int resolution)
Construct an empty segment with the given resolution.
const Matrix< 2, 2, BasePoint > & getControlPoints() const
Accessor for 2D matrix of base points.
Surfacestore & getSurfaces()
Accessor for modifying list of attached Surface objects.
float getMin() const
Accessor for the minimum height value in this Segment.
float * getNormals()
Accessor for write access to buffer containing surface normals.
int getXRef() const
Accessor for Global x reference of this segment.
std::map< int, std::unique_ptr< Surface > > Surfacestore
STL map of pointers to Surface objects.
void getHeightAndNormal(float x, float z, float &h, WFMath::Vector< 3 > &normal) const
Get an accurate height and normal vector at a given coordinate relative to this segment.
float getMax() const
Accessor for the maximum height value in this Segment.
const Areastore & getAreas() const
Accessor for multimap of Area objects.
HeightMap & getHeightMap()
Accessor for write access to height map.
int getZRef() const
Accessor for Global y reference of this segment.
void populateSurfaces()
Populate the surfaces associated with this Segment.
void invalidate(bool points=true)
Mark the contents of this Segment as stale.
void clearMods()
Delete all the modifications applied to this Segment.
float get(int x, int z) const
Get the height at a relative integer position in the Segment.
~Segment()
Destruct the Segment.
const Surfacestore & getSurfaces() const
Accessor for list of attached Surface objects.
Base class for modifiers to the procedurally generated terrain.