mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 22:22:00 +08:00
SPE-2349: Allow painting on broken meshes.
There are checks for a number of hits inside the MeshRaycaster::unproject_on_mesh(), but those checks are valid only on unbroken meshes. So, those checks are bypassed for painting gizmos.
This commit is contained in:
parent
3e4e9835f9
commit
40eee4cae7
@ -760,13 +760,9 @@ void GLGizmoPainterBase::update_raycast_cache(const Vec2d& mouse_position,
|
|||||||
for (int mesh_id = 0; mesh_id < int(trafo_matrices.size()); ++mesh_id) {
|
for (int mesh_id = 0; mesh_id < int(trafo_matrices.size()); ++mesh_id) {
|
||||||
|
|
||||||
if (m_c->raycaster()->raycasters()[mesh_id]->unproject_on_mesh(
|
if (m_c->raycaster()->raycasters()[mesh_id]->unproject_on_mesh(
|
||||||
mouse_position,
|
mouse_position, trafo_matrices[mesh_id], camera, hit, normal,
|
||||||
trafo_matrices[mesh_id],
|
m_c->object_clipper()->get_clipping_plane(), &facet, false
|
||||||
camera,
|
))
|
||||||
hit,
|
|
||||||
normal,
|
|
||||||
m_c->object_clipper()->get_clipping_plane(),
|
|
||||||
&facet))
|
|
||||||
{
|
{
|
||||||
// In case this hit is clipped, skip it.
|
// In case this hit is clipped, skip it.
|
||||||
if (is_mesh_point_clipped(hit.cast<double>(), trafo_matrices[mesh_id]))
|
if (is_mesh_point_clipped(hit.cast<double>(), trafo_matrices[mesh_id]))
|
||||||
|
@ -426,14 +426,11 @@ void MeshRaycaster::line_from_mouse_pos(const Vec2d& mouse_pos, const Transform3
|
|||||||
|
|
||||||
bool MeshRaycaster::unproject_on_mesh(const Vec2d& mouse_pos, const Transform3d& trafo, const Camera& camera,
|
bool MeshRaycaster::unproject_on_mesh(const Vec2d& mouse_pos, const Transform3d& trafo, const Camera& camera,
|
||||||
Vec3f& position, Vec3f& normal, const ClippingPlane* clipping_plane,
|
Vec3f& position, Vec3f& normal, const ClippingPlane* clipping_plane,
|
||||||
size_t* facet_idx) const
|
size_t* facet_idx, const bool require_even_number_of_hits) const
|
||||||
{
|
{
|
||||||
Vec3d point;
|
Vec3d point;
|
||||||
Vec3d direction;
|
Vec3d direction;
|
||||||
CameraUtils::ray_from_screen_pos(camera, mouse_pos, point, direction);
|
line_from_mouse_pos(mouse_pos, trafo, camera, point, direction);
|
||||||
Transform3d inv = trafo.inverse();
|
|
||||||
point = inv*point;
|
|
||||||
direction = inv.linear()*direction;
|
|
||||||
|
|
||||||
std::vector<AABBMesh::hit_result> hits = m_emesh.query_ray_hits(point, direction);
|
std::vector<AABBMesh::hit_result> hits = m_emesh.query_ray_hits(point, direction);
|
||||||
|
|
||||||
@ -451,7 +448,7 @@ bool MeshRaycaster::unproject_on_mesh(const Vec2d& mouse_pos, const Transform3d&
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i==hits.size() || (hits.size()-i) % 2 != 0) {
|
if (i == hits.size() || (require_even_number_of_hits && (hits.size() - i) % 2 != 0)) {
|
||||||
// All hits are either clipped, or there is an odd number of unclipped
|
// All hits are either clipped, or there is an odd number of unclipped
|
||||||
// hits - meaning the nearest must be from inside the mesh.
|
// hits - meaning the nearest must be from inside the mesh.
|
||||||
return false;
|
return false;
|
||||||
|
@ -186,7 +186,8 @@ public:
|
|||||||
Vec3f& position, // where to save the positibon of the hit (mesh coords)
|
Vec3f& position, // where to save the positibon of the hit (mesh coords)
|
||||||
Vec3f& normal, // normal of the triangle that was hit
|
Vec3f& normal, // normal of the triangle that was hit
|
||||||
const ClippingPlane* clipping_plane = nullptr, // clipping plane (if active)
|
const ClippingPlane* clipping_plane = nullptr, // clipping plane (if active)
|
||||||
size_t* facet_idx = nullptr // index of the facet hit
|
size_t* facet_idx = nullptr, // index of the facet hit
|
||||||
|
bool require_even_number_of_hits = true // When it is true, then an odd number (unclipped) of hits are ignored, and false is returned.
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
const AABBMesh &get_aabb_mesh() const { return m_emesh; }
|
const AABBMesh &get_aabb_mesh() const { return m_emesh; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user