1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-17 02:15:22 +02:00

Allow access into MapSector::m_blocks (#14232)

* New API to allow access into MapSector::m_blocks
* Use this API on ClientMap::touchMapBlocks(), ClientMap::updateDrawList(), and ClientMap::updateDrawListShadow() to speed them up
This commit is contained in:
lhofhansl
2024-01-10 09:17:26 -08:00
committed by GitHub
parent 2766c70ad3
commit 4bf95703a0
2 changed files with 18 additions and 16 deletions

View File

@@ -45,7 +45,7 @@ public:
void deleteBlocks();
v2s16 getPos()
v2s16 getPos() const
{
return m_pos;
}
@@ -62,8 +62,16 @@ public:
// Returns an owning ptr to block.
std::unique_ptr<MapBlock> detachBlock(MapBlock *block);
// This makes a copy of the internal collection.
// Prefer getBlocks() if possible.
void getBlocks(MapBlockVect &dest);
// Get access to the internal collection
// This is explicitly only allowed on a const object since modifying anything while iterating is unsafe.
// The caller needs to make sure that this does not happen.
const auto &getBlocks() const { return m_blocks; }
const auto &getBlocks() = delete;
bool empty() const { return m_blocks.empty(); }
int size() const { return m_blocks.size(); }