From 1f13106f5167b947c177e45be6c3d97450c575c6 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 9 Jul 2015 15:05:03 -0700 Subject: [PATCH] FIxed the issue on mac due to the abs function not correctly executing --- libraries/model/src/model/Light.cpp | 8 +++++--- .../render-utils/src/DeferredLightingEffect.cpp | 17 ++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/libraries/model/src/model/Light.cpp b/libraries/model/src/model/Light.cpp index 1bad381137..b7635b4af3 100755 --- a/libraries/model/src/model/Light.cpp +++ b/libraries/model/src/model/Light.cpp @@ -88,9 +88,11 @@ void Light::setSpotAngle(float angle) { dangle = glm::half_pi(); } - editSchema()._spot.x = (float)abs(cos(dangle)); - editSchema()._spot.y = (float)abs(sin(dangle)); - editSchema()._spot.z = (float)dangle; + auto cosAngle = cos(dangle); + auto sinAngle = sin(dangle); + editSchema()._spot.x = (float) std::abs(cosAngle); + editSchema()._spot.y = (float) std::abs(sinAngle); + editSchema()._spot.z = (float) angle; } void Light::setSpotExponent(float exponent) { diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 813127f349..a721e0cad3 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -509,15 +509,9 @@ void DeferredLightingEffect::render(RenderArgs* args) { batch._glUniform4fv(_spotLightLocations.coneParam, 1, reinterpret_cast< const GLfloat* >(&coneParam)); Transform model; - model.setTranslation(glm::vec3(light->getPosition().x, light->getPosition().y, light->getPosition().z)); - - glm::quat spotRotation = rotationBetween(glm::vec3(0.0f, 0.0f, -1.0f), light->getDirection()); - spotRotation = light->getOrientation(); - model.postRotate(spotRotation); - - float base = expandedRadius * glm::tan(light->getSpotAngle()); - float height = expandedRadius; - model.postScale(glm::vec3(height, height, height)); + model.setTranslation(light->getPosition()); + model.postRotate(light->getOrientation()); + model.postScale(glm::vec3(expandedRadius, expandedRadius, expandedRadius)); batch.setModelTransform(model); auto mesh = getSpotLightMesh(); @@ -679,7 +673,7 @@ model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { if (!_spotLightMesh) { _spotLightMesh.reset(new model::Mesh()); - int slices = 16; + int slices = 32; int rings = 3; int vertices = 2 + rings * slices; int originVertex = vertices - 2; @@ -762,7 +756,8 @@ model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { delete[] indexData; model::Mesh::Part part(0, indices, 0, model::Mesh::TRIANGLES); - + //DEBUG: model::Mesh::Part part(0, indices, 0, model::Mesh::LINE_STRIP); + _spotLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(sizeof(part), (gpu::Byte*) &part), gpu::Element::PART_DRAWCALL)); _spotLightMesh->makeBufferStream();