feat: Adjust zoom speed based on distance for consistent feel
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -44,7 +44,13 @@ void Camera::wheelEvent(QWheelEvent* event, const QVector3D& worldPos)
|
||||
{
|
||||
QPoint numDegrees = event->angleDelta() / 8;
|
||||
if (!numDegrees.isNull()) {
|
||||
float zoomAmount = numDegrees.y() / 5.0f;
|
||||
// Make zoom speed proportional to distance, with a minimum speed and a cap.
|
||||
// The factors are chosen to match the original zoom speed at the default zoom level.
|
||||
float dist = -m_zoom;
|
||||
dist = qMin(dist, 200.0f); // Cap distance to avoid crazy fast zoom out.
|
||||
float zoomFactor = dist * 0.009f + 0.02f;
|
||||
float zoomAmount = numDegrees.y() * zoomFactor;
|
||||
|
||||
float oldZoom = m_zoom;
|
||||
float newZoom = oldZoom + zoomAmount;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user