]> git.lizzy.rs Git - minetest.git/commitdiff
Fix rotation for falling mesh degrotate nodes (#11159)
authorWuzzy <wuzzy2@mail.ru>
Wed, 28 Apr 2021 06:38:47 +0000 (06:38 +0000)
committerGitHub <noreply@github.com>
Wed, 28 Apr 2021 06:38:47 +0000 (08:38 +0200)
builtin/game/falling.lua
games/devtest/mods/experimental/commands.lua
games/devtest/mods/testnodes/drawtypes.lua

index 1f0a63993e5309f63ea752319c7d4f75e2ea5c47..2cc0d8fac8ec4b9cd34c7869f5a392e3c965fde0 100644 (file)
@@ -205,6 +205,14 @@ core.register_entity(":__builtin:falling_node", {
                                        end
                                end
                                self.object:set_rotation({x=pitch, y=yaw, z=roll})
+                       elseif (def.drawtype == "mesh" and def.paramtype2 == "degrotate") then
+                               local p2 = (node.param2 - (def.place_param2 or 0)) % 240
+                               local yaw = (p2 / 240) * (math.pi * 2)
+                               self.object:set_yaw(yaw)
+                       elseif (def.drawtype == "mesh" and def.paramtype2 == "colordegrotate") then
+                               local p2 = (node.param2 % 32 - (def.place_param2 or 0) % 32) % 24
+                               local yaw = (p2 / 24) * (math.pi * 2)
+                               self.object:set_yaw(yaw)
                        end
                end
        end,
index 8bfa467e10c99c377020c002c7e0ac54c0188be5..e42ae954d89f39401b0090aeeeb7d5485eee3b1a 100644 (file)
@@ -131,10 +131,11 @@ local function place_nodes(param)
                                p2_max = 63
                        elseif def.paramtype2 == "leveled" then
                                p2_max = 127
-                       elseif def.paramtype2 == "degrotate" and def.drawtype == "plantlike" then
-                               p2_max = 179
+                       elseif def.paramtype2 == "degrotate" and (def.drawtype == "plantlike" or def.drawtype == "mesh") then
+                               p2_max = 239
                        elseif def.paramtype2 == "colorfacedir" or
                                def.paramtype2 == "colorwallmounted" or
+                               def.paramtype2 == "colordegrotate" or
                                def.paramtype2 == "color" then
                                p2_max = 255
                        end
@@ -143,7 +144,8 @@ local function place_nodes(param)
                        -- Skip undefined param2 values
                        if not ((def.paramtype2 == "meshoptions" and p2 % 8 > 4) or
                                        (def.paramtype2 == "colorwallmounted" and p2 % 8 > 5) or
-                                       (def.paramtype2 == "colorfacedir" and p2 % 32 > 23)) then
+                                       ((def.paramtype2 == "colorfacedir" or def.paramtype2 == "colordegrotate")
+                                       and p2 % 32 > 23)) then
 
                                minetest.set_node(pos, { name = itemstring, param2 = p2 })
                                nodes_placed = nodes_placed + 1
index 3bf63171400b99eb10a3ca6f1b8fdae576bf9aa5..2bc7ec2e3d5e5a29e8b2fa5f23e84fd822309cf4 100644 (file)
@@ -254,11 +254,11 @@ minetest.register_node("testnodes:mesh_degrotate", {
        drawtype = "mesh",
        paramtype = "light",
        paramtype2 = "degrotate",
-       mesh = "testnodes_pyramid.obj",
+       mesh = "testnodes_ocorner.obj",
        tiles = { "testnodes_mesh_stripes2.png" },
 
        on_rightclick = rotate_on_rightclick,
-       place_param2 = 7,
+       place_param2 = 10, -- 15°
        sunlight_propagates = true,
        groups = { dig_immediate = 3 },
 })
@@ -266,14 +266,15 @@ minetest.register_node("testnodes:mesh_degrotate", {
 minetest.register_node("testnodes:mesh_colordegrotate", {
        description = S("Color Degrotate Mesh Drawtype Test Node"),
        drawtype = "mesh",
+       paramtype = "light",
        paramtype2 = "colordegrotate",
        palette = "testnodes_palette_facedir.png",
-       mesh = "testnodes_pyramid.obj",
-       tiles = { "testnodes_mesh_stripes2.png" },
+       mesh = "testnodes_ocorner.obj",
+       tiles = { "testnodes_mesh_stripes3.png" },
 
        on_rightclick = rotate_on_rightclick,
-       -- color index 1, 7 steps rotated
-       place_param2 = 1 * 2^5 + 7,
+       -- color index 1, 1 step (=15°) rotated
+       place_param2 = 1 * 2^5 + 1,
        sunlight_propagates = true,
        groups = { dig_immediate = 3 },
 })