diff --git a/src/Gui/Inventor/So3DAnnotation.cpp b/src/Gui/Inventor/So3DAnnotation.cpp index 2a2fb91811..87f54d86e9 100644 --- a/src/Gui/Inventor/So3DAnnotation.cpp +++ b/src/Gui/Inventor/So3DAnnotation.cpp @@ -44,8 +44,7 @@ bool SoDelayedAnnotationsElement::isProcessingDelayedPaths = false; void SoDelayedAnnotationsElement::init(SoState* state) { SoElement::init(state); - priorityPaths.clear(); - paths.truncate(0); + paths.clear(); } void SoDelayedAnnotationsElement::initClass() @@ -58,41 +57,32 @@ void SoDelayedAnnotationsElement::initClass() void SoDelayedAnnotationsElement::addDelayedPath(SoState* state, SoPath* path, int priority) { auto elt = static_cast(state->getElementNoPush(classStackIndex)); - - // add to priority-aware storage if priority has been specified - if (priority > 0) { - elt->priorityPaths.emplace_back(path, priority); - return; - } - elt->paths.append(path); + // add to unified storage with specified priority (default = 0) + elt->paths.emplace_back(path, priority); } SoPathList SoDelayedAnnotationsElement::getDelayedPaths(SoState* state) { auto elt = static_cast(state->getElementNoPush(classStackIndex)); - // if we don't have priority paths, just return normal delayed paths - if (elt->priorityPaths.empty()) { - auto copy = elt->paths; - elt->paths.truncate(0); - return copy; + if (elt->paths.empty()) { + return SoPathList(); } // sort by priority (lower numbers render first) - std::stable_sort(elt->priorityPaths.begin(), elt->priorityPaths.end(), + std::stable_sort(elt->paths.begin(), elt->paths.end(), [](const PriorityPath& a, const PriorityPath& b) { return a.priority < b.priority; }); SoPathList sortedPaths; - for (const auto& priorityPath : elt->priorityPaths) { + for (const auto& priorityPath : elt->paths) { sortedPaths.append(priorityPath.path); } // Clear storage - elt->priorityPaths.clear(); - elt->paths.truncate(0); + elt->paths.clear(); return sortedPaths; } @@ -101,16 +91,16 @@ void SoDelayedAnnotationsElement::processDelayedPathsWithPriority(SoState* state { auto elt = static_cast(state->getElementNoPush(classStackIndex)); - if (elt->priorityPaths.empty()) return; + if (elt->paths.empty()) return; - std::stable_sort(elt->priorityPaths.begin(), elt->priorityPaths.end(), + std::stable_sort(elt->paths.begin(), elt->paths.end(), [](const PriorityPath& a, const PriorityPath& b) { return a.priority < b.priority; }); isProcessingDelayedPaths = true; - for (const auto& priorityPath : elt->priorityPaths) { + for (const auto& priorityPath : elt->paths) { SoPathList singlePath; singlePath.append(priorityPath.path); @@ -119,8 +109,7 @@ void SoDelayedAnnotationsElement::processDelayedPathsWithPriority(SoState* state isProcessingDelayedPaths = false; - elt->priorityPaths.clear(); - elt->paths.truncate(0); + elt->paths.clear(); } SO_NODE_SOURCE(So3DAnnotation); diff --git a/src/Gui/Inventor/So3DAnnotation.h b/src/Gui/Inventor/So3DAnnotation.h index dbd29e5e4d..fee78372d4 100644 --- a/src/Gui/Inventor/So3DAnnotation.h +++ b/src/Gui/Inventor/So3DAnnotation.h @@ -80,10 +80,7 @@ public: } private: - // priority-aware paths - std::vector priorityPaths; - - SoPathList paths; + std::vector paths; }; /*! @brief 3D Annotation Node - Annotation with depth buffer