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:
-rw-r--r--source/blender/blenkernel/BKE_customdata.h5
-rw-r--r--source/blender/blenkernel/BKE_geometry_set.hh6
-rw-r--r--source/blender/blenkernel/BKE_mesh.h2
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc15
-rw-r--r--source/blender/blenkernel/intern/customdata.cc18
-rw-r--r--source/blender/blenkernel/intern/mesh.cc8
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.cc4
-rw-r--r--source/blender/editors/object/object_add.cc7
-rw-r--r--source/blender/editors/object/object_modifier.cc5
9 files changed, 34 insertions, 36 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 6b805a4c29d..f05dfb164cf 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -236,11 +236,6 @@ bool CustomData_free_layer_active(struct CustomData *data, int type, int totelem
void CustomData_free_layers(struct CustomData *data, int type, int totelem);
/**
- * Free all anonymous attributes.
- */
-void CustomData_free_layers_anonymous(struct CustomData *data, int totelem);
-
-/**
* Returns true if a layer with the specified type exists.
*/
bool CustomData_has_layer(const struct CustomData *data, int type);
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index 559007d1aee..dfd9fccebbd 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -148,6 +148,12 @@ class GeometryComponent {
/** Returns true when the attribute has been deleted. */
bool attribute_try_delete(const blender::bke::AttributeIDRef &attribute_id);
+ /**
+ * Remove any anonymous attributes on the geometry (they generally shouldn't exist on original
+ * geometry).
+ */
+ void attributes_remove_anonymous();
+
/** Returns true when the attribute has been created. */
bool attribute_try_create(const blender::bke::AttributeIDRef &attribute_id,
AttributeDomain domain,
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 602fd47bfd1..bd9bacb52c1 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -318,8 +318,6 @@ void BKE_mesh_vert_coords_apply_with_mat4(struct Mesh *mesh,
const float mat[4][4]);
void BKE_mesh_vert_coords_apply(struct Mesh *mesh, const float (*vert_coords)[3]);
-void BKE_mesh_anonymous_attributes_remove(struct Mesh *mesh);
-
/* *** mesh_tessellate.c *** */
/**
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 98db5013a00..d33b64c493b 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -926,6 +926,21 @@ bool GeometryComponent::attribute_try_delete(const AttributeIDRef &attribute_id)
return success;
}
+void GeometryComponent::attributes_remove_anonymous()
+{
+ using namespace blender;
+ Vector<const AnonymousAttributeID *> anonymous_ids;
+ for (const AttributeIDRef &id : this->attribute_ids()) {
+ if (id.is_anonymous()) {
+ anonymous_ids.append(&id.anonymous_id());
+ }
+ }
+
+ while (!anonymous_ids.is_empty()) {
+ this->attribute_try_delete(anonymous_ids.pop_last());
+ }
+}
+
bool GeometryComponent::attribute_try_create(const AttributeIDRef &attribute_id,
const AttributeDomain domain,
const CustomDataType data_type,
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 22db90a06b0..a5138856d53 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -2883,24 +2883,6 @@ void CustomData_free_layers(CustomData *data, int type, int totelem)
}
}
-void CustomData_free_layers_anonymous(struct CustomData *data, int totelem)
-{
- while (true) {
- bool found_anonymous_layer = false;
- for (int i = 0; i < data->totlayer; i++) {
- const CustomDataLayer *layer = &data->layers[i];
- if (layer->anonymous_id != nullptr) {
- CustomData_free_layer(data, layer->type, totelem, i);
- found_anonymous_layer = true;
- break;
- }
- }
- if (!found_anonymous_layer) {
- break;
- }
- }
-}
-
bool CustomData_has_layer(const CustomData *data, int type)
{
return (CustomData_get_layer_index(data, type) != -1);
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index c13a2bc794a..628f59ae449 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -1930,14 +1930,6 @@ void BKE_mesh_vert_coords_apply_with_mat4(Mesh *mesh,
BKE_mesh_normals_tag_dirty(mesh);
}
-void BKE_mesh_anonymous_attributes_remove(Mesh *mesh)
-{
- CustomData_free_layers_anonymous(&mesh->vdata, mesh->totvert);
- CustomData_free_layers_anonymous(&mesh->edata, mesh->totedge);
- CustomData_free_layers_anonymous(&mesh->pdata, mesh->totpoly);
- CustomData_free_layers_anonymous(&mesh->ldata, mesh->totloop);
-}
-
void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spacearr)
{
float(*r_loopnors)[3];
diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc
index a289d208684..0038a2aa806 100644
--- a/source/blender/blenkernel/intern/mesh_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_convert.cc
@@ -1219,7 +1219,9 @@ Mesh *BKE_mesh_new_from_object_to_bmain(Main *bmain,
BKE_mesh_nomain_to_mesh(mesh, mesh_in_bmain, nullptr, &CD_MASK_MESH, true);
/* Anonymous attributes shouldn't exist on original data. */
- BKE_mesh_anonymous_attributes_remove(mesh_in_bmain);
+ MeshComponent component;
+ component.replace(mesh_in_bmain, GeometryOwnershipType::Editable);
+ component.attributes_remove_anonymous();
/* User-count is required because so far mesh was in a limbo, where library management does
* not perform any user management (i.e. copy of a mesh will not increase users of materials). */
diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc
index 508d452bfe4..5b857d2dba1 100644
--- a/source/blender/editors/object/object_add.cc
+++ b/source/blender/editors/object/object_add.cc
@@ -52,6 +52,7 @@
#include "BKE_duplilist.h"
#include "BKE_effect.h"
#include "BKE_geometry_set.h"
+#include "BKE_geometry_set.hh"
#include "BKE_gpencil_curve.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
@@ -3120,8 +3121,12 @@ static int object_convert_exec(bContext *C, wmOperator *op)
BKE_object_material_from_eval_data(bmain, newob, &me_eval->id);
Mesh *new_mesh = (Mesh *)newob->data;
BKE_mesh_nomain_to_mesh(me_eval, new_mesh, newob, &CD_MASK_MESH, true);
+
/* Anonymous attributes shouldn't be available on the applied geometry. */
- BKE_mesh_anonymous_attributes_remove(new_mesh);
+ MeshComponent component;
+ component.replace(new_mesh, GeometryOwnershipType::Editable);
+ component.attributes_remove_anonymous();
+
BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */
}
else if (ob->type == OB_FONT) {
diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc
index 8b2dbd4a865..8dec2a5eb1c 100644
--- a/source/blender/editors/object/object_modifier.cc
+++ b/source/blender/editors/object/object_modifier.cc
@@ -41,6 +41,7 @@
#include "BKE_displist.h"
#include "BKE_editmesh.h"
#include "BKE_effect.h"
+#include "BKE_geometry_set.hh"
#include "BKE_global.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_key.h"
@@ -750,7 +751,9 @@ static bool modifier_apply_obdata(
BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, &CD_MASK_MESH, true);
/* Anonymous attributes shouldn't be available on the applied geometry. */
- BKE_mesh_anonymous_attributes_remove(me);
+ MeshComponent component;
+ component.replace(me, GeometryOwnershipType::Editable);
+ component.attributes_remove_anonymous();
if (md_eval->type == eModifierType_Multires) {
multires_customdata_delete(me);