diff --git a/examples/dminer/src/dminer/core/chunk.d b/examples/dminer/src/dminer/core/chunk.d index 70837494..fc737b3d 100644 --- a/examples/dminer/src/dminer/core/chunk.d +++ b/examples/dminer/src/dminer/core/chunk.d @@ -6,7 +6,7 @@ import dminer.core.world; import dlangui.graphics.scene.mesh; -//version = FAST_VISIBILITY_PATH; +version = FAST_VISIBILITY_PATH; // Y range: 0..CHUNK_DY-1 immutable int CHUNK_DY = 128; @@ -1529,6 +1529,7 @@ struct VisibilityCheckIterator { Vector3d camPos; SmallChunk * startChunk; ChunkVisitor visitor; + int maxHeight; int maxDistance; int maxDistanceSquared; VisibilityCheckChunk[] plannedChunks; @@ -1549,17 +1550,19 @@ struct VisibilityCheckIterator { // mask test if (!mask) return; + if (p.y > maxHeight + 16 && p.y > startPos.y) + return; // distance test Vector3d diff = (p + Vector3d(4,4,4)) - camPos; if (diff.squaredLength() > maxDistanceSquared) return; int distance = diff.squaredLength; - if (distance > 10*10) { + if (distance > 16*16) { diff = (diff * 256 + cameraDirection * 16) / 256; //diff += cameraDirection; // direction test (TODO) int dot = diff.dot(cameraDirection); - if (dot < 12000) + if (dot < 8000) return; } //.... @@ -1619,6 +1622,9 @@ struct VisibilityCheckIterator { visitedChunks.length = 0; maxDistanceSquared = maxDistance * maxDistance; this.maxDistance = maxDistance; + maxHeight = world.regionHeight(startPos.x, startPos.z, maxDistance + 8) & 0xFFFFFF8 + 7; + import dlangui.core.logger; + Log.d("startPos: ", startPos, " maxHeight:", maxHeight); } Vector3d cameraDirection; void visitVisibleChunks(ChunkVisitor visitor, Vector3d cameraDirection) { diff --git a/examples/dminer/src/dminer/core/world.d b/examples/dminer/src/dminer/core/world.d index a2fcde70..46234007 100644 --- a/examples/dminer/src/dminer/core/world.d +++ b/examples/dminer/src/dminer/core/world.d @@ -178,7 +178,7 @@ class World { /// get max Y position of non-empty cell in region (x +- size, z +- size) int regionHeight(int x, int z, int size) { int top = -1; - int delta = size / 8 + 1; + int delta = size + 1; for (int dx = x - delta; dx <= x + delta; dx += 8) { for (int dz = z - delta; dz <= z + delta; dz += 8) { if (ChunkStack * stack = getCellChunkStack(x, z)) { diff --git a/examples/dminer/src/minermain.d b/examples/dminer/src/minermain.d index 88b56348..ccd282b6 100644 --- a/examples/dminer/src/minermain.d +++ b/examples/dminer/src/minermain.d @@ -132,9 +132,9 @@ class MinerDrawable : MaterialDrawableObject, ChunkVisitor { float camDist = (_camPosition - chunkPos).length; vec3 chunkDirection = (chunkPos - (_camPosition - (_camForwardVector * 12))).normalized; float dot = _camForwardVector.dot(chunkDirection); - float threshold = 0.87; - if (camDist < 12) - threshold = 0.5; + float threshold = 0.80; + if (camDist < 16) + threshold = 0.2; //Log.d("visit() chunkPos ", chunkPos, " chunkDir ", chunkDirection, " camDir ", " dot ", dot, " threshold ", threshold); if (dot < threshold) { // cos(45)