Fix hair random rotation limited to 180 degrees

The issue was caused by phase being limited from 0 to 1, which gave only
0..M_PI distribution which is not good enough for good randomness.

Now the phase is being randomized across full 0..2*M_PI range.
This commit is contained in:
Mai Lavelle 2015-04-13 14:14:43 +05:00 committed by Sergey Sharybin
parent 6fbf05f326
commit 176ed5bfe2
Notes: blender-bot 2023-02-14 08:33:26 +01:00
Referenced by commit 4ce437fff0, Revert "Fix hair random rotation limited to 180 degrees"
4 changed files with 11 additions and 3 deletions

View File

@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 274
#define BLENDER_SUBVERSION 4
#define BLENDER_SUBVERSION 5
/* Several breakages with 270, e.g. constraint deg vs rad */
#define BLENDER_MINVERSION 270
#define BLENDER_MINSUBVERSION 5

View File

@ -4100,7 +4100,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
float q_phase[4];
float phasefac = psys->part->phasefac;
if (psys->part->randphasefac != 0.0f)
phasefac += psys->part->randphasefac * psys_frand(psys, (pa - psys->particles) + 20);
phasefac += psys->part->randphasefac * psys_frand(psys, (pa - psys->particles) + 20) * 2.0f;
axis_angle_to_quat(q_phase, vec, phasefac * (float)M_PI);
mul_qt_v3(q_phase, side);

View File

@ -928,7 +928,7 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
/* rotation phase */
phasefac = part->phasefac;
if (part->randphasefac != 0.0f)
phasefac += part->randphasefac * psys_frand(psys, p + 20);
phasefac += part->randphasefac * psys_frand(psys, p + 20) * 2.0f;
axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI);
/* combine base rotation & phase */

View File

@ -799,4 +799,12 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
if (!MAIN_VERSION_ATLEAST(main, 274, 5)) {
/* Particle random phase range doubled. */
ParticleSettings *part;
for (part = main->particle.first; part; part = part->id.next) {
part->randphasefac *= 0.5f;
}
}
}