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/intern/object.c | |
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/intern/object.c')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 10 |
1 files changed, 10 insertions, 0 deletions
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; } |