[Bf-blender-cvs] [370a506ad05] functions: refactor age reached event
Jacques Lucke
noreply at git.blender.org
Tue Sep 3 11:42:39 CEST 2019
Commit: 370a506ad05250ddddefcfc6150832b424e19300
Author: Jacques Lucke
Date: Tue Sep 3 11:16:17 2019 +0200
Branches: functions
https://developer.blender.org/rB370a506ad05250ddddefcfc6150832b424e19300
refactor age reached event
===================================================================
M source/blender/simulations/bparticles/events.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/events.cpp b/source/blender/simulations/bparticles/events.cpp
index 60a1baa68dc..d560353bca4 100644
--- a/source/blender/simulations/bparticles/events.cpp
+++ b/source/blender/simulations/bparticles/events.cpp
@@ -17,24 +17,29 @@ void AgeReachedEvent::attributes(AttributesDeclaration &builder)
void AgeReachedEvent::filter(EventFilterInterface &interface)
{
AttributesRef attributes = interface.attributes();
- auto birth_times = attributes.get<float>("Birth Time");
auto ids = attributes.get<int32_t>("ID");
- auto was_activated_before = attributes.get<uint8_t>(m_identifier);
-
- float end_time = interface.step_end_time();
auto inputs = m_compute_inputs->compute(interface);
+ TemporaryArray<float> trigger_ages(attributes.size());
+ for (uint pindex : interface.pindices()) {
+ float age = inputs->get<float>("Age", 0, pindex);
+ float variation = inputs->get<float>("Variation", 1, pindex);
+ int32_t id = ids[pindex];
+ float random_factor = BLI_hash_int_01(id);
+ trigger_ages[pindex] = age + random_factor * variation;
+ }
+
+ float end_time = interface.step_end_time();
+ auto birth_times = attributes.get<float>("Birth Time");
+ auto was_activated_before = attributes.get<uint8_t>(m_identifier);
+
for (uint pindex : interface.pindices()) {
if (was_activated_before[pindex]) {
continue;
}
- float trigger_age = inputs->get<float>("Age", 0, pindex);
- float variation = inputs->get<float>("Variation", 1, pindex);
- int32_t id = ids[pindex];
- trigger_age += BLI_hash_int_01(id) * variation;
-
+ float trigger_age = trigger_ages[pindex];
float birth_time = birth_times[pindex];
float age_at_end = end_time - birth_time;
More information about the Bf-blender-cvs
mailing list