aboutsummaryrefslogtreecommitdiff
path: root/src/nodedef.h
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2022-05-09 20:59:28 +0200
committersfan5 <sfan5@live.de>2022-05-26 15:49:12 +0200
commit8b74257bf3cbb54e78614ac6aaaba79adf75cc8e (patch)
treebceabcb03441991743f5677a0dec62335931aa24 /src/nodedef.h
parent9a01581cdd3cb54750e9fe4a065aa435262d5225 (diff)
downloadminetest-8b74257bf3cbb54e78614ac6aaaba79adf75cc8e.tar.gz
minetest-8b74257bf3cbb54e78614ac6aaaba79adf75cc8e.tar.bz2
minetest-8b74257bf3cbb54e78614ac6aaaba79adf75cc8e.zip
Reduce size of ContentFeatures structure
On my system this is a reduction from 4664 to 3704 bytes. This is not for the sake of saving RAM but ensuring commonly used structures fit into caches better.
Diffstat (limited to 'src/nodedef.h')
-rw-r--r--src/nodedef.h38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/nodedef.h b/src/nodedef.h
index 8c817179d..edd8d00a7 100644
--- a/src/nodedef.h
+++ b/src/nodedef.h
@@ -99,17 +99,8 @@ enum NodeBoxType
NODEBOX_CONNECTED, // optionally draws nodeboxes if a neighbor node attaches
};
-struct NodeBox
+struct NodeBoxConnected
{
- enum NodeBoxType type;
- // NODEBOX_REGULAR (no parameters)
- // NODEBOX_FIXED
- std::vector<aabb3f> fixed;
- // NODEBOX_WALLMOUNTED
- aabb3f wall_top;
- aabb3f wall_bottom;
- aabb3f wall_side; // being at the -X side
- // NODEBOX_CONNECTED
std::vector<aabb3f> connect_top;
std::vector<aabb3f> connect_bottom;
std::vector<aabb3f> connect_front;
@@ -124,9 +115,35 @@ struct NodeBox
std::vector<aabb3f> disconnected_right;
std::vector<aabb3f> disconnected;
std::vector<aabb3f> disconnected_sides;
+};
+
+struct NodeBox
+{
+ enum NodeBoxType type;
+ // NODEBOX_REGULAR (no parameters)
+ // NODEBOX_FIXED
+ std::vector<aabb3f> fixed;
+ // NODEBOX_WALLMOUNTED
+ aabb3f wall_top;
+ aabb3f wall_bottom;
+ aabb3f wall_side; // being at the -X side
+ // NODEBOX_CONNECTED
+ // (kept externally to not bloat the structure)
+ std::shared_ptr<NodeBoxConnected> connected;
NodeBox()
{ reset(); }
+ ~NodeBox() = default;
+
+ inline NodeBoxConnected &getConnected() {
+ if (!connected)
+ connected = std::make_shared<NodeBoxConnected>();
+ return *connected;
+ }
+ inline const NodeBoxConnected &getConnected() const {
+ assert(connected);
+ return *connected;
+ }
void reset();
void serialize(std::ostream &os, u16 protocol_version) const;
@@ -290,7 +307,6 @@ struct ContentFeatures
// up down right left back front
TileSpec tiles[6];
// Special tiles
- // - Currently used for flowing liquids
TileSpec special_tiles[CF_SPECIAL_COUNT];
u8 solidness; // Used when choosing which face is drawn
u8 visual_solidness; // When solidness=0, this tells how it looks like