move seekOrigin logic to the blocks_agent

This commit is contained in:
MihailRis
2024-12-16 22:37:55 +03:00
parent 87c19d69dc
commit c7c2fe29d2
3 changed files with 43 additions and 25 deletions
+1 -17
View File
@@ -160,23 +160,7 @@ Chunk* Chunks::getChunk(int x, int z) const {
glm::ivec3 Chunks::seekOrigin(
const glm::ivec3& srcpos, const Block& def, blockstate state
) const {
auto pos = srcpos;
const auto& rotation = def.rotations.variants[state.rotation];
auto segment = state.segment;
while (true) {
if (!segment) {
return pos;
}
if (segment & 1) pos -= rotation.axisX;
if (segment & 2) pos -= rotation.axisY;
if (segment & 4) pos -= rotation.axisZ;
if (auto* voxel = get(pos.x, pos.y, pos.z)) {
segment = voxel->state.segment;
} else {
return pos;
}
}
return blocks_agent::seek_origin(*this, srcpos, def, state);
}
void Chunks::eraseSegments(