From 6bb96249088b784fab85283d9a80697641a31a22 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Sun, 15 Mar 2015 20:12:55 +0100 Subject: [PATCH] Fixing lights not respecting ignoreHeightmap setting. --- game/loader.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/game/loader.cc b/game/loader.cc index 9cd2a45..3dd9456 100644 --- a/game/loader.cc +++ b/game/loader.cc @@ -374,10 +374,17 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa float compYOffset = queryFloat(thisComposition, "yOffset"); float compZPos = queryFloat(thisComposition, "zPos"); float lightIntensity = queryFloat(xmlLight, "intensity"); - glm::vec3 compPos = glm::vec3(compXPos, - compYOffset+level->getTerrain()->getHeightmap()[int(compXPos-0.5+0.5*level->getTerrain()->getHeightmapHeight())] + bool ignoreHeightmap = queryBool(composition, "ignoreHeightmap"); + glm::vec3 compPos = glm::vec3(0.0f); + if (!ignoreHeightmap) { + compPos = glm::vec3(compXPos, + compYOffset+level->getTerrain()->getHeightmap()[int(compXPos-0.5+0.5*level->getTerrain()->getHeightmapHeight())] [int(compZPos-0.5+0.5*level->getTerrain()->getHeightmapWidth())], - compZPos); + compZPos); + } + else { + compPos = glm::vec3(compXPos, compYOffset, compZPos); + } lightOffset = lightOffset * compScale; glm::vec4 rotatedLightOffset = glm::rotate(compRot.x, glm::vec3(1.0f, 0.0f, 0.0f)) * glm::rotate(compRot.y, glm::vec3(0.0f, 1.0f, 0.0f))