From e5869ac7505c86f1ed2abd3fa588fd7934ec8163 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Oct 2023 23:30:00 +0200 Subject: [PATCH] pview: Fix camera positioning differences with offscreen window --- panda/src/framework/windowFramework.cxx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/panda/src/framework/windowFramework.cxx b/panda/src/framework/windowFramework.cxx index f28c05f3d7..69a84db74c 100644 --- a/panda/src/framework/windowFramework.cxx +++ b/panda/src/framework/windowFramework.cxx @@ -468,20 +468,24 @@ setup_trackball() { return; } + _trackball = new Trackball("trackball"); + _trackball->set_pos(LVector3::forward() * 50.0); + if (_window->is_of_type(GraphicsWindow::get_class_type()) && DCAST(GraphicsWindow, _window)->get_num_input_devices() > 0) { NodePath mouse = get_mouse(); - NodePath camera = get_camera_group(); - - _trackball = new Trackball("trackball"); - _trackball->set_pos(LVector3::forward() * 50.0); mouse.attach_new_node(_trackball); - - PT(Transform2SG) tball2cam = new Transform2SG("tball2cam"); - tball2cam->set_node(camera.node()); - _trackball->add_child(tball2cam); + } else { + // Still need to have a Trackball so that the camera positioning works the + // same way when we're rendering offscreen. + _panda_framework->get_data_root().attach_new_node(_trackball); } + NodePath camera = get_camera_group(); + PT(Transform2SG) tball2cam = new Transform2SG("tball2cam"); + tball2cam->set_node(camera.node()); + _trackball->add_child(tball2cam); + _got_trackball = true; }