diff --git a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp index 2e55901bbd..a7fcbf53ae 100644 --- a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp @@ -31,7 +31,7 @@ bool RenderableLightEntityItem::addToScene(EntityItemPointer self, std::shared_p _myItem = scene->allocateID(); auto renderItem = std::make_shared(); - updateRenderItemFromEntity(renderItem.get()); + updateRenderItemFromEntity((*renderItem)); auto renderPayload = std::make_shared(renderItem); @@ -109,24 +109,24 @@ void RenderableLightEntityItem::updateLightFromEntity(render::PendingChanges& pe } - pendingChanges.updateItem(_myItem, [this](LightPayload& data) { - this->updateRenderItemFromEntity(&data); + pendingChanges.updateItem(_myItem, [&](LightPayload& data) { + updateRenderItemFromEntity(data); }); } -void RenderableLightEntityItem::updateRenderItemFromEntity(LightPayload* lightPayload) { +void RenderableLightEntityItem::updateRenderItemFromEntity(LightPayload& lightPayload) { auto entity = this; - lightPayload->setVisible(entity->getVisible()); + lightPayload.setVisible(entity->getVisible()); - auto light = lightPayload->editLight(); + auto light = lightPayload.editLight(); light->setPosition(entity->getPosition()); light->setOrientation(entity->getRotation()); bool success; - lightPayload->editBound() = entity->getAABox(success); + lightPayload.editBound() = entity->getAABox(success); if (!success) { - lightPayload->editBound() = render::Item::Bound(); + lightPayload.editBound() = render::Item::Bound(); } glm::vec3 dimensions = entity->getDimensions(); diff --git a/libraries/entities-renderer/src/RenderableLightEntityItem.h b/libraries/entities-renderer/src/RenderableLightEntityItem.h index d37fa30318..36ba0d6311 100644 --- a/libraries/entities-renderer/src/RenderableLightEntityItem.h +++ b/libraries/entities-renderer/src/RenderableLightEntityItem.h @@ -49,7 +49,7 @@ private: // Dirty flag turn true when either setSubClassProperties or readEntitySubclassDataFromBuffer is changing a value - void updateRenderItemFromEntity(LightPayload* lightPayload); + void updateRenderItemFromEntity(LightPayload& lightPayload); }; diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index fffdd2e0ff..8100d02e1c 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -95,7 +95,8 @@ public: virtual bool setProperties(const EntityItemProperties& properties); // Set properties for sub class so they can add their own properties - // it does nothing in the root eclass + // it does nothing in the root class + // This function is called by setProperties which then can detects if any property changes value in the SubClass (see aboe comment on setProperties) virtual bool setSubClassProperties(const EntityItemProperties& properties) { return false; } // Update properties with empty parent id and globalized/absolute values (applying offset), and apply (non-empty) log template to args id, name-or-type, parent id. diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index c365ab6a9f..872aac974e 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -719,36 +719,9 @@ void RenderDeferredLocals::run(const render::SceneContextPointer& sceneContext, auto textureFrameTransform = gpu::Framebuffer::evalSubregionTexcoordTransformCoefficients(deferredFramebuffer->getFrameSize(), viewport); - // batch.setProjectionTransform(projMat); - // batch.setViewTransform(viewTransform, true); - // gather lights - /* auto& srcPointLights = deferredLightingEffect->_pointLights; - auto& srcSpotLights = deferredLightingEffect->_spotLights; - int numPointLights = (int) srcPointLights.size(); - int offsetPointLights = 0; - int numSpotLights = (int) srcSpotLights.size(); - int offsetSpotLights = numPointLights; - - - std::vector lightIndices(numPointLights + numSpotLights + 1); - lightIndices[0] = 0; - - if (points && !srcPointLights.empty()) { - memcpy(lightIndices.data() + (lightIndices[0] + 1), srcPointLights.data(), srcPointLights.size() * sizeof(int)); - lightIndices[0] += (int)srcPointLights.size(); - } - if (spots && !srcSpotLights.empty()) { - memcpy(lightIndices.data() + (lightIndices[0] + 1), srcSpotLights.data(), srcSpotLights.size() * sizeof(int)); - lightIndices[0] += (int)srcSpotLights.size(); - }*/ - //auto lightClusters = deferredLightingEffect->_lightClusters; auto& lightIndices = lightClusters->_visibleLightIndices; if (!lightIndices.empty() && lightIndices[0] > 0) { - // _localLightsBuffer._buffer->setData(lightIndices.size() * sizeof(int), (const gpu::Byte*) lightIndices.data()); - // _localLightsBuffer._size = lightIndices.size() * sizeof(int); - - // Bind the global list of lights and the visible lights this frame batch.setUniformBuffer(deferredLightingEffect->_localLightLocations->lightBufferUnit, lightClusters->_lightStage->_lightArrayBuffer); @@ -756,44 +729,6 @@ void RenderDeferredLocals::run(const render::SceneContextPointer& sceneContext, batch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, lightClusters->_clusterGridBuffer); batch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, lightClusters->_clusterContentBuffer); - - // before we get to the real lighting, let s try to cull down the number of pixels - if (false) {/* - if (numPointLights > 0) { - auto mesh = deferredLightingEffect->getPointLightMesh(); - batch.setIndexBuffer(mesh->getIndexBuffer()); - batch.setInputBuffer(0, mesh->getVertexBuffer()); - batch.setInputFormat(mesh->getVertexFormat()); - auto& pointPart = mesh->getPartBuffer().get(0); - - // Point light pipeline - batch.setPipeline(deferredLightingEffect->_pointLightBack); - - batch.drawIndexedInstanced(numPointLights, model::Mesh::topologyToPrimitive(pointPart._topology), pointPart._numIndices, pointPart._startIndex, offsetPointLights); - - batch.setPipeline(deferredLightingEffect->_pointLightFront); - - batch.drawIndexedInstanced(numPointLights, model::Mesh::topologyToPrimitive(pointPart._topology), pointPart._numIndices, pointPart._startIndex, offsetPointLights); - } - - if (numSpotLights > 0) { - auto mesh = deferredLightingEffect->getSpotLightMesh(); - batch.setIndexBuffer(mesh->getIndexBuffer()); - batch.setInputBuffer(0, mesh->getVertexBuffer()); - batch.setInputFormat(mesh->getVertexFormat()); - auto& conePart = mesh->getPartBuffer().get(0); - - // Spot light pipeline - batch.setPipeline(deferredLightingEffect->_spotLightBack); - - batch.drawIndexedInstanced(numSpotLights, model::Mesh::topologyToPrimitive(conePart._topology), conePart._numIndices, conePart._startIndex, offsetSpotLights); - - batch.setPipeline(deferredLightingEffect->_spotLightFront); - - batch.drawIndexedInstanced(numSpotLights, model::Mesh::topologyToPrimitive(conePart._topology), conePart._numIndices, conePart._startIndex, offsetSpotLights); - }*/ - } - // Local light pipeline batch.setPipeline(deferredLightingEffect->_localLight); batch._glUniform4fv(deferredLightingEffect->_localLightLocations->texcoordFrameTransform, 1, reinterpret_cast(&textureFrameTransform));