[Bf-blender-cvs] [49425471f70] temp-geometry-nodes-text: Initial support for custom attributes on instances

Erik noreply at git.blender.org
Thu Oct 28 23:29:01 CEST 2021


Commit: 49425471f70b230b929307f0a6ea4ef9c514116f
Author: Erik
Date:   Thu Oct 28 23:18:30 2021 +0200
Branches: temp-geometry-nodes-text
https://developer.blender.org/rB49425471f70b230b929307f0a6ea4ef9c514116f

Initial support for custom attributes on instances

===================================================================

M	source/blender/blenkernel/BKE_geometry_set.hh
M	source/blender/blenkernel/intern/geometry_component_instances.cc

===================================================================

diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index 58a89d0207a..e912b2037ba 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -638,6 +638,7 @@ class InstancesComponent : public GeometryComponent {
   mutable blender::Array<int> almost_unique_ids_;
 
  public:
+  blender::bke::CustomDataAttributes attributes;
   InstancesComponent();
   ~InstancesComponent() = default;
   GeometryComponent *copy() const override;
diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc
index d02121b44a6..2a7c8cd4cb4 100644
--- a/source/blender/blenkernel/intern/geometry_component_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_component_instances.cc
@@ -501,7 +501,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_POINT,
+                                                          instance_custom_data_access);
+
+  return ComponentAttributeProviders({&position, &id}, {&instance_custom_data});
 }
 }  // namespace blender::bke



More information about the Bf-blender-cvs mailing list