Leveled nodebox: Change levels from 1/63rds to 1/64ths

Add missing documentation of leveled nodebox to lua_api.txt, plus
a little cleaning up nearby.
This commit is contained in:
paramat 2017-09-18 05:08:56 +01:00 committed by SmallJoker
parent b1fae4c7be
commit b8f473be21
3 changed files with 11 additions and 13 deletions

@ -809,6 +809,11 @@ node definition:
0 = y+ 1 = z+ 2 = z- 3 = x+ 4 = x- 5 = y- 0 = y+ 1 = z+ 2 = z- 3 = x+ 4 = x- 5 = y-
facedir modulo 4 = rotation around that axis facedir modulo 4 = rotation around that axis
paramtype2 == "leveled" 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" paramtype2 == "degrotate"
^ The rotation of this node is stored in param2. Plants are rotated this way. ^ 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 Values range 0 - 179. The value stored in param2 is multiplied by two to

@ -249,18 +249,11 @@ void transformNodeBox(const MapNode &n, const NodeBox &nodebox,
int facedir = n.getFaceDir(nodemgr); int facedir = n.getFaceDir(nodemgr);
u8 axisdir = facedir>>2; u8 axisdir = facedir>>2;
facedir&=0x03; facedir&=0x03;
for(std::vector<aabb3f>::const_iterator for (aabb3f box : fixed) {
i = fixed.begin(); if (nodebox.type == NODEBOX_LEVELED)
i != fixed.end(); ++i) box.MaxEdge.Y = (-0.5f + n.getLevel(nodemgr) / 64.0f) * BS;
{
aabb3f box = *i;
if (nodebox.type == NODEBOX_LEVELED) { switch (axisdir) {
box.MaxEdge.Y = -BS/2 + BS*((float)1/LEVELED_MAX) * n.getLevel(nodemgr);
}
switch (axisdir)
{
case 0: case 0:
if(facedir == 1) if(facedir == 1)
{ {

@ -103,8 +103,8 @@ enum Rotation {
#define LIQUID_INFINITY_MASK 0x80 //0b10000000 #define LIQUID_INFINITY_MASK 0x80 //0b10000000
// mask for param2, now as for liquid // mask for leveled nodebox param2
#define LEVELED_MASK 0x3F #define LEVELED_MASK 0x7F
#define LEVELED_MAX LEVELED_MASK #define LEVELED_MAX LEVELED_MASK