Improve physical geometry, fluid solvers, audio, and profiling

This commit is contained in:
max
2026-10-30 18:57:56 +01:00
parent bf8621ad39
commit eb2b6366c2
130 changed files with 14649 additions and 862 deletions

View File

@@ -0,0 +1,24 @@
#pragma once
#include <SFML/Window/Event.hpp>
#include <algorithm>
#include <cmath>
namespace fluidsim::port::desktop {
class PlaybackControl {
public:
bool realtime() const {return realtime_;}
double target_speed() const {return realtime_?1.0:manual_speed_;}
bool handle_event(const sf::Event& event,bool shift=false) {
if(const auto* key=event.getIf<sf::Event::KeyPressed>()) {
if(key->code==sf::Keyboard::Key::Space){realtime_=!realtime_;return true;}
if(!realtime_&&key->code==sf::Keyboard::Key::PageUp){adjust(1);return true;}
if(!realtime_&&key->code==sf::Keyboard::Key::PageDown){adjust(-1);return true;}
}
if(const auto* wheel=event.getIf<sf::Event::MouseWheelScrolled>();wheel&&!realtime_&&shift) {adjust(wheel->delta);return true;}
return false;
}
private:
bool realtime_{true};
double manual_speed_{1};
void adjust(double steps){manual_speed_=std::clamp(manual_speed_*std::exp(steps*.12),.0001,1.0);}
};
}