diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-08-11 18:50:28 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-08-11 18:55:52 +0400 |
commit | 0fe70b5e2871bd82d868614548fd62d81f1873c3 (patch) | |
tree | aa4a3d98231ca0db7d536fb2105980def184b2fa /extern/carve/carve-util.cc | |
parent | ce960028a4c086553959684c7a9930145225c1ce (diff) |
Fix T41360: Crash on Boolean Modifier
The issue was caused by the wrong attributes maps in certain
circumstances after union intersections.
Namely issue might have happen when more than one iteration of
union was happening and it was caused by the fact that new faces
might be allocated on the same address as freed face from the
old mesh.
Didn't find a nicer fix for this apart from correcting the whole
attributes map after each union step.
We could try removing attributes for the meshes which are getting
deleted, but in asymptotic it's gonna to give exactly the same
complexity as the current approach.
Diffstat (limited to 'extern/carve/carve-util.cc')
-rw-r--r-- | extern/carve/carve-util.cc | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/extern/carve/carve-util.cc b/extern/carve/carve-util.cc index 1106fa16a21..0dff1deb750 100644 --- a/extern/carve/carve-util.cc +++ b/extern/carve/carve-util.cc @@ -365,7 +365,10 @@ MeshSet<3> *getIntersectedOperand(std::vector<MeshSet<3>::mesh_t*> *meshes, MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg, MeshSet<3> *poly, - const MeshSet<3>::aabb_t &otherAABB) + const MeshSet<3> *other_poly, + const MeshSet<3>::aabb_t &otherAABB, + UnionIntersectionsCallback callback, + void *user_data) { if (poly->meshes.size() <= 1) { return poly; @@ -409,6 +412,7 @@ MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE); + callback(result, other_poly, user_data); delete left; delete right; @@ -420,6 +424,8 @@ MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg, MeshSet<3> *result = meshSetFromTwoMeshes(left->meshes, right->meshes); + callback(result, other_poly, user_data); + delete left; delete right; @@ -455,37 +461,36 @@ MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg, // TODO(sergey): This function is to be totally re-implemented to make it // more clear what's going on and hopefully optimize it as well. -bool carve_unionIntersections(carve::csg::CSG *csg, +void carve_unionIntersections(carve::csg::CSG *csg, MeshSet<3> **left_r, - MeshSet<3> **right_r) + MeshSet<3> **right_r, + UnionIntersectionsCallback callback, + void *user_data) { MeshSet<3> *left = *left_r, *right = *right_r; - bool changed = false; if (left->meshes.size() == 1 && right->meshes.size() == 0) { - return false; + return; } MeshSet<3>::aabb_t leftAABB = left->getAABB(); MeshSet<3>::aabb_t rightAABB = right->getAABB();; - left = unionIntersectingMeshes(csg, left, rightAABB); - right = unionIntersectingMeshes(csg, right, leftAABB); + left = unionIntersectingMeshes(csg, left, right, rightAABB, + callback, user_data); + right = unionIntersectingMeshes(csg, right, left, leftAABB, + callback, user_data); if (left != *left_r) { - changed = true; delete *left_r; } if (right != *right_r) { - changed = true; delete *right_r; } *left_r = left; *right_r = right; - - return changed; } static inline void add_newell_cross_v3_v3v3(const Vector &v_prev, |