18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-19 22:44:59 +01:00

fix(render): Mouse_Hit() no longer says yes when it doesn't know

The base renderer answered true, so the legacy OpenGL renderer and any other one without its own answer told the editor the
cursor was over something even over the sky, with a stale Mouse_Position(). The base answers false now; the legacy renderer
answers from the depth it reads under the cursor, as the gl33 one does (the gl46 and Vulkan ones of feat/gl46-migration do
already).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ
This commit is contained in:
Claude
2026-11-11 12:06:10 +01:00
parent 10c7527a64
commit 8b730b889b
3 changed files with 8 additions and 2 deletions

View File

@@ -4288,7 +4288,8 @@ opengl_renderer::Update_Mouse_Position() {
GLfloat pointdepth;
::glReadPixels( mousepos.x, mousepos.y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &pointdepth );
if( pointdepth < 1.0 ) {
m_mousehit = pointdepth < 1.0;
if( m_mousehit ) {
m_worldmousecoordinates =
glm::unProject(
glm::vec3{ mousepos, pointdepth },

View File

@@ -108,6 +108,8 @@ public:
Forget_Node( scene::basic_node const *Node ) override;
glm::dvec3
Mouse_Position() const override { return m_worldmousecoordinates; }
bool
Mouse_Hit() const override { return m_mousehit; }
glm::mat4
Camera_View_Matrix() const override { return glm::mat4( glm::mat3( m_colorpass.camera.modelview() ) ); }
glm::mat4
@@ -377,6 +379,7 @@ private:
std::vector<scene::basic_node *> m_picksceneryitems;
scene::basic_node *m_picksceneryitem { nullptr };
glm::vec3 m_worldmousecoordinates { 0.f };
bool m_mousehit { false }; // the depth under the cursor was of something drawn, not of the far plane
std::vector<std::function<void( TSubModel const *, const glm::vec2 )>> m_control_pick_requests;
std::vector<std::function<void( scene::basic_node * )>> m_node_pick_requests;
#ifdef EU07_USE_DEBUG_CAMERA

View File

@@ -111,7 +111,9 @@ public:
}
virtual auto Mouse_Position() const -> glm::dvec3 = 0;
virtual auto Mouse_Hit() const -> bool { return true; }
// whether the cursor was over something drawn when Mouse_Position() was read; a renderer which doesn't read it says no,
// so a caller never takes a stale or empty position for a hit
virtual auto Mouse_Hit() const -> bool { return false; }
// editor helpers: matrices/position of the most recent color pass camera.
// the view matrix is camera-relative (rotation only, camera at origin), matching the
// camera-relative rendering used by the engine; build object matrices relative to Camera_Position().