From 09239caf88e2d4df820ecc227c2a807a544e6f30 Mon Sep 17 00:00:00 2001 From: Imbris Date: Sun, 12 Jan 2020 00:54:41 -0500 Subject: [PATCH] While copying terrain sample to flat array, keep track of highest and lowest positions with exposed faces in order to constrain further iteration --- voxygen/src/mesh/terrain.rs | 70 ++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/voxygen/src/mesh/terrain.rs b/voxygen/src/mesh/terrain.rs index c88541f5d6..08c4cf8c1e 100644 --- a/voxygen/src/mesh/terrain.rs +++ b/voxygen/src/mesh/terrain.rs @@ -229,6 +229,12 @@ impl + ReadVol + Debug> Meshable + ReadVol + Debug> Meshable + ReadVol + Debug> Meshable lowest_opaque && lowest_air <= lowest_fluid) + || (lowest_air > lowest_fluid && lowest_air <= lowest_opaque) + { + lowest_air - 2 + } else if lowest_fluid > lowest_opaque && lowest_fluid <= lowest_air { + lowest_fluid - 2 + } else if lowest_fluid > lowest_air && lowest_fluid <= lowest_opaque { + lowest_fluid - 1 + } else { + lowest_opaque - 1 + } + .max(0); + let z_end = if (highest_air < highest_opaque && highest_air >= highest_fluid) + || (highest_air < highest_fluid && highest_air >= highest_opaque) + { + highest_air + 1 + } else if highest_fluid < highest_opaque && highest_fluid >= highest_air { + highest_fluid + 1 + } else if highest_fluid < highest_air && highest_fluid >= highest_opaque { + highest_fluid + } else { + highest_opaque + } + .min(range.size().d - 1); for x in 1..range.size().w - 1 { for y in 1..range.size().w - 1 { let mut lights = [[[0.0; 3]; 3]; 3]; @@ -266,7 +309,7 @@ impl + ReadVol + Debug> Meshable + ReadVol + Debug> Meshable + ReadVol + Debug> Meshable + ReadVol + Debug> Meshable + ReadVol + Debug> Meshable for VolGrid3d { } } */ - -fn interleave_i32_with_zeros(mut x: i32) -> i64 { - x = (x ^ (x << 16)) & 0x0000ffff0000ffff; - x = (x ^ (x << 8)) & 0x00ff00ff00ff00ff; - x = (x ^ (x << 4)) & 0x0f0f0f0f0f0f0f0f; - x = (x ^ (x << 2)) & 0x3333333333333333; - x = (x ^ (x << 1)) & 0x5555555555555555; - x -} - -fn morton_code(pos: Vec2) -> i64 { - interleave_i32_with_zeros(pos.x) | (interleave_i32_with_zeros(pos.y) << 1) -}