diff options
author | Hans Goudey <h.goudey@me.com> | 2021-01-07 18:27:42 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-01-07 18:27:42 +0300 |
commit | 3db975f30dd327381dc1a0e08305460a1a12eba4 (patch) | |
tree | f6e2f3a004e8a7c6b055af8c56652ae707ab942e /source/blender/blenkernel/BKE_geometry_set.hh | |
parent | 4c0fc60105d7b7ff3f5c926510d77bb261e71977 (diff) |
Fix T84326: No ID for geometry nodes instances after scattering
Instances are created with an "index" parameter used for persistence over
time through animation. Currently the geometry nodes instancer passes
the index in the array for this value, but the arrays created by the
"Point Distribution" node aren't necessarily stable in this way when
the input mesh is deformed. In D9832 we already mostly solved this
problem with an `id` attribute. The solution here is to create instances
with this attribute as well.
It's important to note that deforming the instanced points *after*
distribution will usually be a better solution for this problem. This
solution is likely still important though.
Differential Revision: https://developer.blender.org/D10024
Diffstat (limited to 'source/blender/blenkernel/BKE_geometry_set.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_geometry_set.hh | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index e4232a84a00..9dc2b80d4d4 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -364,6 +364,7 @@ class InstancesComponent : public GeometryComponent { blender::Vector<blender::float3> positions_; blender::Vector<blender::float3> rotations_; blender::Vector<blender::float3> scales_; + blender::Vector<int> ids_; blender::Vector<InstancedData> instanced_data_; public: @@ -375,20 +376,24 @@ class InstancesComponent : public GeometryComponent { void add_instance(Object *object, blender::float3 position, blender::float3 rotation = {0, 0, 0}, - blender::float3 scale = {1, 1, 1}); + blender::float3 scale = {1, 1, 1}, + const int id = -1); void add_instance(Collection *collection, blender::float3 position, blender::float3 rotation = {0, 0, 0}, - blender::float3 scale = {1, 1, 1}); + blender::float3 scale = {1, 1, 1}, + const int id = -1); void add_instance(InstancedData data, blender::float3 position, blender::float3 rotation, - blender::float3 scale); + blender::float3 scale, + const int id = -1); blender::Span<InstancedData> instanced_data() const; blender::Span<blender::float3> positions() const; blender::Span<blender::float3> rotations() const; blender::Span<blender::float3> scales() const; + blender::Span<int> ids() const; blender::MutableSpan<blender::float3> positions(); int instances_amount() const; |