From c10fa3bf20f5ac000a0ba67f2ec8e101af040d6f Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Thu, 23 Feb 2017 16:07:18 +0100 Subject: Integrate EnvironmentLight with Entity This will be needed to gather the environment lights in the scene. Change-Id: Icabcfb378c4938448bd241460b0f3fa3811c0287 Reviewed-by: Sean Harmer --- src/render/backend/entity.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/render/backend/entity.cpp') diff --git a/src/render/backend/entity.cpp b/src/render/backend/entity.cpp index 42233c85a..898c1e36e 100644 --- a/src/render/backend/entity.cpp +++ b/src/render/backend/entity.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -118,6 +119,7 @@ void Entity::cleanup() m_levelOfDetailComponents.clear(); m_shaderDataComponents.clear(); m_lightComponents.clear(); + m_environmentLightComponents.clear(); m_localBoundingVolume.reset(); m_worldBoundingVolume.reset(); m_worldBoundingVolumeWithChildren.reset(); @@ -174,6 +176,7 @@ void Entity::initializeFromPeer(const QNodeCreatedChangeBasePtr &change) m_levelOfDetailComponents.clear(); m_shaderDataComponents.clear(); m_lightComponents.clear(); + m_environmentLightComponents.clear(); m_localBoundingVolume.reset(new Sphere(peerId())); m_worldBoundingVolume.reset(new Sphere(peerId())); m_worldBoundingVolumeWithChildren.reset(new Sphere(peerId())); @@ -293,6 +296,8 @@ void Entity::addComponent(Qt3DCore::QComponent *component) m_materialComponent = component->id(); } else if (qobject_cast(component) != nullptr) { m_lightComponents.append(component->id()); + } else if (qobject_cast(component) != nullptr) { + m_environmentLightComponents.append(component->id()); } else if (qobject_cast(component) != nullptr) { m_shaderDataComponents.append(component->id()); } else if (qobject_cast(component) != nullptr) { @@ -326,6 +331,8 @@ void Entity::addComponent(Qt3DCore::QNodeIdTypePair idAndType) m_materialComponent = id; } else if (type->inherits(&QAbstractLight::staticMetaObject)) { // QAbstractLight subclasses QShaderData m_lightComponents.append(id); + } else if (type->inherits(&QEnvironmentLight::staticMetaObject)) { + m_environmentLightComponents.append(id); } else if (type->inherits(&QShaderData::staticMetaObject)) { m_shaderDataComponents.append(id); } else if (type->inherits(&QGeometryRenderer::staticMetaObject)) { @@ -363,6 +370,8 @@ void Entity::removeComponent(Qt3DCore::QNodeId nodeId) // m_boundingVolumeDebugComponent = QNodeId(); } else if (m_lightComponents.contains(nodeId)) { m_lightComponents.removeAll(nodeId); + } else if (m_environmentLightComponents.contains(nodeId)) { + m_environmentLightComponents.removeAll(nodeId); } else if (m_computeComponent == nodeId) { m_computeComponent = QNodeId(); } @@ -456,6 +465,16 @@ QVector Entity::componentsHandle() const return lightHandles; } +template<> +QVector Entity::componentsHandle() const +{ + QVector lightHandles; + lightHandles.reserve(m_environmentLightComponents.size()); + for (QNodeId id : m_environmentLightComponents) + lightHandles.append(m_nodeManagers->environmentLightManager()->lookupHandle(id)); + return lightHandles; +} + template<> HComputeCommand Entity::componentHandle() const { @@ -534,6 +553,16 @@ QVector Entity::renderComponents() const return lights; } +template<> +QVector Entity::renderComponents() const +{ + QVector lights; + lights.reserve(m_environmentLightComponents.size()); + for (QNodeId id : m_environmentLightComponents) + lights.append(m_nodeManagers->environmentLightManager()->lookupResource(id)); + return lights; +} + //template<> //BoundingVolumeDebug *Entity::renderComponent() const //{ @@ -581,6 +610,9 @@ QNodeId Entity::componentUuid() const { return m_computeComponen template<> QVector Entity::componentsUuid() const { return m_lightComponents; } +template<> +QVector Entity::componentsUuid() const { return m_environmentLightComponents; } + RenderEntityFunctor::RenderEntityFunctor(AbstractRenderer *renderer, NodeManagers *manager) : m_nodeManagers(manager) , m_renderer(renderer) -- cgit v1.2.3