[Bf-blender-cvs] [09ffcc5de18] functions: initial Always Execute node
Jacques Lucke
noreply at git.blender.org
Wed Sep 11 17:24:52 CEST 2019
Commit: 09ffcc5de18d43dba21f6941950931f529abd306
Author: Jacques Lucke
Date: Wed Sep 11 17:24:47 2019 +0200
Branches: functions
https://developer.blender.org/rB09ffcc5de18d43dba21f6941950931f529abd306
initial Always Execute node
===================================================================
A release/scripts/startup/nodes/bparticle_nodes/always_execute.py
M source/blender/simulations/bparticles/action_interface.hpp
M source/blender/simulations/bparticles/node_frontend.cpp
M source/blender/simulations/bparticles/offset_handlers.cpp
M source/blender/simulations/bparticles/offset_handlers.hpp
===================================================================
diff --git a/release/scripts/startup/nodes/bparticle_nodes/always_execute.py b/release/scripts/startup/nodes/bparticle_nodes/always_execute.py
new file mode 100644
index 00000000000..308d8b6a771
--- /dev/null
+++ b/release/scripts/startup/nodes/bparticle_nodes/always_execute.py
@@ -0,0 +1,15 @@
+import bpy
+from bpy.props import *
+from .. base import BParticlesNode
+from .. node_builder import NodeBuilder
+
+
+class AlwaysExecuteNode(bpy.types.Node, BParticlesNode):
+ bl_idname = "bp_AlwaysExecuteNode"
+ bl_label = "Always Execute"
+
+ execute__prop: NodeBuilder.ExecuteInputProperty()
+
+ def declaration(self, builder: NodeBuilder):
+ builder.execute_input("execute", "Execute", "execute__prop")
+ builder.particle_effector_output("type", "Type")
diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp
index fd2ccb78ef1..ee9ac270729 100644
--- a/source/blender/simulations/bparticles/action_interface.hpp
+++ b/source/blender/simulations/bparticles/action_interface.hpp
@@ -93,6 +93,8 @@ class Action {
const BuildContextF &build_context);
void execute_from_event(EventExecuteInterface &event_interface,
ActionContext *action_context = nullptr);
+ void execute_from_offset_handler(OffsetHandlerInterface &offset_handler_interface,
+ ActionContext *action_context = nullptr);
void execute_for_subset(ArrayRef<uint> pindices, ActionInterface &action_interface);
void execute_for_new_particles(AttributesRefGroup &new_particles,
ActionInterface &action_interface,
@@ -176,6 +178,28 @@ inline void Action::execute_from_event(EventExecuteInterface &event_interface,
this->execute(action_interface);
}
+inline void Action::execute_from_offset_handler(OffsetHandlerInterface &offset_handler_interface,
+ ActionContext *action_context)
+{
+ EmptyActionContext empty_action_context;
+ ActionContext &used_action_context = (action_context == nullptr) ? empty_action_context :
+ *action_context;
+
+ TemporaryArray<float> current_times(offset_handler_interface.array_size());
+ for (uint pindex : offset_handler_interface.pindices()) {
+ current_times[pindex] = offset_handler_interface.time_span(pindex).start();
+ }
+
+ ActionInterface action_interface(offset_handler_interface.particle_allocator(),
+ offset_handler_interface.pindices(),
+ offset_handler_interface.attributes(),
+ offset_handler_interface.attribute_offsets(),
+ current_times,
+ offset_handler_interface.remaining_durations(),
+ used_action_context);
+ this->execute(action_interface);
+}
+
inline void Action::execute_for_subset(ArrayRef<uint> pindices, ActionInterface &action_interface)
{
ActionInterface sub_interface(action_interface.particle_allocator(),
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index 7d63658e089..3bdc1e222e1 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -650,6 +650,20 @@ static void PARSE_custom_event(BehaviorCollector &collector,
}
}
+static void PARSE_always_execute(BehaviorCollector &collector,
+ VTreeDataGraph &vtree_data_graph,
+ WorldTransition &UNUSED(world_transition),
+ VirtualNode *vnode)
+{
+ Vector<std::string> type_names = find_connected_particle_type_names(vnode->output(0, "Type"));
+ for (std::string &type_name : type_names) {
+ auto action = build_action_list(vtree_data_graph, vnode, "Execute");
+
+ OffsetHandler *handler = new AlwaysExecuteHandler(std::move(action));
+ collector.m_offset_handlers.add(type_name, handler);
+ }
+}
+
BLI_LAZY_INIT_STATIC(StringMap<ParseNodeCallback>, get_node_parsers)
{
StringMap<ParseNodeCallback> map;
@@ -665,6 +679,7 @@ BLI_LAZY_INIT_STATIC(StringMap<ParseNodeCallback>, get_node_parsers)
map.add_new("bp_DragForceNode", PARSE_drag_force);
map.add_new("bp_MeshForceNode", PARSE_mesh_force);
map.add_new("bp_CustomEventNode", PARSE_custom_event);
+ map.add_new("bp_AlwaysExecuteNode", PARSE_always_execute);
return map;
}
diff --git a/source/blender/simulations/bparticles/offset_handlers.cpp b/source/blender/simulations/bparticles/offset_handlers.cpp
index 1c8d8c75390..20958c8dc73 100644
--- a/source/blender/simulations/bparticles/offset_handlers.cpp
+++ b/source/blender/simulations/bparticles/offset_handlers.cpp
@@ -63,4 +63,9 @@ void SizeOverTimeHandler::execute(OffsetHandlerInterface &interface)
}
}
+void AlwaysExecuteHandler::execute(OffsetHandlerInterface &interface)
+{
+ m_action->execute_from_offset_handler(interface);
+}
+
} // namespace BParticles
diff --git a/source/blender/simulations/bparticles/offset_handlers.hpp b/source/blender/simulations/bparticles/offset_handlers.hpp
index d59e3f61493..2a35eaf6fa6 100644
--- a/source/blender/simulations/bparticles/offset_handlers.hpp
+++ b/source/blender/simulations/bparticles/offset_handlers.hpp
@@ -37,4 +37,16 @@ class SizeOverTimeHandler : public OffsetHandler {
void execute(OffsetHandlerInterface &interface) override;
};
+class AlwaysExecuteHandler : public OffsetHandler {
+ private:
+ std::unique_ptr<Action> m_action;
+
+ public:
+ AlwaysExecuteHandler(std::unique_ptr<Action> action) : m_action(std::move(action))
+ {
+ }
+
+ void execute(OffsetHandlerInterface &interface) override;
+};
+
} // namespace BParticles
More information about the Bf-blender-cvs
mailing list