GPv3: Rename layer domain to just "Layer"
We had a short discussion on this change. "Grease Pencil Layer" is just a bit too long, especially in the UI. Even though "Layer" might be ambiguous, it shouldn't be in the context of geometry nodes. There are currently no other "Layers" and if there were, using the same domain name could be fine (just like we reuse the point domain for e.g. vertices in meshes and control points in curves). This also renames the internal enum to `ATTR_DOMAIN_LAYER` Pull Request: https://projects.blender.org/blender/blender/pulls/113589
This commit is contained in:
@@ -31,7 +31,7 @@ typedef enum eAttrDomain {
|
||||
ATTR_DOMAIN_CORNER = 3, /* Mesh Corner */
|
||||
ATTR_DOMAIN_CURVE = 4, /* A single curve in a larger curve data-block */
|
||||
ATTR_DOMAIN_INSTANCE = 5, /* Instance */
|
||||
ATTR_DOMAIN_GREASE_PENCIL_LAYER = 6, /* A layer in a grease pencil data-block */
|
||||
ATTR_DOMAIN_LAYER = 6, /* A layer in a grease pencil data-block */
|
||||
} eAttrDomain;
|
||||
#define ATTR_DOMAIN_NUM 7
|
||||
|
||||
|
||||
@@ -175,8 +175,7 @@ class GeometryFieldContext : public fn::FieldContext {
|
||||
int grease_pencil_layer_index() const
|
||||
{
|
||||
BLI_assert(this->type_ == GeometryComponent::Type::GreasePencil);
|
||||
BLI_assert(ELEM(
|
||||
this->domain_, ATTR_DOMAIN_GREASE_PENCIL_LAYER, ATTR_DOMAIN_CURVE, ATTR_DOMAIN_POINT));
|
||||
BLI_assert(ELEM(this->domain_, ATTR_DOMAIN_LAYER, ATTR_DOMAIN_CURVE, ATTR_DOMAIN_POINT));
|
||||
return grease_pencil_layer_index_;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,8 +93,8 @@ static void get_domains(const ID *id, DomainInfo info[ATTR_DOMAIN_NUM])
|
||||
}
|
||||
case ID_GP: {
|
||||
GreasePencil *grease_pencil = (GreasePencil *)id;
|
||||
info[ATTR_DOMAIN_GREASE_PENCIL_LAYER].customdata = &grease_pencil->layers_data;
|
||||
info[ATTR_DOMAIN_GREASE_PENCIL_LAYER].length = grease_pencil->layers().size();
|
||||
info[ATTR_DOMAIN_LAYER].customdata = &grease_pencil->layers_data;
|
||||
info[ATTR_DOMAIN_LAYER].length = grease_pencil->layers().size();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -147,7 +147,7 @@ static int attribute_domain_priority(const eAttrDomain domain)
|
||||
switch (domain) {
|
||||
case ATTR_DOMAIN_INSTANCE:
|
||||
return 0;
|
||||
case ATTR_DOMAIN_GREASE_PENCIL_LAYER:
|
||||
case ATTR_DOMAIN_LAYER:
|
||||
return 1;
|
||||
case ATTR_DOMAIN_CURVE:
|
||||
return 2;
|
||||
|
||||
@@ -115,8 +115,7 @@ static ComponentAttributeProviders create_attribute_providers_for_grease_pencil(
|
||||
return grease_pencil.layers().size();
|
||||
}};
|
||||
|
||||
static CustomDataAttributeProvider layer_custom_data(ATTR_DOMAIN_GREASE_PENCIL_LAYER,
|
||||
layers_access);
|
||||
static CustomDataAttributeProvider layer_custom_data(ATTR_DOMAIN_LAYER, layers_access);
|
||||
|
||||
return ComponentAttributeProviders({}, {&layer_custom_data});
|
||||
}
|
||||
@@ -144,14 +143,14 @@ static AttributeAccessorFunctions get_grease_pencil_accessor_functions()
|
||||
}
|
||||
const GreasePencil &grease_pencil = *static_cast<const GreasePencil *>(owner);
|
||||
switch (domain) {
|
||||
case ATTR_DOMAIN_GREASE_PENCIL_LAYER:
|
||||
case ATTR_DOMAIN_LAYER:
|
||||
return int(grease_pencil.layers().size());
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
fn.domain_supported = [](const void * /*owner*/, const eAttrDomain domain) {
|
||||
return domain == ATTR_DOMAIN_GREASE_PENCIL_LAYER;
|
||||
return domain == ATTR_DOMAIN_LAYER;
|
||||
};
|
||||
fn.adapt_domain = [](const void *owner,
|
||||
const GVArray &varray,
|
||||
|
||||
@@ -109,7 +109,7 @@ GeometryFieldContext::GeometryFieldContext(const GeometryComponent &component,
|
||||
static_cast<const GreasePencilComponent &>(component);
|
||||
geometry_ = grease_pencil_component.get();
|
||||
/* Need to use another constructor for other domains. */
|
||||
BLI_assert(domain == ATTR_DOMAIN_GREASE_PENCIL_LAYER);
|
||||
BLI_assert(domain == ATTR_DOMAIN_LAYER);
|
||||
break;
|
||||
}
|
||||
case GeometryComponent::Type::Instance: {
|
||||
@@ -165,7 +165,7 @@ std::optional<AttributeAccessor> GeometryFieldContext::attributes() const
|
||||
return pointcloud->attributes();
|
||||
}
|
||||
if (const GreasePencil *grease_pencil = this->grease_pencil()) {
|
||||
if (domain_ == ATTR_DOMAIN_GREASE_PENCIL_LAYER) {
|
||||
if (domain_ == ATTR_DOMAIN_LAYER) {
|
||||
return grease_pencil->attributes();
|
||||
}
|
||||
else if (const greasepencil::Drawing *drawing =
|
||||
@@ -365,7 +365,7 @@ GVArray AttributeFieldInput::get_varray_for_context(const GeometryFieldContext &
|
||||
const eAttrDomain domain = context.domain();
|
||||
if (const GreasePencil *grease_pencil = context.grease_pencil()) {
|
||||
const AttributeAccessor layer_attributes = grease_pencil->attributes();
|
||||
if (domain == ATTR_DOMAIN_GREASE_PENCIL_LAYER) {
|
||||
if (domain == ATTR_DOMAIN_LAYER) {
|
||||
return *layer_attributes.lookup(name_, data_type);
|
||||
}
|
||||
else if (ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) {
|
||||
@@ -742,7 +742,7 @@ std::optional<eAttrDomain> try_detect_field_domain(const GeometryComponent &comp
|
||||
return ATTR_DOMAIN_POINT;
|
||||
}
|
||||
if (component_type == GeometryComponent::Type::GreasePencil) {
|
||||
return ATTR_DOMAIN_GREASE_PENCIL_LAYER;
|
||||
return ATTR_DOMAIN_LAYER;
|
||||
}
|
||||
if (component_type == GeometryComponent::Type::Instance) {
|
||||
return ATTR_DOMAIN_INSTANCE;
|
||||
|
||||
@@ -102,7 +102,7 @@ class GeometryDataSetTreeView : public ui::AbstractTreeView {
|
||||
ICON_OUTLINER_DATA_GREASEPENCIL);
|
||||
grease_pencil.add_tree_item<GeometryDataSetTreeViewItem>(
|
||||
bke::GeometryComponent::Type::GreasePencil,
|
||||
ATTR_DOMAIN_GREASE_PENCIL_LAYER,
|
||||
ATTR_DOMAIN_LAYER,
|
||||
IFACE_("Layer"),
|
||||
ICON_OUTLINER_DATA_GP_LAYER);
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ typedef struct GreasePencil {
|
||||
GreasePencilLayerTreeGroup *root_group_ptr;
|
||||
|
||||
/**
|
||||
* All attributes stored on the grease pencil layers (#ATTR_DOMAIN_GREASE_PENCIL_LAYER).
|
||||
* All attributes stored on the grease pencil layers (#ATTR_DOMAIN_LAYER).
|
||||
*/
|
||||
CustomData layers_data;
|
||||
/**
|
||||
|
||||
@@ -88,11 +88,7 @@ const EnumPropertyItem rna_enum_attribute_domain_items[] = {
|
||||
// {ATTR_DOMAIN_GRIDS, "GRIDS", 0, "Grids", "Attribute on mesh multires grids"},
|
||||
{ATTR_DOMAIN_CURVE, "CURVE", 0, "Spline", "Attribute on spline"},
|
||||
{ATTR_DOMAIN_INSTANCE, "INSTANCE", 0, "Instance", "Attribute on instance"},
|
||||
{ATTR_DOMAIN_GREASE_PENCIL_LAYER,
|
||||
"GREASE_PENCIL_LAYER",
|
||||
0,
|
||||
"Grease Pencil Layer",
|
||||
"Attribute on grease pencil layer"},
|
||||
{ATTR_DOMAIN_LAYER, "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
@@ -251,9 +247,7 @@ const EnumPropertyItem *rna_enum_attribute_domain_itemf(ID *id,
|
||||
if (!include_instances && domain_item->value == ATTR_DOMAIN_INSTANCE) {
|
||||
continue;
|
||||
}
|
||||
if (!U.experimental.use_grease_pencil_version3 &&
|
||||
domain_item->value == ATTR_DOMAIN_GREASE_PENCIL_LAYER)
|
||||
{
|
||||
if (!U.experimental.use_grease_pencil_version3 && domain_item->value == ATTR_DOMAIN_LAYER) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -395,8 +395,7 @@ static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_attribute_domain_item
|
||||
for (const EnumPropertyItem *item = rna_enum_attribute_domain_items; item->identifier != nullptr;
|
||||
item++)
|
||||
{
|
||||
if (!U.experimental.use_grease_pencil_version3 &&
|
||||
item->value == ATTR_DOMAIN_GREASE_PENCIL_LAYER) {
|
||||
if (!U.experimental.use_grease_pencil_version3 && item->value == ATTR_DOMAIN_LAYER) {
|
||||
continue;
|
||||
}
|
||||
RNA_enum_item_add(&item_array, &items_len, item);
|
||||
|
||||
@@ -1886,8 +1886,7 @@ static const EnumPropertyItem *rna_GeometryNodeAttributeDomain_attribute_domain_
|
||||
for (const EnumPropertyItem *item = rna_enum_attribute_domain_items; item->identifier != nullptr;
|
||||
item++)
|
||||
{
|
||||
if (!U.experimental.use_grease_pencil_version3 &&
|
||||
item->value == ATTR_DOMAIN_GREASE_PENCIL_LAYER) {
|
||||
if (!U.experimental.use_grease_pencil_version3 && item->value == ATTR_DOMAIN_LAYER) {
|
||||
continue;
|
||||
}
|
||||
RNA_enum_item_add(&item_array, &items_len, item);
|
||||
|
||||
@@ -3322,8 +3322,7 @@ const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext * /
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!U.experimental.use_grease_pencil_version3 &&
|
||||
item->value == ATTR_DOMAIN_GREASE_PENCIL_LAYER) {
|
||||
if (!U.experimental.use_grease_pencil_version3 && item->value == ATTR_DOMAIN_LAYER) {
|
||||
continue;
|
||||
}
|
||||
if (item->value == ATTR_DOMAIN_POINT &&
|
||||
|
||||
@@ -99,12 +99,11 @@ const EnumPropertyItem *domain_experimental_grease_pencil_version3_fn(bContext *
|
||||
bool *r_free)
|
||||
{
|
||||
*r_free = true;
|
||||
return enum_items_filter(rna_enum_attribute_domain_items,
|
||||
[](const EnumPropertyItem &item) -> bool {
|
||||
return (item.value == ATTR_DOMAIN_GREASE_PENCIL_LAYER) ?
|
||||
U.experimental.use_grease_pencil_version3 :
|
||||
true;
|
||||
});
|
||||
return enum_items_filter(
|
||||
rna_enum_attribute_domain_items, [](const EnumPropertyItem &item) -> bool {
|
||||
return (item.value == ATTR_DOMAIN_LAYER) ? U.experimental.use_grease_pencil_version3 :
|
||||
true;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace enums
|
||||
|
||||
@@ -117,13 +117,11 @@ class EvaluateOnDomainInput final : public bke::GeometryFieldInput {
|
||||
const CPPType &cpp_type = src_field_.cpp_type();
|
||||
|
||||
if (context.type() == GeometryComponent::Type::GreasePencil &&
|
||||
(src_domain_ == ATTR_DOMAIN_GREASE_PENCIL_LAYER) !=
|
||||
(dst_domain == ATTR_DOMAIN_GREASE_PENCIL_LAYER))
|
||||
(src_domain_ == ATTR_DOMAIN_LAYER) != (dst_domain == ATTR_DOMAIN_LAYER))
|
||||
{
|
||||
/* Evaluate field just for the current layer. */
|
||||
if (src_domain_ == ATTR_DOMAIN_GREASE_PENCIL_LAYER) {
|
||||
const bke::GeometryFieldContext src_domain_context{context,
|
||||
ATTR_DOMAIN_GREASE_PENCIL_LAYER};
|
||||
if (src_domain_ == ATTR_DOMAIN_LAYER) {
|
||||
const bke::GeometryFieldContext src_domain_context{context, ATTR_DOMAIN_LAYER};
|
||||
const int layer_index = context.grease_pencil_layer_index();
|
||||
|
||||
const IndexMask single_layer_mask = IndexRange(layer_index, 1);
|
||||
|
||||
@@ -132,8 +132,7 @@ GeometryInfoLog::GeometryInfoLog(const bke::GeometrySet &geometry_set)
|
||||
const auto &grease_pencil_component = *static_cast<const bke::GreasePencilComponent *>(
|
||||
component);
|
||||
GreasePencilInfo &info = this->grease_pencil_info.emplace();
|
||||
info.layers_num = grease_pencil_component.attribute_domain_size(
|
||||
ATTR_DOMAIN_GREASE_PENCIL_LAYER);
|
||||
info.layers_num = grease_pencil_component.attribute_domain_size(ATTR_DOMAIN_LAYER);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user