2022-02-10 23:07:11 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
2023-02-22 10:16:42 +01:00
|
|
|
* Copyright 2006 Blender Foundation */
|
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 00:00:20 +02:00
|
|
|
/** #Attribute.domain */
|
2022-06-01 06:38:06 +02: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 18:55:54 +01: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 18:55:54 +01: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 06:38:06 +02: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 06:38:06 +02:00
|
|
|
typedef enum eAttrDomainMask {
|
2022-04-05 20:42:55 +02: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 06:38:06 +02:00
|
|
|
} eAttrDomainMask;
|
2023-02-20 11:51:16 +01:00
|
|
|
ENUM_OPERATORS(eAttrDomainMask, ATTR_DOMAIN_MASK_ALL);
|
2022-04-05 20:42:55 +02:00
|
|
|
|
2022-06-01 06:38:06 +02:00
|
|
|
#define ATTR_DOMAIN_AS_MASK(domain) ((eAttrDomainMask)((1 << (int)(domain))))
|
2022-06-01 00:46:09 +02:00
|
|
|
|
2022-04-05 20:42:55 +02:00
|
|
|
/* All domains that support color attributes. */
|
|
|
|
#define ATTR_DOMAIN_MASK_COLOR \
|
2022-06-01 06:38:06 +02:00
|
|
|
((eAttrDomainMask)((ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER)))
|
2022-04-05 20:42:55 +02: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 06:48:00 +02:00
|
|
|
/**
|
|
|
|
* Create a new attribute layer.
|
2022-04-05 20:42:55 +02:00
|
|
|
*/
|
2023-03-29 17:10:49 +02:00
|
|
|
struct CustomDataLayer *BKE_id_attribute_new(struct ID *id,
|
|
|
|
const char *name,
|
|
|
|
eCustomDataType 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 21:10:32 +02: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 21:10:32 +02: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,
|
2023-03-29 17:10:49 +02:00
|
|
|
eCustomDataType type,
|
2022-06-01 07:06:21 +02:00
|
|
|
eAttrDomain domain);
|
2022-06-01 00:46:09 +02:00
|
|
|
|
2022-06-14 17:25:53 +02:00
|
|
|
struct CustomDataLayer *BKE_id_attribute_search(struct ID *id,
|
2022-06-01 00:46:09 +02:00
|
|
|
const char *name,
|
2022-06-01 07:06:21 +02:00
|
|
|
eCustomDataMask type,
|
|
|
|
eAttrDomainMask domain_mask);
|
2021-09-09 17:22:20 +02:00
|
|
|
|
2022-06-01 06:38:06 +02: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 20:42:55 +02:00
|
|
|
int BKE_id_attributes_length(const struct ID *id,
|
2022-06-01 06:38:06 +02:00
|
|
|
eAttrDomainMask domain_mask,
|
|
|
|
eCustomDataMask mask);
|
2020-07-03 15:30:04 +02:00
|
|
|
|
|
|
|
struct CustomDataLayer *BKE_id_attributes_active_get(struct ID *id);
|
2022-11-10 21:38:49 +01:00
|
|
|
void BKE_id_attributes_active_set(struct ID *id, const char *name);
|
2020-07-03 15:30:04 +02:00
|
|
|
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 20:42:55 +02:00
|
|
|
CustomDataLayer *BKE_id_attribute_from_index(struct ID *id,
|
|
|
|
int lookup_index,
|
2022-06-01 06:38:06 +02:00
|
|
|
eAttrDomainMask domain_mask,
|
|
|
|
eCustomDataMask layer_mask);
|
2022-04-05 20:42:55 +02: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 06:38:06 +02:00
|
|
|
eAttrDomainMask domain_mask,
|
|
|
|
eCustomDataMask layer_mask);
|
2022-04-05 20:42:55 +02:00
|
|
|
|
2022-12-15 21:18:57 +01:00
|
|
|
const char *BKE_id_attributes_active_color_name(const struct ID *id);
|
|
|
|
const char *BKE_id_attributes_default_color_name(const struct ID *id);
|
|
|
|
void BKE_id_attributes_active_color_set(struct ID *id, const char *name);
|
|
|
|
void BKE_id_attributes_default_color_set(struct ID *id, const char *name);
|
2023-03-14 16:31:20 +01:00
|
|
|
|
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 20:42:55 +02:00
|
|
|
|
|
|
|
bool BKE_id_attribute_calc_unique_name(struct ID *id, const char *name, char *outname);
|
2020-07-03 15:30:04 +02:00
|
|
|
|
Mesh: Move UV layers to generic attributes
Currently the `MLoopUV` struct stores UV coordinates and flags related
to editing UV maps in the UV editor. This patch changes the coordinates
to use the generic 2D vector type, and moves the flags into three
separate boolean attributes. This follows the design in T95965, with
the ultimate intention of simplifying code and improving performance.
Importantly, the change allows exporters and renderers to use UVs
"touched" by geometry nodes, which only creates generic attributes.
It also allows geometry nodes to create "proper" UV maps from scratch,
though only with the Store Named Attribute node for now.
The new design considers any 2D vector attribute on the corner domain
to be a UV map. In the future, they might be distinguished from regular
2D vectors with attribute metadata, which may be helpful because they
are often interpolated differently.
Most of the code changes deal with passing around UV BMesh custom data
offsets and tracking the boolean "sublayers". The boolean layers are
use the following prefixes for attribute names: vert selection: `.vs.`,
edge selection: `.es.`, pinning: `.pn.`. Currently these are short to
avoid using up the maximum length of attribute names. To accommodate
for these 4 extra characters, the name length limit is enlarged to 68
bytes, while the maximum user settable name length is still 64 bytes.
Unfortunately Python/RNA API access to the UV flag data becomes slower.
Accessing the boolean layers directly is be better for performance in
general.
Like the other mesh SoA refactors, backward and forward compatibility
aren't affected, and won't be changed until 4.0. We pay for that by
making mesh reading and writing more expensive with conversions.
Resolves T85962
Differential Revision: https://developer.blender.org/D14365
2023-01-10 06:47:04 +01:00
|
|
|
const char *BKE_uv_map_vert_select_name_get(const char *uv_map_name, char *buffer);
|
|
|
|
const char *BKE_uv_map_edge_select_name_get(const char *uv_map_name, char *buffer);
|
|
|
|
const char *BKE_uv_map_pin_name_get(const char *uv_map_name, char *buffer);
|
|
|
|
|
2020-07-03 15:30:04 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|