Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_opengl_3_rebase

This commit is contained in:
enricoturri1966 2022-06-08 09:06:12 +02:00
commit 8f40270f93
3 changed files with 17 additions and 5 deletions

View File

@ -53,7 +53,7 @@ template<class T> struct TracerTraits_
template<class T>
using TracerNodeT = typename TracerTraits_<remove_cvref_t<T>>::Node;
constexpr size_t Unassigned = size_t(-1);
constexpr auto Unassigned = std::numeric_limits<size_t>::max();
template<class Tracer>
struct QNode // Queue node. Keeps track of scores g, and h
@ -69,7 +69,11 @@ struct QNode // Queue node. Keeps track of scores g, and h
size_t p = Unassigned,
float gval = std::numeric_limits<float>::infinity(),
float hval = 0.f)
: node{std::move(n)}, parent{p}, queue_id{Unassigned}, g{gval}, h{hval}
: node{std::move(n)}
, parent{p}
, queue_id{InvalidQueueID}
, g{gval}
, h{hval}
{}
};
@ -154,7 +158,7 @@ bool search_route(const Tracer &tracer,
// The cache needs to be updated either way
prev_nd = qsucc_nd;
if (queue_id == decltype(qopen)::invalid_id())
if (queue_id == InvalidQueueID)
// was in closed or unqueued, rescheduling
qopen.push(succ_id);
else // was in open, updating

View File

@ -7,6 +7,10 @@
#include <limits>
#include <cstdlib> // adds size_t (without std::)
namespace Slic3r {
constexpr auto InvalidQueueID = std::numeric_limits<size_t>::max();
template<typename T, typename IndexSetter, typename LessPredicate, const bool ResetIndexWhenRemoved = false>
class MutablePriorityQueue
{
@ -41,7 +45,7 @@ public:
bool empty() const { return m_heap.empty(); }
T& operator[](std::size_t idx) noexcept { return m_heap[idx]; }
const T& operator[](std::size_t idx) const noexcept { return m_heap[idx]; }
static constexpr size_t invalid_id() { return std::numeric_limits<size_t>::max(); }
static constexpr size_t invalid_id() { return InvalidQueueID; }
using iterator = typename std::vector<T>::iterator;
using const_iterator = typename std::vector<T>::const_iterator;
@ -291,7 +295,7 @@ public:
bool empty() const { return m_heap.empty(); }
T& operator[](std::size_t idx) noexcept { assert(! address::is_padding(idx)); return m_heap[idx]; }
const T& operator[](std::size_t idx) const noexcept { assert(! address::is_padding(idx)); return m_heap[idx]; }
static constexpr size_t invalid_id() { return std::numeric_limits<size_t>::max(); }
static constexpr size_t invalid_id() { return InvalidQueueID; }
protected:
void update_heap_up(size_t top, size_t bottom);
@ -450,4 +454,6 @@ inline void MutableSkipHeapPriorityQueue<T, LessPredicate, IndexSetter, blocking
}
}
} // namespace Slic3r
#endif /* slic3r_MutablePriorityQueue_hpp_ */

View File

@ -4,6 +4,8 @@
#include "libslic3r/MutablePriorityQueue.hpp"
using namespace Slic3r;
// based on https://raw.githubusercontent.com/rollbear/prio_queue/master/self_test.cpp
// original source Copyright Björn Fahller 2015, Boost Software License, Version 1.0, http://www.boost.org/LICENSE_1_0.txt