mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 22:44:59 +01:00
Merge pull request #327 from miloszunio/pr/mouse-hit
fix(render): Mouse_Hit() no longer says yes when it doesn't know
This commit is contained in:
@@ -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 },
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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().
|
||||
|
||||
Reference in New Issue
Block a user