@@ -173,6 +173,14 @@ void ChunkWater::autoGen(MapChunk *chunk, float factor)
|
|||||||
update_layers();
|
update_layers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChunkWater::update_underground_vertices_depth(MapChunk* chunk)
|
||||||
|
{
|
||||||
|
for (liquid_layer& layer : _layers)
|
||||||
|
{
|
||||||
|
layer.update_underground_vertices_depth(chunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChunkWater::CropWater(MapChunk* chunkTerrain)
|
void ChunkWater::CropWater(MapChunk* chunkTerrain)
|
||||||
{
|
{
|
||||||
@@ -282,11 +290,13 @@ void ChunkWater::update_layers()
|
|||||||
_water_tile->tagExtents(true);
|
_water_tile->tagExtents(true);
|
||||||
|
|
||||||
vcenter = (vmin + vmax) * 0.5f;
|
vcenter = (vmin + vmax) * 0.5f;
|
||||||
|
|
||||||
|
_layer_count = _layers.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChunkWater::hasData(size_t layer) const
|
bool ChunkWater::hasData(size_t layer) const
|
||||||
{
|
{
|
||||||
return _layers.size() > layer;
|
return _layer_count > layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
void autoGen(MapChunk* chunk, float factor);
|
void autoGen(MapChunk* chunk, float factor);
|
||||||
|
void update_underground_vertices_depth(MapChunk* chunk);
|
||||||
void CropWater(MapChunk* chunkTerrain);
|
void CropWater(MapChunk* chunkTerrain);
|
||||||
|
|
||||||
void setType(int type, size_t layer);
|
void setType(int type, size_t layer);
|
||||||
@@ -91,6 +92,8 @@ private:
|
|||||||
void update_attributes();
|
void update_attributes();
|
||||||
|
|
||||||
std::vector<liquid_layer> _layers;
|
std::vector<liquid_layer> _layers;
|
||||||
|
int _layer_count = 0;
|
||||||
|
|
||||||
MapChunk* _chunk;
|
MapChunk* _chunk;
|
||||||
TileWater* _water_tile;
|
TileWater* _water_tile;
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ public:
|
|||||||
|
|
||||||
void autoGen(float factor);
|
void autoGen(float factor);
|
||||||
|
|
||||||
|
void update_underground_vertices_depth();
|
||||||
|
|
||||||
void setType(int type, size_t layer);
|
void setType(int type, size_t layer);
|
||||||
int getType(size_t layer);
|
int getType(size_t layer);
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, glm::vec3 const& base, float heigh
|
|||||||
|
|
||||||
changeLiquidID(_liquid_id);
|
changeLiquidID(_liquid_id);
|
||||||
|
|
||||||
|
update_min_max();
|
||||||
}
|
}
|
||||||
|
|
||||||
liquid_layer::liquid_layer(ChunkWater* chunk, glm::vec3 const& base, mclq& liquid, int liquid_id)
|
liquid_layer::liquid_layer(ChunkWater* chunk, glm::vec3 const& base, mclq& liquid, int liquid_id)
|
||||||
@@ -85,7 +86,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, glm::vec3 const& base, mclq& liqui
|
|||||||
_vertices[v_index] = lv;
|
_vertices[v_index] = lv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
update_min_max();
|
||||||
}
|
}
|
||||||
|
|
||||||
liquid_layer::liquid_layer(ChunkWater* chunk
|
liquid_layer::liquid_layer(ChunkWater* chunk
|
||||||
@@ -170,8 +171,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk
|
|||||||
|
|
||||||
changeLiquidID(_liquid_id); // to update the liquid type
|
changeLiquidID(_liquid_id); // to update the liquid type
|
||||||
|
|
||||||
if (check_fatigue())
|
update_min_max();
|
||||||
_fatigue_enabled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
liquid_layer::liquid_layer(liquid_layer&& other)
|
liquid_layer::liquid_layer(liquid_layer&& other)
|
||||||
@@ -456,6 +456,35 @@ void liquid_layer::update_opacity(MapChunk* chunk, float factor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void liquid_layer::update_underground_vertices_depth(MapChunk* chunk)
|
||||||
|
{
|
||||||
|
// set depth = 0 to liquid verts under ground. This is for LODs.
|
||||||
|
{
|
||||||
|
for (int z = 0; z < 9; ++z)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < 9; ++x)
|
||||||
|
{
|
||||||
|
float diff = _vertices[z * 9 + x].position.y - chunk->mVertices[z * 17 + x].y;
|
||||||
|
|
||||||
|
if (diff < 0.f)
|
||||||
|
{
|
||||||
|
_vertices[z * 9 + x].depth = 0.f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (x < 8 && z < 8 && !hasSubchunk(x, z))
|
||||||
|
{
|
||||||
|
_vertices[z * 9 + x].depth = 0.f;
|
||||||
|
_vertices[z * 9 + x + 1].depth = 0.f;
|
||||||
|
_vertices[(z + 1) * 9 + x].depth = 0.f;
|
||||||
|
_vertices[(z + 1) * 9 + (x + 1)].depth = 0.f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool liquid_layer::hasSubchunk(int x, int z, int size) const
|
bool liquid_layer::hasSubchunk(int x, int z, int size) const
|
||||||
{
|
{
|
||||||
for (int pz = z; pz < z + size; ++pz)
|
for (int pz = z; pz < z + size; ++pz)
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ public:
|
|||||||
|
|
||||||
void crop(MapChunk* chunk);
|
void crop(MapChunk* chunk);
|
||||||
void update_opacity(MapChunk* chunk, float factor);
|
void update_opacity(MapChunk* chunk, float factor);
|
||||||
|
void update_underground_vertices_depth(MapChunk* chunk);
|
||||||
|
|
||||||
std::array<liquid_vertex, 9 * 9>& getVertices() { return _vertices; };
|
std::array<liquid_vertex, 9 * 9>& getVertices() { return _vertices; };
|
||||||
// std::array<float, 9 * 9>& getDepth() { return _depth; };
|
// std::array<float, 9 * 9>& getDepth() { return _depth; };
|
||||||
|
|||||||
Reference in New Issue
Block a user