From e06f53b11eae74f00209d136032f7a5ac9e43e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=27=C3=A9lectron=20rare?= <108685187+electron-rare@users.noreply.github.com> Date: Mon, 18 May 2026 17:48:10 +0200 Subject: [PATCH] fix: pause sphere auto-rotation while dragging Auto-rotation ran unconditionally, so it kept spinning during a camera-orbit drag. Accumulate a frame-rate-independent angle only when the mouse is not pressed. --- oscope-sphere/src/ofApp.cpp | 6 +++++- oscope-sphere/src/ofApp.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/oscope-sphere/src/ofApp.cpp b/oscope-sphere/src/ofApp.cpp index 3708b9c..f8d46ec 100644 --- a/oscope-sphere/src/ofApp.cpp +++ b/oscope-sphere/src/ofApp.cpp @@ -30,6 +30,10 @@ void ofApp::setup() { void ofApp::update() { if (frozen_) return; + // Auto-rotation advances only when the mouse is not orbiting the camera. + if (!ofGetMousePressed()) + spin_ += 6.0f * static_cast(ofGetLastFrameTime()); + if (demoMode_) { demo_.next(buf1_, buf2_, 8192); } else { @@ -54,7 +58,7 @@ void ofApp::update() { void ofApp::draw() { cam_.begin(); ofPushMatrix(); - ofRotateYDeg(ofGetElapsedTimef() * 6.0f); + ofRotateYDeg(spin_); if (layerA_) sphere_.drawSkin(); if (layerC_) sphere_.drawPoints(); if (layerB_) rings_.draw(); diff --git a/oscope-sphere/src/ofApp.h b/oscope-sphere/src/ofApp.h index 84304b5..49e35d6 100644 --- a/oscope-sphere/src/ofApp.h +++ b/oscope-sphere/src/ofApp.h @@ -37,5 +37,6 @@ private: bool layerC_ = true; int colormap_ = 0; float scopeSr_ = 16.0e6f; + float spin_ = 0.0f; std::string statusText_; };