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/functions
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/functions')
-rw-r--r--source/blender/functions/FN_field.hh2
-rw-r--r--source/blender/functions/intern/field.cc13
2 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/functions/FN_field.hh b/source/blender/functions/FN_field.hh
index 78a49e342a5..ed5064fdf25 100644
--- a/source/blender/functions/FN_field.hh
+++ b/source/blender/functions/FN_field.hh
@@ -418,6 +418,8 @@ class IndexFieldInput final : public FieldInput {
public:
IndexFieldInput();
+ static GVArray *get_index_varray(IndexMask mask, ResourceScope &scope);
+
const GVArray *get_varray_for_context(const FieldContext &context,
IndexMask mask,
ResourceScope &scope) const final;
diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc
index 1f7bad134a8..c6125b65c5e 100644
--- a/source/blender/functions/intern/field.cc
+++ b/source/blender/functions/intern/field.cc
@@ -519,17 +519,22 @@ IndexFieldInput::IndexFieldInput() : FieldInput(CPPType::get<int>(), "Index")
{
}
-const GVArray *IndexFieldInput::get_varray_for_context(const fn::FieldContext &UNUSED(context),
- IndexMask mask,
- ResourceScope &scope) const
+GVArray *IndexFieldInput::get_index_varray(IndexMask mask, ResourceScope &scope)
{
- /* TODO: Investigate a similar method to IndexRange::as_span() */
auto index_func = [](int i) { return i; };
return &scope.construct<
fn::GVArray_For_EmbeddedVArray<int, VArray_For_Func<int, decltype(index_func)>>>(
mask.min_array_size(), mask.min_array_size(), index_func);
}
+const GVArray *IndexFieldInput::get_varray_for_context(const fn::FieldContext &UNUSED(context),
+ IndexMask mask,
+ ResourceScope &scope) const
+{
+ /* TODO: Investigate a similar method to IndexRange::as_span() */
+ return get_index_varray(mask, scope);
+}
+
uint64_t IndexFieldInput::hash() const
{
/* Some random constant hash. */