summaryrefslogtreecommitdiff
path: root/src/voxel.h
diff options
context:
space:
mode:
authorunknown <gregory.currie@gmail.com>2015-01-13 23:23:31 +1000
committerCraig Robbins <kde.psych@gmail.com>2015-01-13 23:24:32 +1000
commit5d08ada2241569501fa22bfc5e5cde0ee7dfd0c7 (patch)
tree928cca01282922afd0518a0748964454d02952f4 /src/voxel.h
parentc0066a75cd567b4dd96ff3b38550e9b3a65a529c (diff)
downloadminetest-5d08ada2241569501fa22bfc5e5cde0ee7dfd0c7.tar.gz
minetest-5d08ada2241569501fa22bfc5e5cde0ee7dfd0c7.tar.bz2
minetest-5d08ada2241569501fa22bfc5e5cde0ee7dfd0c7.zip
Add VoxelArea::hasEmptyExtent
Diffstat (limited to 'src/voxel.h')
-rw-r--r--src/voxel.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/voxel.h b/src/voxel.h
index 53b6edbc7..52274ac19 100644
--- a/src/voxel.h
+++ b/src/voxel.h
@@ -82,7 +82,7 @@ public:
void addArea(const VoxelArea &a)
{
- if(getExtent() == v3s16(0,0,0))
+ if (hasEmptyExtent())
{
*this = a;
return;
@@ -96,7 +96,7 @@ public:
}
void addPoint(const v3s16 &p)
{
- if(getExtent() == v3s16(0,0,0))
+ if(hasEmptyExtent())
{
MinEdge = p;
MaxEdge = p;
@@ -137,6 +137,15 @@ public:
{
return MaxEdge - MinEdge + v3s16(1,1,1);
}
+
+ /* Because MaxEdge and MinEdge are included in the voxel area an empty extent
+ * is not represented by (0, 0, 0), but instead (-1, -1, -1)
+ */
+ bool hasEmptyExtent() const
+ {
+ return MaxEdge - MinEdge == v3s16(-1, -1, -1);
+ }
+
s32 getVolume() const
{
v3s16 e = getExtent();
@@ -146,7 +155,7 @@ public:
{
// No area contains an empty area
// NOTE: Algorithms depend on this, so do not change.
- if(a.getExtent() == v3s16(0,0,0))
+ if(a.hasEmptyExtent())
return false;
return(