[Bf-blender-cvs] [1bfe5671292] functions: new node_frontend interface

Jacques Lucke noreply at git.blender.org
Tue Jul 9 18:01:25 CEST 2019


Commit: 1bfe5671292da8d77491951b706d21a9adfa1851
Author: Jacques Lucke
Date:   Tue Jul 9 12:27:26 2019 +0200
Branches: functions
https://developer.blender.org/rB1bfe5671292da8d77491951b706d21a9adfa1851

new node_frontend interface

===================================================================

M	source/blender/simulations/CMakeLists.txt
M	source/blender/simulations/bparticles/c_wrapper.cpp
M	source/blender/simulations/bparticles/inserters.cpp
M	source/blender/simulations/bparticles/inserters.hpp
A	source/blender/simulations/bparticles/node_frontend.cpp
A	source/blender/simulations/bparticles/node_frontend.hpp

===================================================================

diff --git a/source/blender/simulations/CMakeLists.txt b/source/blender/simulations/CMakeLists.txt
index 9e07ffc1d8d..242e6c8bb22 100644
--- a/source/blender/simulations/CMakeLists.txt
+++ b/source/blender/simulations/CMakeLists.txt
@@ -41,6 +41,8 @@ set(SRC
   bparticles/integrator.cpp
   bparticles/inserters.hpp
   bparticles/inserters.cpp
+  bparticles/node_frontend.hpp
+  bparticles/node_frontend.cpp
 )
 
 set(LIB
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index cdd3f0e4e20..b0846cad5bd 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -2,7 +2,7 @@
 #include "core.hpp"
 #include "simulate.hpp"
 #include "world_state.hpp"
-#include "inserters.hpp"
+#include "node_frontend.hpp"
 
 #include "BLI_timeit.hpp"
 #include "BLI_task.hpp"
@@ -79,9 +79,7 @@ void BParticles_simulate_modifier(NodeParticlesModifierData *npmd,
   bNodeTree *btree = (bNodeTree *)DEG_get_original_id((ID *)npmd->bparticles_tree);
   IndexedNodeTree indexed_tree(btree);
 
-  ModifierStepDescription *step_description = step_description_from_node_tree(indexed_tree,
-                                                                              world_state);
-  step_description->m_duration = 1.0f / 24.0f;
+  auto step_description = step_description_from_node_tree(indexed_tree, world_state, 1.0f / 24.0f);
 
   ParticlesState &particles_state = *unwrap(particles_state_c);
   simulate_step(particles_state, *step_description);
@@ -92,8 +90,6 @@ void BParticles_simulate_modifier(NodeParticlesModifierData *npmd,
     std::cout << "  Particles: " << item.value->count_active() << "\n";
     std::cout << "  Blocks: " << item.value->active_blocks().size() << "\n";
   }
-
-  delete step_description;
 }
 
 uint BParticles_state_particle_count(BParticlesState state_c)
diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp
index 242396a28dc..7e900bc568d 100644
--- a/source/blender/simulations/bparticles/inserters.cpp
+++ b/source/blender/simulations/bparticles/inserters.cpp
@@ -347,8 +347,8 @@ static void INSERT_FORCE_turbulence(bNode *force_node,
   }
 }
 
-ModifierStepDescription *step_description_from_node_tree(IndexedNodeTree &indexed_tree,
-                                                         WorldState &world_state)
+ModifierStepDescription *step_description_from_node_tree_impl(IndexedNodeTree &indexed_tree,
+                                                              WorldState &world_state)
 {
   SCOPED_TIMER(__func__);
 
diff --git a/source/blender/simulations/bparticles/inserters.hpp b/source/blender/simulations/bparticles/inserters.hpp
index 97dfb31d696..45480a49402 100644
--- a/source/blender/simulations/bparticles/inserters.hpp
+++ b/source/blender/simulations/bparticles/inserters.hpp
@@ -11,7 +11,7 @@ namespace BParticles {
 
 using BKE::IndexedNodeTree;
 
-ModifierStepDescription *step_description_from_node_tree(IndexedNodeTree &indexed_tree,
-                                                         WorldState &world_state);
+ModifierStepDescription *step_description_from_node_tree_impl(IndexedNodeTree &indexed_tree,
+                                                              WorldState &world_state);
 
 }  // namespace BParticles
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
new file mode 100644
index 00000000000..c4a84dddd81
--- /dev/null
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -0,0 +1,16 @@
+#include "node_frontend.hpp"
+#include "inserters.hpp"
+
+namespace BParticles {
+
+std::unique_ptr<StepDescription> step_description_from_node_tree(IndexedNodeTree &indexed_tree,
+                                                                 WorldState &world_state,
+                                                                 float time_step)
+{
+  ModifierStepDescription *description = step_description_from_node_tree_impl(indexed_tree,
+                                                                              world_state);
+  description->m_duration = time_step;
+  return std::unique_ptr<StepDescription>(description);
+}
+
+}  // namespace BParticles
diff --git a/source/blender/simulations/bparticles/node_frontend.hpp b/source/blender/simulations/bparticles/node_frontend.hpp
new file mode 100644
index 00000000000..7cfe12fd728
--- /dev/null
+++ b/source/blender/simulations/bparticles/node_frontend.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "BKE_node_tree.hpp"
+
+#include "world_state.hpp"
+#include "step_description.hpp"
+
+namespace BParticles {
+
+using BKE::IndexedNodeTree;
+
+std::unique_ptr<StepDescription> step_description_from_node_tree(IndexedNodeTree &indexed_tree,
+                                                                 WorldState &world_state,
+                                                                 float time_step);
+
+}  // namespace BParticles



More information about the Bf-blender-cvs mailing list