forked from bartvdbraak/blender
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.
This commit is contained in:
parent
11014aa34b
commit
e1466b8ca2
@ -92,19 +92,56 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_MOD_BOOLEAN
|
#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,
|
static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||||
DerivedMesh *derivedData,
|
DerivedMesh *derivedData,
|
||||||
int UNUSED(useRenderParams),
|
int UNUSED(useRenderParams),
|
||||||
int UNUSED(isFinalCalc))
|
int UNUSED(isFinalCalc))
|
||||||
{
|
{
|
||||||
BooleanModifierData *bmd = (BooleanModifierData*) md;
|
BooleanModifierData *bmd = (BooleanModifierData*) md;
|
||||||
DerivedMesh *dm = bmd->object->derivedFinal;
|
DerivedMesh *dm;
|
||||||
|
|
||||||
/* we do a quick sanity check */
|
if(!bmd->object)
|
||||||
if(dm && (derivedData->getNumFaces(derivedData) > 3)
|
return derivedData;
|
||||||
&& bmd->object && dm->getNumFaces(dm) > 3) {
|
|
||||||
DerivedMesh *result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob,
|
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);
|
||||||
|
|
||||||
|
if(result == NULL) {
|
||||||
|
result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob,
|
||||||
1 + bmd->operation);
|
1 + bmd->operation);
|
||||||
|
}
|
||||||
|
|
||||||
/* if new mesh returned, return it; otherwise there was
|
/* if new mesh returned, return it; otherwise there was
|
||||||
* an error, so delete the modifier object */
|
* an error, so delete the modifier object */
|
||||||
|
Loading…
Reference in New Issue
Block a user