[Bf-blender-cvs] [81795f30b4a] functions: move world state to separate file
Jacques Lucke
noreply at git.blender.org
Tue Jul 9 18:01:13 CEST 2019
Commit: 81795f30b4a6146da529c9dc225af1aa7345cfca
Author: Jacques Lucke
Date: Tue Jul 9 11:44:37 2019 +0200
Branches: functions
https://developer.blender.org/rB81795f30b4a6146da529c9dc225af1aa7345cfca
move world state to separate file
===================================================================
M source/blender/simulations/bparticles/c_wrapper.cpp
A source/blender/simulations/bparticles/world_state.hpp
===================================================================
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index db9d04e77d9..58a5b074223 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -6,6 +6,7 @@
#include "events.hpp"
#include "actions.hpp"
#include "simulate.hpp"
+#include "world_state.hpp"
#include "BLI_timeit.hpp"
#include "BLI_listbase.h"
@@ -63,11 +64,6 @@ void BParticles_state_free(BParticlesState state_c)
delete unwrap(state_c);
}
-class WorldState {
- public:
- SmallMap<std::string, float4x4> m_cached_matrices;
-};
-
WRAPPERS(WorldState *, BParticlesWorldState);
BParticlesWorldState BParticles_new_world_state()
@@ -399,13 +395,9 @@ static void INSERT_EMITTER_mesh_surface(bNode *emitter_node,
continue;
}
- std::string tranformation_key = emitter_node->name;
- float4x4 last_transformation = world_state.m_cached_matrices.lookup_default(tranformation_key,
- object->obmat);
+ float4x4 last_transformation = world_state.update(emitter_node->name, object->obmat);
float4x4 current_transformation = object->obmat;
- world_state.m_cached_matrices.add_override(tranformation_key, current_transformation);
-
Emitter *emitter = EMITTER_mesh_surface(
type_node->name, (Mesh *)object->data, last_transformation, current_transformation, 1.0f);
step_description.m_emitters.append(emitter);
diff --git a/source/blender/simulations/bparticles/world_state.hpp b/source/blender/simulations/bparticles/world_state.hpp
new file mode 100644
index 00000000000..3eb257ae3b4
--- /dev/null
+++ b/source/blender/simulations/bparticles/world_state.hpp
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "BLI_math.hpp"
+#include "BLI_small_map.hpp"
+#include "BLI_string_ref.hpp"
+
+namespace BParticles {
+
+using BLI::float4x4;
+using BLI::SmallMap;
+using BLI::StringRef;
+
+class WorldState {
+ private:
+ SmallMap<std::string, float4x4> m_matrices;
+
+ public:
+ float4x4 update(StringRef id, float4x4 value)
+ {
+ std::string id_string = id.to_std_string();
+ float4x4 old = m_matrices.lookup_default(id_string, value);
+ m_matrices.add_override(id_string, value);
+ return old;
+ }
+};
+
+}; // namespace BParticles
More information about the Bf-blender-cvs
mailing list