Fix #30496: Bugs and crashes about "make links modifers" function.

Was missed check for if modifier is available for particular object type
which ended up with unpredictable results when modifier which isn't supported
yet for some object type as linked to that object type.
This commit is contained in:
2012-03-12 14:35:07 +00:00
parent 74b7bc1228
commit a527e3ea25
3 changed files with 32 additions and 2 deletions

View File

@@ -199,16 +199,40 @@ void object_free_modifiers(Object *ob)
object_free_softbody(ob);
}
int object_support_modifier_type(Object *ob, int modifier_type)
{
ModifierTypeInfo *mti;
mti = modifierType_getInfo(modifier_type);
if (!((mti->flags & eModifierTypeFlag_AcceptsCVs) ||
(ob->type==OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh))))
{
return FALSE;
}
return TRUE;
}
void object_link_modifiers(struct Object *ob, struct Object *from)
{
ModifierData *md;
object_free_modifiers(ob);
if (!ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
/* only objects listed above can have modifiers and linking them to objects
* which doesn't have modifiers stack is quite silly */
return;
}
for (md=from->modifiers.first; md; md=md->next) {
ModifierData *nmd = NULL;
if (ELEM4(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance, eModifierType_Collision)) continue;
if (!object_support_modifier_type(ob, md->type))
continue;
nmd = modifier_new(md->type);
modifier_copyData(md, nmd);
BLI_addtail(&ob->modifiers, nmd);
@@ -954,6 +978,11 @@ void copy_object_particlesystems(Object *obn, Object *ob)
ParticleSystem *psys, *npsys;
ModifierData *md;
if (obn->type != OB_MESH) {
/* currently only mesh objects can have soft body */
return;
}
obn->particlesystem.first= obn->particlesystem.last= NULL;
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
npsys= copy_particlesystem(psys);