diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 1e9bb85b549..f5937304e76 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -67,6 +67,8 @@ void update_base_layer(struct Scene *scene, struct Object *ob); void free_object(struct Object *ob); void object_free_display(struct Object *ob); +int object_support_modifier_type(struct Object *ob, int modifier_type); + void object_link_modifiers(struct Object *ob, struct Object *from); void object_free_modifiers(struct Object *ob); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 32a3ca2b732..0557fcf5fcd 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -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); |