[Bf-blender-cvs] [c78acc85f3a] functions: initial variation input for age reached event
Jacques Lucke
noreply at git.blender.org
Tue Sep 3 11:42:37 CEST 2019
Commit: c78acc85f3a45e204d0a1bbc26f288366d5f4923
Author: Jacques Lucke
Date: Tue Sep 3 11:07:17 2019 +0200
Branches: functions
https://developer.blender.org/rBc78acc85f3a45e204d0a1bbc26f288366d5f4923
initial variation input for age reached event
===================================================================
M release/scripts/startup/nodes/bparticle_nodes/age_reached_event.py
M source/blender/simulations/bparticles/events.cpp
===================================================================
diff --git a/release/scripts/startup/nodes/bparticle_nodes/age_reached_event.py b/release/scripts/startup/nodes/bparticle_nodes/age_reached_event.py
index 35f5efcddea..5c3b50781a9 100644
--- a/release/scripts/startup/nodes/bparticle_nodes/age_reached_event.py
+++ b/release/scripts/startup/nodes/bparticle_nodes/age_reached_event.py
@@ -11,6 +11,7 @@ class AgeReachedEventNode(bpy.types.Node, BParticlesNode):
def declaration(self, builder: NodeBuilder):
builder.fixed_input("age", "Age", "Float", default=3)
+ builder.fixed_input("variation", "Variation", "Float")
builder.execute_input("execute_on_event", "Execute on Event", "execute_on_event__prop")
builder.particle_effector_output("event", "Event")
diff --git a/source/blender/simulations/bparticles/events.cpp b/source/blender/simulations/bparticles/events.cpp
index d7b9aae9f66..60a1baa68dc 100644
--- a/source/blender/simulations/bparticles/events.cpp
+++ b/source/blender/simulations/bparticles/events.cpp
@@ -1,5 +1,7 @@
-#include "events.hpp"
+#include "BLI_utildefines.h"
+#include "BLI_hash.h"
+#include "events.hpp"
#include "action_contexts.hpp"
namespace BParticles {
@@ -16,6 +18,7 @@ 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();
@@ -28,6 +31,9 @@ void AgeReachedEvent::filter(EventFilterInterface &interface)
}
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 birth_time = birth_times[pindex];
float age_at_end = end_time - birth_time;
More information about the Bf-blender-cvs
mailing list