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:
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.cc')
-rw-r--r--source/blender/blenkernel/intern/mesh.cc34
1 files changed, 25 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index cf05dc0404e..7f2c09f049b 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -28,6 +28,7 @@
#include "BLI_math.h"
#include "BLI_math_vector.hh"
#include "BLI_memarena.h"
+#include "BLI_span.hh"
#include "BLI_string.h"
#include "BLI_task.hh"
#include "BLI_utildefines.h"
@@ -36,6 +37,7 @@
#include "BLT_translation.h"
#include "BKE_anim_data.h"
+#include "BKE_attribute.hh"
#include "BKE_bpath.h"
#include "BKE_deform.h"
#include "BKE_editmesh.h"
@@ -62,6 +64,8 @@
#include "BLO_read_write.h"
using blender::float3;
+using blender::MutableSpan;
+using blender::VArray;
using blender::Vector;
static void mesh_clear_geometry(Mesh *mesh);
@@ -109,7 +113,7 @@ static void mesh_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
*
* While this could be the callers responsibility, keep here since it's
* highly unlikely we want to create a duplicate and not use it for drawing. */
- mesh_dst->runtime.is_original = false;
+ mesh_dst->runtime.is_original_bmesh = false;
/* Only do tessface if we have no polys. */
const bool do_tessface = ((mesh_src->totface != 0) && (mesh_src->totpoly == 0));
@@ -208,6 +212,7 @@ static void mesh_foreach_path(ID *id, BPathForeachPathData *bpath_data)
static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
+ using namespace blender;
Mesh *mesh = (Mesh *)id;
const bool is_undo = BLO_write_is_undo(writer);
@@ -241,10 +246,17 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
memset(&mesh->pdata, 0, sizeof(mesh->pdata));
}
else {
- CustomData_blend_write_prepare(mesh->vdata, vert_layers);
- CustomData_blend_write_prepare(mesh->edata, edge_layers);
- CustomData_blend_write_prepare(mesh->ldata, loop_layers);
- CustomData_blend_write_prepare(mesh->pdata, poly_layers);
+ Set<std::string> names_to_skip;
+ if (!BLO_write_is_undo(writer)) {
+ BKE_mesh_legacy_convert_hide_layers_to_flags(mesh);
+ /* When converting to the old mesh format, don't save redunant attributes. */
+ names_to_skip.add_multiple_new({".hide_vert", ".hide_edge", ".hide_poly"});
+ }
+
+ CustomData_blend_write_prepare(mesh->vdata, vert_layers, names_to_skip);
+ CustomData_blend_write_prepare(mesh->edata, edge_layers, names_to_skip);
+ CustomData_blend_write_prepare(mesh->ldata, loop_layers, names_to_skip);
+ CustomData_blend_write_prepare(mesh->pdata, poly_layers, names_to_skip);
}
BLO_write_id_struct(writer, Mesh, id_address, &mesh->id);
@@ -323,6 +335,10 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
}
}
+ if (!BLO_read_data_is_undo(reader)) {
+ BKE_mesh_legacy_convert_flags_to_hide_layers(mesh);
+ }
+
/* We don't expect to load normals from files, since they are derived data. */
BKE_mesh_normals_tag_dirty(mesh);
BKE_mesh_assert_normals_dirty_or_calculated(mesh);
@@ -760,10 +776,10 @@ static void mesh_ensure_tessellation_customdata(Mesh *me)
/* TODO: add some `--debug-mesh` option. */
if (G.debug & G_DEBUG) {
- /* NOTE(campbell): this warning may be un-called for if we are initializing the mesh for
- * the first time from #BMesh, rather than giving a warning about this we could be smarter
- * and check if there was any data to begin with, for now just print the warning with
- * some info to help troubleshoot what's going on. */
+ /* NOTE(@campbellbarton): this warning may be un-called for if we are initializing the mesh
+ * for the first time from #BMesh, rather than giving a warning about this we could be
+ * smarter and check if there was any data to begin with, for now just print the warning
+ * with some info to help troubleshoot what's going on. */
printf(
"%s: warning! Tessellation uvs or vcol data got out of sync, "
"had to reset!\n CD_MTFACE: %d != CD_MLOOPUV: %d || CD_MCOL: %d != "