Skip to content

Instantly share code, notes, and snippets.

@PilzAdam
Created July 9, 2013 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PilzAdam/5957518 to your computer and use it in GitHub Desktop.
Save PilzAdam/5957518 to your computer and use it in GitHub Desktop.
diff --git a/builtin/voxelarea.lua b/builtin/voxelarea.lua
index dd9af79..7749017 100644
--- a/builtin/voxelarea.lua
+++ b/builtin/voxelarea.lua
@@ -44,6 +44,19 @@ function VoxelArea:indexp(p)
return math.floor(i)
end
+function VoxelArea:position(i)
+ local p = {}
+ p.z = math.floor(i / self.zstride) + self.MinEdge.z
+ i = i % self.zstride
+
+ p.y = math.floor(i / self.ystride) + self.MinEdge.y
+ i = i % self.ystride
+
+ p.x = math.floor(i) + self.MinEdge.x - 1
+
+ return p
+end
+
function VoxelArea:contains(x, y, z)
return (x >= self.MinEdge.x) and (x <= self.MaxEdge.x) and
(y >= self.MinEdge.y) and (y <= self.MaxEdge.y) and
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment