mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Fix for uninitialized value in an edge case.
This commit is contained in:
parent
01091152be
commit
a50ffd0791
1 changed files with 14 additions and 10 deletions
|
@ -618,10 +618,13 @@ double pinhead_mesh_intersect(const Vec3d& s,
|
||||||
// We have to address the case when the direction vector v (same as dir)
|
// We have to address the case when the direction vector v (same as dir)
|
||||||
// is coincident with one of the world axes. In this case two of its
|
// is coincident with one of the world axes. In this case two of its
|
||||||
// components will be completely zero and one is 1.0. Our method becomes
|
// components will be completely zero and one is 1.0. Our method becomes
|
||||||
// dangerous here due to division with zero. Instead, vector a can be a
|
// dangerous here due to division with zero. Instead, vector 'a' can be an
|
||||||
// rotated version of v
|
// element-wise rotated version of 'v'
|
||||||
auto chk1 = [] (double val) { return std::abs(std::abs(val) - 1) < 1e-20; };
|
auto chk1 = [] (double val) { return std::abs(std::abs(val) - 1) < 1e-20; };
|
||||||
if(chk1(v(X)) || chk1(v(Y)) || chk1(v(Z))) a = {v(Z), v(X), v(Y)};
|
if(chk1(v(X)) || chk1(v(Y)) || chk1(v(Z))) {
|
||||||
|
a = {v(Z), v(X), v(Y)};
|
||||||
|
b = {v(Y), v(Z), v(X)};
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
a(Z) = -(v(Y)*a(Y)) / v(Z); a.normalize();
|
a(Z) = -(v(Y)*a(Y)) / v(Z); a.normalize();
|
||||||
b = a.cross(v);
|
b = a.cross(v);
|
||||||
|
@ -650,18 +653,14 @@ double pinhead_mesh_intersect(const Vec3d& s,
|
||||||
s(Z) + rpscos * a(Z) + rpssin * b(Z));
|
s(Z) + rpscos * a(Z) + rpssin * b(Z));
|
||||||
|
|
||||||
// Point ps is not on mesh but can be inside or outside as well. This
|
// Point ps is not on mesh but can be inside or outside as well. This
|
||||||
// would cause many problems with ray-casting. So we query the closest
|
// would cause many problems with ray-casting. To detect the position we
|
||||||
// point on the mesh to this.
|
// will use the ray-casting result (which has an is_inside predicate).
|
||||||
// auto psq = m.signed_distance(ps);
|
|
||||||
|
|
||||||
// This is the point on the circle on the back sphere
|
// This is the point on the circle on the back sphere
|
||||||
Vec3d p(c(X) + rpbcos * a(X) + rpbsin * b(X),
|
Vec3d p(c(X) + rpbcos * a(X) + rpbsin * b(X),
|
||||||
c(Y) + rpbcos * a(Y) + rpbsin * b(Y),
|
c(Y) + rpbcos * a(Y) + rpbsin * b(Y),
|
||||||
c(Z) + rpbcos * a(Z) + rpbsin * b(Z));
|
c(Z) + rpbcos * a(Z) + rpbsin * b(Z));
|
||||||
|
|
||||||
// Vec3d n = (p - psq.point_on_mesh()).normalized();
|
|
||||||
// phi = m.query_ray_hit(psq.point_on_mesh() + sd*n, n);
|
|
||||||
|
|
||||||
Vec3d n = (p - ps).normalized();
|
Vec3d n = (p - ps).normalized();
|
||||||
auto hr = m.query_ray_hit(ps + sd*n, n);
|
auto hr = m.query_ray_hit(ps + sd*n, n);
|
||||||
|
|
||||||
|
@ -695,9 +694,14 @@ double bridge_mesh_intersect(const Vec3d& s,
|
||||||
Vec3d a(0, 1, 0), b;
|
Vec3d a(0, 1, 0), b;
|
||||||
const double& sd = safety_distance;
|
const double& sd = safety_distance;
|
||||||
|
|
||||||
|
// INFO: for explanation of the method used here, see the previous method's
|
||||||
|
// comments.
|
||||||
|
|
||||||
auto chk1 = [] (double val) { return std::abs(std::abs(val) - 1) < 1e-20; };
|
auto chk1 = [] (double val) { return std::abs(std::abs(val) - 1) < 1e-20; };
|
||||||
if(chk1(dir(X)) || chk1(dir(Y)) || chk1(dir(Z)))
|
if(chk1(dir(X)) || chk1(dir(Y)) || chk1(dir(Z))) {
|
||||||
a = {dir(Z), dir(X), dir(Y)};
|
a = {dir(Z), dir(X), dir(Y)};
|
||||||
|
b = {dir(Y), dir(Z), dir(X)};
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
a(Z) = -(dir(Y)*a(Y)) / dir(Z); a.normalize();
|
a(Z) = -(dir(Y)*a(Y)) / dir(Z); a.normalize();
|
||||||
b = a.cross(dir);
|
b = a.cross(dir);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue