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/io/collada/ControllerExporter.cpp | |
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/io/collada/ControllerExporter.cpp')
-rw-r--r-- | source/blender/io/collada/ControllerExporter.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/source/blender/io/collada/ControllerExporter.cpp b/source/blender/io/collada/ControllerExporter.cpp index 6f0d422dbe2..e61ed47adee 100644 --- a/source/blender/io/collada/ControllerExporter.cpp +++ b/source/blender/io/collada/ControllerExporter.cpp @@ -29,6 +29,7 @@ #include "BKE_action.h" #include "BKE_armature.h" +#include "BKE_deform.h" #include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lib_id.h" @@ -194,9 +195,9 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) add_bind_shape_mat(ob); - std::string joints_source_id = add_joints_source(ob_arm, &ob->defbase, controller_id); - std::string inv_bind_mat_source_id = add_inv_bind_mats_source( - ob_arm, &ob->defbase, controller_id); + const ListBase *defbase = BKE_object_defgroup_list(ob); + std::string joints_source_id = add_joints_source(ob_arm, defbase, controller_id); + std::string inv_bind_mat_source_id = add_inv_bind_mats_source(ob_arm, defbase, controller_id); std::list<int> vcounts; std::list<int> joints; @@ -207,9 +208,9 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) /* def group index -> joint index */ std::vector<int> joint_index_by_def_index; - bDeformGroup *def; + const bDeformGroup *def; - for (def = (bDeformGroup *)ob->defbase.first, i = 0, j = 0; def; def = def->next, i++) { + for (def = (const bDeformGroup *)defbase->first, i = 0, j = 0; def; def = def->next, i++) { if (is_bone_defgroup(ob_arm, def)) { joint_index_by_def_index.push_back(j++); } @@ -269,7 +270,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) } std::string weights_source_id = add_weights_source(me, controller_id, weights); - add_joints_element(&ob->defbase, joints_source_id, inv_bind_mat_source_id); + add_joints_element(defbase, joints_source_id, inv_bind_mat_source_id); add_vertex_weights_element(weights_source_id, joints_source_id, vcounts, joints); BKE_id_free(nullptr, me); @@ -392,7 +393,7 @@ void ControllerExporter::add_weight_extras(Key *key) } } -void ControllerExporter::add_joints_element(ListBase *defbase, +void ControllerExporter::add_joints_element(const ListBase *defbase, const std::string &joints_source_id, const std::string &inv_bind_mat_source_id) { @@ -431,7 +432,7 @@ void ControllerExporter::add_bind_shape_mat(Object *ob) } std::string ControllerExporter::add_joints_source(Object *ob_arm, - ListBase *defbase, + const ListBase *defbase, const std::string &controller_id) { std::string source_id = controller_id + JOINTS_SOURCE_ID_SUFFIX; @@ -468,7 +469,7 @@ std::string ControllerExporter::add_joints_source(Object *ob_arm, } std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, - ListBase *defbase, + const ListBase *defbase, const std::string &controller_id) { std::string source_id = controller_id + BIND_POSES_SOURCE_ID_SUFFIX; @@ -568,13 +569,13 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, return source_id; } -Bone *ControllerExporter::get_bone_from_defgroup(Object *ob_arm, bDeformGroup *def) +Bone *ControllerExporter::get_bone_from_defgroup(Object *ob_arm, const bDeformGroup *def) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, def->name); return pchan ? pchan->bone : nullptr; } -bool ControllerExporter::is_bone_defgroup(Object *ob_arm, bDeformGroup *def) +bool ControllerExporter::is_bone_defgroup(Object *ob_arm, const bDeformGroup *def) { return get_bone_from_defgroup(ob_arm, def) != nullptr; } |