terrain: instead of fixed grass chunk generation distance, it will be computed from custom grass view distance to avoid popping
This commit is contained in:
@@ -687,6 +687,9 @@ namespace wi::terrain
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that enough grass chunks are generated so that grass view distance will not cause popping:
|
||||
grass_chunk_dist = int(grass_properties.viewDistance / chunk_width + 0.5f);
|
||||
|
||||
for (auto it = chunks.begin(); it != chunks.end();)
|
||||
{
|
||||
const Chunk& chunk = it->first;
|
||||
@@ -752,7 +755,7 @@ namespace wi::terrain
|
||||
else
|
||||
{
|
||||
// Grass patch removal:
|
||||
if (chunk_data.grass_entity != INVALID_ENTITY && (dist > 1 || !IsGrassEnabled()))
|
||||
if (chunk_data.grass_entity != INVALID_ENTITY && (dist > grass_chunk_dist || !IsGrassEnabled()))
|
||||
{
|
||||
scene->Entity_Remove(chunk_data.grass_entity);
|
||||
chunk_data.grass_entity = INVALID_ENTITY; // grass can be generated here by generation thread...
|
||||
@@ -1034,7 +1037,7 @@ namespace wi::terrain
|
||||
const int dist = std::max(std::abs(center_chunk.x - chunk.x), std::abs(center_chunk.z - chunk.z));
|
||||
|
||||
// Grass patch placement:
|
||||
if (dist <= 1 && IsGrassEnabled())
|
||||
if (dist <= grass_chunk_dist && IsGrassEnabled())
|
||||
{
|
||||
it = chunks.find(chunk);
|
||||
if (it != chunks.end() && it->second.entity != INVALID_ENTITY)
|
||||
|
||||
@@ -281,6 +281,7 @@ namespace wi::terrain
|
||||
Chunk center_chunk = {};
|
||||
wi::noise::Perlin perlin_noise;
|
||||
wi::vector<Prop> props;
|
||||
int grass_chunk_dist = 1;
|
||||
|
||||
// For generating scene on a background thread:
|
||||
std::shared_ptr<Generator> generator;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wi::version
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 71;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 569;
|
||||
const int revision = 570;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user