2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2006 Blender Foundation. All rights reserved. */
|
2020-07-03 15:30:04 +02:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
|
|
|
|
* \brief Generic geometry attributes built on CustomData.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_customdata.h"
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
struct CustomData;
|
|
|
|
|
struct CustomDataLayer;
|
|
|
|
|
struct ID;
|
|
|
|
|
struct ReportList;
|
|
|
|
|
|
2022-04-05 08:00:20 +10:00
|
|
|
/** #Attribute.domain */
|
2022-06-01 14:38:06 +10:00
|
|
|
typedef enum eAttrDomain {
|
2021-11-19 17:53:48 +01:00
|
|
|
ATTR_DOMAIN_AUTO = -1, /* Use for nodes to choose automatically based on other data. */
|
Curves: Rename "Hair" types, variables, and functions to "Curves"
Based on discussions from T95355 and T94193, the plan is to use
the name "Curves" to describe the data-block container for multiple
curves. Eventually this will replace the existing "Curve" data-block.
However, it will be a while before the curve data-block can be replaced
so in order to distinguish the two curve types in the UI, "Hair Curves"
will be used, but eventually changed back to "Curves".
This patch renames "hair-related" files, functions, types, and variable
names to this convention. A deep rename is preferred to keep code
consistent and to avoid any "hair" terminology from leaking, since the
new data-block is meant for all curve types, not just hair use cases.
The downside of this naming is that the difference between "Curve"
and "Curves" has become important. That was considered during
design discussons and deemed acceptable, especially given the
non-permanent nature of the somewhat common conflict.
Some points of interest:
- All DNA compatibility is lost, just like rBf59767ff9729.
- I renamed `ID_HA` to `ID_CV` so there is no complete mismatch.
- `hair_curves` is used where necessary to distinguish from the
existing "curves" plural.
- I didn't rename any of the cycles/rendering code function names,
since that is also used by the old hair particle system.
Differential Revision: https://developer.blender.org/D14007
2022-02-07 11:55:54 -06:00
|
|
|
ATTR_DOMAIN_POINT = 0, /* Mesh, Curve or Point Cloud Point */
|
2021-11-19 17:53:48 +01:00
|
|
|
ATTR_DOMAIN_EDGE = 1, /* Mesh Edge */
|
|
|
|
|
ATTR_DOMAIN_FACE = 2, /* Mesh Face */
|
|
|
|
|
ATTR_DOMAIN_CORNER = 3, /* Mesh Corner */
|
Curves: Rename "Hair" types, variables, and functions to "Curves"
Based on discussions from T95355 and T94193, the plan is to use
the name "Curves" to describe the data-block container for multiple
curves. Eventually this will replace the existing "Curve" data-block.
However, it will be a while before the curve data-block can be replaced
so in order to distinguish the two curve types in the UI, "Hair Curves"
will be used, but eventually changed back to "Curves".
This patch renames "hair-related" files, functions, types, and variable
names to this convention. A deep rename is preferred to keep code
consistent and to avoid any "hair" terminology from leaking, since the
new data-block is meant for all curve types, not just hair use cases.
The downside of this naming is that the difference between "Curve"
and "Curves" has become important. That was considered during
design discussons and deemed acceptable, especially given the
non-permanent nature of the somewhat common conflict.
Some points of interest:
- All DNA compatibility is lost, just like rBf59767ff9729.
- I renamed `ID_HA` to `ID_CV` so there is no complete mismatch.
- `hair_curves` is used where necessary to distinguish from the
existing "curves" plural.
- I didn't rename any of the cycles/rendering code function names,
since that is also used by the old hair particle system.
Differential Revision: https://developer.blender.org/D14007
2022-02-07 11:55:54 -06:00
|
|
|
ATTR_DOMAIN_CURVE = 4, /* A single curve in a larger curve data-block */
|
2021-11-19 17:53:48 +01:00
|
|
|
ATTR_DOMAIN_INSTANCE = 5, /* Instance */
|
2022-06-01 14:38:06 +10:00
|
|
|
} eAttrDomain;
|
2022-05-30 17:30:37 +02:00
|
|
|
#define ATTR_DOMAIN_NUM 6
|
2020-07-03 15:30:04 +02:00
|
|
|
|
2022-06-01 14:38:06 +10:00
|
|
|
typedef enum eAttrDomainMask {
|
2022-04-05 11:42:55 -07:00
|
|
|
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
|
2022-06-01 14:38:06 +10:00
|
|
|
} eAttrDomainMask;
|
2022-04-05 11:42:55 -07:00
|
|
|
|
2022-06-01 14:38:06 +10:00
|
|
|
#define ATTR_DOMAIN_AS_MASK(domain) ((eAttrDomainMask)((1 << (int)(domain))))
|
2022-05-31 15:46:09 -07:00
|
|
|
|
2022-04-05 11:42:55 -07:00
|
|
|
/* All domains that support color attributes. */
|
|
|
|
|
#define ATTR_DOMAIN_MASK_COLOR \
|
2022-06-01 14:38:06 +10:00
|
|
|
((eAttrDomainMask)((ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER)))
|
2022-04-05 11:42:55 -07:00
|
|
|
|
|
|
|
|
/* Attributes. */
|
2020-07-03 15:30:04 +02:00
|
|
|
|
2022-06-07 18:55:56 +02:00
|
|
|
bool BKE_id_attributes_supported(const struct ID *id);
|
2022-05-31 13:20:16 +02:00
|
|
|
bool BKE_attribute_allow_procedural_access(const char *attribute_name);
|
2020-08-19 18:12:52 +02:00
|
|
|
|
2022-04-07 14:48:00 +10:00
|
|
|
/**
|
|
|
|
|
* Create a new attribute layer.
|
2022-04-05 11:42:55 -07:00
|
|
|
*/
|
2022-01-07 11:38:08 +11:00
|
|
|
struct CustomDataLayer *BKE_id_attribute_new(
|
2022-06-01 14:38:06 +10:00
|
|
|
struct ID *id, const char *name, int type, eAttrDomain domain, struct ReportList *reports);
|
2022-06-08 10:42:21 +02:00
|
|
|
bool BKE_id_attribute_remove(struct ID *id, const char *name, struct ReportList *reports);
|
2020-07-03 15:30:04 +02:00
|
|
|
|
2022-06-08 12:10:32 -07:00
|
|
|
/**
|
|
|
|
|
* Creates a duplicate attribute layer.
|
|
|
|
|
*/
|
|
|
|
|
struct CustomDataLayer *BKE_id_attribute_duplicate(struct ID *id,
|
2022-06-14 16:25:24 +02:00
|
|
|
const char *name,
|
2022-06-08 12:10:32 -07:00
|
|
|
struct ReportList *reports);
|
|
|
|
|
|
2021-09-09 17:22:20 +02:00
|
|
|
struct CustomDataLayer *BKE_id_attribute_find(const struct ID *id,
|
|
|
|
|
const char *name,
|
2022-06-01 15:06:21 +10:00
|
|
|
int type,
|
|
|
|
|
eAttrDomain domain);
|
2022-05-31 15:46:09 -07:00
|
|
|
|
2022-06-14 17:25:53 +02:00
|
|
|
struct CustomDataLayer *BKE_id_attribute_search(struct ID *id,
|
2022-05-31 15:46:09 -07:00
|
|
|
const char *name,
|
2022-06-01 15:06:21 +10:00
|
|
|
eCustomDataMask type,
|
|
|
|
|
eAttrDomainMask domain_mask);
|
2021-09-09 17:22:20 +02:00
|
|
|
|
2022-06-01 14:38:06 +10:00
|
|
|
eAttrDomain BKE_id_attribute_domain(const struct ID *id, const struct CustomDataLayer *layer);
|
2020-07-03 15:30:04 +02:00
|
|
|
int BKE_id_attribute_data_length(struct ID *id, struct CustomDataLayer *layer);
|
2022-06-08 10:42:21 +02:00
|
|
|
bool BKE_id_attribute_required(const struct ID *id, const char *name);
|
2020-07-03 15:30:04 +02:00
|
|
|
bool BKE_id_attribute_rename(struct ID *id,
|
2022-06-08 10:42:21 +02:00
|
|
|
const char *old_name,
|
2020-07-03 15:30:04 +02:00
|
|
|
const char *new_name,
|
|
|
|
|
struct ReportList *reports);
|
|
|
|
|
|
2022-04-05 11:42:55 -07:00
|
|
|
int BKE_id_attributes_length(const struct ID *id,
|
2022-06-01 14:38:06 +10:00
|
|
|
eAttrDomainMask domain_mask,
|
|
|
|
|
eCustomDataMask mask);
|
2020-07-03 15:30:04 +02:00
|
|
|
|
|
|
|
|
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);
|
2022-04-05 11:42:55 -07:00
|
|
|
CustomDataLayer *BKE_id_attribute_from_index(struct ID *id,
|
|
|
|
|
int lookup_index,
|
2022-06-01 14:38:06 +10:00
|
|
|
eAttrDomainMask domain_mask,
|
|
|
|
|
eCustomDataMask layer_mask);
|
2022-04-05 11:42:55 -07:00
|
|
|
|
|
|
|
|
/** 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,
|
2022-06-01 14:38:06 +10:00
|
|
|
eAttrDomainMask domain_mask,
|
|
|
|
|
eCustomDataMask layer_mask);
|
2022-04-05 11:42:55 -07:00
|
|
|
|
|
|
|
|
struct CustomDataLayer *BKE_id_attribute_subset_active_get(const struct ID *id,
|
|
|
|
|
int active_flag,
|
2022-06-01 14:38:06 +10:00
|
|
|
eAttrDomainMask domain_mask,
|
|
|
|
|
eCustomDataMask mask);
|
2022-04-05 11:42:55 -07:00
|
|
|
void BKE_id_attribute_subset_active_set(struct ID *id,
|
|
|
|
|
struct CustomDataLayer *layer,
|
|
|
|
|
int active_flag,
|
2022-06-01 14:38:06 +10:00
|
|
|
eAttrDomainMask domain_mask,
|
|
|
|
|
eCustomDataMask mask);
|
2022-04-05 11:42:55 -07:00
|
|
|
|
|
|
|
|
/**
|
2022-04-07 14:48:00 +10:00
|
|
|
* Sets up a temporary ID with arbitrary CustomData domains. `r_id` will
|
2022-04-05 11:42:55 -07:00
|
|
|
* be zero initialized with ID type id_type and any non-nullptr
|
|
|
|
|
* CustomData parameter will be copied into the appropriate struct members.
|
|
|
|
|
*
|
2022-04-07 14:48:00 +10:00
|
|
|
* \param r_id: Pointer to storage sufficient for ID type-code id_type.
|
2022-04-05 11:42:55 -07:00
|
|
|
*/
|
|
|
|
|
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);
|
2022-04-08 16:37:35 +02:00
|
|
|
struct CustomDataLayer *BKE_id_attributes_color_find(const struct ID *id, const char *name);
|
2022-04-05 11:42:55 -07:00
|
|
|
|
|
|
|
|
bool BKE_id_attribute_calc_unique_name(struct ID *id, const char *name, char *outname);
|
2020-07-03 15:30:04 +02:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|