Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-07-13 19:10:34 +0300
committerHans Goudey <h.goudey@me.com>2021-07-13 19:10:34 +0300
commit3b6ee8cee7080af200e25e944fe30d310240e138 (patch)
tree724f298a53b12811e17425b84a909f2aaf2557a3 /source/blender/io/collada
parent52b94049f2a71a74f52247f83657cf3a5c8712b4 (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')
-rw-r--r--source/blender/io/collada/ControllerExporter.cpp23
-rw-r--r--source/blender/io/collada/ControllerExporter.h10
-rw-r--r--source/blender/io/collada/SkinInfo.cpp4
3 files changed, 20 insertions, 17 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;
}
diff --git a/source/blender/io/collada/ControllerExporter.h b/source/blender/io/collada/ControllerExporter.h
index 6a377a4119e..0aec9e8d179 100644
--- a/source/blender/io/collada/ControllerExporter.h
+++ b/source/blender/io/collada/ControllerExporter.h
@@ -97,7 +97,7 @@ class ControllerExporter : public COLLADASW::LibraryControllers,
void export_morph_controller(Object *ob, Key *key);
- void add_joints_element(ListBase *defbase,
+ void add_joints_element(const ListBase *defbase,
const std::string &joints_source_id,
const std::string &inv_bind_mat_source_id);
@@ -110,16 +110,16 @@ class ControllerExporter : public COLLADASW::LibraryControllers,
void add_weight_extras(Key *key);
std::string add_joints_source(Object *ob_arm,
- ListBase *defbase,
+ const ListBase *defbase,
const std::string &controller_id);
std::string add_inv_bind_mats_source(Object *ob_arm,
- ListBase *defbase,
+ const ListBase *defbase,
const std::string &controller_id);
- Bone *get_bone_from_defgroup(Object *ob_arm, bDeformGroup *def);
+ Bone *get_bone_from_defgroup(Object *ob_arm, const bDeformGroup *def);
- bool is_bone_defgroup(Object *ob_arm, bDeformGroup *def);
+ bool is_bone_defgroup(Object *ob_arm, const bDeformGroup *def);
std::string add_weights_source(Mesh *me,
const std::string &controller_id,
diff --git a/source/blender/io/collada/SkinInfo.cpp b/source/blender/io/collada/SkinInfo.cpp
index c2f17174d75..f0e1c5e4c26 100644
--- a/source/blender/io/collada/SkinInfo.cpp
+++ b/source/blender/io/collada/SkinInfo.cpp
@@ -36,6 +36,7 @@
#include "DNA_scene_types.h"
#include "BKE_action.h"
+#include "BKE_deform.h"
#include "BKE_object.h"
#include "BKE_object_deform.h"
@@ -289,7 +290,8 @@ void SkinInfo::link_armature(bContext *C,
/* -1 means "weight towards the bind shape", we just don't assign it to any group */
if (joint != -1) {
- bDeformGroup *def = (bDeformGroup *)BLI_findlink(&ob->defbase, joint);
+ const ListBase *defbase = BKE_object_defgroup_list(ob);
+ bDeformGroup *def = (bDeformGroup *)BLI_findlink(defbase, joint);
ED_vgroup_vert_add(ob, def, vertex, weights[joint_weight], WEIGHT_REPLACE);
}