diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-04-09 12:23:35 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-04-09 12:27:34 +0400 |
commit | ccf9afddbaa0a08f4e277b3c19bc15735be9f4a4 (patch) | |
tree | 676d2d4bc38f053606bfa24d545bdf1a7b3d2492 /extern/carve/carve-util.cc | |
parent | dfbd994aaf6f95ddf3d6f9ecc64fa3a550b5e895 (diff) |
Fix T39608: Blender 2.70 crashes when performing union
This was a nasty bug which was caused by specific of how face-edge
attributes are stored in Carve.
Face pointer is used in the map key which works just fine in all
cases except for the cases when some face is getting freed after
it was stored in the map.
This might give real issues when new face is allocating because
it's possible new face would have the same address as the freed
one.
Such cases used to happen when union of separate manifolds is
needed for the operands AND jemalloc is enabled.
Solved by dropping attributes for the freed faces from the map.
Maybe not the fastest ever approach, but not sure how to make
it faster actually. Should work just fine. It only happens for
complex setups with intersecting manifolds in the operands.
Diffstat (limited to 'extern/carve/carve-util.cc')
-rw-r--r-- | extern/carve/carve-util.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/extern/carve/carve-util.cc b/extern/carve/carve-util.cc index ac6dcbc1a94..b268dae9dd6 100644 --- a/extern/carve/carve-util.cc +++ b/extern/carve/carve-util.cc @@ -486,14 +486,15 @@ 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. -void carve_unionIntersections(carve::csg::CSG *csg, +bool carve_unionIntersections(carve::csg::CSG *csg, MeshSet<3> **left_r, MeshSet<3> **right_r) { MeshSet<3> *left = *left_r, *right = *right_r; + bool changed = false; if (left->meshes.size() == 1 && right->meshes.size() == 0) { - return; + return false; } MeshSet<3>::aabb_t leftAABB = left->getAABB(); @@ -503,14 +504,19 @@ void carve_unionIntersections(carve::csg::CSG *csg, right = unionIntersectingMeshes(csg, right, leftAABB); if (left != *left_r) { + changed = true; delete *left_r; } - if (right != *right_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, |