mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-14 03:41:48 +08:00
PrintApply: Limiting the update of a modifier to an intersection
of bounding boxes of all the modifiers up to the parent printable volume.
This commit is contained in:
parent
f458101db6
commit
bcc02172f9
@ -613,13 +613,25 @@ const PrintObjectRegions::BoundingBox* find_volume_extents(const PrintObjectRegi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find a bounding box of a topmost printable volume referenced by this modifier given this_region_id.
|
// Find a bounding box of a topmost printable volume referenced by this modifier given this_region_id.
|
||||||
const PrintObjectRegions::BoundingBox* find_modifier_volume_extents(const PrintObjectRegions::LayerRangeRegions &layer_range, const int this_region_id)
|
PrintObjectRegions::BoundingBox find_modifier_volume_extents(const PrintObjectRegions::LayerRangeRegions &layer_range, const int this_region_id)
|
||||||
{
|
{
|
||||||
// Find the top-most printable volume of this modifier, or the printable volume itself.
|
// Find the top-most printable volume of this modifier, or the printable volume itself.
|
||||||
int parent_region_id = this_region_id;
|
const PrintObjectRegions::VolumeRegion &this_region = layer_range.volume_regions[this_region_id];
|
||||||
for (; ! layer_range.volume_regions[parent_region_id].model_volume->is_model_part(); parent_region_id = layer_range.volume_regions[parent_region_id].parent)
|
const PrintObjectRegions::BoundingBox *this_extents = find_volume_extents(layer_range, *this_region.model_volume);
|
||||||
|
assert(this_extents);
|
||||||
|
PrintObjectRegions::BoundingBox out { *this_extents };
|
||||||
|
if (! this_region.model_volume->is_model_part())
|
||||||
|
for (int parent_region_id = this_region.parent;;) {
|
||||||
assert(parent_region_id >= 0);
|
assert(parent_region_id >= 0);
|
||||||
return find_volume_extents(layer_range, *layer_range.volume_regions[parent_region_id].model_volume);
|
const PrintObjectRegions::VolumeRegion &parent_region = layer_range.volume_regions[parent_region_id];
|
||||||
|
const PrintObjectRegions::BoundingBox *parent_extents = find_volume_extents(layer_range, *parent_region.model_volume);
|
||||||
|
assert(parent_extents);
|
||||||
|
out.extend(*parent_extents);
|
||||||
|
if (parent_region.model_volume->is_model_part())
|
||||||
|
break;
|
||||||
|
parent_region_id = parent_region.parent;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintRegionConfig region_config_from_model_volume(const PrintRegionConfig &default_or_parent_region_config, const DynamicPrintConfig *layer_range_config, const ModelVolume &volume, size_t num_extruders);
|
PrintRegionConfig region_config_from_model_volume(const PrintRegionConfig &default_or_parent_region_config, const DynamicPrintConfig *layer_range_config, const ModelVolume &volume, size_t num_extruders);
|
||||||
@ -679,11 +691,8 @@ bool verify_update_print_object_regions(
|
|||||||
layer_range.volume_regions[next_region_id].parent == parent_region_id) {
|
layer_range.volume_regions[next_region_id].parent == parent_region_id) {
|
||||||
// A parent region is already overridden.
|
// A parent region is already overridden.
|
||||||
++ next_region_id;
|
++ next_region_id;
|
||||||
} else {
|
} else if (PrintObjectRegions::BoundingBox parent_bbox = find_modifier_volume_extents(layer_range, parent_region_id); parent_bbox.intersects(*bbox))
|
||||||
// Such parent region does not exist. If it is needed, then we need to reslice.
|
// Such parent region does not exist. If it is needed, then we need to reslice.
|
||||||
const PrintObjectRegions::BoundingBox *parent_bbox = find_modifier_volume_extents(layer_range, parent_region_id);
|
|
||||||
assert(parent_bbox != nullptr);
|
|
||||||
if (parent_bbox->intersects(*bbox))
|
|
||||||
// Only create new region for a modifier, which actually modifies config of it's parent.
|
// Only create new region for a modifier, which actually modifies config of it's parent.
|
||||||
if (PrintRegionConfig config = region_config_from_model_volume(parent_region.region->config(), nullptr, **it_model_volume, num_extruders);
|
if (PrintRegionConfig config = region_config_from_model_volume(parent_region.region->config(), nullptr, **it_model_volume, num_extruders);
|
||||||
config != parent_region.region->config())
|
config != parent_region.region->config())
|
||||||
@ -692,7 +701,6 @@ bool verify_update_print_object_regions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
PrintRegionConfig cfg = region.parent == -1 ?
|
PrintRegionConfig cfg = region.parent == -1 ?
|
||||||
region_config_from_model_volume(default_region_config, layer_range.config, **it_model_volume, num_extruders) :
|
region_config_from_model_volume(default_region_config, layer_range.config, **it_model_volume, num_extruders) :
|
||||||
region_config_from_model_volume(layer_range.volume_regions[region.parent].region->config(), nullptr, **it_model_volume, num_extruders);
|
region_config_from_model_volume(layer_range.volume_regions[region.parent].region->config(), nullptr, **it_model_volume, num_extruders);
|
||||||
@ -911,10 +919,8 @@ static PrintObjectRegions* generate_print_object_regions(
|
|||||||
for (int parent_region_id = int(layer_range.volume_regions.size()) - 1; parent_region_id >= 0; -- parent_region_id) {
|
for (int parent_region_id = int(layer_range.volume_regions.size()) - 1; parent_region_id >= 0; -- parent_region_id) {
|
||||||
const PrintObjectRegions::VolumeRegion &parent_region = layer_range.volume_regions[parent_region_id];
|
const PrintObjectRegions::VolumeRegion &parent_region = layer_range.volume_regions[parent_region_id];
|
||||||
const ModelVolume &parent_volume = *parent_region.model_volume;
|
const ModelVolume &parent_volume = *parent_region.model_volume;
|
||||||
if (parent_volume.is_model_part() || parent_volume.is_modifier()) {
|
if (parent_volume.is_model_part() || parent_volume.is_modifier())
|
||||||
const PrintObjectRegions::BoundingBox *parent_bbox = find_modifier_volume_extents(layer_range, parent_region_id);
|
if (PrintObjectRegions::BoundingBox parent_bbox = find_modifier_volume_extents(layer_range, parent_region_id); parent_bbox.intersects(*bbox))
|
||||||
assert(parent_bbox != nullptr);
|
|
||||||
if (parent_bbox->intersects(*bbox))
|
|
||||||
// Only create new region for a modifier, which actually modifies config of it's parent.
|
// Only create new region for a modifier, which actually modifies config of it's parent.
|
||||||
if (PrintRegionConfig config = region_config_from_model_volume(parent_region.region->config(), nullptr, volume, num_extruders);
|
if (PrintRegionConfig config = region_config_from_model_volume(parent_region.region->config(), nullptr, volume, num_extruders);
|
||||||
config != parent_region.region->config()) {
|
config != parent_region.region->config()) {
|
||||||
@ -923,7 +929,6 @@ static PrintObjectRegions* generate_print_object_regions(
|
|||||||
} else if (parent_model_part_id == -1 && parent_volume.is_model_part())
|
} else if (parent_model_part_id == -1 && parent_volume.is_model_part())
|
||||||
parent_model_part_id = parent_region_id;
|
parent_model_part_id = parent_region_id;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (! added && parent_model_part_id >= 0)
|
if (! added && parent_model_part_id >= 0)
|
||||||
// This modifier does not override any printable volume's configuration, however it may in the future.
|
// This modifier does not override any printable volume's configuration, however it may in the future.
|
||||||
// Store it so that verify_update_print_object_regions() will handle this modifier correctly if its configuration changes.
|
// Store it so that verify_update_print_object_regions() will handle this modifier correctly if its configuration changes.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user