-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing again render distance/Chunk Slice/Proc gen bugs...
- Loading branch information
1 parent
7ab2f74
commit a5e0d7a
Showing
7 changed files
with
233 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
function BlockRendering(self, i, j, k, x, y, z, thisTransparency, thisLight, model, scale) | ||
-- top | ||
local get = self.parent:getVoxel(i, j - 1, k) | ||
if CanDrawFace(get, thisTransparency) then | ||
local otx, oty = NumberToCoord(TileTextures(get)[math.min(2, #TileTextures(get))], 16, 16) | ||
otx = otx + 16 * thisLight | ||
local otx2, oty2 = otx + 1, oty + 1 | ||
local tx, ty = otx * TileWidth / LightValues, oty * TileHeight | ||
local tx2, ty2 = otx2 * TileWidth / LightValues, oty2 * TileHeight | ||
|
||
model[#model + 1] = { x, y, z, tx, ty } | ||
model[#model + 1] = { x + scale, y, z, tx2, ty } | ||
model[#model + 1] = { x, y, z + scale, tx, ty2 } | ||
model[#model + 1] = { x + scale, y, z, tx2, ty } | ||
model[#model + 1] = { x + scale, y, z + scale, tx2, ty2 } | ||
model[#model + 1] = { x, y, z + scale, tx, ty2 } | ||
end | ||
|
||
-- bottom | ||
local get = self.parent:getVoxel(i, j + 1, k) | ||
if CanDrawFace(get, thisTransparency) then | ||
local otx, oty = NumberToCoord(TileTextures(get)[math.min(3, #TileTextures(get))], 16, 16) | ||
otx = otx + 16 * math.max(thisLight - 3, 0) | ||
local otx2, oty2 = otx + 1, oty + 1 | ||
local tx, ty = otx * TileWidth / LightValues, oty * TileHeight | ||
local tx2, ty2 = otx2 * TileWidth / LightValues, oty2 * TileHeight | ||
|
||
model[#model + 1] = { x + scale, y + scale, z, tx2, ty } | ||
model[#model + 1] = { x, y + scale, z, tx, ty } | ||
model[#model + 1] = { x, y + scale, z + scale, tx, ty2 } | ||
model[#model + 1] = { x + scale, y + scale, z + scale, tx2, ty2 } | ||
model[#model + 1] = { x + scale, y + scale, z, tx2, ty } | ||
model[#model + 1] = { x, y + scale, z + scale, tx, ty2 } | ||
end | ||
|
||
-- positive x | ||
local get = self.parent:getVoxel(i - 1, j, k) | ||
if i == 1 then | ||
local chunkGet = GetChunk(x - 1, y, z) | ||
if chunkGet ~= nil then | ||
get = chunkGet:getVoxel(ChunkSize, j, k) | ||
end | ||
end | ||
if CanDrawFace(get, thisTransparency) then | ||
local otx, oty = NumberToCoord(TileTextures(get)[1], 16, 16) | ||
otx = otx + 16 * math.max(thisLight - 2, 0) | ||
local otx2, oty2 = otx + 1, oty + 1 | ||
local tx, ty = otx * TileWidth / LightValues, oty * TileHeight | ||
local tx2, ty2 = otx2 * TileWidth / LightValues, oty2 * TileHeight | ||
|
||
model[#model + 1] = { x, y + scale, z, tx2, ty } | ||
model[#model + 1] = { x, y, z, tx2, ty2 } | ||
model[#model + 1] = { x, y, z + scale, tx, ty2 } | ||
model[#model + 1] = { x, y + scale, z + scale, tx, ty } | ||
model[#model + 1] = { x, y + scale, z, tx2, ty } | ||
model[#model + 1] = { x, y, z + scale, tx, ty2 } | ||
end | ||
|
||
-- negative x | ||
local get = self.parent:getVoxel(i + 1, j, k) | ||
if i == ChunkSize then | ||
local chunkGet = GetChunk(x + 1, y, z) | ||
if chunkGet ~= nil then | ||
get = chunkGet:getVoxel(1, j, k) | ||
end | ||
end | ||
if CanDrawFace(get, thisTransparency) then | ||
local otx, oty = NumberToCoord(TileTextures(get)[1], 16, 16) | ||
otx = otx + 16 * math.max(thisLight - 2, 0) | ||
local otx2, oty2 = otx + 1, oty + 1 | ||
local tx, ty = otx * TileWidth / LightValues, oty * TileHeight | ||
local tx2, ty2 = otx2 * TileWidth / LightValues, oty2 * TileHeight | ||
|
||
model[#model + 1] = { x + scale, y, z, tx, ty2 } | ||
model[#model + 1] = { x + scale, y + scale, z, tx, ty } | ||
model[#model + 1] = { x + scale, y, z + scale, tx2, ty2 } | ||
model[#model + 1] = { x + scale, y + scale, z, tx, ty } | ||
model[#model + 1] = { x + scale, y + scale, z + scale, tx2, ty } | ||
model[#model + 1] = { x + scale, y, z + scale, tx2, ty2 } | ||
end | ||
|
||
-- positive z | ||
local get = self.parent:getVoxel(i, j, k - 1) | ||
if k == 1 then | ||
local chunkGet = GetChunk(x, y, z - 1) | ||
if chunkGet ~= nil then | ||
get = chunkGet:getVoxel(i, j, ChunkSize) | ||
end | ||
end | ||
if CanDrawFace(get, thisTransparency) then | ||
local otx, oty = NumberToCoord(TileTextures(get)[1], 16, 16) | ||
otx = otx + 16 * math.max(thisLight - 1, 0) | ||
local otx2, oty2 = otx + 1, oty + 1 | ||
local tx, ty = otx * TileWidth / LightValues, oty * TileHeight | ||
local tx2, ty2 = otx2 * TileWidth / LightValues, oty2 * TileHeight | ||
|
||
model[#model + 1] = { x, y, z, tx, ty2 } | ||
model[#model + 1] = { x, y + scale, z, tx, ty } | ||
model[#model + 1] = { x + scale, y, z, tx2, ty2 } | ||
model[#model + 1] = { x, y + scale, z, tx, ty } | ||
model[#model + 1] = { x + scale, y + scale, z, tx2, ty } | ||
model[#model + 1] = { x + scale, y, z, tx2, ty2 } | ||
end | ||
|
||
-- negative z | ||
local get = self.parent:getVoxel(i, j, k + 1) | ||
if k == ChunkSize then | ||
local chunkGet = GetChunk(x, y, z + 1) | ||
if chunkGet ~= nil then | ||
get = chunkGet:getVoxel(i, j, 1) | ||
end | ||
end | ||
if CanDrawFace(get, thisTransparency) then | ||
local otx, oty = NumberToCoord(TileTextures(get)[1], 16, 16) | ||
otx = otx + 16 * math.max(thisLight - 1, 0) | ||
local otx2, oty2 = otx + 1, oty + 1 | ||
local tx, ty = otx * TileWidth / LightValues, oty * TileHeight | ||
local tx2, ty2 = otx2 * TileWidth / LightValues, oty2 * TileHeight | ||
|
||
model[#model + 1] = { x, y + scale, z + scale, tx2, ty } | ||
model[#model + 1] = { x, y, z + scale, tx2, ty2 } | ||
model[#model + 1] = { x + scale, y, z + scale, tx, ty2 } | ||
model[#model + 1] = { x + scale, y + scale, z + scale, tx, ty } | ||
model[#model + 1] = { x, y + scale, z + scale, tx2, ty } | ||
model[#model + 1] = { x + scale, y, z + scale, tx, ty2 } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
function TileRendering(self, i, j, k, x, y, z, thisLight, model, scale) | ||
local this = self.parent:getVoxel(i, j, k) | ||
if TileModel(this) == 1 then | ||
local otx, oty = NumberToCoord(TileTextures(this)[1], 16, 16) | ||
otx = otx + 16 * thisLight | ||
local otx2, oty2 = otx + 1, oty + 1 | ||
local tx, ty = otx * TileWidth / LightValues, oty * TileHeight | ||
local tx2, ty2 = otx2 * TileWidth / LightValues, oty2 * TileHeight | ||
|
||
local diagLong = 0.7071 * scale * 0.5 + 0.5 | ||
local diagShort = -0.7071 * scale * 0.5 + 0.5 | ||
|
||
local vertices = {} | ||
|
||
for _, v in ipairs({ | ||
{ diagShort, 0, diagShort, tx2, ty2 }, | ||
{ diagLong, 0, diagLong, tx, ty2 }, | ||
{ diagShort, scale, diagShort, tx2, ty }, | ||
{ diagLong, 0, diagLong, tx, ty2 }, | ||
{ diagLong, scale, diagLong, tx, ty }, | ||
{ diagShort, scale, diagShort, tx2, ty }, | ||
}) do | ||
table.insert(vertices, { x + v[1], y + v[2], z + v[3], v[4], v[5] }) | ||
end | ||
|
||
for _, v in ipairs(vertices) do | ||
model[#model + 1] = v | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.