[Bf-blender-cvs] [b6e0a11e414] functions: prepare simulation for optimizations

Jacques Lucke noreply at git.blender.org
Sun Jun 30 16:00:31 CEST 2019


Commit: b6e0a11e414138fa0b6caf05a4cf4ddc88d1aeb9
Author: Jacques Lucke
Date:   Sun Jun 30 09:22:28 2019 +0200
Branches: functions
https://developer.blender.org/rBb6e0a11e414138fa0b6caf05a4cf4ddc88d1aeb9

prepare simulation for optimizations

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

M	source/blender/simulations/bparticles/c_wrapper.cpp
M	source/blender/simulations/bparticles/simulate.cpp

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

diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index 5bbfed6b806..a333cec3b4a 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -188,7 +188,7 @@ class ModifierStepDescription : public StepDescription {
 
   ArrayRef<uint> particle_type_ids() override
   {
-    return {0, 1};
+    return {0};
   }
 
   ParticleType &particle_type(uint type_id) override
@@ -206,42 +206,43 @@ void BParticles_simulate_modifier(NodeParticlesModifierData *npmd,
   ParticlesState &state = *unwrap(state_c);
   ModifierStepDescription description;
   description.m_duration = 1.0f / 24.0f;
+  description.m_emitters.append(EMITTER_emit_at_start());
 
   auto *type0 = new ModifierParticleType();
   description.m_types.add_new(0, type0);
 
-  if (npmd->emitter_object) {
-    description.m_emitters.append(EMITTER_mesh_surface(
-        0, (Mesh *)npmd->emitter_object->data, npmd->emitter_object->obmat, npmd->control1));
-  }
-  BVHTreeFromMesh treedata = {0};
-  if (npmd->collision_object) {
-    BKE_bvhtree_from_mesh_get(
-        &treedata, (Mesh *)npmd->collision_object->data, BVHTREE_FROM_LOOPTRI, 4);
-
-    EventActionTest *event_action = new EventActionTest();
-    event_action->m_event = EVENT_mesh_collection(&treedata, npmd->collision_object->obmat);
-    event_action->m_action = ACTION_explode();
-    type0->m_event_actions.append(event_action);
-  }
+  // if (npmd->emitter_object) {
+  //   description.m_emitters.append(EMITTER_mesh_surface(
+  //       0, (Mesh *)npmd->emitter_object->data, npmd->emitter_object->obmat, npmd->control1));
+  // }
+  // BVHTreeFromMesh treedata = {0};
+  // if (npmd->collision_object) {
+  //   BKE_bvhtree_from_mesh_get(
+  //       &treedata, (Mesh *)npmd->collision_object->data, BVHTREE_FROM_LOOPTRI, 4);
+
+  //   EventActionTest *event_action = new EventActionTest();
+  //   event_action->m_event = EVENT_mesh_collection(&treedata, npmd->collision_object->obmat);
+  //   event_action->m_action = ACTION_explode();
+  //   type0->m_event_actions.append(event_action);
+  // }
   type0->m_integrator = new EulerIntegrator();
   type0->m_integrator->m_forces.append(FORCE_directional({0, 0, -2}));
 
-  auto *type1 = new ModifierParticleType();
-  description.m_types.add_new(1, type1);
-  {
-    EventActionTest *event_action = new EventActionTest();
-    event_action->m_event = EVENT_age_reached(0.3f);
-    event_action->m_action = ACTION_kill();
-    type1->m_event_actions.append(event_action);
-  }
-  type1->m_integrator = new EulerIntegrator();
+  // auto *type1 = new ModifierParticleType();
+  // description.m_types.add_new(1, type1);
+  // {
+  //   EventActionTest *event_action = new EventActionTest();
+  //   event_action->m_event = EVENT_age_reached(0.3f);
+  //   event_action->m_action = ACTION_kill();
+  //   type1->m_event_actions.append(event_action);
+  // }
+  // type1->m_integrator = new EulerIntegrator();
 
   simulate_step(state, description);
 
-  if (npmd->collision_object) {
-    free_bvhtree_from_mesh(&treedata);
-  }
+  // if (npmd->collision_object) {
+  //   free_bvhtree_from_mesh(&treedata);
+  // }
 
   auto &containers = state.particle_containers();
   for (auto item : containers.items()) {
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index c7998e33405..900110f16a4 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -3,8 +3,9 @@
 
 #include "BLI_lazy_init.hpp"
 #include "BLI_task.h"
+#include "BLI_timeit.hpp"
 
-#define USE_THREADING true
+#define USE_THREADING false
 
 namespace BParticles {
 
@@ -337,9 +338,9 @@ BLI_NOINLINE static void simulate_block(BlockAllocator &block_allocator,
 
   Integrator &integrator = particle_type.integrator();
   AttributesInfo &offsets_info = integrator.offset_attributes_info();
-  auto integrated_attributes_core = AttributeArraysCore::NewWithSeparateAllocations(offsets_info,
-                                                                                    amount);
-  AttributeArrays attribute_offsets = integrated_attributes_core.slice_all();
+  AttributeArraysCore attribute_offsets_core = AttributeArraysCore::NewWithSeparateAllocations(
+      offsets_info, amount);
+  AttributeArrays attribute_offsets = attribute_offsets_core.slice_all();
 
   integrator.integrate(block, durations, attribute_offsets);
 
@@ -356,7 +357,7 @@ BLI_NOINLINE static void simulate_block(BlockAllocator &block_allocator,
   ParticleSet remaining_particles(block, unfinished_particle_indices);
   apply_remaining_offsets(remaining_particles, attribute_offsets);
 
-  integrated_attributes_core.free_buffers();
+  attribute_offsets_core.free_buffers();
 }
 
 class BlockAllocators {
@@ -426,6 +427,8 @@ BLI_NOINLINE static void simulate_block_time_span_cb(void *__restrict userdata,
                                                      const int index,
                                                      const ParallelRangeTLS *__restrict tls)
 {
+  SCOPED_TIMER(__func__);
+
   SimulateTimeSpanData *data = (SimulateTimeSpanData *)userdata;
 
   BlockAllocator &block_allocator = data->block_allocators.get_threadlocal_allocator(



More information about the Bf-blender-cvs mailing list