Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-07-12 12:41:27 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-07-12 12:41:27 +0400
commitce172d60ce2c65bc72ca13804b9ddda21c137aa5 (patch)
tree69c9784dbd690656a30d407c53b560ed57b42f69 /source/blender/blenkernel
parent791be2f79ffcddca1bc8862b03ca8a439f9c3245 (diff)
fix [#36093] Stationary Particle system - particle Y axis fails to follow emitter object rotation
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/particle_system.c52
1 files changed, 46 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index c9be73c4bd4..c150854e293 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -1823,35 +1823,75 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
unit_qt(state->rot);
if (part->rotmode) {
+ bool use_global_space;
+
/* create vector into which rotation is aligned */
switch (part->rotmode) {
case PART_ROT_NOR:
copy_v3_v3(rot_vec, nor);
+ use_global_space = false;
break;
case PART_ROT_VEL:
copy_v3_v3(rot_vec, vel);
+ use_global_space = true;
break;
case PART_ROT_GLOB_X:
case PART_ROT_GLOB_Y:
case PART_ROT_GLOB_Z:
rot_vec[part->rotmode - PART_ROT_GLOB_X] = 1.0f;
+ use_global_space = true;
break;
case PART_ROT_OB_X:
case PART_ROT_OB_Y:
case PART_ROT_OB_Z:
copy_v3_v3(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]);
+ use_global_space = false;
+ break;
+ default:
+ use_global_space = true;
break;
}
/* create rotation quat */
negate_v3(rot_vec);
- vec_to_quat( q2,rot_vec, OB_POSX, OB_POSZ);
- /* randomize rotation quat */
- if (part->randrotfac!=0.0f)
- interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
- else
- copy_qt_qt(rot,q2);
+ if (use_global_space) {
+ /* calculate rotation in global-space */
+ vec_to_quat(q2, rot_vec, OB_POSX, OB_POSZ);
+
+ /* randomize rotation quat */
+ if (part->randrotfac != 0.0f) {
+ interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
+ }
+ else {
+ copy_qt_qt(rot, q2);
+ }
+ }
+ else {
+ /* calculate rotation in local-space */
+ float q_obmat[4];
+ float q_imat[4];
+ float tvec[3];
+
+ mat4_to_quat(q_obmat, ob->obmat);
+ invert_qt_qt(q_imat, q_obmat);
+
+ copy_v3_v3(tvec, rot_vec);
+ mul_qt_v3(q_imat, tvec);
+ normalize_v3(tvec);
+ vec_to_quat(q2, tvec, OB_POSX, OB_POSZ);
+
+ /* randomize rotation quat */
+ if (part->randrotfac != 0.0f) {
+ mul_qt_qtqt(r_rot, r_rot, q_imat);
+ interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
+ }
+ else {
+ copy_qt_qt(rot, q2);
+ }
+
+ mul_qt_qtqt(rot, q_obmat, rot);
+ }
/* rotation phase */
phasefac = part->phasefac;