Simple hair children: Make twist affected by texture
This completes twist feature, which is now possible to also control by texture. Since textures can not easily contain negative values as well, same trick with 0.5 neutral as vertex groups is used. All in all, this twist features allows to do following things. Original hair: {F2287535} Hair with scientifically calculated twist value of 0.5: {F2287540} And we can also twist braids in opposite directions dependent on left/right side: {F2287548}
This commit is contained in:
parent
5ce6ca0536
commit
6d4022f619
|
@ -1173,6 +1173,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel):
|
|||
col = split.column()
|
||||
factor_but(col, "use_map_length", "length_factor", "Length")
|
||||
factor_but(col, "use_map_clump", "clump_factor", "Clump")
|
||||
factor_but(col, "use_map_twist", "twist_factor", "Twist")
|
||||
|
||||
col = split.column()
|
||||
factor_but(col, "use_map_kink_amp", "kink_amp_factor", "Kink Amplitude")
|
||||
|
|
|
@ -3568,6 +3568,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
|
|||
SET_PARTICLE_TEXTURE(PAMAP_KINK_AMP, ptex->kink_amp, mtex->kinkampfac);
|
||||
SET_PARTICLE_TEXTURE(PAMAP_KINK_FREQ, ptex->kink_freq, mtex->kinkfac);
|
||||
SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac);
|
||||
SET_PARTICLE_TEXTURE(PAMAP_TWIST, ptex->twist, mtex->twistfac);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3668,6 +3669,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
|
|||
SET_PARTICLE_TEXTURE(PAMAP_GRAVITY, ptex->gravity, mtex->gravityfac);
|
||||
SET_PARTICLE_TEXTURE(PAMAP_DAMP, ptex->damp, mtex->dampfac);
|
||||
SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac);
|
||||
SET_PARTICLE_TEXTURE(PAMAP_TWIST, ptex->twist, mtex->twistfac);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -358,6 +358,7 @@ void psys_apply_child_modifiers(ParticleThreadContext *ctx, struct ListBase *mod
|
|||
totkeys = ctx->segments + 1;
|
||||
max_length = ptex->length;
|
||||
|
||||
printf("%f\n", ptex->twist);
|
||||
for (k = 0, key = keys; k < totkeys; k++, key++) {
|
||||
ParticlePathIterator iter;
|
||||
psys_path_iter_get(&iter, keys, totkeys, parent_keys, k);
|
||||
|
|
|
@ -412,6 +412,7 @@ void BKE_texture_mtex_default(MTex *mtex)
|
|||
mtex->kinkfac = 1.0f;
|
||||
mtex->kinkampfac = 1.0f;
|
||||
mtex->roughfac = 1.0f;
|
||||
mtex->twistfac = 1.0f;
|
||||
mtex->padensfac = 1.0f;
|
||||
mtex->lifefac = 1.0f;
|
||||
mtex->sizefac = 1.0f;
|
||||
|
|
|
@ -614,7 +614,8 @@ typedef enum eParticleTextureInfluence {
|
|||
PAMAP_KINK_AMP = (1<<12),
|
||||
PAMAP_ROUGH = (1<<9),
|
||||
PAMAP_LENGTH = (1<<4),
|
||||
PAMAP_CHILD = (PAMAP_CLUMP | PAMAP_KINK_FREQ | PAMAP_KINK_AMP | PAMAP_ROUGH | PAMAP_LENGTH),
|
||||
PAMAP_TWIST = (1<<13),
|
||||
PAMAP_CHILD = (PAMAP_CLUMP | PAMAP_KINK_FREQ | PAMAP_KINK_AMP | PAMAP_ROUGH | PAMAP_LENGTH | PAMAP_TWIST),
|
||||
} eParticleTextureInfluence;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -86,7 +86,7 @@ typedef struct MTex {
|
|||
float timefac, lengthfac, clumpfac, dampfac;
|
||||
float kinkfac, kinkampfac, roughfac, padensfac, gravityfac;
|
||||
float lifefac, sizefac, ivelfac, fieldfac;
|
||||
int pad2;
|
||||
float twistfac;
|
||||
|
||||
/* lamp */
|
||||
float shadowfac;
|
||||
|
|
|
@ -1894,6 +1894,10 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Length", "Affect the child hair length");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
|
||||
|
||||
prop = RNA_def_property(srna, "use_map_twist", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_TWIST);
|
||||
RNA_def_property_ui_text(prop, "Twist", "Affect the child twist");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
|
||||
|
||||
/* influence factors */
|
||||
prop = RNA_def_property(srna, "time_factor", PROP_FLOAT, PROP_NONE);
|
||||
|
@ -1975,6 +1979,12 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna)
|
|||
RNA_def_property_ui_range(prop, 0, 1, 10, 3);
|
||||
RNA_def_property_ui_text(prop, "Rough Factor", "Amount texture affects child roughness");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
|
||||
|
||||
prop = RNA_def_property(srna, "twist_factor", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "twistfac");
|
||||
RNA_def_property_ui_range(prop, 0, 1, 10, 3);
|
||||
RNA_def_property_ui_text(prop, "Twist Factor", "Amount texture affects child twist");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
|
||||
}
|
||||
|
||||
static void rna_def_particle_settings(BlenderRNA *brna)
|
||||
|
|
Loading…
Reference in New Issue