mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-28 15:43:16 +08:00
ENH: speed up timelapse pos pick
1. Cache the bbox of object jira: STUDIO-11625 Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I4682cd5fe2aef1dc5cd5fd6be33425c7095263eb
This commit is contained in:
parent
89a0af1c87
commit
07516d1fec
@ -16,6 +16,7 @@ namespace Slic3r {
|
||||
m_bed_polygon.clear();
|
||||
m_extruder_printable_area.clear();
|
||||
m_all_layer_pos = std::nullopt;
|
||||
bbox_cache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,6 +172,10 @@ namespace Slic3r {
|
||||
// get the real instance bounding box, remove the plate offset and add raft height
|
||||
BoundingBoxf3 TimelapsePosPicker::get_real_instance_bbox(const PrintInstance& instance)
|
||||
{
|
||||
auto iter = bbox_cache.find(&instance);
|
||||
if (iter != bbox_cache.end())
|
||||
return iter->second;
|
||||
|
||||
auto bbox = instance.get_bounding_box();
|
||||
double raft_height =get_raft_height(instance.print_object);
|
||||
bbox.max.z() += raft_height;
|
||||
@ -179,6 +184,9 @@ namespace Slic3r {
|
||||
bbox.max.x() -= m_plate_offset.x();
|
||||
bbox.min.y() -= m_plate_offset.y();
|
||||
bbox.max.y() -= m_plate_offset.y();
|
||||
|
||||
bbox_cache[&instance] = bbox;
|
||||
|
||||
return bbox;
|
||||
}
|
||||
|
||||
@ -270,7 +278,7 @@ namespace Slic3r {
|
||||
if (!obj)
|
||||
return {};
|
||||
// in bambu studio, each object only has one instance
|
||||
auto instance = obj->instances().front();
|
||||
const auto& instance = obj->instances().front();
|
||||
auto instance_bbox = get_real_instance_bbox(instance);
|
||||
Point min_p{ instance_bbox.min.x(),instance_bbox.min.y() };
|
||||
Point max_p{ instance_bbox.max.x(),instance_bbox.max.y() };
|
||||
|
@ -64,6 +64,8 @@ namespace Slic3r {
|
||||
Polygon m_bed_polygon;
|
||||
Point m_plate_offset;
|
||||
|
||||
std::unordered_map<const PrintInstance*, BoundingBoxf3> bbox_cache;
|
||||
|
||||
std::optional<Point> m_all_layer_pos;
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user