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:
authorBrecht Van Lommel <brecht@blender.org>2020-08-04 13:52:04 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-09-09 18:01:17 +0300
commita1397a3cc69382a64ab97bb71e4769fc0add0791 (patch)
tree3ed860ff99a6a2469e6a11bc5de9304284d502d8 /source/blender/blenkernel/intern/attribute.c
parent565510bd7fd87ae146cabafb27f1dfd550450f58 (diff)
Geometry: use generic attributes for Hair and Point Clouds
Instead of custom data layer with special types, using general Vector and Float attributes. Ref T76659 Differential Revision: https://developer.blender.org/D8635
Diffstat (limited to 'source/blender/blenkernel/intern/attribute.c')
-rw-r--r--source/blender/blenkernel/intern/attribute.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c
index 49c255fc065..8a67e4581f0 100644
--- a/source/blender/blenkernel/intern/attribute.c
+++ b/source/blender/blenkernel/intern/attribute.c
@@ -39,6 +39,8 @@
#include "BKE_attribute.h"
#include "BKE_customdata.h"
+#include "BKE_hair.h"
+#include "BKE_pointcloud.h"
#include "BKE_report.h"
#include "RNA_access.h"
@@ -104,6 +106,11 @@ bool BKE_id_attribute_rename(ID *id,
const char *new_name,
ReportList *reports)
{
+ if (BKE_id_attribute_required(id, layer)) {
+ BLI_assert(!"Required attribute name is not editable");
+ return false;
+ }
+
CustomData *customdata = attribute_customdata_find(id, layer);
if (customdata == NULL) {
BKE_report(reports, RPT_ERROR, "Attribute is not part of this geometry");
@@ -144,6 +151,11 @@ void BKE_id_attribute_remove(ID *id, CustomDataLayer *layer, ReportList *reports
return;
}
+ if (BKE_id_attribute_required(id, layer)) {
+ BKE_report(reports, RPT_ERROR, "Attribute is required and can't be removed");
+ return;
+ }
+
const int length = BKE_id_attribute_data_length(id, layer);
CustomData_free_layer(customdata, layer->type, length, index);
}
@@ -197,6 +209,20 @@ int BKE_id_attribute_data_length(ID *id, CustomDataLayer *layer)
return 0;
}
+bool BKE_id_attribute_required(ID *id, CustomDataLayer *layer)
+{
+ switch (GS(id->name)) {
+ case ID_PT: {
+ return BKE_pointcloud_customdata_required((PointCloud *)id, layer);
+ }
+ case ID_HA: {
+ return BKE_hair_customdata_required((Hair *)id, layer);
+ }
+ default:
+ return false;
+ }
+}
+
CustomDataLayer *BKE_id_attributes_active_get(ID *id)
{
int active_index = *BKE_id_attributes_active_index_p(id);