diff options
author | Erik Abrahamsson <erik85> | 2020-12-28 20:17:49 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-12-28 20:18:52 +0300 |
commit | 6fbeb6e2e05408af448e9409f8e7e11470f82db6 (patch) | |
tree | af7a763798177bb54e61b164bc215ed610983b0c /source/blender/blenkernel | |
parent | 7f3601e70dd094b6f9162bb03a8a3440d50de47e (diff) |
Add operator to copy a modifier to all selected objects
These two operators (one for grease pencil, one for other objects)
copy a single modifier from the active object to all selected objects.
The operators are exposed in the dropdown menus in modifier headers.
Note that It's currently possible to drag and drop modifiers between
objects in the outliner, but that only works for dragging to one object
at a time. Modifiers can also be copied with the "Make Links" operator,
but that copies *all* modifiers rather than just one. The placement
and scope of these new operators allow for more useful poll messages
and error messages as well.
Every object type that supports modifiers is supported. Although hook
and collision modifiers aren't supported because of an unexplained
comment in `BKE_object_copy_modifier`, other than that, every modifier
type is supported, including particle systems, nodes modifiers, etc.
The new modifiers are set active, which required two small tweaks to
`object.c` and `particle.c`.
Reviewed By: Hans Goudey (with additional edits)
Differential Revision: https://developer.blender.org/D9537
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 2 |
3 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index a620d9af946..cd253ca4bbc 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -75,6 +75,7 @@ bool BKE_object_modifier_gpencil_use_time(struct Object *ob, struct GpencilModif bool BKE_object_shaderfx_use_time(struct Object *ob, struct ShaderFxData *md); +bool BKE_object_supports_modifiers(const struct Object *ob); bool BKE_object_support_modifier_type_check(const struct Object *ob, int modifier_type); /* Active modifier. */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 7ed906e2cea..163e7d51235 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1315,6 +1315,15 @@ ModifierData *BKE_object_active_modifier(const Object *ob) return NULL; } +/** + * \return True if the object's type supports regular modifiers (not grease pencil modifiers). + */ +bool BKE_object_supports_modifiers(const Object *ob) +{ + return ( + ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE, OB_POINTCLOUD, OB_VOLUME)); +} + bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type) { const ModifierTypeInfo *mti = BKE_modifier_get_info(modifier_type); @@ -1377,6 +1386,7 @@ bool BKE_object_copy_modifier(struct Object *ob_dst, const struct Object *ob_src BKE_modifier_copydata(md, nmd); BLI_addtail(&ob_dst->modifiers, nmd); BKE_modifier_unique_name(&ob_dst->modifiers, nmd); + BKE_object_modifier_set_active(ob_dst, nmd); return true; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index dce45f44583..335913c9b8e 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -75,6 +75,7 @@ #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_modifier.h" +#include "BKE_object.h" #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_scene.h" @@ -3948,6 +3949,7 @@ static ModifierData *object_add_or_copy_particle_system( psmd = (ParticleSystemModifierData *)md; psmd->psys = psys; BLI_addtail(&ob->modifiers, md); + BKE_object_modifier_set_active(ob, md); psys->totpart = 0; psys->flag = PSYS_CURRENT; |