Migrate 32 engine definitions into validated startup-loaded TOML files and separate configuration and snapshots from scenario assembly. Add camera-based stereo propagation from shared pipe geometry, preserve exhaust character, tune carburetor mixtures and idle, use ignition cuts for carb engines, and support returning to the scenario menu. Validation: full Windows build and all 14 CTest checks passed.
28 lines
1.3 KiB
C++
28 lines
1.3 KiB
C++
#pragma once
|
|
#include "FluidSim/AudioProcessing.hpp"
|
|
#include <SFML/System/Vector2.hpp>
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
namespace fluidsim::port::desktop {
|
|
struct OrbitCamera {
|
|
Vec3 target{.12f,.25f,0};
|
|
float yaw{-28},pitch{24},distance{2.2f};
|
|
AudioListener listener(float distance_scale=1, float target_offset_x=0) const {
|
|
const float y=yaw*.017453293f,p=pitch*.017453293f,d=distance*distance_scale;
|
|
// Inverse of the renderer's pitch/yaw world-to-view rotation.
|
|
return {{target.x+target_offset_x-std::sin(y)*std::cos(p)*d,
|
|
target.y+std::sin(p)*d,target.z+std::cos(y)*std::cos(p)*d},
|
|
{std::cos(y),0,std::sin(y)}};
|
|
}
|
|
void reset(float aspect) {target={.12f,.25f,0};yaw=-28;pitch=24;distance=std::max(.65f,1.6f/aspect)/.414214f;}
|
|
void orbit(sf::Vector2i delta) {yaw+=delta.x*.35f;pitch=std::clamp(pitch+delta.y*.3f,-75.f,80.f);}
|
|
void pan(sf::Vector2i delta,float height) {
|
|
const float y=yaw*.017453293f,p=pitch*.017453293f,k=distance*.828427f/std::max(height,1.f);
|
|
target.x+=k*(-delta.x*std::cos(y)+delta.y*std::sin(p)*std::sin(y));
|
|
target.y+=k*delta.y*std::cos(p);
|
|
target.z+=k*(-delta.x*std::sin(y)-delta.y*std::sin(p)*std::cos(y));
|
|
}
|
|
void zoom(float delta) {distance=std::clamp(distance*std::exp(-delta*.12f),.35f,12.f);}
|
|
};
|
|
}
|