Commit: e8ddfb1fe24962c1966a50c055862d351e35308f
Author: Lukas Tönne
Date:   Mon Nov 17 17:45:21 2014 +0100
Branches: gooseberry
https://developer.blender.org/rBe8ddfb1fe24962c1966a50c055862d351e35308f

Fix for particle instance initial frames.

These were not orthonormal and tended to flip with changing hair
direction, now use the particle hair matrix which is stable wrt. the
mesh surface.

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

M       source/blender/modifiers/intern/MOD_particleinstance.c

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

diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c 
b/source/blender/modifiers/intern/MOD_particleinstance.c
index 2f49209..bc3ff7c 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -43,6 +43,7 @@
 #include "BLI_utildefines.h"
 
 #include "BKE_cdderivedmesh.h"
+#include "BKE_effect.h"
 #include "BKE_global.h"
 #include "BKE_lattice.h"
 #include "BKE_modifier.h"
@@ -329,17 +330,11 @@ static DerivedMesh *applyModifier(ModifierData *md, 
Object *ob,
 
                                /* Incrementally Rotating Frame (Bishop Frame) 
*/
                                if (k == 0) {
+                                       float hairmat[4][4];
                                        float mat[3][3];
-                                       float temp[3] = {0.0f, 0.0f, 0.0f};
-                                       temp[axis] = 1.0f;
                                        
-                                       /* normal direction */
-                                       copy_v3_v3(mat[0], state.vel);
-                                       /* tangent from projecting axis onto 
the surface plane */
-                                       project_v3_plane(mat[1], state.vel, 
temp);
-                                       normalize_v3(mat[1]);
-                                       /* cotangent */
-                                       cross_v3_v3v3(mat[2], mat[0], mat[1]);
+                                       psys_mat_hair_to_global(sim.ob, 
sim.psmd->dm, sim.psys->part->from, pa, hairmat);
+                                       copy_m3_m4(mat, hairmat);
                                        /* to quaternion */
                                        mat3_to_quat(frame, mat);
                                        
@@ -357,7 +352,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object 
*ob,
                                        mul_qt_qtqt(frame, rot, frame);
                                        
                                        copy_v3_v3(prev_dir, state.vel);
-                                       }
+                               }
                                
                                copy_qt_qt(state.rot, frame);
 #if 0

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to