diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2021-06-05 21:31:08 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2021-06-05 21:31:08 +0300 |
commit | 8e43ef5f318690d4924bd0861f5fd37a85999083 (patch) | |
tree | ef951ca5b1bb1014e8144616aeab0b0f74e5859a /source/blender/blenlib/intern/mesh_intersect.cc | |
parent | edaaa2afddb2132e56f39791e559b084b6df8773 (diff) |
Exact Boolean: speed up when there are many separate components.
Use bounding box tests quickly tell that two components cannot
have a containment relation between each other. This change
cut about 0.6s off a test with 25 big icospheres.
Diffstat (limited to 'source/blender/blenlib/intern/mesh_intersect.cc')
-rw-r--r-- | source/blender/blenlib/intern/mesh_intersect.cc | 52 |
1 files changed, 1 insertions, 51 deletions
diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc index 97f856476c5..5b7b6d9a929 100644 --- a/source/blender/blenlib/intern/mesh_intersect.cc +++ b/source/blender/blenlib/intern/mesh_intersect.cc @@ -744,62 +744,12 @@ std::ostream &operator<<(std::ostream &os, const IMesh &mesh) return os; } -struct BoundingBox { - float3 min{FLT_MAX, FLT_MAX, FLT_MAX}; - float3 max{-FLT_MAX, -FLT_MAX, -FLT_MAX}; - - BoundingBox() = default; - BoundingBox(const float3 &min, const float3 &max) : min(min), max(max) - { - } - - void combine(const float3 &p) - { - min.x = min_ff(min.x, p.x); - min.y = min_ff(min.y, p.y); - min.z = min_ff(min.z, p.z); - max.x = max_ff(max.x, p.x); - max.y = max_ff(max.y, p.y); - max.z = max_ff(max.z, p.z); - } - - void combine(const double3 &p) - { - min.x = min_ff(min.x, static_cast<float>(p.x)); - min.y = min_ff(min.y, static_cast<float>(p.y)); - min.z = min_ff(min.z, static_cast<float>(p.z)); - max.x = max_ff(max.x, static_cast<float>(p.x)); - max.y = max_ff(max.y, static_cast<float>(p.y)); - max.z = max_ff(max.z, static_cast<float>(p.z)); - } - - void combine(const BoundingBox &bb) - { - min.x = min_ff(min.x, bb.min.x); - min.y = min_ff(min.y, bb.min.y); - min.z = min_ff(min.z, bb.min.z); - max.x = max_ff(max.x, bb.max.x); - max.y = max_ff(max.y, bb.max.y); - max.z = max_ff(max.z, bb.max.z); - } - - void expand(float pad) - { - min.x -= pad; - min.y -= pad; - min.z -= pad; - max.x += pad; - max.y += pad; - max.z += pad; - } -}; - /** * Assume bounding boxes have been expanded by a sufficient epsilon on all sides * so that the comparisons against the bb bounds are sufficient to guarantee that * if an overlap or even touching could happen, this will return true. */ -static bool bbs_might_intersect(const BoundingBox &bb_a, const BoundingBox &bb_b) +bool bbs_might_intersect(const BoundingBox &bb_a, const BoundingBox &bb_b) { return isect_aabb_aabb_v3(bb_a.min, bb_a.max, bb_b.min, bb_b.max); } |