16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-20 10:19:19 +02:00

mouse picking improvements: filter out backfacing; include near plane in ray origin computation

This commit is contained in:
Wls50
2025-11-28 22:01:27 +01:00
committed by Hirek
parent a22f449ecd
commit aa0b6e9965
2 changed files with 18 additions and 7 deletions

View File

@@ -386,12 +386,21 @@ bool NvRenderer::Render() {
(static_cast<glm::dvec2>(Global.cursor_pos) /
static_cast<glm::dvec2>(Global.window_size) -
.5);
m_mouse_ro = pass.m_origin;
glm::dvec4 mouse_rd_norm =
inverse(projection) * glm::dvec4(mousepos, 1., 1.);
mouse_rd_norm /= mouse_rd_norm.w;
m_mouse_rd =
normalize(inverse(transform) * glm::dvec4(mouse_rd_norm.xyz, 0.));
{
glm::dvec4 mouse_ro_norm =
inverse(projection) * glm::dvec4(mousepos, 1., 1.);
mouse_ro_norm /= mouse_ro_norm.w;
m_mouse_ro = pass.m_origin + static_cast<glm::dvec3>(
inverse(transform) *
glm::dvec4(mouse_ro_norm.xyz, 1.));
}
{
glm::dvec4 mouse_rd_norm =
inverse(projection) * glm::dvec4(mousepos, 0., 1.);
mouse_rd_norm /= mouse_rd_norm.w;
m_mouse_rd =
normalize(inverse(transform) * glm::dvec4(mouse_rd_norm.xyz, 0.));
}
}
m_picked_submodel = nullptr;