Bugfix [#25291] Objects that should not have subsurface modifier have

it (eg cameras)

When trying to add a modifier to non-geometry objects, warnings are
now shown instead of just adding some (useless) modifiers that cannot
be removed later.
This commit is contained in:
Joshua Leung 2010-12-19 01:14:57 +00:00
parent 555427765d
commit 43af26fa41
2 changed files with 14 additions and 5 deletions

@ -207,9 +207,12 @@ class SubdivisionSet(bpy.types.Operator):
return
# adda new modifier
mod = obj.modifiers.new("Subsurf", 'SUBSURF')
mod.levels = level
# add a new modifier
try:
mod = obj.modifiers.new("Subsurf", 'SUBSURF')
mod.levels = level
except:
self.report({'WARNING'}, "Modifiers cannot be added to object: " + obj.name)
for obj in context.selected_editable_objects:
set_object_subd(obj)

@ -82,14 +82,20 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
{
ModifierData *md=NULL, *new_md=NULL;
ModifierTypeInfo *mti = modifierType_getInfo(type);
/* only geometry objects should be able to get modifiers [#25291] */
if(!ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to Object '%s'", ob->id.name+2);
return NULL;
}
if(mti->flags&eModifierTypeFlag_Single) {
if(modifiers_findByType(ob, type)) {
BKE_report(reports, RPT_WARNING, "Only one modifier of this type allowed.");
return NULL;
}
}
if(type == eModifierType_ParticleSystem) {
/* don't need to worry about the new modifier's name, since that is set to the number
* of particle systems which shouldn't have too many duplicates