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:
authorErik <ecke101@gmail.com>2021-11-19 19:53:48 +0300
committerErik <ecke101@gmail.com>2021-11-19 19:53:48 +0300
commit97533eede444217bd28df50a721707bdce340403 (patch)
tree0d3577b480ffd4b1c7f8030186b08ea95cb5d7b8 /source/blender/blenkernel/intern/geometry_component_instances.cc
parent9e3a913b35df9f9519d48e18223192a34ab8f22a (diff)
Geometry Nodes: Support custom instance attributes
Adds an attribute provider for instance attributes. A new domain `ATTR_DOMAIN_INSTANCE` is implemented. Instance attributes are not yet realized correctly. Differential Revision: D13149
Diffstat (limited to 'source/blender/blenkernel/intern/geometry_component_instances.cc')
-rw-r--r--source/blender/blenkernel/intern/geometry_component_instances.cc32
1 files changed, 28 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc
index 047bceda4fe..9a30c86c1e5 100644
--- a/source/blender/blenkernel/intern/geometry_component_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_component_instances.cc
@@ -363,12 +363,22 @@ blender::Span<int> InstancesComponent::almost_unique_ids() const
int InstancesComponent::attribute_domain_size(const AttributeDomain domain) const
{
- if (domain != ATTR_DOMAIN_POINT) {
+ if (domain != ATTR_DOMAIN_INSTANCE) {
return 0;
}
return this->instances_amount();
}
+blender::bke::CustomDataAttributes &InstancesComponent::attributes()
+{
+ return this->attributes_;
+}
+
+const blender::bke::CustomDataAttributes &InstancesComponent::attributes() const
+{
+ return this->attributes_;
+}
+
namespace blender::bke {
static float3 get_transform_position(const float4x4 &transform)
@@ -385,7 +395,7 @@ class InstancePositionAttributeProvider final : public BuiltinAttributeProvider
public:
InstancePositionAttributeProvider()
: BuiltinAttributeProvider(
- "position", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, NonCreatable, Writable, NonDeletable)
+ "position", ATTR_DOMAIN_INSTANCE, CD_PROP_FLOAT3, NonCreatable, Writable, NonDeletable)
{
}
@@ -428,7 +438,7 @@ class InstanceIDAttributeProvider final : public BuiltinAttributeProvider {
public:
InstanceIDAttributeProvider()
: BuiltinAttributeProvider(
- "id", ATTR_DOMAIN_POINT, CD_PROP_INT32, Creatable, Writable, Deletable)
+ "id", ATTR_DOMAIN_INSTANCE, CD_PROP_INT32, Creatable, Writable, Deletable)
{
}
@@ -499,7 +509,21 @@ static ComponentAttributeProviders create_attribute_providers_for_instances()
static InstancePositionAttributeProvider position;
static InstanceIDAttributeProvider id;
- return ComponentAttributeProviders({&position, &id}, {});
+ static CustomDataAccessInfo instance_custom_data_access = {
+ [](GeometryComponent &component) -> CustomData * {
+ InstancesComponent &inst = static_cast<InstancesComponent &>(component);
+ return &inst.attributes().data;
+ },
+ [](const GeometryComponent &component) -> const CustomData * {
+ const InstancesComponent &inst = static_cast<const InstancesComponent &>(component);
+ return &inst.attributes().data;
+ },
+ nullptr};
+
+ static CustomDataAttributeProvider instance_custom_data(ATTR_DOMAIN_INSTANCE,
+ instance_custom_data_access);
+
+ return ComponentAttributeProviders({&position, &id}, {&instance_custom_data});
}
} // namespace blender::bke