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:
authorJoseph Eagar <joeedh@gmail.com>2022-04-05 21:42:55 +0300
committerJoseph Eagar <joeedh@gmail.com>2022-04-05 21:42:55 +0300
commiteae36be372a6b16ee3e76eff0485a47da4f3c230 (patch)
treed1ca2dc30951e31f1b91eed6a4edfdfb0824bf1f /source/blender/blenkernel/BKE_attribute.h
parenta3e122b9aec59fc303c2375a78183cfb8642c14f (diff)
Refactor: Unify vertex and sculpt colors into new
color attribute system. This commit removes sculpt colors from experimental status and unifies it with vertex colors. It introduces the concept of "color attributes", which are any attributes that represents colors. Color attributes can be represented with byte or floating-point numbers and can be stored in either vertices or face corners. Color attributes share a common namespace (so you can no longer have a floating-point sculpt color attribute and a byte vertex color attribute with the same name). Note: this commit does not include vertex paint mode, which is a separate patch, see: https://developer.blender.org/D14179 Differential Revision: https://developer.blender.org/D12587 Ref D12587
Diffstat (limited to 'source/blender/blenkernel/BKE_attribute.h')
-rw-r--r--source/blender/blenkernel/BKE_attribute.h65
1 files changed, 62 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h
index 452d6a4316e..f3968c0d761 100644
--- a/source/blender/blenkernel/BKE_attribute.h
+++ b/source/blender/blenkernel/BKE_attribute.h
@@ -34,10 +34,25 @@ typedef enum AttributeDomain {
ATTR_DOMAIN_NUM
} AttributeDomain;
-/* Attributes */
+typedef enum AttributeDomainMask {
+ ATTR_DOMAIN_MASK_POINT = (1 << 0),
+ ATTR_DOMAIN_MASK_EDGE = (1 << 1),
+ ATTR_DOMAIN_MASK_FACE = (1 << 2),
+ ATTR_DOMAIN_MASK_CORNER = (1 << 3),
+ ATTR_DOMAIN_MASK_CURVE = (1 << 4),
+ ATTR_DOMAIN_MASK_ALL = (1 << 5) - 1
+} AttributeDomainMask;
+
+/* All domains that support color attributes. */
+#define ATTR_DOMAIN_MASK_COLOR \
+ ((AttributeDomainMask)((ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER)))
+
+/* Attributes. */
bool BKE_id_attributes_supported(struct ID *id);
+/** Create a new attribute layer.
+ */
struct CustomDataLayer *BKE_id_attribute_new(
struct ID *id, const char *name, int type, AttributeDomain domain, struct ReportList *reports);
bool BKE_id_attribute_remove(struct ID *id,
@@ -49,7 +64,7 @@ struct CustomDataLayer *BKE_id_attribute_find(const struct ID *id,
int type,
AttributeDomain domain);
-AttributeDomain BKE_id_attribute_domain(struct ID *id, struct CustomDataLayer *layer);
+AttributeDomain BKE_id_attribute_domain(struct ID *id, const struct CustomDataLayer *layer);
int BKE_id_attribute_data_length(struct ID *id, struct CustomDataLayer *layer);
bool BKE_id_attribute_required(struct ID *id, struct CustomDataLayer *layer);
bool BKE_id_attribute_rename(struct ID *id,
@@ -57,13 +72,57 @@ bool BKE_id_attribute_rename(struct ID *id,
const char *new_name,
struct ReportList *reports);
-int BKE_id_attributes_length(struct ID *id, CustomDataMask mask);
+int BKE_id_attributes_length(const struct ID *id,
+ AttributeDomainMask domain_mask,
+ CustomDataMask mask);
struct CustomDataLayer *BKE_id_attributes_active_get(struct ID *id);
void BKE_id_attributes_active_set(struct ID *id, struct CustomDataLayer *layer);
int *BKE_id_attributes_active_index_p(struct ID *id);
CustomData *BKE_id_attributes_iterator_next_domain(struct ID *id, struct CustomDataLayer *layers);
+CustomDataLayer *BKE_id_attribute_from_index(struct ID *id,
+ int lookup_index,
+ AttributeDomainMask domain_mask,
+ CustomDataMask layer_mask);
+
+/** Layer is allowed to be nullptr; if so -1 (layer not found) will be returned. */
+int BKE_id_attribute_to_index(const struct ID *id,
+ const CustomDataLayer *layer,
+ AttributeDomainMask domain_mask,
+ CustomDataMask layer_mask);
+
+struct CustomDataLayer *BKE_id_attribute_subset_active_get(const struct ID *id,
+ int active_flag,
+ AttributeDomainMask domain_mask,
+ CustomDataMask mask);
+void BKE_id_attribute_subset_active_set(struct ID *id,
+ struct CustomDataLayer *layer,
+ int active_flag,
+ AttributeDomainMask domain_mask,
+ CustomDataMask mask);
+
+/**
+ * Sets up a temporary ID with arbitrary CustomData domains. r_id will
+ * be zero initialized with ID type id_type and any non-nullptr
+ * CustomData parameter will be copied into the appropriate struct members.
+ *
+ * \param r_id Pointer to storage sufficient for ID typecode id_type.
+ */
+void BKE_id_attribute_copy_domains_temp(short id_type,
+ const struct CustomData *vdata,
+ const struct CustomData *edata,
+ const struct CustomData *ldata,
+ const struct CustomData *pdata,
+ const struct CustomData *cdata,
+ struct ID *r_id);
+
+struct CustomDataLayer *BKE_id_attributes_active_color_get(const struct ID *id);
+void BKE_id_attributes_active_color_set(struct ID *id, struct CustomDataLayer *active_layer);
+struct CustomDataLayer *BKE_id_attributes_render_color_get(const struct ID *id);
+void BKE_id_attributes_render_color_set(struct ID *id, struct CustomDataLayer *active_layer);
+
+bool BKE_id_attribute_calc_unique_name(struct ID *id, const char *name, char *outname);
#ifdef __cplusplus
}