[Bf-blender-cvs] [b5786bdafde] temp-trimesh-sculpt: Fix clang compile errors with #ifdefs. Someone more knowledable then me can fix them properly.
Joseph Eagar
noreply at git.blender.org
Wed Oct 21 12:57:50 CEST 2020
Commit: b5786bdafde1644eeed89cbd705dfdba406822f7
Author: Joseph Eagar
Date: Wed Oct 21 01:22:41 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBb5786bdafde1644eeed89cbd705dfdba406822f7
Fix clang compile errors with #ifdefs. Someone more knowledable then me
can fix them properly.
===================================================================
M source/blender/blenkernel/intern/mesh_validate.cc
M source/blender/blenkernel/intern/pbvh.c
M source/blender/blenlib/BLI_span.hh
M source/blender/editors/sculpt_paint/sculpt_smooth.c
===================================================================
diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc
index d8ea760825d..c5ebb55cb5c 100644
--- a/source/blender/blenkernel/intern/mesh_validate.cc
+++ b/source/blender/blenkernel/intern/mesh_validate.cc
@@ -1,22 +1,22 @@
/*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
/** \file
-* \ingroup bke
-*/
+ * \ingroup bke
+ */
#define NOMINMAX
@@ -36,195 +36,265 @@
namespace blender::bke::calc_edges {
- /** This is used to uniquely identify edges in a hash map. */
- struct OrderedEdge {
- int v_low, v_high;
+/** This is used to uniquely identify edges in a hash map. */
+struct OrderedEdge {
+ int v_low, v_high;
- OrderedEdge(const int v1, const int v2)
- {
- if (v1 < v2) {
- v_low = v1;
- v_high = v2;
- }
- else {
- v_low = v2;
- v_high = v1;
- }
+ OrderedEdge(const int v1, const int v2)
+ {
+ if (v1 < v2) {
+ v_low = v1;
+ v_high = v2;
}
-
- OrderedEdge(const uint v1, const uint v2)
- : OrderedEdge(static_cast<int>(v1), static_cast<int>(v2))
- {
+ else {
+ v_low = v2;
+ v_high = v1;
}
+ }
- uint64_t hash() const
- {
- return (this->v_low << 8) ^ this->v_high;
- }
+ OrderedEdge(const uint v1, const uint v2)
+ : OrderedEdge(static_cast<int>(v1), static_cast<int>(v2))
+ {
+ }
- /** Return a hash value that is likely to be different in the low bits from the normal `hash()`
- * function. This is necessary to avoid collisions in #BKE_mesh_calc_edges. */
- uint64_t hash2() const
- {
- return this->v_low;
- }
+ uint64_t hash() const
+ {
+ return (this->v_low << 8) ^ this->v_high;
+ }
- friend bool operator==(const OrderedEdge &e1, const OrderedEdge &e2)
- {
- BLI_assert(e1.v_low < e1.v_high);
- BLI_assert(e2.v_low < e2.v_high);
- return e1.v_low == e2.v_low && e1.v_high == e2.v_high;
- }
- };
-
- /* The map first contains an edge pointer and later an index. */
- typedef union OrigEdgeOrIndex {
- const MEdge *original_edge;
- int index;
- } OrigEdgeOrIndex;
- using EdgeMap = Map<OrderedEdge, OrigEdgeOrIndex>;
-
- static void reserve_hash_maps(const Mesh *mesh,
- const bool keep_existing_edges,
- MutableSpan<EdgeMap> edge_maps)
+ /** Return a hash value that is likely to be different in the low bits from the normal `hash()`
+ * function. This is necessary to avoid collisions in #BKE_mesh_calc_edges. */
+ uint64_t hash2() const
{
- const int totedge_guess = std::max(keep_existing_edges ? mesh->totedge : 0, mesh->totpoly * 2);
- parallel_for_each(
- edge_maps, [&](EdgeMap &edge_map) { edge_map.reserve(totedge_guess / edge_maps.size()); });
+ return this->v_low;
}
- static void add_existing_edges_to_hash_maps(Mesh *mesh,
- MutableSpan<EdgeMap> edge_maps,
- uint32_t parallel_mask)
+ friend bool operator==(const OrderedEdge &e1, const OrderedEdge &e2)
{
- /* Assume existing edges are valid. */
- parallel_for_each(edge_maps, [&](EdgeMap &edge_map) {
- const int task_index = &edge_map - &edge_maps[0];
- for (const MEdge &edge : Span(mesh->medge, mesh->totedge)) {
- OrderedEdge ordered_edge{edge.v1, edge.v2};
- /* Only add the edge when it belongs into this map. */
- if (task_index == (parallel_mask & ordered_edge.hash2())) {
- edge_map.add_new(ordered_edge, {&edge});
- }
+ BLI_assert(e1.v_low < e1.v_high);
+ BLI_assert(e2.v_low < e2.v_high);
+ return e1.v_low == e2.v_low && e1.v_high == e2.v_high;
+ }
+};
+
+/* The map first contains an edge pointer and later an index. */
+typedef union OrigEdgeOrIndex {
+ const MEdge *original_edge;
+ int index;
+} OrigEdgeOrIndex;
+using EdgeMap = Map<OrderedEdge, OrigEdgeOrIndex>;
+
+static void reserve_hash_maps(const Mesh *mesh,
+ const bool keep_existing_edges,
+ MutableSpan<EdgeMap> edge_maps)
+{
+ const int totedge_guess = std::max(keep_existing_edges ? mesh->totedge : 0, mesh->totpoly * 2);
+
+#ifndef __clang__
+ parallel_for_each(
+ edge_maps, [&](EdgeMap &edge_map) {
+#else
+ int ilen = edge_maps.size();
+
+ for (int i = 0; i < ilen; i++) {
+ EdgeMap &edge_map = edge_maps[i];
+#endif
+ edge_map.reserve(totedge_guess / edge_maps.size());
+ }
+#ifndef __clang__
+ );
+#endif
+}
+
+static void add_existing_edges_to_hash_maps(Mesh *mesh,
+ MutableSpan<EdgeMap> edge_maps,
+ uint32_t parallel_mask)
+{
+#ifndef __clang__
+ /* Assume existing edges are valid. */
+ parallel_for_each(edge_maps, [&](EdgeMap &edge_map) {
+#else
+ int ilen = edge_maps.size();
+
+ for (int i = 0; i < ilen; i++) {
+ EdgeMap &edge_map = edge_maps[i];
+#endif
+ const int task_index = &edge_map - &edge_maps[0];
+ for (const MEdge &edge : Span(mesh->medge, mesh->totedge)) {
+ OrderedEdge ordered_edge{edge.v1, edge.v2};
+ /* Only add the edge when it belongs into this map. */
+ if (task_index == (parallel_mask & ordered_edge.hash2())) {
+ edge_map.add_new(ordered_edge, {&edge});
}
- });
+ }
}
- static void add_polygon_edges_to_hash_maps(Mesh *mesh,
- MutableSpan<EdgeMap> edge_maps,
- uint32_t parallel_mask)
- {
- const Span<MLoop> loops{mesh->mloop, mesh->totloop};
- parallel_for_each(edge_maps, [&](EdgeMap &edge_map) {
- const int task_index = &edge_map - &edge_maps[0];
- for (const MPoly &poly : Span(mesh->mpoly, mesh->totpoly)) {
- Span<MLoop> poly_loops = loops.slice(poly.loopstart, poly.totloop);
- const MLoop *prev_loop = &poly_loops.last();
- for (const MLoop &next_loop : poly_loops) {
- /* Can only be the same when the mesh data is invalid. */
- if (prev_loop->v != next_loop.v) {
- OrderedEdge ordered_edge{prev_loop->v, next_loop.v};
- /* Only add the edge when it belongs into this map. */
- if (task_index == (parallel_mask & ordered_edge.hash2())) {
- edge_map.lookup_or_add(ordered_edge, {nullptr});
- }
+#ifndef __clang__
+ );
+#endif
+}
+
+static void add_polygon_edges_to_hash_maps(Mesh *mesh,
+ MutableSpan<EdgeMap> edge_maps,
+ uint32_t parallel_mask)
+{
+ const Span<MLoop> loops{mesh->mloop, mesh->totloop};
+#ifndef __clang__
+ parallel_for_each(edge_maps, [&](EdgeMap &edge_map) {
+#else
+ int ilen = edge_maps.size();
+
+ for (int i = 0; i < ilen; i++) {
+ EdgeMap &edge_map = edge_maps[i];
+
+#endif
+ const int task_index = &edge_map - &edge_maps[0];
+ for (const MPoly &poly : Span(mesh->mpoly, mesh->totpoly)) {
+ Span<MLoop> poly_loops = loops.slice(poly.loopstart, poly.totloop);
+ const MLoop *prev_loop = &poly_loops.last();
+ for (const MLoop &next_loop : poly_loops) {
+ /* Can only be the same when the mesh data is invalid. */
+ if (prev_loop->v != next_loop.v) {
+ OrderedEdge ordered_edge{prev_loop->v, next_loop.v};
+ /* Only add the edge when it belongs into this map. */
+ if (task_index == (parallel_mask & ordered_edge.hash2())) {
+ edge_map.lookup_or_add(ordered_edge, {nullptr});
}
- prev_loop = &next_loop;
}
+ prev_loop = &next_loop;
}
- });
+ }
}
+#ifndef __clang__
+ );
+#endif
+}
- static void serialize_and_initialize_deduplicated_edges(MutableSpan<EdgeMap> edge_maps,
- MutableSpan<MEdge> new_edges,
- short new_edge_flag)
- {
- /* All edges are distributed in the hash tables now. They have to be serialized into a single
- * array below. To be able to parallelize this, we have to compute edge index offsets for each
- * map. */
- Array<int> edge_index_offsets(edge_maps.size());
- edge_index_offsets[0] = 0;
- for (const int i : IndexRange(edge_maps.size() - 1)) {
- edge_index_offsets[i + 1] = edge_index_offsets[i] + edge_maps[i].size();
+static void serialize_and_initialize_deduplicated_edges(MutableSpan<EdgeMap> edge_maps,
+ MutableSpan<MEdge> new_edges,
+ short new_edge_flag)
+{
+ /* All edges are distributed in the hash tables now. They have to be serialized into a single
+ * array below. To be able to parallelize this, we have to compute edge index offsets for each
+ * map. */
+ Array<int> edge_index_offsets(edge_maps.size());
+ edge_index_offsets[0] = 0;
+ for (const int i : IndexRange(edge_maps.size() - 1)) {
+ edge_index_offsets[i + 1] = edge_index_offsets[i] + edge_maps[i].size
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list