mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
ifcviewer: event-driven rendering, idle scenes cost zero CPU
Replaced the 16ms QTimer with QEvent::UpdateRequest delivered via requestUpdate(), posted from every state mutator (mouse/wheel, model lifecycle, selection, visibility, resize). A static BIM scene — the common case for a viewer — now does no work at all between user actions. FPS is now measured as time spent inside render() rather than wall-clock gap between frames, so idle gaps don't pollute the 1-second window and the headline number reflects real render throughput. Headline fps still caps at vsync; sub-vsync profiling lives in the cull[...] phase timers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
#include <QWindow>
|
||||
#include <QOpenGLContext>
|
||||
#include <QtOpenGL/QOpenGLFunctions_4_5_Core>
|
||||
#include <QTimer>
|
||||
#include <QElapsedTimer>
|
||||
#include <QMatrix4x4>
|
||||
#include <QVector3D>
|
||||
@@ -107,6 +106,11 @@ struct ModelGpuData {
|
||||
bool hidden = false;
|
||||
};
|
||||
|
||||
// Rendering is event-driven: render() runs only when QEvent::UpdateRequest
|
||||
// is delivered, posted via requestUpdate(). An idle scene costs zero CPU.
|
||||
// INVARIANT: every public mutator that changes what should be on screen
|
||||
// (camera, selection, model lifecycle, visibility) MUST call requestUpdate()
|
||||
// before returning, or the viewport will go silently stale.
|
||||
class ViewportWindow : public QWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -217,8 +221,6 @@ private:
|
||||
|
||||
QOpenGLContext* context_ = nullptr;
|
||||
QOpenGLFunctions_4_5_Core* gl_ = nullptr;
|
||||
QTimer render_timer_;
|
||||
QElapsedTimer frame_clock_;
|
||||
bool gl_initialized_ = false;
|
||||
|
||||
// Shaders
|
||||
|
||||
Reference in New Issue
Block a user