1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Perform server occlusion check before a block is loaded or generated (#14148)

This commit is contained in:
lhofhansl 2023-12-29 12:53:27 -08:00 committed by GitHub
parent edd947b645
commit 22a1653702
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 17 deletions

View file

@ -1155,7 +1155,7 @@ bool Map::isOccluded(const v3s16 &pos_camera, const v3s16 &pos_target,
return false;
}
bool Map::isBlockOccluded(MapBlock *block, v3s16 cam_pos_nodes, bool simple_check)
bool Map::isBlockOccluded(v3s16 pos_relative, v3s16 cam_pos_nodes, bool simple_check)
{
// Check occlusion for center and all 8 corners of the mapblock
// Overshoot a little for less flickering
@ -1172,7 +1172,7 @@ bool Map::isBlockOccluded(MapBlock *block, v3s16 cam_pos_nodes, bool simple_chec
v3s16(-1, -1, -1) * bs2,
};
v3s16 pos_blockcenter = block->getPosRelative() + (MAP_BLOCKSIZE / 2);
v3s16 pos_blockcenter = pos_relative + (MAP_BLOCKSIZE / 2);
// Starting step size, value between 1m and sqrt(3)m
float step = BS * 1.2f;
@ -1203,7 +1203,7 @@ bool Map::isBlockOccluded(MapBlock *block, v3s16 cam_pos_nodes, bool simple_chec
// Additional occlusion check, see comments in that function
v3s16 check;
if (determineAdditionalOcclusionCheck(cam_pos_nodes, block->getBox(), check)) {
if (determineAdditionalOcclusionCheck(cam_pos_nodes, MapBlock::getBox(pos_relative), check)) {
// node is always on a side facing the camera, end_offset can be lower
if (!isOccluded(cam_pos_nodes, check, step, stepfac, start_offset,
-1.0f, needed_count))