mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 22:45:58 +08:00
Slight performance improvement
With parallel avoidance search for leaf nodes
This commit is contained in:
parent
816371f37c
commit
9a33537b1d
@ -106,7 +106,7 @@ public:
|
|||||||
virtual bool add_mesh_bridge(const Node &from, const Node &to) = 0;
|
virtual bool add_mesh_bridge(const Node &from, const Node &to) = 0;
|
||||||
|
|
||||||
virtual std::optional<Vec3f> suggest_avoidance(const Node &from,
|
virtual std::optional<Vec3f> suggest_avoidance(const Node &from,
|
||||||
float max_bridge_len)
|
float max_bridge_len) const
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@ class BranchingTreeBuilder: public branchingtree::Builder {
|
|||||||
std::vector<branchingtree::Node> m_pillars; // to put an index over them
|
std::vector<branchingtree::Node> m_pillars; // to put an index over them
|
||||||
|
|
||||||
// cache succesfull ground connections
|
// cache succesfull ground connections
|
||||||
std::map<int, GroundConnection> m_gnd_connections;
|
mutable std::map<int, GroundConnection> m_gnd_connections;
|
||||||
|
mutable execution::SpinningMutex<ExecutionTBB> m_gnd_connections_mtx;
|
||||||
|
|
||||||
// Scaling of the input value 'widening_factor:<0, 1>' to produce resonable
|
// Scaling of the input value 'widening_factor:<0, 1>' to produce resonable
|
||||||
// widening behaviour
|
// widening behaviour
|
||||||
@ -144,7 +145,7 @@ public:
|
|||||||
const branchingtree::Node &to) override;
|
const branchingtree::Node &to) override;
|
||||||
|
|
||||||
std::optional<Vec3f> suggest_avoidance(const branchingtree::Node &from,
|
std::optional<Vec3f> suggest_avoidance(const branchingtree::Node &from,
|
||||||
float max_bridge_len) override;
|
float max_bridge_len) const override;
|
||||||
|
|
||||||
void report_unroutable(const branchingtree::Node &j) override
|
void report_unroutable(const branchingtree::Node &j) override
|
||||||
{
|
{
|
||||||
@ -307,7 +308,7 @@ static std::optional<Vec3f> get_avoidance(const GroundConnection &conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Vec3f> BranchingTreeBuilder::suggest_avoidance(
|
std::optional<Vec3f> BranchingTreeBuilder::suggest_avoidance(
|
||||||
const branchingtree::Node &from, float max_bridge_len)
|
const branchingtree::Node &from, float max_bridge_len) const
|
||||||
{
|
{
|
||||||
std::optional<Vec3f> ret;
|
std::optional<Vec3f> ret;
|
||||||
|
|
||||||
@ -317,13 +318,23 @@ std::optional<Vec3f> BranchingTreeBuilder::suggest_avoidance(
|
|||||||
dst.weight += from.pos.z() - glvl;
|
dst.weight += from.pos.z() - glvl;
|
||||||
sla::Junction j{from.pos.cast<double>(), get_radius(from)};
|
sla::Junction j{from.pos.cast<double>(), get_radius(from)};
|
||||||
|
|
||||||
auto found_it = m_gnd_connections.find(from.id);
|
auto found_it = m_gnd_connections.end();
|
||||||
|
{
|
||||||
|
std::lock_guard lk{m_gnd_connections_mtx};
|
||||||
|
found_it = m_gnd_connections.find(from.id);
|
||||||
|
}
|
||||||
|
|
||||||
if (found_it != m_gnd_connections.end()) {
|
if (found_it != m_gnd_connections.end()) {
|
||||||
ret = get_avoidance(found_it->second, max_bridge_len);
|
ret = get_avoidance(found_it->second, max_bridge_len);
|
||||||
} else {
|
} else {
|
||||||
auto conn = deepsearch_ground_connection(
|
auto conn = deepsearch_ground_connection(
|
||||||
beam_ex_policy , m_sm, j, get_radius(dst), sla::DOWN);
|
beam_ex_policy , m_sm, j, get_radius(dst), sla::DOWN);
|
||||||
m_gnd_connections[from.id] = conn;
|
|
||||||
|
{
|
||||||
|
std::lock_guard lk{m_gnd_connections_mtx};
|
||||||
|
m_gnd_connections[from.id] = conn;
|
||||||
|
}
|
||||||
|
|
||||||
ret = get_avoidance(conn, max_bridge_len);
|
ret = get_avoidance(conn, max_bridge_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,6 +405,15 @@ void create_branching_tree(SupportTreeBuilder &builder, const SupportableMesh &s
|
|||||||
std::move(leafs), props};
|
std::move(leafs), props};
|
||||||
|
|
||||||
BranchingTreeBuilder vbuilder{builder, sm, nodes};
|
BranchingTreeBuilder vbuilder{builder, sm, nodes};
|
||||||
|
|
||||||
|
execution::for_each(ex_tbb,
|
||||||
|
size_t(0),
|
||||||
|
nodes.get_leafs().size(),
|
||||||
|
[&nodes, &vbuilder](size_t leaf_idx) {
|
||||||
|
vbuilder.suggest_avoidance(nodes.get_leafs()[leaf_idx],
|
||||||
|
nodes.properties().max_branch_length());
|
||||||
|
});
|
||||||
|
|
||||||
branchingtree::build_tree(nodes, vbuilder);
|
branchingtree::build_tree(nodes, vbuilder);
|
||||||
|
|
||||||
build_pillars(builder, vbuilder, sm);
|
build_pillars(builder, vbuilder, sm);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user