adressed reveiw comments

This commit is contained in:
samcake 2016-11-22 10:15:49 -08:00
parent 31232a1078
commit dfc0b7beac
4 changed files with 11 additions and 75 deletions

View file

@ -31,7 +31,7 @@ bool RenderableLightEntityItem::addToScene(EntityItemPointer self, std::shared_p
_myItem = scene->allocateID();
auto renderItem = std::make_shared<LightPayload>();
updateRenderItemFromEntity(renderItem.get());
updateRenderItemFromEntity((*renderItem));
auto renderPayload = std::make_shared<LightPayload::Payload>(renderItem);
@ -109,24 +109,24 @@ void RenderableLightEntityItem::updateLightFromEntity(render::PendingChanges& pe
}
pendingChanges.updateItem<LightPayload>(_myItem, [this](LightPayload& data) {
this->updateRenderItemFromEntity(&data);
pendingChanges.updateItem<LightPayload>(_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();

View file

@ -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);
};

View file

@ -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.

View file

@ -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<int> 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<model::Mesh::Part>(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<model::Mesh::Part>(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<const float*>(&textureFrameTransform));