Leveled nodebox: Change levels from 1/63rds to 1/64ths
authorparamat <paramat@users.noreply.github.com>
Mon, 18 Sep 2017 04:08:56 +0000 (05:08 +0100)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:31:59 +0000 (17:31 +0200)
Add missing documentation of leveled nodebox to lua_api.txt, plus
a little cleaning up nearby.

doc/lua_api.txt
src/mapnode.cpp
src/mapnode.h

index f0e6931db7636a904429f948f00cd25701c658e0..8e750c5a4c29bcb233ac9d3e7101fcbb6f2f38af 100644 (file)
@@ -809,6 +809,11 @@ node definition:
       0 = y+    1 = z+    2 = z-    3 = x+    4 = x-    5 = y-
       facedir modulo 4 = rotation around that axis
     paramtype2 == "leveled"
+    ^ Only valid for "nodebox" with type = "leveled".
+        The level of the top face of the nodebox is stored in param2.
+        The other faces are defined by 'fixed = {}' like 'type = "fixed"' nodeboxes.
+        The nodebox height is param2 / 64 nodes.
+        The maximum accepted value of param2 is 127.
     paramtype2 == "degrotate"
     ^ The rotation of this node is stored in param2. Plants are rotated this way.
       Values range 0 - 179. The value stored in param2 is multiplied by two to
index d835daba27f461f0629fe33958dec3d69854254f..ff5ad5557137fc04ab22eb44e08d82610e76b86a 100644 (file)
@@ -249,18 +249,11 @@ void transformNodeBox(const MapNode &n, const NodeBox &nodebox,
                int facedir = n.getFaceDir(nodemgr);
                u8 axisdir = facedir>>2;
                facedir&=0x03;
-               for(std::vector<aabb3f>::const_iterator
-                               i = fixed.begin();
-                               i != fixed.end(); ++i)
-               {
-                       aabb3f box = *i;
-
-                       if (nodebox.type == NODEBOX_LEVELED) {
-                               box.MaxEdge.Y = -BS/2 + BS*((float)1/LEVELED_MAX) * n.getLevel(nodemgr);
-                       }
+               for (aabb3f box : fixed) {
+                       if (nodebox.type == NODEBOX_LEVELED)
+                               box.MaxEdge.Y = (-0.5f + n.getLevel(nodemgr) / 64.0f) * BS;
 
-                       switch (axisdir)
-                       {
+                       switch (axisdir) {
                        case 0:
                                if(facedir == 1)
                                {
index 9c56a7e170c9b4b73d8b5217041356e27ee328d1..23248c45d7c0b4c64476836eb01adb3c8617b29a 100644 (file)
@@ -103,8 +103,8 @@ enum Rotation {
 
 #define LIQUID_INFINITY_MASK 0x80 //0b10000000
 
-// mask for param2, now as for liquid
-#define LEVELED_MASK 0x3F
+// mask for leveled nodebox param2
+#define LEVELED_MASK 0x7F
 #define LEVELED_MAX LEVELED_MASK