Fixed shifted clippimg plane triangulation on scaled meshes,

fighting z-fighting has to be done in world coords.
This commit is contained in:
Lukas Matena 2021-08-27 19:46:44 +02:00
parent 8dfc0422a8
commit d9f2fd7501

View File

@ -106,7 +106,6 @@ void MeshClipper::recalculate_triangles()
Transform3d tr = Transform3d::Identity(); Transform3d tr = Transform3d::Identity();
tr.rotate(q); tr.rotate(q);
tr = m_trafo.get_matrix() * tr; tr = m_trafo.get_matrix() * tr;
height_mesh += 0.001f; // to avoid z-fighting
if (m_limiting_plane != ClippingPlane::ClipsNothing()) if (m_limiting_plane != ClippingPlane::ClipsNothing())
{ {
@ -165,6 +164,8 @@ void MeshClipper::recalculate_triangles()
m_triangles2d = triangulate_expolygons_2f(expolys, m_trafo.get_matrix().matrix().determinant() < 0.); m_triangles2d = triangulate_expolygons_2f(expolys, m_trafo.get_matrix().matrix().determinant() < 0.);
tr.pretranslate(0.001 * m_plane.get_normal().normalized()); // to avoid z-fighting
m_vertex_array.release_geometry(); m_vertex_array.release_geometry();
for (auto it=m_triangles2d.cbegin(); it != m_triangles2d.cend(); it=it+3) { for (auto it=m_triangles2d.cbegin(); it != m_triangles2d.cend(); it=it+3) {
m_vertex_array.push_geometry(tr * Vec3d((*(it+0))(0), (*(it+0))(1), height_mesh), up); m_vertex_array.push_geometry(tr * Vec3d((*(it+0))(0), (*(it+0))(1), height_mesh), up);