Skip to content

Commit

Permalink
Mapblock Mesh BspTree: Increase the depth of block-level splits
Browse files Browse the repository at this point in the history
... before going node-level triangle search.
Fixes transparent grass on transparent land
  • Loading branch information
x2048 committed Jun 7, 2022
1 parent edc7df5 commit 3107c98
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/client/mapblock_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,12 @@ void MapBlockBspTree::buildTree(const std::vector<MeshTriangle> *triangles)
for (u32 i = 0; i < triangles->size(); i++)
indexes.push_back(i);

root = buildTree(v3f(1, 0, 0), v3f(85, 85, 85), 40, indexes, 0);
if (!indexes.empty()) {
// Start in the center of the block with increment of one quarter in each direction
root = buildTree(v3f(1, 0, 0), v3f((MAP_BLOCKSIZE + 1) * 0.5f * BS), MAP_BLOCKSIZE * 0.25f * BS, indexes, 0);
} else {
root = -1;
}
}

/**
Expand Down Expand Up @@ -1097,7 +1102,7 @@ s32 MapBlockBspTree::buildTree(v3f normal, v3f origin, float delta, const std::v
v3f next_normal = candidate_normal;
v3f next_origin = origin + delta * normal;
float next_delta = candidate_delta;
if (next_delta < 10) {
if (next_delta < 5) {
const MeshTriangle *candidate = findSplitCandidate(front_list, *triangles);
next_normal = candidate->getNormal();
next_origin = candidate->centroid;
Expand All @@ -1113,7 +1118,7 @@ s32 MapBlockBspTree::buildTree(v3f normal, v3f origin, float delta, const std::v
v3f next_normal = candidate_normal;
v3f next_origin = origin - delta * normal;
float next_delta = candidate_delta;
if (next_delta < 10) {
if (next_delta < 5) {
const MeshTriangle *candidate = findSplitCandidate(back_list, *triangles);
next_normal = candidate->getNormal();
next_origin = candidate->centroid;
Expand Down

0 comments on commit 3107c98

Please sign in to comment.