diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-19 15:32:53 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-20 11:30:32 +0300 |
commit | 8ac20d1dee6f0a7f9781a0b1270db5104fce2064 (patch) | |
tree | 265de2045f954898d400c4240bf4fe14c8528e19 /source/blender | |
parent | 1a918cb66e45d2bfa1ac2153c08f81b09429695a (diff) |
Use separate flags to enable/disable clump and roughness curves for
child hairs.
This allows disabling the curves temporarily without losing the setup.
Conflicts:
source/blender/blenkernel/BKE_blender.h
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_blender.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 16 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_child.c | 6 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 10 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_particle_types.h | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 44 |
6 files changed, 40 insertions, 44 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 0215becd2a0..3053c9906c2 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 273 -#define BLENDER_SUBVERSION 2 +#define BLENDER_SUBVERSION 3 /* 262 was the last editmesh release but it has compatibility code for bmesh data */ #define BLENDER_MINVERSION 270 #define BLENDER_MINSUBVERSION 5 diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index b146a40db63..c489dced9df 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1754,6 +1754,8 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, int index, float time) { + CurveMapping *clumpcurve = (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) ? part->clumpcurve : NULL; + CurveMapping *roughcurve = (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) ? part->roughcurve : NULL; EffectorCache *eff; PartDeflect *pd; Curve *cu; @@ -1821,10 +1823,10 @@ 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); + if (clumpcurve) + curvemapping_changed_all(clumpcurve); + if (roughcurve) + curvemapping_changed_all(roughcurve); { ParticleKey key; @@ -1836,7 +1838,7 @@ int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, i copy_v3_v3(key.co, vec_to_point); do_kink(&key, par_co, par_vel, par_rot, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, 0.f, pd->kink, pd->kink_axis, 0, 0); do_clump(&key, par_co, guidetime, orco_offset, pd->clump_fac, pd->clump_pow, 1.0f, - part->child_flag & PART_CHILD_USE_CLUMP_NOISE, part->clump_noise_size, part->clumpcurve); + part->child_flag & PART_CHILD_USE_CLUMP_NOISE, part->clump_noise_size, clumpcurve); copy_v3_v3(vec_to_point, key.co); } @@ -2041,9 +2043,9 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx, ParticleSi ctx->vg_effector = psys_cache_vgroup(ctx->dm, psys, PSYS_VG_EFFECTOR); /* prepare curvemapping tables */ - if (part->clumpcurve) + if ((part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && part->clumpcurve) curvemapping_changed_all(part->clumpcurve); - if (part->roughcurve) + if ((part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && part->roughcurve) curvemapping_changed_all(part->roughcurve); return true; diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c index fb877e44eb6..df03f39f62a 100644 --- a/source/blender/blenkernel/intern/particle_child.c +++ b/source/blender/blenkernel/intern/particle_child.c @@ -661,6 +661,8 @@ void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, cons ChildParticle *cpa, const float orco[3], float mat[4][4], ParticleKey *state, float t) { ParticleSettings *part = sim->psys->part; + CurveMapping *clumpcurve = (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) ? part->clumpcurve : NULL; + CurveMapping *roughcurve = (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) ? part->roughcurve : NULL; int i = cpa - sim->psys->child; int guided = 0; @@ -690,7 +692,7 @@ void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, cons sub_v3_v3v3(orco_offset, orco, par_orco); clump = do_clump(state, par_co, t, orco_offset, part->clumpfac, part->clumppow, ptex ? ptex->clump : 1.f, - part->child_flag & PART_CHILD_USE_CLUMP_NOISE, part->clump_noise_size, part->clumpcurve); + part->child_flag & PART_CHILD_USE_CLUMP_NOISE, part->clump_noise_size, clumpcurve); if (kink_freq != 0.f) { kink_amp *= (1.f - kink_amp_clump * clump); @@ -702,7 +704,7 @@ void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, cons } if (part->roughcurve) { - do_rough_curve(orco, mat, t, rough1, part->rough1_size, part->roughcurve, state); + do_rough_curve(orco, mat, t, rough1, part->rough1_size, roughcurve, state); } else { if (rough1 > 0.f) diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 5c0d1537829..29068d21ab3 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -518,4 +518,14 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } } + + if (!MAIN_VERSION_ATLEAST(main, 273, 3)) { + ParticleSettings *part; + for (part = main->particle.first; part; part = part->id.next) { + if (part->clumpcurve) + part->child_flag |= PART_CHILD_USE_CLUMP_CURVE; + if (part->roughcurve) + part->child_flag |= PART_CHILD_USE_ROUGH_CURVE; + } + } } diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 4f8b14a82b8..04408196b56 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -428,9 +428,11 @@ typedef enum eParticleKink { PART_KINK_SPIRAL = 5, } eParticleKink; -/* part->kink_flag */ +/* part->child_flag */ typedef enum eParticleChildFlag { - PART_CHILD_USE_CLUMP_NOISE = 1, + PART_CHILD_USE_CLUMP_NOISE = (1<<0), + PART_CHILD_USE_CLUMP_CURVE = (1<<1), + PART_CHILD_USE_ROUGH_CURVE = (1<<2), } eParticleChildFlag; /* part->draw_col */ diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index b69ede9e935..36444b2642c 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -877,50 +877,30 @@ static int rna_PartSettings_is_fluid_get(PointerRNA *ptr) return part->type == PART_FLUID; } -int rna_ParticleSettings_use_clump_curve_get(PointerRNA *ptr) -{ - ParticleSettings *part = ptr->data; - return part->clumpcurve != NULL; -} - -void rna_ParticleSettings_use_clump_curve_set(PointerRNA *ptr, int value) +static void rna_ParticleSettings_use_clump_curve_update(Main *bmain, Scene *scene, PointerRNA *ptr) { ParticleSettings *part = ptr->data; - if (!value) { - if (part->clumpcurve) { - curvemapping_free(part->clumpcurve); - part->clumpcurve = NULL; - } - } - else { + if (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) { if (!part->clumpcurve) { BKE_particlesettings_clump_curve_init(part); } } + + rna_Particle_redo_child(bmain, scene, ptr); } -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) +static void rna_ParticleSettings_use_roughness_curve_update(Main *bmain, Scene *scene, PointerRNA *ptr) { ParticleSettings *part = ptr->data; - if (!value) { - if (part->roughcurve) { - curvemapping_free(part->roughcurve); - part->roughcurve = NULL; - } - } - else { + if (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) { if (!part->roughcurve) { BKE_particlesettings_rough_curve_init(part); } } + + rna_Particle_redo_child(bmain, scene, ptr); } static void rna_ParticleSystem_name_set(PointerRNA *ptr, const char *value) @@ -2859,9 +2839,9 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); prop = RNA_def_property(srna, "use_clump_curve", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_ParticleSettings_use_clump_curve_get", "rna_ParticleSettings_use_clump_curve_set"); + RNA_def_property_boolean_sdna(prop, NULL, "child_flag", PART_CHILD_USE_CLUMP_CURVE); RNA_def_property_ui_text(prop, "Use Clump Curve", "Use a curve to define clump tapering"); - RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + RNA_def_property_update(prop, 0, "rna_ParticleSettings_use_clump_curve_update"); prop = RNA_def_property(srna, "clump_curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "clumpcurve"); @@ -2979,9 +2959,9 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); prop = RNA_def_property(srna, "use_roughness_curve", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_ParticleSettings_use_roughness_curve_get", "rna_ParticleSettings_use_roughness_curve_set"); + RNA_def_property_boolean_sdna(prop, NULL, "child_flag", PART_CHILD_USE_ROUGH_CURVE); RNA_def_property_ui_text(prop, "Use Roughness Curve", "Use a curve to define roughness"); - RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + RNA_def_property_update(prop, 0, "rna_ParticleSettings_use_roughness_curve_update"); prop = RNA_def_property(srna, "roughness_curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "roughcurve"); |