mirror of
https://github.com/minetest/minetest.git
synced 2025-01-03 20:07:30 +01:00
Fix meaning of VoxelArea::hasEmptyExtent()
This commit is contained in:
parent
8957739cdf
commit
67126cbd1b
@ -93,7 +93,7 @@ public:
|
|||||||
MapEditEventAreaIgnorer(VoxelArea *ignorevariable, const VoxelArea &a):
|
MapEditEventAreaIgnorer(VoxelArea *ignorevariable, const VoxelArea &a):
|
||||||
m_ignorevariable(ignorevariable)
|
m_ignorevariable(ignorevariable)
|
||||||
{
|
{
|
||||||
if (m_ignorevariable->getVolume() == 0)
|
if (m_ignorevariable->hasEmptyExtent())
|
||||||
*m_ignorevariable = a;
|
*m_ignorevariable = a;
|
||||||
else
|
else
|
||||||
m_ignorevariable = nullptr;
|
m_ignorevariable = nullptr;
|
||||||
@ -102,7 +102,7 @@ public:
|
|||||||
~MapEditEventAreaIgnorer()
|
~MapEditEventAreaIgnorer()
|
||||||
{
|
{
|
||||||
if (m_ignorevariable) {
|
if (m_ignorevariable) {
|
||||||
assert(m_ignorevariable->getVolume() != 0);
|
assert(!m_ignorevariable->hasEmptyExtent());
|
||||||
*m_ignorevariable = VoxelArea();
|
*m_ignorevariable = VoxelArea();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ void TestVoxelArea::test_extent()
|
|||||||
|
|
||||||
UASSERT(VoxelArea().hasEmptyExtent());
|
UASSERT(VoxelArea().hasEmptyExtent());
|
||||||
UASSERT(VoxelArea({2,3,4}, {1,2,3}).hasEmptyExtent());
|
UASSERT(VoxelArea({2,3,4}, {1,2,3}).hasEmptyExtent());
|
||||||
UASSERT(VoxelArea({2,3,4}, {2,2,3}).hasEmptyExtent() == false);
|
UASSERT(VoxelArea({2,3,4}, {2,2,3}).hasEmptyExtent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestVoxelArea::test_volume()
|
void TestVoxelArea::test_volume()
|
||||||
|
@ -114,11 +114,9 @@ public:
|
|||||||
return m_cache_extent;
|
return m_cache_extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @note `getVolume() == 0` and `getEmptyExtent()` are not equivalent.
|
|
||||||
bool hasEmptyExtent() const
|
bool hasEmptyExtent() const
|
||||||
{
|
{
|
||||||
// FIXME: shouldn't this actually be a component-wise check?
|
return !m_cache_extent.X || !m_cache_extent.Y || !m_cache_extent.Z;
|
||||||
return m_cache_extent == v3s32(0,0,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 getVolume() const
|
s32 getVolume() const
|
||||||
@ -207,7 +205,7 @@ public:
|
|||||||
if(a.hasEmptyExtent())
|
if(a.hasEmptyExtent())
|
||||||
{
|
{
|
||||||
VoxelArea b = *this;
|
VoxelArea b = *this;
|
||||||
if (b.getVolume() != 0)
|
if (!b.hasEmptyExtent())
|
||||||
result.push_back(b);
|
result.push_back(b);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -216,7 +214,7 @@ public:
|
|||||||
|
|
||||||
const auto &take = [&result] (v3s16 min, v3s16 max) {
|
const auto &take = [&result] (v3s16 min, v3s16 max) {
|
||||||
VoxelArea b(min, max);
|
VoxelArea b(min, max);
|
||||||
if (b.getVolume() != 0)
|
if (!b.hasEmptyExtent())
|
||||||
result.push_back(b);
|
result.push_back(b);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user