Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-04-09 12:23:35 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-04-09 12:27:34 +0400
commitccf9afddbaa0a08f4e277b3c19bc15735be9f4a4 (patch)
tree676d2d4bc38f053606bfa24d545bdf1a7b3d2492 /extern/carve/carve-util.h
parentdfbd994aaf6f95ddf3d6f9ecc64fa3a550b5e895 (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.h')
-rw-r--r--extern/carve/carve-util.h39
1 files changed, 36 insertions, 3 deletions
diff --git a/extern/carve/carve-util.h b/extern/carve/carve-util.h
index a658b2fea96..f650810e9e3 100644
--- a/extern/carve/carve-util.h
+++ b/extern/carve/carve-util.h
@@ -70,7 +70,7 @@ void carve_getRescaleMinMax(const carve::mesh::MeshSet<3> *left,
carve::geom3d::Vector *min,
carve::geom3d::Vector *max);
-void carve_unionIntersections(carve::csg::CSG *csg,
+bool carve_unionIntersections(carve::csg::CSG *csg,
carve::mesh::MeshSet<3> **left_r,
carve::mesh::MeshSet<3> **right_r);
@@ -115,8 +115,8 @@ namespace carve {
attrs.find(new_edge_iter->vert);
if (found == attrs.end()) {
for (const_edge_iter_t orig_edge_iter = orig_face->begin();
- orig_edge_iter != orig_face->end();
- ++orig_edge_iter)
+ orig_edge_iter != orig_face->end();
+ ++orig_edge_iter)
{
if ((orig_edge_iter->vert->v - new_edge_iter->vert->v).length2() < 1e-5) {
attrs[new_edge_iter->vert] = attrs[orig_edge_iter->vert];
@@ -236,6 +236,20 @@ namespace carve {
attrs[std::make_pair(f, e)] = attr;
}
+ void copyAttribute(const meshset_t::face_t *face,
+ unsigned edge,
+ SimpleFaceEdgeAttr<attr_t> *interpolator) {
+ key_t key(face, edge);
+ typename attrmap_t::const_iterator fv = interpolator->attrs.find(key);
+ if (fv != interpolator->attrs.end()) {
+ attrs[key] = (*fv).second;
+ }
+ }
+
+ void swapAttributes(SimpleFaceEdgeAttr<attr_t> *interpolator) {
+ attrs.swap(interpolator->attrs);
+ }
+
SimpleFaceEdgeAttr() : Interpolator() {
}
@@ -243,6 +257,25 @@ namespace carve {
}
};
+ template<typename attr_t>
+ class SwapableFaceEdgeAttr : public FaceEdgeAttr<attr_t> {
+ public:
+ typedef carve::mesh::MeshSet<3> meshset_t;
+
+ void copyAttribute(const meshset_t::face_t *face,
+ unsigned edge,
+ SwapableFaceEdgeAttr<attr_t> *interpolator) {
+ typename FaceEdgeAttr<attr_t>::key_t key(face, edge);
+ typename FaceEdgeAttr<attr_t>::attrmap_t::const_iterator fv = interpolator->attrs.find(key);
+ if (fv != interpolator->attrs.end()) {
+ this->attrs[key] = (*fv).second;
+ }
+ }
+
+ void swapAttributes(SwapableFaceEdgeAttr<attr_t> *interpolator) {
+ this->attrs.swap(interpolator->attrs);
+ }
+ };
} // namespace interpolate
} // namespace carve