mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 17:55:56 +08:00
Minor performance optimization
This commit is contained in:
parent
8a78428d10
commit
91c0741f61
@ -175,10 +175,14 @@ float PointCloud::get_distance(const Vec3f &p, size_t node_id) const
|
|||||||
case LEAF:
|
case LEAF:
|
||||||
case JUNCTION:{
|
case JUNCTION:{
|
||||||
auto mergept = find_merge_pt(p, node.pos, m_props.max_slope());
|
auto mergept = find_merge_pt(p, node.pos, m_props.max_slope());
|
||||||
|
double maxL2 = m_props.max_branch_length() * m_props.max_branch_length();
|
||||||
|
|
||||||
if (!mergept || mergept->z() < (m_props.ground_level() + 2 * node.Rmin))
|
if (!mergept || mergept->z() < (m_props.ground_level() + 2 * node.Rmin))
|
||||||
ret = std::numeric_limits<float>::infinity();
|
ret = std::numeric_limits<float>::infinity();
|
||||||
else if ( (node.pos - *mergept).norm() < m_props.max_branch_length())
|
else if (double a = (node.pos - *mergept).squaredNorm(),
|
||||||
ret = (p - *mergept).norm();
|
b = (p - *mergept).squaredNorm();
|
||||||
|
a < maxL2 && b < maxL2)
|
||||||
|
ret = std::sqrt(b);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -187,7 +191,7 @@ float PointCloud::get_distance(const Vec3f &p, size_t node_id) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setting the ret val to infinity will effectively discard this
|
// Setting the ret val to infinity will effectively discard this
|
||||||
// connection of nodes. max_branch_length property if used here
|
// connection of nodes. max_branch_length property is used here
|
||||||
// to discard node=>node and node=>mesh connections longer than this
|
// to discard node=>node and node=>mesh connections longer than this
|
||||||
// property.
|
// property.
|
||||||
if (t != BED && ret > m_props.max_branch_length())
|
if (t != BED && ret > m_props.max_branch_length())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user