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:
authorHans Goudey <h.goudey@me.com>2021-10-20 18:54:54 +0300
committerHans Goudey <h.goudey@me.com>2021-10-20 18:54:54 +0300
commit40c3b8836b7a36303ea9c78b0932758cbf277f93 (patch)
tree84cf99f5f726384def64e79333b7566e36ff1156 /source/blender/blenkernel/intern/attribute_access_intern.hh
parent1a96045eec96e0c6f52ded6fd40040c4b88524d9 (diff)
Geometry Nodes: Make Random ID a builtin attribute, remove sockets
In order to address feedback that the "Stable ID" was not easy enough to use, remove the "Stable ID" output from the distribution node and the input from the instance on points node. Instead, the nodes write or read a builtin named attribute called `id`. In the future we may add more attributes like `edge_id` and `face_id`. The downside is that more behavior is invisible, which is les expected now that most attributes are passed around with node links. This behavior will have to be explained in the manual. The random value node's "ID" input that had an implicit index input is converted to a special implicit input that uses the `id` attribute if possible, but otherwise defaults to the index. There is no way to tell in the UI which it uses, except by knowing that rule and checking in the spreadsheet for the id attribute. Because it isn't always possible to create stable randomness, this attribute does not always exist, and it will be possible to remove it when we have the attribute remove node back, to improve performance. Differential Revision: https://developer.blender.org/D12903
Diffstat (limited to 'source/blender/blenkernel/intern/attribute_access_intern.hh')
-rw-r--r--source/blender/blenkernel/intern/attribute_access_intern.hh7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access_intern.hh b/source/blender/blenkernel/intern/attribute_access_intern.hh
index 6e5cdd6faba..5cedcf69953 100644
--- a/source/blender/blenkernel/intern/attribute_access_intern.hh
+++ b/source/blender/blenkernel/intern/attribute_access_intern.hh
@@ -227,6 +227,9 @@ class NamedLegacyCustomDataProvider final : public DynamicAttributesProvider {
* This provider is used to provide access to builtin attributes. It supports making internal types
* available as different types. For example, the vertex position attribute is stored as part of
* the #MVert struct, but is exposed as float3 attribute.
+ *
+ * It also supports named builtin attributes, and will look up attributes in #CustomData by name
+ * if the stored type is the same as the attribute type.
*/
class BuiltinCustomDataLayerProvider final : public BuiltinAttributeProvider {
using AsReadAttribute = GVArrayPtr (*)(const void *data, const int domain_size);
@@ -238,6 +241,7 @@ class BuiltinCustomDataLayerProvider final : public BuiltinAttributeProvider {
const AsReadAttribute as_read_attribute_;
const AsWriteAttribute as_write_attribute_;
const UpdateOnWrite update_on_write_;
+ bool stored_as_named_attribute_;
public:
BuiltinCustomDataLayerProvider(std::string attribute_name,
@@ -257,7 +261,8 @@ class BuiltinCustomDataLayerProvider final : public BuiltinAttributeProvider {
custom_data_access_(custom_data_access),
as_read_attribute_(as_read_attribute),
as_write_attribute_(as_write_attribute),
- update_on_write_(update_on_write)
+ update_on_write_(update_on_write),
+ stored_as_named_attribute_(data_type_ == stored_type_)
{
}