]> git.lizzy.rs Git - minetest.git/commitdiff
Offset cuboid origin after scaling the cuboid. (#12558)
authorx2048 <codeforsmile@gmail.com>
Tue, 19 Jul 2022 08:48:00 +0000 (10:48 +0200)
committerGitHub <noreply@github.com>
Tue, 19 Jul 2022 08:48:00 +0000 (10:48 +0200)
This avoids the problem of offset nodes with visual_scale > 1.

src/client/content_mapblock.cpp

index 8675275aa4a298e15c5b2554adb959ac838ce2a6..0bac5e827f40932b627b55dbe40a23edf44bfb0d 100644 (file)
@@ -377,10 +377,6 @@ 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);
@@ -389,11 +385,12 @@ void MapblockMeshGenerator::drawAutoLightedCuboid(aabb3f box, const f32 *txc,
                box.MinEdge *= f->visual_scale;
                box.MaxEdge *= f->visual_scale;
        }
+       box.MinEdge += origin;
+       box.MaxEdge += origin;
        if (!txc) {
                generateCuboidTextureCoords(box, texture_coord_buf);
                txc = texture_coord_buf;
        }
-
        if (!tiles) {
                tiles = &tile;
                tile_count = 1;