[Bf-blender-cvs] [3917661753d] newboolean: After merge from master, updated for changes to BLI.
Howard Trickey
noreply at git.blender.org
Thu Jun 11 19:50:57 CEST 2020
Commit: 3917661753dc8cf976418f7d79f42759efe502b3
Author: Howard Trickey
Date: Thu Jun 11 13:47:20 2020 -0400
Branches: newboolean
https://developer.blender.org/rB3917661753dc8cf976418f7d79f42759efe502b3
After merge from master, updated for changes to BLI.
Mainly namespace changes, BLI -> blender, so I changed my
own namespaces to follow that pattern.
ArrayRef -> Span.
Now can have hash() as member of data structures rather
that having to make a DefaultHash for them.
Fixed a bad assumption about Arrays of bool being initialized to false.
===================================================================
M release/datafiles/locale
M release/scripts/addons
M release/scripts/addons_contrib
M source/blender/blenlib/BLI_delaunay_2d.h
M source/blender/blenlib/BLI_double2.hh
M source/blender/blenlib/BLI_double3.hh
M source/blender/blenlib/BLI_mesh_intersect.hh
M source/blender/blenlib/BLI_mpq2.hh
M source/blender/blenlib/BLI_mpq3.hh
M source/blender/blenlib/intern/boolean.cc
M source/blender/blenlib/intern/delaunay_2d.cc
M source/blender/blenlib/intern/math_vec.cc
M source/blender/blenlib/intern/mesh_intersect.cc
M tests/gtests/blenlib/BLI_delaunay_2d_test.cc
M tests/gtests/blenlib/BLI_mesh_intersect_test.cc
===================================================================
diff --git a/release/datafiles/locale b/release/datafiles/locale
index 1cc27d5282a..6a514935090 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 1cc27d5282aa4978ee36663aca857eb550df194b
+Subproject commit 6a51493509090c7fa3bd2e69105761c3c144c7dd
diff --git a/release/scripts/addons b/release/scripts/addons
index 084eec36977..ba2521b7ed1 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 084eec36977c9a084aa020031f4a1aa0f0352170
+Subproject commit ba2521b7ed14b5deb6bb9a82a442bc85d2e05224
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 9468c406fb5..4cf486c4eba 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 9468c406fb554e32ff47b62bfef356b3908ec651
+Subproject commit 4cf486c4eba158b453bdd87d97b74192ef7497b2
diff --git a/source/blender/blenlib/BLI_delaunay_2d.h b/source/blender/blenlib/BLI_delaunay_2d.h
index fc5c7123890..51820247e50 100644
--- a/source/blender/blenlib/BLI_delaunay_2d.h
+++ b/source/blender/blenlib/BLI_delaunay_2d.h
@@ -217,7 +217,7 @@ void BLI_delaunay_2d_cdt_free(CDT_result *result);
# include "BLI_mpq2.hh"
# include "BLI_vector.hh"
-namespace BLI {
+namespace blender {
template<typename Arith_t> struct vec2_impl;
template<> struct vec2_impl<double> {
@@ -252,7 +252,7 @@ CDT_result<double> delaunay_2d_calc(const CDT_input<double> &input, CDT_output_t
CDT_result<mpq_class> delaunay_2d_calc(const CDT_input<mpq_class> &input,
CDT_output_type output_type);
-} /* namespace BLI */
+} /* namespace blender */
#endif /* __cplusplus */
diff --git a/source/blender/blenlib/BLI_double2.hh b/source/blender/blenlib/BLI_double2.hh
index 994d6213502..c505f860f3c 100644
--- a/source/blender/blenlib/BLI_double2.hh
+++ b/source/blender/blenlib/BLI_double2.hh
@@ -19,7 +19,7 @@
#include "BLI_double3.hh"
-namespace BLI {
+namespace blender {
struct double2 {
double x, y;
@@ -135,6 +135,6 @@ struct double2 {
static int incircle_fast(const double2 &a, const double2 &b, const double2 &c, const double2 &d);
};
-} // namespace BLI
+} // namespace blender
#endif /* __BLI_DOUBLE_HH__ */
diff --git a/source/blender/blenlib/BLI_double3.hh b/source/blender/blenlib/BLI_double3.hh
index d9926751e39..72085df2eb9 100644
--- a/source/blender/blenlib/BLI_double3.hh
+++ b/source/blender/blenlib/BLI_double3.hh
@@ -21,7 +21,7 @@
#include "BLI_math_vector.h"
-namespace BLI {
+namespace blender {
struct double3 {
double x, y, z;
@@ -233,6 +233,6 @@ struct double3 {
const double3 &a, const double3 &b, const double3 &c, const double3 &d, const double3 &e);
};
-} // namespace BLI
+} // namespace blender
#endif /* __BLI_DOUBLE3_HH__ */
diff --git a/source/blender/blenlib/BLI_mesh_intersect.hh b/source/blender/blenlib/BLI_mesh_intersect.hh
index 0cda31a6b8e..dcdc93d8e6f 100644
--- a/source/blender/blenlib/BLI_mesh_intersect.hh
+++ b/source/blender/blenlib/BLI_mesh_intersect.hh
@@ -31,9 +31,9 @@
#include "BLI_mpq3.hh"
#include "BLI_vector.hh"
-namespace BLI {
+namespace blender {
-namespace MeshIntersect {
+namespace meshintersect {
/* The indices are for vertices in some external space of coordinates.
* The "orig" component is used to track how a triangle originally came
@@ -104,7 +104,7 @@ class IndexedTriangle {
};
struct TriMesh {
- Array<mpq3> vert;
+ Array<blender::mpq3> vert;
Array<IndexedTriangle> tri;
TriMesh() = default;
@@ -133,8 +133,8 @@ void write_obj_trimesh(const Array<mpq3> &vert,
const Array<IndexedTriangle> &tri,
const std::string &objname);
-} /* namespace MeshIntersect */
+} /* namespace meshintersect */
-} /* namespace BLI */
+} /* namespace blender */
#endif /* __BLI_MESH_INTERSECT_HH__ */
diff --git a/source/blender/blenlib/BLI_mpq2.hh b/source/blender/blenlib/BLI_mpq2.hh
index 48c9aa9580d..3769abe8ca6 100644
--- a/source/blender/blenlib/BLI_mpq2.hh
+++ b/source/blender/blenlib/BLI_mpq2.hh
@@ -22,7 +22,7 @@
#include "BLI_math_mpq.hh"
#include "BLI_mpq3.hh"
-namespace BLI {
+namespace blender {
struct mpq2 {
mpq_class x, y;
@@ -37,7 +37,7 @@ struct mpq2 {
{
}
- mpq2(const mpq3 &other) : x(other.x), y(other.y)
+ mpq2(const blender::mpq3 &other) : x(other.x), y(other.y)
{
}
@@ -136,8 +136,13 @@ struct mpq2 {
static int orient2d(const mpq2 &a, const mpq2 &b, const mpq2 &c);
static int incircle(const mpq2 &a, const mpq2 &b, const mpq2 &c, const mpq2 &d);
+
+ /* There is a sensible use for hashing on exact arithmetic types. */
+ uint32_t hash() const;
};
-} // namespace BLI
+uint32_t hash_mpq_class(const mpq_class &value);
+
+} // namespace blender
#endif /* __BLI_MPQ_HH__ */
diff --git a/source/blender/blenlib/BLI_mpq3.hh b/source/blender/blenlib/BLI_mpq3.hh
index ca556e46e83..af510e9f849 100644
--- a/source/blender/blenlib/BLI_mpq3.hh
+++ b/source/blender/blenlib/BLI_mpq3.hh
@@ -23,7 +23,7 @@
#include "BLI_math_mpq.hh"
#include "gmpxx.h"
-namespace BLI {
+namespace blender {
struct mpq3 {
mpq_class x, y, z;
@@ -250,8 +250,13 @@ struct mpq3 {
}
static int orient3d(const mpq3 &a, const mpq3 &b, const mpq3 &c, const mpq3 &d);
+
+ /* There is a sensible use for hashing on exact arithmetic types. */
+ uint32_t hash() const;
};
-} // namespace BLI
+uint32_t hash_mpq_class(const mpq_class &value);
+
+} // namespace blender
#endif /* __BLI_MPQ3_HH__ */
diff --git a/source/blender/blenlib/intern/boolean.cc b/source/blender/blenlib/intern/boolean.cc
index d0a3d214cb2..12b461242bd 100644
--- a/source/blender/blenlib/intern/boolean.cc
+++ b/source/blender/blenlib/intern/boolean.cc
@@ -19,20 +19,21 @@
#include "gmpxx.h"
#include "BLI_array.hh"
-#include "BLI_array_ref.hh"
#include "BLI_assert.h"
#include "BLI_hash.hh"
#include "BLI_map.hh"
#include "BLI_mesh_intersect.hh"
#include "BLI_mpq3.hh"
#include "BLI_set.hh"
+#include "BLI_span.hh"
#include "BLI_stack.hh"
#include "BLI_vector.hh"
#include "BLI_boolean.h"
-namespace BLI {
-namespace MeshIntersect {
+namespace blender {
+
+namespace meshintersect {
/* Edge as two vert indices, in a canonical order (lower vert index first). */
class Edge {
@@ -67,6 +68,13 @@ class Edge {
return m_v[0] == other.m_v[0] && m_v[1] == other.m_v[1];
}
+ uint32_t hash() const
+ {
+ uint32_t v0hash = DefaultHash<int>{}(m_v[0]);
+ uint32_t v1hash = DefaultHash<int>{}(m_v[1]);
+ return v0hash ^ (v1hash * 33);
+ }
+
private:
int m_v[2]{-1, -1};
};
@@ -77,7 +85,7 @@ static std::ostream &operator<<(std::ostream &os, const Edge &e)
return os;
}
-static std::ostream &operator<<(std::ostream &os, const ArrayRef<int> &a)
+static std::ostream &operator<<(std::ostream &os, const Span<int> &a)
{
for (uint i = 0; i < a.size(); ++i) {
os << a[i];
@@ -90,13 +98,13 @@ static std::ostream &operator<<(std::ostream &os, const ArrayRef<int> &a)
static std::ostream &operator<<(std::ostream &os, const Vector<int> &ivec)
{
- os << ArrayRef<int>(ivec);
+ os << Span<int>(ivec);
return os;
}
static std::ostream &operator<<(std::ostream &os, const Array<int> &iarr)
{
- os << ArrayRef<int>(iarr);
+ os << Span<int>(iarr);
return os;
}
@@ -146,7 +154,7 @@ TriMeshTopology::TriMeshTopology(const TriMesh *tm)
Edge e(tri[i], tri[(i + 1) % 3]);
auto createf = [t](Vector<int> **pvec) { *pvec = new Vector<int>{t}; };
auto modifyf = [t](Vector<int> **pvec) { (*pvec)->append_non_duplicates(t); };
- this->m_edge_tri.add_or_modify(e, createf, modifyf);
+ this->m_edge_tri.add_or_modify(Edge(tri[i], tri[(i + 1) % 3]), createf, modifyf);
}
}
/* Debugging. */
@@ -155,7 +163,7 @@ TriMeshTopology::TriMeshTopology(const TriMesh *tm)
for (auto item : m_edge_tri.items()) {
std::cout << item.key << ": " << *item.value << "\n";
if (false) {
- m_edge_tri.print_table();
+ m_edge_tri.print_stats();
}
}
}
@@ -565,7 +573,7 @@ static int sort_tris_class(const IndexedTriangle &tri,
static Array<int> sort_tris_around_edge(const TriMesh &tm,
const TriMeshTopology &tmtopo,
const Edge e,
- const ArrayRef<int> &tris,
+ const Span<int> &tris,
const int t0)
{
/* Divide and conquer, quicsort-like sort.
@@ -624,7 +632,7 @@ static Array<int> sort_tris_around_edge(const TriMesh &tm,
g3tris[i] = tris[g3[i]];
}
Array<int> g3sorted = sort_tris_around_edge(tm, tmtopo, e, g3tris, t0);
- BLI::copy(g3sorted.begin(), g3sorted.end(), g3.begin());
+ std::copy(g3sorted.begin(), g3sorted.end(), g3.begin());
}
if (g4.size() > 1) {
Array<int> g4tris(g4.size());
@@ -632,22 +640,22 @@ static Array<int> sort_tris_around_edge(const TriMesh &tm,
g4tris[i] = tris[g4[i]];
}
Array<int> g4sorted = sort_tris_around_edge(tm, tmtopo, e, g4tris, t0);
- BLI::copy(g4sorted.begin(), g4sorted.end(), g4.begin());
+ std::copy(g4sorted.begin(), g4sorted.end(), g4.begin());
}
uint group_tot_size = g1.size() + g2.size() + g3.size() + g4.size();
Array<int> ans(group_tot_size);
int *p = ans.begin();
if (tris[0] == t0) {
- p = BLI::copy(g1.begin(), g1.end(), p);
- p = BLI::copy(g3.begin(), g3.end(), p);
- p = BLI::copy(g2.begin(), g2.end(), p);
- BLI::copy(g4.begin(), g4.end(), p);
+ p = std::copy(g1.begin(), g1.end(), p);
+ p = std::copy(g3.begin(), g3.end(), p);
+ p = std::copy(g2.begin(), g2.end(), p);
+ std::copy(g4.begin(), g4.end(), p);
}
else {
- p = BLI::copy(g3.begin(), g3.end(), p);
- p = BLI::copy(g1.begin(), g1.end(), p);
- p = BLI::copy(g4.begin(), g4.end(), p);
- BLI::copy(g2.begin(), g2.end(), p);
+ p = std::copy(g3.begin(), g3.end(), p);
+ p = std::copy(g1.begin(), g1.end(), p);
+ p = std::copy(g4.begin(), g4.end(), p);
+ std::copy(g2.begin(), g2.end(), p);
}
if (dbg_level > 0) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list