[Bf-blender-cvs] [298b0cd863d] functions: Remove Action Context concept for now
Jacques Lucke
noreply at git.blender.org
Wed Dec 18 13:53:22 CET 2019
Commit: 298b0cd863d5a8c1d3314e1b1047d9591dacf2c4
Author: Jacques Lucke
Date: Wed Dec 18 10:04:53 2019 +0100
Branches: functions
https://developer.blender.org/rB298b0cd863d5a8c1d3314e1b1047d9591dacf2c4
Remove Action Context concept for now
===================================================================
M source/blender/simulations/CMakeLists.txt
D source/blender/simulations/bparticles/action_contexts.cpp
D source/blender/simulations/bparticles/action_contexts.hpp
M source/blender/simulations/bparticles/action_interface.cpp
M source/blender/simulations/bparticles/action_interface.hpp
M source/blender/simulations/bparticles/actions.cpp
M source/blender/simulations/bparticles/emitters.cpp
M source/blender/simulations/bparticles/events.cpp
M source/blender/simulations/bparticles/particle_function.cpp
M source/blender/simulations/bparticles/particle_function.hpp
===================================================================
diff --git a/source/blender/simulations/CMakeLists.txt b/source/blender/simulations/CMakeLists.txt
index d536f124b82..dd2d3ff5b86 100644
--- a/source/blender/simulations/CMakeLists.txt
+++ b/source/blender/simulations/CMakeLists.txt
@@ -28,8 +28,6 @@ set(SRC
bparticles/actions.cpp
bparticles/action_interface.hpp
bparticles/action_interface.cpp
- bparticles/action_contexts.hpp
- bparticles/action_contexts.cpp
bparticles/events.hpp
bparticles/events.cpp
bparticles/emitter_interface.hpp
diff --git a/source/blender/simulations/bparticles/action_contexts.cpp b/source/blender/simulations/bparticles/action_contexts.cpp
deleted file mode 100644
index a62cbaaa033..00000000000
--- a/source/blender/simulations/bparticles/action_contexts.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-
-#include "BKE_mesh_runtime.h"
-
-#include "BLI_math_geom.h"
-
-#include "action_contexts.hpp"
-
-namespace BParticles {
-
-void MeshSurfaceContext::compute_barycentric_coords(ArrayRef<uint> pindices)
-{
- BLI_assert(m_object->type == OB_MESH);
- uint size = m_local_positions.size();
- auto barycentric_coords = BLI::temporary_allocate_array<float3>(size);
-
- Mesh *mesh = (Mesh *)m_object->data;
- const MLoopTri *triangles = BKE_mesh_runtime_looptri_ensure(mesh);
-
- for (uint pindex : pindices) {
- uint triangle_index = m_looptri_indices[pindex];
- const MLoopTri &triangle = triangles[triangle_index];
- float3 position = m_local_positions[pindex];
-
- float3 v1 = mesh->mvert[mesh->mloop[triangle.tri[0]].v].co;
- float3 v2 = mesh->mvert[mesh->mloop[triangle.tri[1]].v].co;
- float3 v3 = mesh->mvert[mesh->mloop[triangle.tri[2]].v].co;
-
- float3 weights;
- interp_weights_tri_v3(weights, v1, v2, v3, position);
-
- barycentric_coords[pindex] = weights;
- }
-
- m_barycentric_coords = barycentric_coords;
- m_buffers_to_free.append(barycentric_coords.begin());
-}
-
-} // namespace BParticles
diff --git a/source/blender/simulations/bparticles/action_contexts.hpp b/source/blender/simulations/bparticles/action_contexts.hpp
deleted file mode 100644
index b4552b05a39..00000000000
--- a/source/blender/simulations/bparticles/action_contexts.hpp
+++ /dev/null
@@ -1,129 +0,0 @@
-#pragma once
-
-#include "BLI_temporary_allocator_cxx.h"
-#include "BLI_utility_mixins.h"
-
-#include "action_interface.hpp"
-
-struct Object;
-
-namespace BParticles {
-
-using BLI::float3;
-using BLI::float4x4;
-
-class MeshSurfaceContext : public ActionContext, BLI::NonCopyable, BLI::NonMovable {
- private:
- Vector<void *> m_buffers_to_free;
- Object *m_object;
- ArrayRef<float4x4> m_world_transforms;
- ArrayRef<float3> m_local_positions;
- ArrayRef<float3> m_local_normals;
- ArrayRef<float3> m_world_normals;
- ArrayRef<uint> m_looptri_indices;
- ArrayRef<float3> m_world_surface_velocities;
- ArrayRef<float3> m_barycentric_coords;
-
- public:
- MeshSurfaceContext(Object *object,
- ArrayRef<float4x4> world_transforms,
- ArrayRef<float3> local_positions,
- ArrayRef<float3> local_normals,
- ArrayRef<float3> world_normals,
- ArrayRef<uint> looptri_indices,
- ArrayRef<float3> world_surface_velocities)
- : m_object(object),
- m_world_transforms(world_transforms),
- m_local_positions(local_positions),
- m_local_normals(local_normals),
- m_world_normals(world_normals),
- m_looptri_indices(looptri_indices),
- m_world_surface_velocities(world_surface_velocities)
- {
- this->compute_barycentric_coords(IndexRange(m_local_positions.size()).as_array_ref());
- }
-
- MeshSurfaceContext(Object *object,
- float4x4 world_transform,
- ArrayRef<uint> pindices,
- ArrayRef<float3> local_positions,
- ArrayRef<float3> local_normals,
- ArrayRef<uint> looptri_indices)
- : m_object(object),
- m_local_positions(local_positions),
- m_local_normals(local_normals),
- m_looptri_indices(looptri_indices)
- {
- uint size = local_positions.size();
- auto world_transforms = BLI::temporary_allocate_array<float4x4>(size);
- auto world_normals = BLI::temporary_allocate_array<float3>(size);
- auto surface_velocities = BLI::temporary_allocate_array<float3>(size);
-
- for (uint pindex : pindices) {
- world_transforms[pindex] = world_transform;
- world_normals[pindex] = world_transform.transform_direction(local_normals[pindex]);
- surface_velocities[pindex] = float3(0, 0, 0);
- }
-
- m_world_transforms = world_transforms;
- m_world_normals = world_normals;
- m_world_surface_velocities = surface_velocities;
-
- m_buffers_to_free.extend(
- {world_transforms.begin(), world_normals.begin(), surface_velocities.begin()});
-
- this->compute_barycentric_coords(pindices);
- }
-
- ~MeshSurfaceContext()
- {
- for (void *buffer : m_buffers_to_free) {
- BLI_temporary_deallocate(buffer);
- }
- }
-
- Object *object() const
- {
- return m_object;
- }
-
- ArrayRef<float4x4> world_transforms() const
- {
- return m_world_transforms;
- }
-
- ArrayRef<float3> local_positions() const
- {
- return m_local_positions;
- }
-
- ArrayRef<float3> local_normals() const
- {
- return m_local_normals;
- }
-
- ArrayRef<float3> world_normals() const
- {
- return m_world_normals;
- }
-
- ArrayRef<uint> looptri_indices() const
- {
- return m_looptri_indices;
- }
-
- ArrayRef<float3> world_surface_velicities() const
- {
- return m_world_surface_velocities;
- }
-
- ArrayRef<float3> barycentric_coords() const
- {
- return m_barycentric_coords;
- }
-
- private:
- void compute_barycentric_coords(ArrayRef<uint> pindices);
-};
-
-} // namespace BParticles
diff --git a/source/blender/simulations/bparticles/action_interface.cpp b/source/blender/simulations/bparticles/action_interface.cpp
index 07b57cb3483..1e172d87aa5 100644
--- a/source/blender/simulations/bparticles/action_interface.cpp
+++ b/source/blender/simulations/bparticles/action_interface.cpp
@@ -2,10 +2,6 @@
namespace BParticles {
-ActionContext::~ActionContext()
-{
-}
-
Action::~Action()
{
}
diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp
index 693044e663b..f807f05d1d9 100644
--- a/source/blender/simulations/bparticles/action_interface.hpp
+++ b/source/blender/simulations/bparticles/action_interface.hpp
@@ -12,11 +12,6 @@ namespace BParticles {
using BLI::LargeScopedArray;
using FN::AttributesRefGroup;
-class ActionContext {
- public:
- virtual ~ActionContext();
-};
-
class ActionInterface {
private:
ParticleAllocator &m_particle_allocator;
@@ -25,7 +20,6 @@ class ActionInterface {
AttributesRef m_attribute_offsets;
ArrayRef<float> m_current_times;
ArrayRef<float> m_remaining_durations;
- ActionContext &m_action_context;
public:
ActionInterface(ParticleAllocator &particle_allocator,
@@ -33,10 +27,7 @@ class ActionInterface {
AttributesRef attributes,
AttributesRef attribute_offsets,
ArrayRef<float> current_times,
- ArrayRef<float> remaining_durations,
- ActionContext &action_context);
-
- ActionContext &context();
+ ArrayRef<float> remaining_durations);
ArrayRef<uint> pindices();
AttributesRef attributes();
@@ -54,16 +45,10 @@ class Action {
virtual void execute(ActionInterface &interface) = 0;
- template<typename ContextT, typename BuildContextF>
- void execute_from_emitter(AttributesRefGroup &new_particles,
- EmitterInterface &emitter_interface,
- const BuildContextF &build_context);
void execute_from_emitter(AttributesRefGroup &new_particles,
EmitterInterface &emitter_interface);
- 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_from_event(EventExecuteInterface &event_interface);
+ void execute_from_offset_handler(OffsetHandlerInterface &offset_handler_interface);
void execute_for_subset(ArrayRef<uint> pindices, ActionInterface &action_interface);
void execute_for_new_particles(AttributesRefGroup &new_particles,
ActionInterface &action_interface);
@@ -79,39 +64,28 @@ inline ActionInterface::ActionInterface(ParticleAllocator &particle_allocator,
AttributesRef attributes,
AttributesRef attribute_offsets,
ArrayRef<float> current_times,
- ArrayRef<float> remaining_durations,
- ActionContext &action_context)
+ ArrayRef<float> remaining_durations)
: m_particle_allocator(particle_allocator),
m_pindices(pindices),
m_attributes(attributes),
m_attribute_offsets(attribute_offsets),
m_current_times(current_times),
- m_remaining_durations(remaining_durations),
- m_action_context(action_context)
+ m_remaining_durations(remaining_durations)
{
}
-class EmptyActionContext : public ActionContext {
-};
-
-template<typename ContextT, typename BuildContextF>
inline void Action::execute_from_emitter(AttributesRefGroup &new_particles,
- EmitterInterface &emitter_interface,
- const BuildContextF &build_context)
+ EmitterInterface &emitter_interface)
{
AttributesInfo info;
std::array<void *, 0> buffers;
- ContextT *action_context = (ContextT *)alloca(sizeof(Cont
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list