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 | |
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.
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_modifier.py | 16 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_displace.c | 21 |
2 files changed, 25 insertions, 12 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 7485e532bd4..ae0c4d4161c 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -215,6 +215,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.label(text="Face Count" + ": %d" % md.face_count) def DISPLACE(self, layout, ob, md): + has_texture = (md.texture is not None) + split = layout.split() col = split.column() @@ -226,12 +228,18 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col = split.column() col.label(text="Direction:") col.prop(md, "direction", text="") - col.label(text="Texture Coordinates:") - col.prop(md, "texture_coords", text="") + colsub = col.column() + colsub.active = has_texture + colsub.label(text="Texture Coordinates:") + colsub.prop(md, "texture_coords", text="") if md.texture_coords == 'OBJECT': - layout.prop(md, "texture_coords_object", text="Object") + row = layout.row() + row.active = has_texture + row.prop(md, "texture_coords_object", text="Object") elif md.texture_coords == 'UV' and ob.type == 'MESH': - layout.prop_search(md, "uv_layer", ob.data, "uv_textures") + row = layout.row() + row.active = has_texture + row.prop_search(md, "uv_layer", ob.data, "uv_textures") layout.separator() 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; |