mirror of
https://github.com/minetest/minetest.git
synced 2024-09-19 23:10:46 +03:00
VoxelManipulator code cleanup (#15114)
Some checks failed
android / build (push) Has been cancelled
cpp_lint / clang_tidy (push) Has been cancelled
linux / gcc_7 (push) Has been cancelled
linux / gcc_14 (push) Has been cancelled
linux / clang_7 (push) Has been cancelled
linux / clang_18 (push) Has been cancelled
linux / clang_11 (PROMETHEUS=1) (push) Has been cancelled
lua_lint / Compile and run multiplayer tests (push) Has been cancelled
lua_lint / Builtin Luacheck and Unit Tests (push) Has been cancelled
macos / build (push) Has been cancelled
whitespace_checks / trailing_whitespaces (push) Has been cancelled
whitespace_checks / tabs_lua_api_files (push) Has been cancelled
windows / MinGW cross-compiler (${{ matrix.bits }}-bit) (32) (push) Has been cancelled
windows / MinGW cross-compiler (${{ matrix.bits }}-bit) (64) (push) Has been cancelled
windows / VS 2019 ${{ matrix.config.arch }}-${{ matrix.type }} (map[arch:x64 generator:-G'Visual Studio 16 2019' -A x64 vcpkg_triplet:x64-windows], portable) (push) Has been cancelled
windows / VS 2019 ${{ matrix.config.arch }}-${{ matrix.type }} (map[arch:x86 generator:-G'Visual Studio 16 2019' -A Win32 vcpkg_triplet:x86-windows], portable) (push) Has been cancelled
Some checks failed
android / build (push) Has been cancelled
cpp_lint / clang_tidy (push) Has been cancelled
linux / gcc_7 (push) Has been cancelled
linux / gcc_14 (push) Has been cancelled
linux / clang_7 (push) Has been cancelled
linux / clang_18 (push) Has been cancelled
linux / clang_11 (PROMETHEUS=1) (push) Has been cancelled
lua_lint / Compile and run multiplayer tests (push) Has been cancelled
lua_lint / Builtin Luacheck and Unit Tests (push) Has been cancelled
macos / build (push) Has been cancelled
whitespace_checks / trailing_whitespaces (push) Has been cancelled
whitespace_checks / tabs_lua_api_files (push) Has been cancelled
windows / MinGW cross-compiler (${{ matrix.bits }}-bit) (32) (push) Has been cancelled
windows / MinGW cross-compiler (${{ matrix.bits }}-bit) (64) (push) Has been cancelled
windows / VS 2019 ${{ matrix.config.arch }}-${{ matrix.type }} (map[arch:x64 generator:-G'Visual Studio 16 2019' -A x64 vcpkg_triplet:x64-windows], portable) (push) Has been cancelled
windows / VS 2019 ${{ matrix.config.arch }}-${{ matrix.type }} (map[arch:x86 generator:-G'Visual Studio 16 2019' -A Win32 vcpkg_triplet:x86-windows], portable) (push) Has been cancelled
* 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
This commit is contained in:
parent
074700b35e
commit
486dc3288d
@ -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);
|
||||
|
33
src/voxel.h
33
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=("<<p.X<<","<<p.Y<<","<<p.Z<<")"
|
||||
<<", index="<<m_area.index(p)
|
||||
<<", flags="<<(int)m_flags[m_area.index(p)]
|
||||
<<" is inexistent"<<std::endl;*/
|
||||
const s32 index = m_area.index(p);
|
||||
|
||||
if (m_flags[index] & VOXELFLAG_NO_DATA) {
|
||||
throw InvalidPositionException
|
||||
("VoxelManipulator: getNode: inexistent");
|
||||
}
|
||||
|
||||
return m_data[m_area.index(p)];
|
||||
return m_data[index];
|
||||
}
|
||||
MapNode getNodeNoEx(const v3s16 &p)
|
||||
{
|
||||
VoxelArea voxel_area(p);
|
||||
addArea(voxel_area);
|
||||
|
||||
if (m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA) {
|
||||
const s32 index = m_area.index(p);
|
||||
|
||||
if (m_flags[index] & VOXELFLAG_NO_DATA) {
|
||||
return {CONTENT_IGNORE};
|
||||
}
|
||||
|
||||
return m_data[m_area.index(p)];
|
||||
return m_data[index];
|
||||
}
|
||||
MapNode getNodeNoExNoEmerge(const v3s16 &p)
|
||||
{
|
||||
if (!m_area.contains(p))
|
||||
return {CONTENT_IGNORE};
|
||||
if (m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA)
|
||||
const s32 index = m_area.index(p);
|
||||
if (m_flags[index] & VOXELFLAG_NO_DATA)
|
||||
return {CONTENT_IGNORE};
|
||||
return m_data[m_area.index(p)];
|
||||
return m_data[index];
|
||||
}
|
||||
// Stuff explodes if non-emerged area is touched with this.
|
||||
// Emerge first, and check VOXELFLAG_NO_DATA if appropriate.
|
||||
@ -456,13 +456,10 @@ public:
|
||||
VoxelArea voxel_area(p);
|
||||
addArea(voxel_area);
|
||||
|
||||
m_data[m_area.index(p)] = n;
|
||||
m_flags[m_area.index(p)] &= ~VOXELFLAG_NO_DATA;
|
||||
}
|
||||
// TODO: Should be removed and replaced with setNode
|
||||
void setNodeNoRef(const v3s16 &p, const MapNode &n)
|
||||
{
|
||||
setNode(p, n);
|
||||
const s32 index = m_area.index(p);
|
||||
|
||||
m_data[index] = n;
|
||||
m_flags[index] &= ~VOXELFLAG_NO_DATA;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user