summaryrefslogtreecommitdiffstats
path: root/src/RendererSectionData.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-03-13 17:55:58 +0100
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-03-13 17:55:58 +0100
commit8616ce6a0bfd4a6c31d4f6dded4137ad9eb2ba2f (patch)
treed7fea08c83a928fcc08c787b93e594d2d7999622 /src/RendererSectionData.cpp
parentImplemented basic lighting (diff)
downloadAltCraft-8616ce6a0bfd4a6c31d4f6dded4137ad9eb2ba2f.tar
AltCraft-8616ce6a0bfd4a6c31d4f6dded4137ad9eb2ba2f.tar.gz
AltCraft-8616ce6a0bfd4a6c31d4f6dded4137ad9eb2ba2f.tar.bz2
AltCraft-8616ce6a0bfd4a6c31d4f6dded4137ad9eb2ba2f.tar.lz
AltCraft-8616ce6a0bfd4a6c31d4f6dded4137ad9eb2ba2f.tar.xz
AltCraft-8616ce6a0bfd4a6c31d4f6dded4137ad9eb2ba2f.tar.zst
AltCraft-8616ce6a0bfd4a6c31d4f6dded4137ad9eb2ba2f.zip
Diffstat (limited to 'src/RendererSectionData.cpp')
-rw-r--r--src/RendererSectionData.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp
index 067728f..e3c4870 100644
--- a/src/RendererSectionData.cpp
+++ b/src/RendererSectionData.cpp
@@ -265,6 +265,13 @@ RendererSectionData ParseSection(World * world, Vector sectionPosition)
std::array<BlockId, 4096> blockIdData = SetBlockIdData(world, sectionPosition);
std::array<unsigned char, 4096> blockVisibility = GetBlockVisibilityData(world, sectionPosition, blockIdData, idModels);
std::string textureName;
+
+ Section* yp = world->GetSectionPtr(sectionPosition + Vector(0, 1, 0));
+ Section* yn = world->GetSectionPtr(sectionPosition + Vector(0, -1, 0));
+ Section* xp = world->GetSectionPtr(sectionPosition + Vector(1, 0, 0));
+ Section* xn = world->GetSectionPtr(sectionPosition + Vector(-1, 0, 0));
+ Section* zp = world->GetSectionPtr(sectionPosition + Vector(0, 0, 1));
+ Section* zn = world->GetSectionPtr(sectionPosition + Vector(0, 0, -1));
const std::map<BlockTextureId, glm::vec4> &textureAtlas = AssetManager::Instance().GetTextureAtlasIndexes();
const Section &section = world->GetSection(sectionPosition);
@@ -287,9 +294,12 @@ RendererSectionData ParseSection(World * world, Vector sectionPosition)
transform = glm::translate(baseOffset, Vector(x, y, z).glm());
+ unsigned char light = world->GetBlockLight(Vector(x, y, z), &section, xp, xn, yp, yn, zp, zn);
+ unsigned char skyLight = world->GetBlockSkyLight(Vector(x, y, z), &section, xp, xn, yp, yn, zp, zn);
+
const BlockModel* model = GetInternalBlockModel(block, idModels);
if (model) {
- AddFacesByBlockModel(sectionsList, world, Vector(x, y, z), *model, transform, world->GetBlockLight(Vector(x, y, z) + sectionPosition * 16), world->GetBlockSkyLight(Vector(x, y, z) + sectionPosition * 16), blockVisibility, textureName, data);
+ AddFacesByBlockModel(sectionsList, world, Vector(x, y, z), *model, transform, light, skyLight, blockVisibility, textureName, data);
}
else {
transform = glm::translate(transform, glm::vec3(0, 1, 0));
@@ -304,7 +314,7 @@ RendererSectionData ParseSection(World * world, Vector sectionPosition)
data.models.push_back(transform);
data.colors.push_back(glm::vec3(0, 0, 0));
- data.lights.push_back(glm::vec2(world->GetBlockLight(Vector(x, y, z) + sectionPosition * 16), world->GetBlockSkyLight(Vector(x, y, z) + sectionPosition * 16)));
+ data.lights.push_back(glm::vec2(light, skyLight));
}
}