From 486dc3288d7b8e8c55bbc20dea11fef32fd7119b Mon Sep 17 00:00:00 2001 From: red-001 Date: Wed, 4 Sep 2024 14:20:39 +0100 Subject: [PATCH] VoxelManipulator code cleanup (#15114) * Cache node in voxel area index when possible The index function according to the MSVC profiler actually takes up a significant time slice (around ~5% of total time for the process) during normal game-play. Might not be accurate but still good to not recalculate it twice. * Remove `setNodeNoRef` from VM * VM: remove old commented out print statement --- src/unittest/test_voxelmanipulator.cpp | 2 +- src/voxel.h | 33 ++++++++++++-------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/unittest/test_voxelmanipulator.cpp b/src/unittest/test_voxelmanipulator.cpp index acc2707e7..6ea0ca9af 100644 --- a/src/unittest/test_voxelmanipulator.cpp +++ b/src/unittest/test_voxelmanipulator.cpp @@ -87,7 +87,7 @@ void TestVoxelManipulator::testVoxelManipulator(const NodeDefManager *nodedef) v.print(infostream, nodedef); infostream << "*** Setting (-1,0,-1)=2 ***" << std::endl; - v.setNodeNoRef(v3s16(-1,0,-1), MapNode(t_CONTENT_GRASS)); + v.setNode(v3s16(-1,0,-1), MapNode(t_CONTENT_GRASS)); v.print(infostream, nodedef); UASSERT(v.getNode(v3s16(-1,0,-1)).getContent() == t_CONTENT_GRASS); diff --git a/src/voxel.h b/src/voxel.h index 286e09abe..882a59b77 100644 --- a/src/voxel.h +++ b/src/voxel.h @@ -392,36 +392,36 @@ public: VoxelArea voxel_area(p); addArea(voxel_area); - if (m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA) { - /*dstream<<"EXCEPT: VoxelManipulator::getNode(): " - <<"p=("<