defer rebuilding the white box mesh by a frame to prevent reentrancy causing issues
This commit is contained in:
@@ -181,6 +181,9 @@ namespace WhiteBox
|
||||
// disconnect from any previously connected asset id
|
||||
AZ::Data::AssetBus::Handler::BusDisconnect();
|
||||
WhiteBoxMeshAssetNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
// ensure we're disconnected from the tick bus
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void EditorWhiteBoxMeshAsset::Release()
|
||||
@@ -215,11 +218,20 @@ namespace WhiteBox
|
||||
if (asset == m_meshAsset)
|
||||
{
|
||||
m_meshAsset = asset;
|
||||
EditorWhiteBoxComponentRequestBus::Event(
|
||||
m_entityComponentIdPair, &EditorWhiteBoxComponentRequestBus::Events::RebuildWhiteBox);
|
||||
|
||||
// defer rebuilding the mesh by a frame by connecting to the tick bus - this prevents issues
|
||||
// with reentrancy when rebuilding the white box mesh
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
}
|
||||
}
|
||||
|
||||
void EditorWhiteBoxMeshAsset::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
|
||||
{
|
||||
// after rebuilding the white box mesh, immediately disconnect from the tick bus (we only use it for deferred rebuilding)
|
||||
EditorWhiteBoxComponentRequestBus::Event(m_entityComponentIdPair, &EditorWhiteBoxComponentRequestBus::Events::RebuildWhiteBox);
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void EditorWhiteBoxMeshAsset::OnAssetReloaded(AZ::Data::Asset<AZ::Data::AssetData> asset)
|
||||
{
|
||||
OnAssetReady(asset);
|
||||
|
||||
Reference in New Issue
Block a user