Accounted for deletion of lights
- Not entirely urgent, but removal of resources from render graph fails. Need a valid check of handles.
This commit is contained in:
parent
64e60a5114
commit
2bba48b09f
|
@ -30,5 +30,5 @@ constexpr SHEventIdentifier SH_BUTTON_RELEASE_EVENT { 21 };
|
||||||
constexpr SHEventIdentifier SH_BUTTON_HOVER_ENTER_EVENT { 22 };
|
constexpr SHEventIdentifier SH_BUTTON_HOVER_ENTER_EVENT { 22 };
|
||||||
constexpr SHEventIdentifier SH_BUTTON_HOVER_EXIT_EVENT { 23 };
|
constexpr SHEventIdentifier SH_BUTTON_HOVER_EXIT_EVENT { 23 };
|
||||||
constexpr SHEventIdentifier SH_ASSET_COMPILE_EVENT { 24 };
|
constexpr SHEventIdentifier SH_ASSET_COMPILE_EVENT { 24 };
|
||||||
constexpr SHEventIdentifier SH_LIGHT_DELETE_EVENT { 25 };
|
constexpr SHEventIdentifier SH_GRAPHICS_LIGHT_DELETE_EVENT { 25 };
|
||||||
|
|
||||||
|
|
|
@ -542,7 +542,7 @@ namespace SHADE
|
||||||
std::make_shared<SHEventReceiverSpec<SHGraphicsSystem>>(this, &SHGraphicsSystem::ReceiveLightDeleteEvent)
|
std::make_shared<SHEventReceiverSpec<SHGraphicsSystem>>(this, &SHGraphicsSystem::ReceiveLightDeleteEvent)
|
||||||
};
|
};
|
||||||
ReceiverPtr lightDeleteReceivePtr = std::dynamic_pointer_cast<SHEventReceiver>(lightDeleteEvent);
|
ReceiverPtr lightDeleteReceivePtr = std::dynamic_pointer_cast<SHEventReceiver>(lightDeleteEvent);
|
||||||
SHEventManager::SubscribeTo(SH_ASSET_COMPILE_EVENT, lightDeleteReceivePtr);
|
SHEventManager::SubscribeTo(SH_GRAPHICS_LIGHT_DELETE_EVENT, lightDeleteReceivePtr);
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<SHEventReceiverSpec<SHGraphicsSystem>> compileAssetReceiever
|
std::shared_ptr<SHEventReceiverSpec<SHGraphicsSystem>> compileAssetReceiever
|
||||||
|
@ -951,19 +951,19 @@ namespace SHADE
|
||||||
auto const& EVENT_DATA = reinterpret_cast<const SHEventSpec<SHLightShadowEvent>*>(eventPtr.get())->data;
|
auto const& EVENT_DATA = reinterpret_cast<const SHEventSpec<SHLightShadowEvent>*>(eventPtr.get())->data;
|
||||||
auto* lightComp = SHComponentManager::GetComponent<SHLightComponent>(EVENT_DATA->lightEntity);
|
auto* lightComp = SHComponentManager::GetComponent<SHLightComponent>(EVENT_DATA->lightEntity);
|
||||||
|
|
||||||
if (lightComp && lightComp->GetShadowMapIndex())
|
if (lightComp && lightComp->GetShadowMapIndex() != SHLightData::INVALID_SHADOW_MAP_INDEX)
|
||||||
{
|
{
|
||||||
std::string depthResourceName = "ShadowMap_Depth " + std::to_string(EVENT_DATA->lightEntity);
|
std::string depthResourceName = "ShadowMap_Depth " + std::to_string(EVENT_DATA->lightEntity);
|
||||||
std::string shadowMapResourceName = "ShadowMap " + std::to_string(EVENT_DATA->lightEntity);
|
std::string shadowMapResourceName = "ShadowMap " + std::to_string(EVENT_DATA->lightEntity);
|
||||||
std::string shadowMapBlurredResourceName = "ShadowMap Blurred" + std::to_string(EVENT_DATA->lightEntity);
|
std::string shadowMapBlurredResourceName = "ShadowMap Blurred" + std::to_string(EVENT_DATA->lightEntity);
|
||||||
|
|
||||||
// Remove render graph node
|
// Remove render graph node
|
||||||
renderGraph->RemoveNode(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName);
|
//renderGraph->RemoveNode(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName);
|
||||||
|
|
||||||
// Remove render graph resource
|
// Remove render graph resource
|
||||||
renderGraph->RemoveResource(depthResourceName);
|
//renderGraph->RemoveResource(depthResourceName);
|
||||||
renderGraph->RemoveResource(shadowMapResourceName);
|
//renderGraph->RemoveResource(shadowMapResourceName);
|
||||||
renderGraph->RemoveResource(shadowMapBlurredResourceName);
|
//renderGraph->RemoveResource(shadowMapBlurredResourceName);
|
||||||
|
|
||||||
// Register light component shadow map index into light system as recyclable
|
// Register light component shadow map index into light system as recyclable
|
||||||
lightingSubSystem->RemoveShadowMap (EVENT_DATA->lightEntity);
|
lightingSubSystem->RemoveShadowMap (EVENT_DATA->lightEntity);
|
||||||
|
|
|
@ -21,6 +21,14 @@ namespace SHADE
|
||||||
|
|
||||||
void SHLightComponent::OnDestroy(void)
|
void SHLightComponent::OnDestroy(void)
|
||||||
{
|
{
|
||||||
|
if (lightData.shadowMapIndex != SHLightData::INVALID_SHADOW_MAP_INDEX)
|
||||||
|
{
|
||||||
|
// Create new event and broadcast it
|
||||||
|
SHDeleteLightEvent newEvent;
|
||||||
|
newEvent.lightEntity = GetEID();
|
||||||
|
|
||||||
|
SHEventManager::BroadcastEvent<SHDeleteLightEvent>(newEvent, SH_GRAPHICS_LIGHT_DELETE_EVENT);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue