[Bf-blender-cvs] [326d7fd] gooseberry: Curve-based control for "roughness" (noise displacement) of child hair.
Lukas Tönne
noreply at git.blender.org
Fri Jan 9 15:59:24 CET 2015
Commit: 326d7fd5fd95159c99976ff9df9db6f5836d54c5
Author: Lukas Tönne
Date: Fri Jan 9 15:58:18 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB326d7fd5fd95159c99976ff9df9db6f5836d54c5
Curve-based control for "roughness" (noise displacement) of child hair.
===================================================================
M release/scripts/startup/bl_ui/properties_particle.py
M source/blender/blenkernel/BKE_particle.h
M source/blender/blenkernel/intern/particle.c
M source/blender/blenkernel/intern/particle_child.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/writefile.c
M source/blender/makesdna/DNA_particle_types.h
M source/blender/makesrna/intern/rna_particle.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 95149f3..9a88d53 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -1304,20 +1304,28 @@ class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
sub.prop(part, "child_parting_max", text="Max")
col = split.column()
- col.label(text="Roughness:")
- sub = col.column(align=True)
- sub.prop(part, "roughness_1", text="Uniform")
- sub.prop(part, "roughness_1_size", text="Size")
+ col.prop(part, "use_roughness_curve")
+ if part.use_roughness_curve:
+ sub = col.column()
+ sub.template_curve_mapping(part, "roughness_curve")
+ sub.prop(part, "roughness_1", text="Roughness")
+ sub.prop(part, "roughness_1_size", text="Size")
+ else:
+ col.label(text="Roughness:")
- sub = col.column(align=True)
- sub.prop(part, "roughness_endpoint", "Endpoint")
- sub.prop(part, "roughness_end_shape")
+ sub = col.column(align=True)
+ sub.prop(part, "roughness_1", text="Uniform")
+ sub.prop(part, "roughness_1_size", text="Size")
- sub = col.column(align=True)
- sub.prop(part, "roughness_2", text="Random")
- sub.prop(part, "roughness_2_size", text="Size")
- sub.prop(part, "roughness_2_threshold", slider=True)
+ sub = col.column(align=True)
+ sub.prop(part, "roughness_endpoint", "Endpoint")
+ sub.prop(part, "roughness_end_shape")
+
+ sub = col.column(align=True)
+ sub.prop(part, "roughness_2", text="Random")
+ sub.prop(part, "roughness_2_size", text="Size")
+ sub.prop(part, "roughness_2_threshold", slider=True)
layout.row().label(text="Kink:")
layout.row().prop(part, "kink", expand=True)
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 48fb4e0..4a3d2be 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -346,6 +346,7 @@ int psys_get_particle_state(struct ParticleSimulationData *sim, int p, struct Pa
/* child paths */
void BKE_particlesettings_clump_curve_init(struct ParticleSettings *part);
+void BKE_particlesettings_rough_curve_init(struct ParticleSettings *part);
void psys_apply_child_modifiers(struct ParticleThreadContext *ctx, struct ListBase *modifiers,
struct ChildParticle *cpa, struct ParticleTexture *ptex, const float orco[3], const float ornor[3], float hairmat[4][4],
struct ParticleCacheKey *keys, struct ParticleCacheKey *parent_keys);
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 959203e..90550f4 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -405,6 +405,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);
@@ -1817,6 +1819,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);
@@ -2023,6 +2027,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;
}
@@ -3216,6 +3222,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;
@@ -3229,6 +3247,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 68e11c9..d797669 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);
+ }
}
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index ba574b1..94da9b2 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3824,6 +3824,9 @@ static void direct_link_particlesettings(FileData *fd, ParticleSettings *part)
part->clumpcurve = newdataadr(fd, part->clumpcurve);
if (part->clumpcurve)
direct_link_curvemapping(fd, part->clumpcurve);
+ part->roughcurve = newdataadr(fd, part->roughcurve);
+ if (part->roughcurve)
+ direct_link_curvemapping(fd, part->roughcurve);
part->effector_weights = newdataadr(fd, part->effector_weights);
if (!part->effector_weights)
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 0dcc48b..728b97b 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1110,6 +1110,8 @@ static void write_particlesettings(WriteData *wd, ListBase *idbase)
if (part->clumpcurve)
write_curvemapping(wd, part->clumpcurve);
+ if (part->roughcurve)
+ write_curvemapping(wd, part->roughcurve);
dw = part->dupliweights.first;
for (; dw; dw=dw->next) {
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 408b1c1..1d858fa 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -237,6 +237,7 @@ typedef struct ParticleSettings {
/* keyed particles */
int keyed_loops;
struct CurveMapping *clumpcurve;
+ struct CurveMapping *roughcurve;
/* hair dynamics */
float bending_random;
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index d55cc36..72dadbd 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -980,6 +980,29 @@ void rna_ParticleSettings_use_clump_curve_set(PointerRNA *ptr, int value)
}
}
+int rna_ParticleSettings_use_roughness_curve_get(PointerRNA *ptr)
+{
+ ParticleSettings *part = ptr->data;
+ return part->roughcurve != NULL;
+}
+
+void rna_ParticleSettings_use_roughness_curve_set(PointerRNA *ptr, int value)
+{
+ ParticleSettings *part = ptr->data;
+
+ if (!value) {
+ if (part->roughcurve) {
+ curvemapping_free(part->roughcurve);
+ part->roughcurve = NULL;
+ }
+ }
+ else {
+ if (!part->roughcurve) {
+ BKE_parti
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list