diff options
author | Hans Goudey <h.goudey@me.com> | 2021-07-13 19:10:34 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-07-13 19:10:34 +0300 |
commit | 3b6ee8cee7080af200e25e944fe30d310240e138 (patch) | |
tree | 724f298a53b12811e17425b84a909f2aaf2557a3 /source/blender/blenkernel/intern/object.c | |
parent | 52b94049f2a71a74f52247f83657cf3a5c8712b4 (diff) |
Refactor: Move vertex group names to object data
This commit moves the storage of `bDeformGroup` and the active index
to `Mesh`, `Lattice`, and `bGPdata` instead of `Object`. Utility
functions are added to allow easy access to the vertex groups given
an object or an ID.
As explained in T88951, the list of vertex group names is currently
stored separately per object, even though vertex group data is stored
on the geometry. This tends to complicate code and cause bugs,
especially as geometry is created procedurally and tied less closely
to an object.
The "Copy Vertex Groups to Linked" operator is removed, since they
are stored on the geometry anyway.
This patch leaves the object-level python API for vertex groups in
place. Creating a geometry-level RNA API can be a separate step;
the changes in this commit are invasive enough as it is.
Note that opening a file saved in 3.0 in an earlier version means
the vertex groups will not be available.
Differential Revision: https://developer.blender.org/D11689
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index d8b9b851865..912b5e0a0dd 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -234,7 +234,7 @@ static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const in BKE_pose_rebuild(bmain, ob_dst, ob_dst->data, do_pose_id_user); } } - BKE_defgroup_copy_list(&ob_dst->defbase, &ob_src->defbase); + BKE_object_facemap_copy_list(&ob_dst->fmaps, &ob_src->fmaps); BKE_constraints_copy_ex(&ob_dst->constraints, &ob_src->constraints, flag_subdata, true); @@ -285,7 +285,6 @@ static void object_free_data(ID *id) MEM_SAFE_FREE(ob->iuser); MEM_SAFE_FREE(ob->runtime.bb); - BLI_freelistN(&ob->defbase); BLI_freelistN(&ob->fmaps); if (ob->pose) { BKE_pose_free_ex(ob->pose, false); @@ -510,13 +509,6 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data) } } -static void write_defgroups(BlendWriter *writer, ListBase *defbase) -{ - LISTBASE_FOREACH (bDeformGroup *, defgroup, defbase) { - BLO_write_struct(writer, bDeformGroup, defgroup); - } -} - static void write_fmaps(BlendWriter *writer, ListBase *fbase) { LISTBASE_FOREACH (bFaceMap *, fmap, fbase) { @@ -561,7 +553,6 @@ static void object_blend_write(BlendWriter *writer, ID *id, const void *id_addre } BKE_pose_blend_write(writer, ob->pose, arm); - write_defgroups(writer, &ob->defbase); write_fmaps(writer, &ob->fmaps); BKE_constraint_blend_write(writer, &ob->constraints); animviz_motionpath_blend_write(writer, ob->mpath); @@ -644,7 +635,9 @@ static void object_blend_read_data(BlendDataReader *reader, ID *id) animviz_motionpath_blend_read_data(reader, ob->mpath); } + /* Only for versioning, vertex group names are now stored on object data. */ BLO_read_list(reader, &ob->defbase); + BLO_read_list(reader, &ob->fmaps); /* XXX deprecated - old animation system <<< */ direct_link_nlastrips(reader, &ob->nlastrips); @@ -2901,9 +2894,6 @@ void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob) ob->data = target->data; id_us_plus((ID *)ob->data); /* ensures lib data becomes LIB_TAG_EXTERN */ - /* copy vertex groups */ - BKE_defgroup_copy_list(&ob->defbase, &target->defbase); - /* copy material and index information */ ob->actcol = ob->totcol = 0; if (ob->mat) { |