This only happens with ofEasyCam's ortho mode + custom viewport.
Expected behavour
Expected behavour is to zoom in/out into the mouse pointer position when user scroll mouse wheel (or R click drag). It works fine with normal viewport with 0,0 position and full window w, h. But when we use custom viewport (e.g. camera.begin(viewport); ) then it zoom in/out into wrong position.
Issue
The problem is that ofEasyCam forgots to give viewport parameter to screenToWorld(). screenToWorld() calls ofCamera::getViewport() internaly but ofCamera seems not storing custom viewport parameter but just get current window's viewport, which is {0,0,fullW, fullH}. Hence it gives wrong world position.
Reproducing this bug
tested on
macOS 14.5
Xcode 15.4
openFrameworks(latest master at the time of this writting)
ofApp.h
#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp {
public:
void setup();
void draw();
void drawViewportOutline(const ofRectangle & viewport);
ofRectangle viewport;
ofEasyCam camera;
};
This only happens with ofEasyCam's ortho mode + custom viewport.
Expected behavour
Expected behavour is to zoom in/out into the mouse pointer position when user scroll mouse wheel (or R click drag). It works fine with normal viewport with 0,0 position and full window w, h. But when we use custom viewport (e.g. camera.begin(viewport); ) then it zoom in/out into wrong position.
Issue
The problem is that ofEasyCam forgots to give viewport parameter to
screenToWorld()
.screenToWorld()
callsofCamera::getViewport()
internaly but ofCamera seems not storing custom viewport parameter but just get current window's viewport, which is {0,0,fullW, fullH}. Hence it gives wrong world position.Reproducing this bug
tested on
ofApp.h
ofApp.cpp
Before and after
Before
After