diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-05-29 19:53:38 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-05-29 19:53:38 +0400 |
commit | e1466b8ca2ce09d3964a1586104d94a43ea07182 (patch) | |
tree | c0fcae9ef80a44768a5828cd5a6b1c27227110ca /source/blender/modifiers | |
parent | 11014aa34b26337023f53e75ebdc3432e7e116c2 (diff) |
Fix #27392: boolean intersect's
It was lag of optimization logic, which always retuns object's derivedMesh
if one of of boolean operation's meshes has got no faces.
Actually, result depends on operation and which mesh has got no faces.
Added small utility function to handle this.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_boolean.c | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index ec6387f44af..4b4d0124aae 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -92,19 +92,56 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } #ifdef WITH_MOD_BOOLEAN +static DerivedMesh *get_quick_derivedMesh(DerivedMesh *derivedData, DerivedMesh *dm, int operation) +{ + DerivedMesh *result = NULL; + + if(derivedData->getNumFaces(derivedData) == 0 || dm->getNumFaces(dm) == 0) { + switch(operation) { + case eBooleanModifierOp_Intersect: + result = CDDM_new(0, 0, 0); + break; + + case eBooleanModifierOp_Union: + if(derivedData->getNumFaces(derivedData)) result = derivedData; + else result = CDDM_copy(dm); + + break; + + case eBooleanModifierOp_Difference: + result = derivedData; + break; + } + } + + return result; +} + static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { BooleanModifierData *bmd = (BooleanModifierData*) md; - DerivedMesh *dm = bmd->object->derivedFinal; + DerivedMesh *dm; + + if(!bmd->object) + return derivedData; + + dm = bmd->object->derivedFinal; + + if(dm) { + DerivedMesh *result; + + /* when one of objects is empty (has got no faces) we could speed up + calculation a bit returning one of objects' derived meshes (or empty one) + Returning mesh is depended on modifieier's operation (sergey) */ + result = get_quick_derivedMesh(derivedData, dm, bmd->operation); - /* we do a quick sanity check */ - if(dm && (derivedData->getNumFaces(derivedData) > 3) - && bmd->object && dm->getNumFaces(dm) > 3) { - DerivedMesh *result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob, - 1 + bmd->operation); + if(result == NULL) { + result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob, + 1 + bmd->operation); + } /* if new mesh returned, return it; otherwise there was * an error, so delete the modifier object */ |