feat: chunk lod distance uses euclidean distance
This commit is contained in:
parent
1641080ff6
commit
d4273eee8e
|
|
@ -51,8 +51,7 @@ void TerrainChunk::process_lod() {
|
||||||
if (is_ready() && this->meshes.size() > 0) {
|
if (is_ready() && this->meshes.size() > 0) {
|
||||||
Vector3 position{ get_global_position() };
|
Vector3 position{ get_global_position() };
|
||||||
Vector3 camera{ get_viewport()->get_camera_3d()->get_global_position() };
|
Vector3 camera{ get_viewport()->get_camera_3d()->get_global_position() };
|
||||||
Vector3 diff{ (position - camera).abs() };
|
float distance{ (position - camera).length() - this->size / 2.f };
|
||||||
float distance{ (diff.x < diff.z ? diff.z : diff.x) - this->size / 2.f };
|
|
||||||
distance = distance > 0.f ? distance : 0.f;
|
distance = distance > 0.f ? distance : 0.f;
|
||||||
size_t lod{ size_t(Math::floor(distance / (this->lod_end_distance / this->meshes.size()))) };
|
size_t lod{ size_t(Math::floor(distance / (this->lod_end_distance / this->meshes.size()))) };
|
||||||
result = lod < this->meshes.size() ? lod : (this->meshes.size() - 1);
|
result = lod < this->meshes.size() ? lod : (this->meshes.size() - 1);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue