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:
authorJacques Lucke <jacques@blender.org>2020-07-24 14:37:55 +0300
committerJacques Lucke <jacques@blender.org>2020-07-24 14:37:55 +0300
commit74fcb4d4c2f3c72747119a672c7e322f6f910478 (patch)
treedc3fc78988e74bad920a6dbb739bdf8fdd80081b /source/blender/simulation/intern/particle_allocator.cc
parentf495b583bee5d43755c19bea4704e40d0e0f8a54 (diff)
Particles: initial particle birth action
A particle action is some function that is triggered by some event. Right now, users cannot control this. There is just a randomize-velocity on-birth action. So the direction of spawned particles is slightly randomized now. This also adds a new integer attribute called "Hash" which is useful for a number of things. Mainly for generating random numbers for a specific particle. The ID of a particle is not necessarily a good source of randomness.
Diffstat (limited to 'source/blender/simulation/intern/particle_allocator.cc')
-rw-r--r--source/blender/simulation/intern/particle_allocator.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/simulation/intern/particle_allocator.cc b/source/blender/simulation/intern/particle_allocator.cc
index 5ff5909f506..e47a6354d81 100644
--- a/source/blender/simulation/intern/particle_allocator.cc
+++ b/source/blender/simulation/intern/particle_allocator.cc
@@ -16,6 +16,8 @@
#include "particle_allocator.hh"
+#include "BLI_rand.hh"
+
namespace blender::sim {
AttributesAllocator::~AttributesAllocator()
@@ -67,6 +69,13 @@ fn::MutableAttributesRef ParticleAllocator::allocate(int size)
ids[pindex] = start_id + pindex;
}
}
+ else if (name == "Hash") {
+ MutableSpan<int> hashes = attributes.get<int>("Hash");
+ RandomNumberGenerator rng(hash_seed_ ^ (uint32_t)next_id_);
+ for (int pindex : IndexRange(size)) {
+ hashes[pindex] = (int)rng.get_uint32();
+ }
+ }
else {
type.fill_uninitialized(info.default_of(i), attributes.get(i).data(), size);
}