diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-14 21:36:41 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-14 21:36:41 +0400 |
commit | 3220ef9d952b71c397849ea64abb882ea65b4d48 (patch) | |
tree | f5d6aba3ba667f275d53da2ada8b82080a285703 /source/blender/modifiers | |
parent | 211d30ea7f4abda6763aa6ee3eae840466eb05cc (diff) |
patch [#32327] Uniform displace modifier
from Fredrik Hansson (fredrikh)
With some edits for python UI.
The patch makes the displace modifier treat an empty texture as white.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_displace.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 01592d63bb2..41ac654fc41 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -140,8 +140,7 @@ static void foreachTexLink(ModifierData *md, Object *ob, static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { DisplaceModifierData *dmd = (DisplaceModifierData *) md; - - return (!dmd->texture || dmd->strength == 0.0f); + return ((!dmd->texture && dmd->direction == MOD_DISP_DIR_RGB_XYZ) || dmd->strength == 0.0f); } static void updateDepgraph(ModifierData *md, DagForest *forest, @@ -176,8 +175,9 @@ static void displaceModifier_do( int defgrp_index; float (*tex_co)[3]; float weight = 1.0f; /* init value unused but some compilers may complain */ + const float delta_fixed = 1.0f - dmd->midlevel; /* when no texture is used, we*/ - if (!dmd->texture) return; + if (!dmd->texture && dmd->direction == MOD_DISP_DIR_RGB_XYZ) return; if (dmd->strength == 0.0f) return; mvert = CDDM_get_verts(dm); @@ -191,17 +191,22 @@ static void displaceModifier_do( for (i = 0; i < numVerts; i++) { TexResult texres; - float delta = 0, strength = dmd->strength; + float strength = dmd->strength; + float delta; if (dvert) { weight = defvert_find_weight(dvert + i, defgrp_index); if (weight == 0.0f) continue; } - texres.nor = NULL; - get_texture_value(dmd->texture, tex_co[i], &texres); - - delta = texres.tin - dmd->midlevel; + if (dmd->texture) { + texres.nor = NULL; + get_texture_value(dmd->texture, tex_co[i], &texres); + delta = texres.tin - dmd->midlevel; + } + else { + delta = delta_fixed; /* (1.0f - dmd->midlevel) */ /* never changes */ + } if (dvert) strength *= weight; |