diff options
author | Thomas--S <Thomas--S@users.noreply.github.com> | 2017-04-22 21:17:46 +0200 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2018-01-03 04:05:21 +0000 |
commit | f3b9d8707691b16d9c8b6a2e9e13db54b091dc93 (patch) | |
tree | 7eb55d8965838aa0b0af74d7d30519a9b5a6d053 /src/mapnode.cpp | |
parent | 345e1041a204ca9d40a25b71ae239ce3275f0755 (diff) | |
download | minetest-f3b9d8707691b16d9c8b6a2e9e13db54b091dc93.tar.gz minetest-f3b9d8707691b16d9c8b6a2e9e13db54b091dc93.tar.bz2 minetest-f3b9d8707691b16d9c8b6a2e9e13db54b091dc93.zip |
Connected Nodeboxes: Add `disconnected` boxes
The `disconnected_*` boxes are the opposites of the `connect_*` ones,
i.e. when a node has no suitable neighbours on the respective side, the
according disconnected box is drawn.
* disconnected_top
* disconnected_bottom
* disconnected_front
* disconnected_left
* disconnected_back
* disconnected_right
* disconnected (when there is *no* neighbour)
* disconnected_sides (when there are *no* neighbours to the sides)
Diffstat (limited to 'src/mapnode.cpp')
-rw-r--r-- | src/mapnode.cpp | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 9d3459173..3a12360f3 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -422,16 +422,40 @@ void transformNodeBox(const MapNode &n, const NodeBox &nodebox, boxes_size += nodebox.fixed.size(); if (neighbors & 1) boxes_size += nodebox.connect_top.size(); + else + boxes_size += nodebox.disconnected_top.size(); + if (neighbors & 2) boxes_size += nodebox.connect_bottom.size(); + else + boxes_size += nodebox.disconnected_bottom.size(); + if (neighbors & 4) boxes_size += nodebox.connect_front.size(); + else + boxes_size += nodebox.disconnected_front.size(); + if (neighbors & 8) boxes_size += nodebox.connect_left.size(); + else + boxes_size += nodebox.disconnected_left.size(); + if (neighbors & 16) boxes_size += nodebox.connect_back.size(); + else + boxes_size += nodebox.disconnected_back.size(); + if (neighbors & 32) boxes_size += nodebox.connect_right.size(); + else + boxes_size += nodebox.disconnected_right.size(); + + if (neighbors == 0) + boxes_size += nodebox.disconnected.size(); + + if (neighbors < 4) + boxes_size += nodebox.disconnected_sides.size(); + boxes.reserve(boxes_size); #define BOXESPUSHBACK(c) \ @@ -442,18 +466,50 @@ void transformNodeBox(const MapNode &n, const NodeBox &nodebox, BOXESPUSHBACK(nodebox.fixed); - if (neighbors & 1) + if (neighbors & 1) { BOXESPUSHBACK(nodebox.connect_top); - if (neighbors & 2) + } else { + BOXESPUSHBACK(nodebox.disconnected_top); + } + + if (neighbors & 2) { BOXESPUSHBACK(nodebox.connect_bottom); - if (neighbors & 4) + } else { + BOXESPUSHBACK(nodebox.disconnected_bottom); + } + + if (neighbors & 4) { BOXESPUSHBACK(nodebox.connect_front); - if (neighbors & 8) + } else { + BOXESPUSHBACK(nodebox.disconnected_front); + } + + if (neighbors & 8) { BOXESPUSHBACK(nodebox.connect_left); - if (neighbors & 16) + } else { + BOXESPUSHBACK(nodebox.disconnected_left); + } + + if (neighbors & 16) { BOXESPUSHBACK(nodebox.connect_back); - if (neighbors & 32) + } else { + BOXESPUSHBACK(nodebox.disconnected_back); + } + + if (neighbors & 32) { BOXESPUSHBACK(nodebox.connect_right); + } else { + BOXESPUSHBACK(nodebox.disconnected_right); + } + + if (neighbors == 0) { + BOXESPUSHBACK(nodebox.disconnected); + } + + if (neighbors < 4) { + BOXESPUSHBACK(nodebox.disconnected_sides); + } + } else // NODEBOX_REGULAR { |