[Bf-blender-cvs] [2111574e092] refactor-mesh-remove-pointers: Cleanup: Remove `Mesh.mloopcol` pointer
Hans Goudey
noreply at git.blender.org
Sun Jul 17 18:07:45 CEST 2022
Commit: 2111574e092faab7024e6e5f692cef2c5a4ce9c5
Author: Hans Goudey
Date: Mon Jul 11 12:47:17 2022 -0500
Branches: refactor-mesh-remove-pointers
https://developer.blender.org/rB2111574e092faab7024e6e5f692cef2c5a4ce9c5
Cleanup: Remove `Mesh.mloopcol` pointer
===================================================================
M source/blender/blenkernel/intern/mesh.cc
M source/blender/editors/include/ED_mesh.h
M source/blender/editors/mesh/mesh_data.cc
M source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
M source/blender/io/collada/MeshImporter.cpp
M source/blender/io/usd/intern/usd_reader_mesh.cc
M source/blender/makesdna/DNA_mesh_types.h
===================================================================
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index 2a14370bf93..c5dff438628 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -286,7 +286,6 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_data_address(reader, &mesh->mtface);
BLO_read_data_address(reader, &mesh->mcol);
BLO_read_data_address(reader, &mesh->dvert);
- BLO_read_data_address(reader, &mesh->mloopcol);
BLO_read_data_address(reader, &mesh->mloopuv);
BLO_read_data_address(reader, &mesh->mselect);
@@ -883,7 +882,6 @@ void BKE_mesh_update_customdata_pointers(Mesh *me, const bool do_ensure_tess_cd)
me->mpoly = (MPoly *)CustomData_get_layer(&me->pdata, CD_MPOLY);
me->mloop = (MLoop *)CustomData_get_layer(&me->ldata, CD_MLOOP);
- me->mloopcol = (MLoopCol *)CustomData_get_layer(&me->ldata, CD_PROP_BYTE_COLOR);
me->mloopuv = (MLoopUV *)CustomData_get_layer(&me->ldata, CD_MLOOPUV);
}
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 52044109702..e0afea3d430 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -557,7 +557,6 @@ bool ED_mesh_color_remove_index(struct Mesh *me, int n);
bool ED_mesh_color_remove_active(struct Mesh *me);
bool ED_mesh_color_remove_named(struct Mesh *me, const char *name);
-bool ED_mesh_sculpt_color_ensure(struct Mesh *me, const char *name);
int ED_mesh_sculpt_color_add(
struct Mesh *me, const char *name, bool active_set, bool do_init, struct ReportList *reports);
bool ED_mesh_sculpt_color_remove_index(struct Mesh *me, int n);
diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc
index 67834bf05ce..118afd2fd06 100644
--- a/source/blender/editors/mesh/mesh_data.cc
+++ b/source/blender/editors/mesh/mesh_data.cc
@@ -18,6 +18,7 @@
#include "BLI_utildefines.h"
#include "BKE_attribute.h"
+#include "BKE_attribute.hh"
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_editmesh.h"
@@ -403,9 +404,13 @@ int ED_mesh_color_add(
return -1;
}
- if (me->mloopcol && do_init) {
- CustomData_add_layer_named(
- &me->ldata, CD_PROP_BYTE_COLOR, CD_DUPLICATE, me->mloopcol, me->totloop, name);
+ if (CustomData_get_active_layer(&me->ldata, CD_PROP_BYTE_COLOR) && do_init) {
+ CustomData_add_layer_named(&me->ldata,
+ CD_PROP_BYTE_COLOR,
+ CD_DUPLICATE,
+ CustomData_get_layer(&me->ldata, CD_PROP_BYTE_COLOR),
+ me->totloop,
+ name);
}
else {
CustomData_add_layer_named(
@@ -572,20 +577,6 @@ int ED_mesh_sculpt_color_add(
return layernum;
}
-bool ED_mesh_sculpt_color_ensure(Mesh *me, const char *name)
-{
- BLI_assert(me->edit_mesh == nullptr);
-
- if (me->totvert && !CustomData_has_layer(&me->vdata, CD_PROP_COLOR)) {
- CustomData_add_layer_named(&me->vdata, CD_PROP_COLOR, CD_DEFAULT, nullptr, me->totvert, name);
- BKE_mesh_update_customdata_pointers(me, true);
- }
-
- DEG_id_tag_update(&me->id, 0);
-
- return (me->mloopcol != nullptr);
-}
-
bool ED_mesh_sculpt_color_remove_index(Mesh *me, const int n)
{
CustomData *vdata = GET_CD_DATA(me, vdata);
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index 979673fd736..e10b72e7243 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -611,7 +611,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
&mesh->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, nullptr, mesh->totloop, "Color");
MLoopCol *transp = (MLoopCol *)CustomData_add_layer_named(
&mesh->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, nullptr, mesh->totloop, "Alpha");
- mesh->mloopcol = colors;
+ CustomData_set_layer_active(&mesh->ldata, CD_PROP_BYTE_COLOR, 0);
mesh->mat = (Material **)MEM_mallocN(sizeof(Material *) * mesh->totcol, "MaterialList");
for (const auto item : group->materials.items()) {
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp
index fa0348fbcf2..d4ce1d09fd8 100644
--- a/source/blender/io/collada/MeshImporter.cpp
+++ b/source/blender/io/collada/MeshImporter.cpp
@@ -483,7 +483,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
CustomData_add_layer_named(
&me->ldata, CD_PROP_BYTE_COLOR, CD_DEFAULT, nullptr, me->totloop, colname.c_str());
}
- me->mloopcol = (MLoopCol *)CustomData_get_layer_n(&me->ldata, CD_PROP_BYTE_COLOR, 0);
+ CustomData_set_layer_active(&mesh->ldata, CD_PROP_BYTE_COLOR, 0);
}
}
}
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 45657525527..6e83b420f0e 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -497,8 +497,6 @@ void USDMeshReader::read_colors(Mesh *mesh, const double motionSampleTime)
MLoopCol *colors = static_cast<MLoopCol *>(cd_ptr);
- mesh->mloopcol = colors;
-
MPoly *poly = mesh->mpoly;
for (int i = 0, e = mesh->totpoly; i < e; ++i, ++poly) {
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index 2eca84959b8..e00e29742be 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -221,12 +221,6 @@ typedef struct Mesh {
* \note This pointer is for convenient access to the #CD_MLOOPUV layer in #ldata.
*/
struct MLoopUV *mloopuv;
- /**
- * The active vertex corner color layer, if it exists. Also called "Vertex Color" in Blender's
- * UI, even though it is stored per face corner.
- * \note This pointer is for convenient access to the #CD_PROP_BYTE_COLOR layer in #ldata.
- */
- struct MLoopCol *mloopcol;
/**
* Runtime storage of the edit mode mesh. If it exists, it generally has the most up-to-date
@@ -341,8 +335,6 @@ typedef struct Mesh {
char _pad1[4];
- void *_pad2;
-
Mesh_Runtime runtime;
} Mesh;
More information about the Bf-blender-cvs
mailing list