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:
authorLukas Tönne <lukas.toenne@gmail.com>2015-01-09 17:58:18 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2015-01-20 11:30:09 +0300
commitd1246969ed59ac36ffa332c283fb9d89f365a2b4 (patch)
treec7db4bed9809b33dd2211f66aced9667ec0aa889 /source/blender/blenkernel/intern
parentc86d55d5e77674982a5d1760d8b895bb87af44f5 (diff)
Curve-based control for "roughness" (noise displacement) of child hair.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/particle.c20
-rw-r--r--source/blender/blenkernel/intern/particle_child.c52
2 files changed, 59 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 1001dde2561..2f0fbbb45ea 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -377,6 +377,8 @@ void BKE_particlesettings_free(ParticleSettings *part)
if (part->clumpcurve)
curvemapping_free(part->clumpcurve);
+ if (part->roughcurve)
+ curvemapping_free(part->roughcurve);
free_partdeflect(part->pd);
free_partdeflect(part->pd2);
@@ -1785,6 +1787,8 @@ int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, i
if (part->clumpcurve)
curvemapping_changed_all(part->clumpcurve);
+ if (part->roughcurve)
+ curvemapping_changed_all(part->roughcurve);
par.co[0] = par.co[1] = par.co[2] = 0.0f;
copy_v3_v3(key.co, vec_to_point);
@@ -1991,6 +1995,8 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx, ParticleSi
/* prepare curvemapping tables */
if (part->clumpcurve)
curvemapping_changed_all(part->clumpcurve);
+ if (part->roughcurve)
+ curvemapping_changed_all(part->roughcurve);
return true;
}
@@ -3166,6 +3172,18 @@ void BKE_particlesettings_clump_curve_init(ParticleSettings *part)
part->clumpcurve = cumap;
}
+void BKE_particlesettings_rough_curve_init(ParticleSettings *part)
+{
+ CurveMapping *cumap = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+
+ cumap->cm[0].curve[0].x = 0.0f;
+ cumap->cm[0].curve[0].y = 1.0f;
+ cumap->cm[0].curve[1].x = 1.0f;
+ cumap->cm[0].curve[1].y = 1.0f;
+
+ part->roughcurve = cumap;
+}
+
ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part)
{
ParticleSettings *partn;
@@ -3179,6 +3197,8 @@ ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part)
if (part->clumpcurve)
partn->clumpcurve = curvemapping_copy(part->clumpcurve);
+ if (part->roughcurve)
+ partn->roughcurve = curvemapping_copy(part->roughcurve);
partn->boids = boid_copy_settings(part->boids);
diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c
index 68e11c9368e..d7976699011 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -413,7 +413,7 @@ static void do_rough(const float loc[3], float mat[4][4], float t, float fac, fl
madd_v3_v3fl(state->co, mat[2], fac * rough[2]);
}
-static void do_rough_end(float *loc, float mat[4][4], float t, float fac, float shape, ParticleKey *state)
+static void do_rough_end(const float loc[3], float mat[4][4], float t, float fac, float shape, ParticleKey *state)
{
float rough[2];
float roughfac;
@@ -428,6 +428,27 @@ static void do_rough_end(float *loc, float mat[4][4], float t, float fac, float
madd_v3_v3fl(state->co, mat[1], rough[1]);
}
+static void do_rough_curve(const float loc[3], float mat[4][4], float time, float fac, float size, CurveMapping *roughcurve, ParticleKey *state)
+{
+ float rough[3];
+ float rco[3];
+
+ if (!roughcurve)
+ return;
+
+ fac *= CLAMPIS(curvemapping_evaluateF(roughcurve, 0, time), 0.0f, 1.0f);
+
+ copy_v3_v3(rco, loc);
+ mul_v3_fl(rco, time);
+ rough[0] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2, 0, 2);
+ rough[1] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2, 0, 2);
+ rough[2] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2, 0, 2);
+
+ madd_v3_v3fl(state->co, mat[0], fac * rough[0]);
+ madd_v3_v3fl(state->co, mat[1], fac * rough[1]);
+ madd_v3_v3fl(state->co, mat[2], fac * rough[2]);
+}
+
void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, const float orco[3], float mat[4][4], ParticleKey *state, float t)
{
ParticleSettings *part = sim->psys->part;
@@ -462,18 +483,23 @@ void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, Part
}
}
- if (rough1 > 0.f)
- do_rough(orco, mat, t, rough1, part->rough1_size, 0.0, state);
-
- if (rough2 > 0.f) {
- float vec[3];
- psys_frand_vec(sim->psys, i + 27, vec);
- do_rough(vec, mat, t, rough2, part->rough2_size, part->rough2_thres, state);
+ if (part->roughcurve) {
+ do_rough_curve(orco, mat, t, rough1, part->rough1_size, part->roughcurve, state);
}
-
- if (rough_end > 0.f) {
- float vec[3];
- psys_frand_vec(sim->psys, i + 27, vec);
- do_rough_end(vec, mat, t, rough_end, part->rough_end_shape, state);
+ else {
+ if (rough1 > 0.f)
+ do_rough(orco, mat, t, rough1, part->rough1_size, 0.0, state);
+
+ if (rough2 > 0.f) {
+ float vec[3];
+ psys_frand_vec(sim->psys, i + 27, vec);
+ do_rough(vec, mat, t, rough2, part->rough2_size, part->rough2_thres, state);
+ }
+
+ if (rough_end > 0.f) {
+ float vec[3];
+ psys_frand_vec(sim->psys, i + 27, vec);
+ do_rough_end(vec, mat, t, rough_end, part->rough_end_shape, state);
+ }
}
}