From 690c77dd7de19783adb228be51b099ed19c22d5a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 23 Jan 2012 17:43:41 +0000 Subject: Fix #29934: New Carve library can't execute boolean operations in some cases Issue was caused by left boolean operand consist of several intersecting manifolds which make Carve triangulator confused and which can't be resolved in general case. Added mesh pre-processing before actual applying boolean operator on it. This preprocessing applies union operation on intersecting manifolds of the same object so intersection edge loop with second object wouldn't confuse tesselator and correct result would be returned. Detecting of intersecting manifolds is based on AABB intersection check which leads to some extra union operation called, but it's possible to speed things up from Carve side so union operation of two not intersecting meshes would work faster. Additional condition for running union for manifold is this manifolds intersects AABB of second operand, so mesh topology wouldn't be changed at all in areas where there's definitely no intersection between operands. It might be improved so only manifolds which actually intersects second operand would be joined together, but it'll slow things down a bit and prefer to do it only if it'll be really a problem. Additional change is fixed memory leak when boolean operation fails to run - it was missed "delete" call if exception happens in Carve library. From side effects of this change might be named boolean operation between suzanne and another object: suzanne is consist of three intersecting open manifolds, so this new meshes preprocessing leads to missed eyes in result because of failure of merging two open manifolds. Don't think making suzanne work for all setups should really be a goal, it's a bit crappy mesh for CSG algorithms. --- source/blender/modifiers/intern/MOD_boolean_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/modifiers/intern/MOD_boolean_util.c') diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index afd16b41131..fa829bcd44b 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -522,7 +522,7 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( CSG_FreeFaceDescriptor(&fd_o); } else - printf("Unknown internal error in boolean"); + printf("Unknown internal error in boolean\n"); CSG_FreeBooleanOperation(bool_op); -- cgit v1.2.3