skipping chunks added.
This commit is contained in:
@@ -267,65 +267,63 @@ public:
|
|||||||
|
|
||||||
float dist = 0;
|
float dist = 0;
|
||||||
|
|
||||||
while (lv != cv && visitedVoxel.size() < 10 && dist < maxDist) {
|
while (lv != cv && visitedVoxel.size() < 10 && dist < maxDist && inGrid(cv)) {
|
||||||
|
|
||||||
Vec3i currentChunk = getChunkCoord(cv);
|
Vec3i currentChunk = getChunkCoord(cv);
|
||||||
|
|
||||||
auto it = activeChunks.find(currentChunk);
|
auto it = activeChunks.find(currentChunk);
|
||||||
bool isChunkActive = (it != activeChunks.end() && it->second);
|
bool isChunkActive = (it != activeChunks.end() && it->second);
|
||||||
|
|
||||||
|
if (get(cv).active) {
|
||||||
|
visitedVoxel.push_back(cv);
|
||||||
|
}
|
||||||
if (!isChunkActive) {
|
if (!isChunkActive) {
|
||||||
while (getChunkCoord(cv) == currentChunk && inGrid(cv)) {
|
Vec3f chunkStep = step * CHUNK_THRESHOLD / 2;
|
||||||
Vec3f chunkStep = step * CHUNK_THRESHOLD / 2;
|
Vec3d chunkDelta = tDelta * CHUNK_THRESHOLD / 2;
|
||||||
Vec3d chunkDelta = tDelta * CHUNK_THRESHOLD / 2;
|
if (tMax.x < tMax.y) {
|
||||||
if (tMax.x < tMax.y) {
|
if (tMax.x < tMax.z) {
|
||||||
if (tMax.x < tMax.z) {
|
dist += chunkDelta.x;
|
||||||
dist += chunkDelta.x;
|
cv.x += chunkStep.x;
|
||||||
cv.x += chunkStep.x;
|
tMax.x += chunkDelta.x;
|
||||||
tMax.x += chunkDelta.x;
|
|
||||||
} else {
|
|
||||||
dist += chunkDelta.z;
|
|
||||||
cv.z += chunkStep.z;
|
|
||||||
tMax.z += chunkDelta.z;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (tMax.y < tMax.z) {
|
dist += chunkDelta.z;
|
||||||
dist += chunkDelta.y;
|
cv.z += chunkStep.z;
|
||||||
cv.y += chunkStep.y;
|
tMax.z += chunkDelta.z;
|
||||||
tMax.y += chunkDelta.y;
|
}
|
||||||
} else {
|
} else {
|
||||||
dist += chunkDelta.z;
|
if (tMax.y < tMax.z) {
|
||||||
cv.z += chunkStep.z;
|
dist += chunkDelta.y;
|
||||||
tMax.z += chunkDelta.z;
|
cv.y += chunkStep.y;
|
||||||
}
|
tMax.y += chunkDelta.y;
|
||||||
|
} else {
|
||||||
|
dist += chunkDelta.z;
|
||||||
|
cv.z += chunkStep.z;
|
||||||
|
tMax.z += chunkDelta.z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (get(cv).active) {
|
|
||||||
visitedVoxel.push_back(cv);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tMax.x < tMax.y) {
|
|
||||||
if (tMax.x < tMax.z) {
|
|
||||||
dist += tDelta.x;
|
|
||||||
cv.x += step.x;
|
|
||||||
tMax.x += tDelta.x;
|
|
||||||
} else {
|
|
||||||
dist += tDelta.z;
|
|
||||||
cv.z += step.z;
|
|
||||||
tMax.z += tDelta.z;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (tMax.y < tMax.z) {
|
if (tMax.x < tMax.y) {
|
||||||
dist += tDelta.y;
|
if (tMax.x < tMax.z) {
|
||||||
cv.y += step.y;
|
dist += tDelta.x;
|
||||||
tMax.y += tDelta.y;
|
cv.x += step.x;
|
||||||
|
tMax.x += tDelta.x;
|
||||||
|
} else {
|
||||||
|
dist += tDelta.z;
|
||||||
|
cv.z += step.z;
|
||||||
|
tMax.z += tDelta.z;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dist += tDelta.z;
|
if (tMax.y < tMax.z) {
|
||||||
cv.z += step.z;
|
dist += tDelta.y;
|
||||||
tMax.z += tDelta.z;
|
cv.y += step.y;
|
||||||
|
tMax.y += tDelta.y;
|
||||||
|
} else {
|
||||||
|
dist += tDelta.z;
|
||||||
|
cv.z += step.z;
|
||||||
|
tMax.z += tDelta.z;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,6 +259,10 @@ public:
|
|||||||
Vec3<int> floorToI() const {
|
Vec3<int> floorToI() const {
|
||||||
return Vec3<int>(static_cast<int>(std::floor(x)), static_cast<int>(std::floor(x)), static_cast<int>(std::floor(z)));
|
return Vec3<int>(static_cast<int>(std::floor(x)), static_cast<int>(std::floor(x)), static_cast<int>(std::floor(z)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vec3<uint8_t> floorToI8() const {
|
||||||
|
return Vec3<uint8_t>(static_cast<uint8_t>(std::floor(x)), static_cast<uint8_t>(std::floor(x)), static_cast<uint8_t>(std::floor(z)));
|
||||||
|
}
|
||||||
|
|
||||||
Vec3<size_t> floorToT() const {
|
Vec3<size_t> floorToT() const {
|
||||||
return Vec3<size_t>(static_cast<size_t>(std::floor(x)), static_cast<size_t>(std::floor(x)), static_cast<size_t>(std::floor(z)));
|
return Vec3<size_t>(static_cast<size_t>(std::floor(x)), static_cast<size_t>(std::floor(x)), static_cast<size_t>(std::floor(z)));
|
||||||
|
|||||||
Reference in New Issue
Block a user