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::unique_ptr<std::vector<float>> m_normals;
66 Surfacestore m_surfaces;
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);
109 void invalidate(
bool points =
true);
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;
178 void getHeightAndNormal(
float x,
float z,
float &h,
179 WFMath::Vector<3> &normal)
const;
180 bool clipToSegment(
const WFMath::AxisBox<2> &bbox,
int &lx,
int &hx,
int &lz,
int &hz)
const;
184 void populateNormals();
185 void populateSurfaces();
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);
213 void invalidateSurfaces();
219 #endif // MERCATOR_SEGMENT_H
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
DataType * getData()
Accessor for a pointer to buffer containing data values.
bool isValid() const
Determine if this buffer has valid allocated storage.
float getMax() const
Accessor for the maximum height value in this Segment.
bool isValid() const
Check whether this Segment contains valid point data.
int getResolution() const
Accessor for resolution of this segment.
Matrix< 2, 2, BasePoint > & getControlPoints()
Accessor for modifying 2D matrix of base points.
int getZRef() const
Accessor for Global y reference of this segment.
float getMin() const
Accessor for the minimum height value in this Segment.
const Surfacestore & getSurfaces() const
Accessor for list of attached Surface objects.
std::map< int, std::unique_ptr< Surface > > Surfacestore
STL map of pointers to Surface objects.
float getMin() const
Accessor for the minimum height value in this Segment.
int getSize() const
Accessor for array size of this segment.
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
const Areastore & getAreas() const
Accessor for multimap of Area objects.
const HeightMap & getHeightMap() const
Accessor for height map.
int getXRef() const
Accessor for Global x reference of this segment.
const float * getNormals() const
Accessor for buffer containing surface normals.
Base class for Shader objects which create surface data for use when rendering terrain.
void setCornerPoint(unsigned int x, unsigned int z, const BasePoint &bp)
Set the BasePoint data for one of the four that define this Segment.
float getMax() const
Accessor for the maximum height value in this Segment.
Point on the fundamental grid that is used as the basis for terrain.
A fixed sized array of objects.
const Matrix< 2, 2, BasePoint > & getControlPoints() const
Accessor for 2D matrix of base points.
std::multimap< int, AreaEntry > Areastore
STL multimap of pointers to Area objects affecting this segment.
float * getNormals()
Accessor for write access to buffer containing surface normals.
const float * getPoints() const
Accessor for buffer containing height points.
float * getPoints()
Accessor for write access to buffer containing height points.
float get(int x, int z) const
Get the height at a relative integer position in the Segment.
Surfacestore & getSurfaces()
Accessor for modifying list of attached Surface objects.
Region of terrain surface which is modified.
HeightMap & getHeightMap()
Accessor for write access to height map.
Base class for modifiers to the procedurally generated terrain.