[Bf-blender-cvs] [df4e43d9fd7] soc-2020-io-performance: Rename get_object_deform_vert; add comments
Ankit Meel
noreply at git.blender.org
Wed Jul 1 21:03:59 CEST 2020
Commit: df4e43d9fd7001fbccb13ad5b0b0e3f0ec7e9ed4
Author: Ankit Meel
Date: Wed Jul 1 23:58:13 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rBdf4e43d9fd7001fbccb13ad5b0b0e3f0ec7e9ed4
Rename get_object_deform_vert; add comments
`get_object_deform_vert` → `get_poly_deform_group_name`
Edit comments, and the UI tooltip of the export option.
===================================================================
M source/blender/editors/io/io_obj.c
M source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mesh.cc
M source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mesh.hh
M source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc
===================================================================
diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c
index 0380cea3739..a970ace4df6 100644
--- a/source/blender/editors/io/io_obj.c
+++ b/source/blender/editors/io/io_obj.c
@@ -345,7 +345,8 @@ void WM_OT_obj_export(struct wmOperatorType *ot)
"export_vertex_groups",
false,
"Export vertex groups",
- "If checked, writes the name of the vertex group to which a face's maximum vertices belong");
+ "If checked, writes the name of the vertex group of a face. It is approximated "
+ "by choosing the vertex group with the most members among the vertices of a face");
}
static int wm_obj_import_invoke(bContext *C, wmOperator *op, const wmEvent *event)
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mesh.cc b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mesh.cc
index 5e0ba7a729d..7d6df6c6ed4 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mesh.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mesh.cc
@@ -265,12 +265,17 @@ void OBJMesh::calc_poly_normal_indices(Vector<uint> &r_normal_indices, uint poly
}
/**
- * Find the name of the group to which maximum number of vertices of a poly belong.
- * If no vertex belongs to any group, name is "off".
- * If there's a tie between two or more vertices, group name depends on the implementation
- * of max_element.
+ * Find the name of the vertex group with the maximum number of vertices in a poly.
+ * If no vertex belongs to any group, returned name is "off".
+ * If two or more groups have the same number of vertices (maximum), group name depends on the
+ * implementation of std::max_element.
+ * If the group corresponding to r_last_vertex_group shows up on another polygon, return nullptr so
+ * that caller can skip that group.
+ *
+ * \param r_last_vertex_group stores the index of the vertex group found in last iteration,
+ * indexing into Object->defbase.
*/
-const char *OBJMesh::get_object_deform_vert(const MPoly &mpoly, short &r_last_vertex_group)
+const char *OBJMesh::get_poly_deform_group_name(const MPoly &mpoly, short &r_last_vertex_group)
{
const MLoop *mloop = &_export_mesh_eval->mloop[mpoly.loopstart];
/* Indices index into deform groups; values are the number of vertices in one deform group. */
@@ -280,9 +285,11 @@ const char *OBJMesh::get_object_deform_vert(const MPoly &mpoly, short &r_last_ve
/* Whether at least one vertex in the polygon belongs to any group. */
bool found_group = false;
+ const MDeformVert *dvert;
+ const MDeformWeight *curr_weight;
for (uint loop_index = 0; loop_index < mpoly.totloop; loop_index++) {
- const MDeformVert dvert = _export_mesh_eval->dvert[(mloop + loop_index)->v];
- const MDeformWeight *curr_weight = dvert.dw;
+ dvert = &_export_mesh_eval->dvert[(mloop + loop_index)->v];
+ curr_weight = dvert->dw;
if (curr_weight) {
bDeformGroup *vertex_group = (bDeformGroup *)BLI_findlink(
(ListBase *)(&_export_object_eval->defbase), curr_weight->def_nr);
@@ -304,7 +311,8 @@ const char *OBJMesh::get_object_deform_vert(const MPoly &mpoly, short &r_last_ve
int max_idx = std::max_element(deform_group_indices.begin(), deform_group_indices.end()) -
deform_group_indices.begin();
if (max_idx == r_last_vertex_group) {
- /* No need to update the name, since it won't be printed. */
+ /* No need to update the name, r_last_vertex_group indicates that it has been written already.
+ */
return nullptr;
}
r_last_vertex_group = max_idx;
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mesh.hh b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mesh.hh
index c3ba1d08c36..d76735d4f25 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mesh.hh
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mesh.hh
@@ -88,13 +88,6 @@ class OBJMesh : NonMovable, NonCopyable {
void ensure_normals();
/** Return mat_nr-th material of the object. */
Material *get_object_material(short mat_nr);
- /**
- * Find the name of the group to which maximum number of vertices of a poly belong.
- * If no vertex belongs to any group, name is "off".
- * If there's a tie between two or more vertices, group name depends on the implementation
- * of max_element.
- */
- const char *get_object_deform_vert(const MPoly &mpoly, short &r_last_vertex_group);
/* Names as they appear in the outliner. */
const char *get_object_name();
@@ -122,6 +115,19 @@ class OBJMesh : NonMovable, NonCopyable {
* Calculate face normal indices of all polygons.
*/
void calc_poly_normal_indices(Vector<uint> &r_normal_indices, uint poly_indices);
+ /**
+ * Find the name of the vertex group with the maximum number of vertices in a poly.
+ * If no vertex belongs to any group, returned name is "off".
+ * If two or more groups have the same number of vertices (maximum), group name depends on the
+ * implementation of std::max_element.
+ * If the group corresponding to r_last_vertex_group shows up on another polygon, return nullptr
+ * so that caller can skip that group.
+ *
+ * \param r_last_vertex_group stores the index of the vertex group found in last iteration,
+ * indexing into Object->defbase.
+ */
+ const char *get_poly_deform_group_name(const MPoly &mpoly, short &r_last_vertex_group);
+
/**
* Only for curve converted to meshes: calculate vertex indices of one edge.
*/
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc b/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc
index 46f3d869417..ac185044187 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc
@@ -217,7 +217,7 @@ void OBJWriter::write_vertex_group(OBJMesh &obj_mesh_data,
if (!_export_params->export_vertex_groups) {
return;
}
- const char *def_group_name = obj_mesh_data.get_object_deform_vert(mpoly, last_face_vertex_group);
+ const char *def_group_name = obj_mesh_data.get_poly_deform_group_name(mpoly, last_face_vertex_group);
if (!def_group_name) {
/* Don't write the name of the group again. If set once, the group name changes only when a new
* one is encountered. */
More information about the Bf-blender-cvs
mailing list