Skip to content

Commit

Permalink
Fix worldaligned textures
Browse files Browse the repository at this point in the history
As reported in minetest#12197, b0b9732
introduces a regression in worldalign textures.

The specific change that seems to be responsible for this issue is the
change in order between the computation of the cuboid texture
coordinates and the box edge correction.

Fix minetest#12197 by moving the box edge correction back to before the cuboid
texture coordinates, as it used to be.
  • Loading branch information
Oblomov authored and sfan5 committed Apr 24, 2022
1 parent 23f981c commit b55d7cd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/client/content_mapblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ void MapblockMeshGenerator::drawAutoLightedCuboid(aabb3f box, const f32 *txc,
f32 dx2 = box.MaxEdge.X;
f32 dy2 = box.MaxEdge.Y;
f32 dz2 = box.MaxEdge.Z;

box.MinEdge += origin;
box.MaxEdge += origin;

if (scale) {
if (!txc) { // generate texture coords before scaling
generateCuboidTextureCoords(box, texture_coord_buf);
Expand All @@ -385,8 +389,7 @@ void MapblockMeshGenerator::drawAutoLightedCuboid(aabb3f box, const f32 *txc,
generateCuboidTextureCoords(box, texture_coord_buf);
txc = texture_coord_buf;
}
box.MinEdge += origin;
box.MaxEdge += origin;

if (!tiles) {
tiles = &tile;
tile_count = 1;
Expand Down

0 comments on commit b55d7cd

Please sign in to comment.