diff --git a/radiant/camera/CamWnd.cpp b/radiant/camera/CamWnd.cpp index 049fbdd3ab..6e28eb4c08 100644 --- a/radiant/camera/CamWnd.cpp +++ b/radiant/camera/CamWnd.cpp @@ -73,6 +73,7 @@ CamWnd::CamWnd(wxWindow* parent) : _view(true), _camera(GlobalCameraManager().createCamera(_view, std::bind(&CamWnd::requestRedraw, this, std::placeholders::_1))), _drawing(false), + _updateRequested(false), _wxGLWidget(new wxutil::GLWidget(_mainWxWidget, std::bind(&CamWnd::onRender, this), "CamWnd")), _timer(this), _timerLock(false), @@ -85,6 +86,7 @@ CamWnd::CamWnd(wxWindow* parent) : { Bind(wxEVT_TIMER, &CamWnd::onFrame, this, _timer.GetId()); Bind(wxEVT_TIMER, &CamWnd::onFreeMoveTimer, this, _freeMoveTimer.GetId()); + _wxGLWidget->Bind(wxEVT_IDLE, &CamWnd::onIdle, this); setFarClipPlaneDistance(calculateFarPlaneDistance(getCameraSettings()->cubicScale())); setFarClipPlaneEnabled(getCameraSettings()->farClipEnabled()); @@ -976,11 +978,14 @@ void CamWnd::releaseStates() void CamWnd::queueDraw() { - if (_drawing) - { - return; - } + _updateRequested = true; +} + +void CamWnd::onIdle(wxIdleEvent& ev) +{ + if (!_updateRequested) return; + _updateRequested = false; _wxGLWidget->Refresh(false); } diff --git a/radiant/camera/CamWnd.h b/radiant/camera/CamWnd.h index c51f5ad471..6e568eac22 100644 --- a/radiant/camera/CamWnd.h +++ b/radiant/camera/CamWnd.h @@ -69,6 +69,9 @@ class CamWnd : // Is true during an active drawing process bool _drawing; + // Update of this window in the next idle event loop + bool _updateRequested; + // The GL widget wxutil::GLWidget* _wxGLWidget; @@ -242,6 +245,7 @@ class CamWnd : void onFrame(wxTimerEvent& ev); void onFreeMoveTimer(wxTimerEvent& ev); + void onIdle(wxIdleEvent& ev); void handleFreeMovement(float timePassed); void setFreeMoveFlags(unsigned int mask); diff --git a/radiant/xyview/XYWnd.cpp b/radiant/xyview/XYWnd.cpp index 9031261d8c..810cd4dd58 100644 --- a/radiant/xyview/XYWnd.cpp +++ b/radiant/xyview/XYWnd.cpp @@ -70,6 +70,7 @@ XYWnd::XYWnd(int id, wxWindow* parent) : _id(id), _wxGLWidget(new wxutil::GLWidget(parent, std::bind(&XYWnd::onRender, this), "XYWnd")), _drawing(false), + _updateRequested(false), _minWorldCoord(game::current::getValue("/defaults/minWorldCoord")), _maxWorldCoord(game::current::getValue("/defaults/maxWorldCoord")), _defaultCursor(wxCURSOR_DEFAULT), @@ -291,15 +292,11 @@ void XYWnd::forceRedraw() void XYWnd::queueDraw() { - if (_drawing) - { - return; // deny redraw requests if we're currently drawing - } - - _wxGLWidget->Refresh(false); + _updateRequested = true; } -void XYWnd::onSceneGraphChange() { +void XYWnd::onSceneGraphChange() +{ // Pass the call to queueDraw. queueDraw(); } @@ -1587,6 +1584,12 @@ void XYWnd::onIdle(wxIdleEvent& ev) { performChaseMouse(); } + + if (_updateRequested) + { + _updateRequested = false; + _wxGLWidget->Refresh(false); + } } void XYWnd::onGLResize(wxSizeEvent& ev) diff --git a/radiant/xyview/XYWnd.h b/radiant/xyview/XYWnd.h index e9945dc93a..7f201f5879 100644 --- a/radiant/xyview/XYWnd.h +++ b/radiant/xyview/XYWnd.h @@ -36,6 +36,7 @@ class XYWnd : wxutil::GLWidget* _wxGLWidget; bool _drawing; + bool _updateRequested; // The maximum/minimum values of a coordinate double _minWorldCoord;