Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
sthalik committed Jan 9, 2024
1 parent a806c1a commit ac04d36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions src/chunk-walls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ GL::Mesh chunk::make_wall_mesh()
{
CORRADE_ASSUME(G < Group_::COUNT);

bool corner_ok = false, pillar_ok = false;
bool corner_ok = false, pillar_ok = false, side_ok = true;

if (!(dir.*member).is_defined)
continue;
Expand All @@ -204,16 +204,15 @@ GL::Mesh chunk::make_wall_mesh()
default:
break;
case Wall::Group_::side:
if (_walls->atlases[k+1]) // west on same tile
if (auto t2 = at_offset_(pos, {-1, 0}); !t2 || !t2->wall_north_atlas())
if (auto t2 = at_offset_(pos, {0, -1}); !t2 || !t2->wall_west_atlas())
pillar_ok = true;
if (!pillar_ok) [[likely]]
if (auto t = at_offset_(pos, {-1, 0}); !(t && t->wall_north_atlas()))
{
if (auto t2 = at_offset_(pos, {-1, 0}); !t2 || !t2->wall_north_atlas())
if (auto t2 = at_offset_(pos, {0, -1}); t2 && t2->wall_west_atlas())
corner_ok = true;
if (_walls->atlases[k+1]) // west on same tile
pillar_ok = true;
if (auto t = at_offset_(pos, {0, -1}); t && t->wall_west_atlas())
corner_ok = true;
}
if (auto t = at_offset_(pos, {1, -1}); t && t->wall_west_atlas())
side_ok = false;
break;
}
}
Expand All @@ -224,11 +223,11 @@ GL::Mesh chunk::make_wall_mesh()
default:
break;
case Wall::Group_::side:
if (auto t2 = at_offset_(pos, {0, 1}); t2 && t2->wall_north_atlas())
continue;
else if (auto t2 = at_offset_(pos, {0, -1}); !t2 || !t2->wall_west_atlas())
if (auto t2 = at_offset_(pos, {-1, 0}); t2 && t2->wall_north_atlas())
if (auto t = at_offset_(pos, {0, -1}); !(t && t->wall_west_atlas()))
if (auto t = at_offset_(pos, {-1, 0}); t && t->wall_north_atlas())
corner_ok = true;
if (auto t = at_offset_(pos, {-1, 1}); t && t->wall_north_atlas())
side_ok = false;
break;
}
}
Expand Down Expand Up @@ -312,6 +311,7 @@ GL::Mesh chunk::make_wall_mesh()
}
}

if (G != Wall::Group_::side || side_ok) [[likely]]
{
const auto& group = dir.*member;
const auto frames = atlas->frames(group);
Expand Down
2 changes: 1 addition & 1 deletion src/chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Optional<tile_ref> chunk::at_offset_(local_coords pos, Vector2i off)
return operator[](coord2.local());
else
{
if (auto* ch = _world->at({coord2}))
if (auto* ch = _world->at(coord2.chunk3()))
return (*ch)[coord2.local()];
else
return NullOpt;
Expand Down

0 comments on commit ac04d36

Please sign in to comment.