summaryrefslogtreecommitdiff
path: root/WorldSegment.cpp
diff options
context:
space:
mode:
authorJapa2011-01-22 05:05:13 +0000
committerJapa2011-01-22 05:05:13 +0000
commit3e627f73cdbf1073f56bfc2aee5def4f3ba2678f (patch)
treeb30bc7eefef25cc61d73ae14b2a26eff00d08683 /WorldSegment.cpp
parentb17f42822cd3d0766e32f46dea58e36102f8a23e (diff)
downloadstonesense-3e627f73cdbf1073f56bfc2aee5def4f3ba2678f.tar.gz
stonesense-3e627f73cdbf1073f56bfc2aee5def4f3ba2678f.tar.bz2
stonesense-3e627f73cdbf1073f56bfc2aee5def4f3ba2678f.tar.xz
Got meself some wide and tall trees working
Diffstat (limited to 'WorldSegment.cpp')
-rw-r--r--WorldSegment.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/WorldSegment.cpp b/WorldSegment.cpp
index 68c0d38..00c1c06 100644
--- a/WorldSegment.cpp
+++ b/WorldSegment.cpp
@@ -73,6 +73,48 @@ Block* WorldSegment::getBlockRelativeTo(uint32_t x, uint32_t y, uint32_t z, dir
return blocksAsPointerVolume[index];
}
+Block* WorldSegment::getBlockRelativeTo(uint32_t x, uint32_t y, uint32_t z, dirRelative direction, int distance)
+{
+ int32_t lx = x;
+ int32_t ly = y;
+ int32_t lz = z;
+ //make local
+ lx -= this->x;
+ ly -= this->y;
+ lz -= this->z;
+
+ correctBlockForRotation( (int32_t&)lx,(int32_t&)ly,(int32_t&)lz );
+ switch (direction){
+ case eUp:
+ ly-= distance; break;
+ case eDown:
+ ly+= distance; break;
+ case eLeft:
+ lx-= distance; break;
+ case eRight:
+ lx+= distance; break;
+ case eAbove:
+ lz+= distance; break;
+ case eBelow:
+ lz-= distance; break;
+ case eUpLeft:
+ ly-= distance; lx-= distance; break;
+ case eUpRight:
+ ly-= distance; lx+= distance; break;
+ case eDownLeft:
+ ly+= distance; lx-= distance; break;
+ case eDownRight:
+ ly+= distance; lx+= distance; break;
+ }
+
+ if((int)lx < 0 || lx >= this->sizex) return 0;
+ if((int)ly < 0 || ly >= this->sizey) return 0;
+ if((int)lz < 0 || lz >= this->sizez) return 0;
+
+ uint32_t index = lx + (ly * this->sizex) + ((lz) * this->sizex * this->sizey);
+ return blocksAsPointerVolume[index];
+}
+
Block* WorldSegment::getBlockLocal(uint32_t x, uint32_t y, uint32_t z){
if((int)x < 0 || x >= (uint32_t)this->sizex) return 0;
if((int)y < 0 || y >= (uint32_t)this->sizey) return 0;