mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-06 00:16:17 +08:00
remove expensive merged layer computation, fix overhang computation, smoothen seams
This commit is contained in:
parent
9a3364d695
commit
8126879e6a
@ -1016,11 +1016,7 @@ class PerimeterDistancer {
|
||||
|
||||
public:
|
||||
PerimeterDistancer(const Layer *layer) {
|
||||
static const float eps = float(scale_(layer->object()->config().slice_closing_radius.value));
|
||||
// merge with offset
|
||||
ExPolygons merged = layer->merged(eps);
|
||||
// ofsset back
|
||||
ExPolygons layer_outline = offset_ex(merged, -eps);
|
||||
ExPolygons layer_outline = layer->lslices;
|
||||
for (const ExPolygon &island : layer_outline) {
|
||||
assert(island.contour.is_counter_clockwise());
|
||||
for (const auto &line : island.contour.lines()) {
|
||||
@ -1130,13 +1126,10 @@ void SeamPlacer::calculate_overhangs_and_layer_embedding(const PrintObject *po)
|
||||
for (SeamCandidate &perimeter_point : layers[layer_idx].points) {
|
||||
Point point = Point::new_scale(Vec2f { perimeter_point.position.head<2>() });
|
||||
if (prev_layer_distancer.get() != nullptr) {
|
||||
perimeter_point.overhang = (prev_layer_distancer->distance_from_perimeter(point)
|
||||
+ 0.5f * perimeter_point.perimeter.flow_width
|
||||
perimeter_point.overhang = prev_layer_distancer->distance_from_perimeter(point)
|
||||
// + 0.5f * perimeter_point.perimeter.flow_width
|
||||
- tan(SeamPlacer::overhang_angle_threshold)
|
||||
* po->layers()[layer_idx]->height)
|
||||
/ (3.0f * perimeter_point.perimeter.flow_width);
|
||||
//NOTE disables the feature to place seams on slowly decreasing areas. Remove the following line to enable.
|
||||
perimeter_point.overhang = perimeter_point.overhang < 0.0f ? 0.0f : perimeter_point.overhang;
|
||||
* po->layers()[layer_idx]->height;
|
||||
}
|
||||
|
||||
if (should_compute_layer_embedding) { // search for embedded perimeter points (points hidden inside the print ,e.g. multimaterial join, best position for seam)
|
||||
@ -1399,7 +1392,7 @@ void SeamPlacer::align_seam_points(const PrintObject *po, const SeamPlacerImpl::
|
||||
observations[index] = current.position.head<2>();
|
||||
observation_points[index] = current.position.z();
|
||||
weights[index] = angle_weight(current.local_ccw_angle);
|
||||
float sign = layer_angle > 2.0 * std::abs(current.local_ccw_angle) ? -1.0f : 1.0f;
|
||||
float sign = layer_angle > 2.0 * std::abs(current.local_ccw_angle) ? -0.8f : 1.0f;
|
||||
if (current.type == EnforcedBlockedSeamPoint::Enforced) {
|
||||
sign = 1.0f;
|
||||
weights[index] += 3.0f;
|
||||
@ -1417,10 +1410,10 @@ void SeamPlacer::align_seam_points(const PrintObject *po, const SeamPlacerImpl::
|
||||
// Perimeter structure of the point; also set flag aligned to true
|
||||
for (size_t index = 0; index < seam_string.size(); ++index) {
|
||||
const auto &pair = seam_string[index];
|
||||
float t = std::min(1.0f, std::abs(layers[pair.first].points[pair.second].local_ccw_angle)
|
||||
/ SeamPlacer::sharp_angle_snapping_threshold);
|
||||
float t = std::min(1.0f, std::pow(std::abs(layers[pair.first].points[pair.second].local_ccw_angle)
|
||||
/ SeamPlacer::sharp_angle_snapping_threshold, 3.0f));
|
||||
if (layers[pair.first].points[pair.second].type == EnforcedBlockedSeamPoint::Enforced){
|
||||
t = std::max(0.7f, t);
|
||||
t = std::max(0.4f, t);
|
||||
}
|
||||
|
||||
Vec3f current_pos = layers[pair.first].points[pair.second].position;
|
||||
|
@ -126,10 +126,12 @@ public:
|
||||
//square of number of rays per sample point
|
||||
static constexpr size_t sqr_rays_per_sample_point = 5;
|
||||
|
||||
// arm length used during angles computation
|
||||
static constexpr float polygon_local_angles_arm_distance = 0.5f;
|
||||
// snapping angle - angles larger than this value will be snapped to during seam painting
|
||||
static constexpr float sharp_angle_snapping_threshold = 55.0f * float(PI) / 180.0f;
|
||||
// overhang angle for seam placement that still yields good results, in degrees, measured from vertical direction
|
||||
static constexpr float overhang_angle_threshold = 50.0f * float(PI) / 180.0f;
|
||||
static constexpr float overhang_angle_threshold = 45.0f * float(PI) / 180.0f;
|
||||
|
||||
// determines angle importance compared to visibility ( neutral value is 1.0f. )
|
||||
static constexpr float angle_importance_aligned = 0.6f;
|
||||
|
Loading…
x
Reference in New Issue
Block a user