diff --git a/source/graphics/ParticleManager.cpp b/source/graphics/ParticleManager.cpp index b30adbf661..865f97c922 100644 --- a/source/graphics/ParticleManager.cpp +++ b/source/graphics/ParticleManager.cpp @@ -55,6 +55,11 @@ void CParticleManager::AddUnattachedEmitter(const CParticleEmitterPtr& emitter) m_UnattachedEmitters.push_back(emitter); } +void CParticleManager::ClearUnattachedEmitters() +{ + m_UnattachedEmitters.clear(); +} + void CParticleManager::Interpolate(float frameLength) { m_CurrentTime += frameLength; diff --git a/source/graphics/ParticleManager.h b/source/graphics/ParticleManager.h index 729daba1c3..c27e653b08 100644 --- a/source/graphics/ParticleManager.h +++ b/source/graphics/ParticleManager.h @@ -40,6 +40,11 @@ public: */ void AddUnattachedEmitter(const CParticleEmitterPtr& emitter); + /** + * Delete unattached emitters if we don't wish to see them anymore (like in actor viewer) + */ + void ClearUnattachedEmitters(); + void RenderSubmit(SceneCollector& collector, const CFrustum& frustum); void Interpolate(float frameLength); diff --git a/source/tools/atlas/GameInterface/ActorViewer.cpp b/source/tools/atlas/GameInterface/ActorViewer.cpp index 6858093129..498ac0771b 100644 --- a/source/tools/atlas/GameInterface/ActorViewer.cpp +++ b/source/tools/atlas/GameInterface/ActorViewer.cpp @@ -200,6 +200,9 @@ void ActorViewer::SetActor(const CStrW& name, const CStrW& animation) m.Entity = INVALID_ENTITY; } + // Clear particles associated with deleted entity + g_Renderer.GetParticleManager().ClearUnattachedEmitters(); + // If there's no actor to display, return with nothing loaded if (id.empty()) return; diff --git a/source/tools/atlas/GameInterface/Handlers/CameraCtrlHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/CameraCtrlHandlers.cpp index e85900880b..a17a592c2b 100644 --- a/source/tools/atlas/GameInterface/Handlers/CameraCtrlHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/CameraCtrlHandlers.cpp @@ -38,7 +38,7 @@ namespace AtlasMessage { MESSAGEHANDLER(CameraReset) { - if (g_Game->GetView()->GetCinema()->IsPlaying()) + if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying()) return; CVector3D focus = g_Game->GetView()->GetCamera()->GetFocus(); @@ -63,7 +63,7 @@ MESSAGEHANDLER(CameraReset) MESSAGEHANDLER(ScrollConstant) { - if (g_Game->GetView()->GetCinema()->IsPlaying()) + if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying()) return; if (msg->dir < 0 || msg->dir > 5) @@ -81,7 +81,7 @@ MESSAGEHANDLER(ScrollConstant) MESSAGEHANDLER(Scroll) { - if (g_Game->GetView()->GetCinema()->IsPlaying()) // TODO: do this better (probably a separate View class for cinematics) + if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying()) // TODO: do this better (probably a separate View class for cinematics) return; static CVector3D targetPos; @@ -131,7 +131,7 @@ MESSAGEHANDLER(Scroll) MESSAGEHANDLER(SmoothZoom) { - if (g_Game->GetView()->GetCinema()->IsPlaying()) + if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying()) return; g_GameLoop->input.zoomDelta += msg->amount; @@ -139,7 +139,7 @@ MESSAGEHANDLER(SmoothZoom) MESSAGEHANDLER(RotateAround) { - if (g_Game->GetView()->GetCinema()->IsPlaying()) + if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying()) return; static CVector3D focusPos; @@ -222,6 +222,9 @@ MESSAGEHANDLER(LookAt) QUERYHANDLER(GetView) { + if (!g_Game) + return; + CVector3D focus = g_Game->GetView()->GetCamera()->GetFocus(); sCameraInfo info; @@ -242,7 +245,7 @@ QUERYHANDLER(GetView) MESSAGEHANDLER(SetView) { - if (g_Game->GetView()->GetCinema()->IsPlaying()) + if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying()) return; CGameView* view = g_Game->GetView();