Fixes crash in Atlas camera handlers, focus loss causes a scroll action, and seg fault if game not initialized. Fixes #988.

Fixes particles lingering in actor viewer when switching actors, by
clearing unattached particle emitters.

This was SVN commit r10457.
This commit is contained in:
historic_bruno 2011-10-30 05:09:31 +00:00
parent cf7aab4425
commit 0db6cfd2f7
4 changed files with 22 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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