[Bf-blender-cvs] [5a31c30b5ca] functions: transform emitter mesh to world space

Jacques Lucke noreply at git.blender.org
Fri Jun 21 13:29:45 CEST 2019


Commit: 5a31c30b5ca1ac763a8947032b41168a20866ea1
Author: Jacques Lucke
Date:   Fri Jun 21 13:28:17 2019 +0200
Branches: functions
https://developer.blender.org/rB5a31c30b5ca1ac763a8947032b41168a20866ea1

transform emitter mesh to world space

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

M	source/blender/simulations/bparticles/c_wrapper.cpp
M	source/blender/simulations/bparticles/emitters.cpp
M	source/blender/simulations/bparticles/emitters.hpp

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

diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index 7ccf8b0fb2c..2b5a7f86af7 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -127,8 +127,10 @@ void BParticles_simulate_modifier(NodeParticlesModifierData *npmd,
   ModifierStepDescription description;
   description.m_duration = 1.0f / 24.0f;
   if (npmd->emitter_object) {
-    description.m_emitters.append(
-        EMITTER_mesh_surface((Mesh *)npmd->emitter_object->data, npmd->control1).release());
+    description.m_emitters.append(EMITTER_mesh_surface((Mesh *)npmd->emitter_object->data,
+                                                       npmd->emitter_object->obmat,
+                                                       npmd->control1)
+                                      .release());
   }
   BVHTreeFromMesh treedata = {0};
   if (npmd->collision_object) {
diff --git a/source/blender/simulations/bparticles/emitters.cpp b/source/blender/simulations/bparticles/emitters.cpp
index 94a6beb1469..acb23b8db3f 100644
--- a/source/blender/simulations/bparticles/emitters.cpp
+++ b/source/blender/simulations/bparticles/emitters.cpp
@@ -35,11 +35,12 @@ class PointEmitter : public Emitter {
 class SurfaceEmitter : public Emitter {
  private:
   Mesh *m_mesh;
+  float4x4 m_transform;
   float m_normal_velocity;
 
  public:
-  SurfaceEmitter(Mesh *mesh, float normal_velocity)
-      : m_mesh(mesh), m_normal_velocity(normal_velocity)
+  SurfaceEmitter(Mesh *mesh, float4x4 transform, float normal_velocity)
+      : m_mesh(mesh), m_transform(transform), m_normal_velocity(normal_velocity)
   {
   }
 
@@ -64,8 +65,8 @@ class SurfaceEmitter : public Emitter {
       normal_tri_v3(normal, v1, v2, v3);
 
       float3 pos = (v1 + v2 + v3) / 3.0f;
-      positions.append(pos);
-      velocities.append(normal * m_normal_velocity);
+      positions.append(m_transform.transform_position(pos));
+      velocities.append(m_transform.transform_direction(normal * m_normal_velocity));
     }
 
     auto target = helper.request(positions.size());
@@ -111,9 +112,11 @@ std::unique_ptr<Emitter> EMITTER_point(float3 point)
   return std::unique_ptr<Emitter>(emitter);
 }
 
-std::unique_ptr<Emitter> EMITTER_mesh_surface(Mesh *mesh, float normal_velocity)
+std::unique_ptr<Emitter> EMITTER_mesh_surface(Mesh *mesh,
+                                              const float4x4 &transform,
+                                              float normal_velocity)
 {
-  Emitter *emitter = new SurfaceEmitter(mesh, normal_velocity);
+  Emitter *emitter = new SurfaceEmitter(mesh, transform, normal_velocity);
   return std::unique_ptr<Emitter>(emitter);
 }
 
diff --git a/source/blender/simulations/bparticles/emitters.hpp b/source/blender/simulations/bparticles/emitters.hpp
index c848cd7af6f..285a5726c87 100644
--- a/source/blender/simulations/bparticles/emitters.hpp
+++ b/source/blender/simulations/bparticles/emitters.hpp
@@ -8,7 +8,9 @@ struct Path;
 namespace BParticles {
 
 std::unique_ptr<Emitter> EMITTER_point(float3 point);
-std::unique_ptr<Emitter> EMITTER_mesh_surface(struct Mesh *mesh, float normal_velocity);
+std::unique_ptr<Emitter> EMITTER_mesh_surface(struct Mesh *mesh,
+                                              const float4x4 &transform,
+                                              float normal_velocity);
 std::unique_ptr<Emitter> EMITTER_path(struct Path *path, float4x4 transform);
 
 }  // namespace BParticles



More information about the Bf-blender-cvs mailing list