Fix boolean modifier crash; if boolean code cannot do the operation on the

meshes, print an error dialog and delete the modifier object.
This commit is contained in:
Ken Hughes 2006-01-01 15:41:20 +00:00
parent 71991cf41e
commit 9b419bb4be
2 changed files with 42 additions and 25 deletions

@ -1210,9 +1210,15 @@ static void *booleanModifier_applyModifier(ModifierData *md, Object *ob, void *d
if( ((Mesh *)ob->data)->totface>3 && bmd->object && ((Mesh *)bmd->object->data)->totface>3) {
DispListMesh *dlm= NewBooleanMeshDLM(bmd->object, ob, 1+bmd->operation);
return derivedmesh_from_displistmesh(dlm, NULL);
/* if new mesh returned, get derived mesh; otherwise there was
* an error, so delete the modifier object */
if( dlm )
return derivedmesh_from_displistmesh(dlm, NULL);
else
bmd->object = NULL;
}
else return derivedData;
return derivedData;
}
/***/

@ -498,37 +498,48 @@ DispListMesh *NewBooleanMeshDLM(Object *ob, Object *ob_select, int int_op_type)
InterpFaceVertexData
);
}
if (success) {
// descriptions of the output;
CSG_VertexIteratorDescriptor vd_o;
CSG_FaceIteratorDescriptor fd_o;
dlm = MEM_callocN(sizeof(*dlm),"dlm");
CSG_OutputFaceDescriptor(bool_op,&fd_o);
CSG_OutputVertexDescriptor(bool_op,&vd_o);
switch( success ) {
case 1:
{
// descriptions of the output;
CSG_VertexIteratorDescriptor vd_o;
CSG_FaceIteratorDescriptor fd_o;
dlm = MEM_callocN(sizeof(*dlm),"dlm");
// iterate through results of operation and insert into new object
CSG_OutputFaceDescriptor(bool_op,&fd_o);
CSG_OutputVertexDescriptor(bool_op,&vd_o);
ConvertCSGDescriptorsToDLM(
dlm,
NULL,
&output_mpd,
&fd_o,
&vd_o,
inv_mat
);
// iterate through results of operation and insert into new object
// free up the memory
ConvertCSGDescriptorsToDLM(
dlm,
NULL,
&output_mpd,
&fd_o,
&vd_o,
inv_mat
);
CSG_FreeVertexDescriptor(&vd_o);
CSG_FreeFaceDescriptor(&fd_o);
// free up the memory
CSG_FreeVertexDescriptor(&vd_o);
CSG_FreeFaceDescriptor(&fd_o);
}
break;
case -1:
error("Selected meshes must have faces to perform boolean operations");
break;
case -2:
error("Both meshes must be closed");
break;
default:
error("unknown internal error");
break;
}
CSG_FreeBooleanOperation(bool_op);
bool_op = NULL;
}
// We may need to map back the tfaces to mcols here.