Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-03-22 03:13:28 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-03-22 03:30:19 +0300
commitfab14f78542ca040cc1606dbd33a4db6aea5976a (patch)
tree080478f6ef6b80c43d8529049b19ea75d3f47733
parent976c91cd770f4323d4a5007e5bf444b8c701278b (diff)
Fix build when using WITH_TBB=OFF after recent changes
And wrap tbb::parallel_sort in blender namespace similar to other TBB functionality.
-rw-r--r--source/blender/blenlib/BLI_sort.hh32
-rw-r--r--source/blender/blenlib/CMakeLists.txt1
-rw-r--r--source/blender/blenlib/intern/mesh_intersect.cc11
-rw-r--r--source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc11
4 files changed, 37 insertions, 18 deletions
diff --git a/source/blender/blenlib/BLI_sort.hh b/source/blender/blenlib/BLI_sort.hh
new file mode 100644
index 00000000000..411e6a0c4df
--- /dev/null
+++ b/source/blender/blenlib/BLI_sort.hh
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#pragma once
+
+/** \file
+ * \ingroup bli
+ */
+
+#ifdef WITH_TBB
+# include <tbb/parallel_sort.h>
+#else
+# include <algorithm>
+#endif
+
+namespace blender {
+
+#ifdef WITH_TBB
+using tbb::parallel_sort;
+#else
+template<typename RandomAccessIterator>
+void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end)
+{
+ std::sort<RandomAccessIterator>(begin, end);
+}
+template<typename RandomAccessIterator, typename Compare>
+void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end, const Compare &comp)
+{
+ std::sort<RandomAccessIterator, Compare>(begin, end, comp);
+}
+#endif
+
+} // namespace blender
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 6c216f873de..af71c96fc10 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -285,6 +285,7 @@ set(SRC
BLI_simd.h
BLI_smallhash.h
BLI_sort.h
+ BLI_sort.hh
BLI_sort_utils.h
BLI_span.hh
BLI_stack.h
diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc
index 8f2c86556aa..96ae0750899 100644
--- a/source/blender/blenlib/intern/mesh_intersect.cc
+++ b/source/blender/blenlib/intern/mesh_intersect.cc
@@ -26,6 +26,7 @@
# include "BLI_math_vector.h"
# include "BLI_polyfill_2d.h"
# include "BLI_set.hh"
+# include "BLI_sort.hh"
# include "BLI_span.hh"
# include "BLI_task.h"
# include "BLI_task.hh"
@@ -37,10 +38,6 @@
# include "BLI_mesh_intersect.hh"
-# ifdef WITH_TBB
-# include <tbb/parallel_sort.h>
-# endif
-
// # define PERFDEBUG
namespace blender::meshintersect {
@@ -672,11 +669,7 @@ void IMesh::populate_vert(int max_verts)
* TODO: when all debugged, set fix_order = false. */
const bool fix_order = true;
if (fix_order) {
-# ifdef WITH_TBB
- tbb::parallel_sort(vert_.begin(), vert_.end(), [](const Vert *a, const Vert *b) {
-# else
- std::sort(vert_.begin(), vert_.end(), [](const Vert *a, const Vert *b) {
-# endif
+ blender::parallel_sort(vert_.begin(), vert_.end(), [](const Vert *a, const Vert *b) {
if (a->orig != NO_INDEX && b->orig != NO_INDEX) {
return a->orig < b->orig;
}
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
index 9975f300150..a7508f01b0f 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
@@ -17,6 +17,7 @@
#include "BLI_listbase.h"
#include "BLI_map.hh"
#include "BLI_math.h"
+#include "BLI_sort.hh"
#include "DEG_depsgraph_query.h"
@@ -27,10 +28,6 @@
#include "obj_export_mesh.hh"
-#ifdef WITH_TBB
-# include <tbb/parallel_sort.h>
-#endif
-
namespace blender::io::obj {
OBJMesh::OBJMesh(Depsgraph *depsgraph, const OBJExportParams &export_params, Object *mesh_object)
{
@@ -207,11 +204,7 @@ void OBJMesh::calc_poly_order()
}
const MPoly *mpolys = export_mesh_eval_->mpoly;
/* Sort polygons by their material index. */
-#ifdef WITH_TBB
- tbb::parallel_sort(poly_order_.begin(), poly_order_.end(), [&](int a, int b) {
-#else
- std::sort(poly_order_.begin(), poly_order_.end(), [&](const Vert *a, const Vert *b) {
-#endif
+ blender::parallel_sort(poly_order_.begin(), poly_order_.end(), [&](int a, int b) {
int mat_a = mpolys[a].mat_nr;
int mat_b = mpolys[b].mat_nr;
return mat_a < mat_b;