[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49897] trunk/blender: patch [#32327] Uniform displace modifier

Campbell Barton ideasman42 at gmail.com
Tue Aug 14 19:36:41 CEST 2012


Revision: 49897
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49897
Author:   campbellbarton
Date:     2012-08-14 17:36:41 +0000 (Tue, 14 Aug 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py
    trunk/blender/source/blender/modifiers/intern/MOD_displace.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py	2012-08-14 16:53:40 UTC (rev 49896)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py	2012-08-14 17:36:41 UTC (rev 49897)
@@ -215,6 +215,8 @@
         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 @@
         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()
 

Modified: trunk/blender/source/blender/modifiers/intern/MOD_displace.c
===================================================================
--- trunk/blender/source/blender/modifiers/intern/MOD_displace.c	2012-08-14 16:53:40 UTC (rev 49896)
+++ trunk/blender/source/blender/modifiers/intern/MOD_displace.c	2012-08-14 17:36:41 UTC (rev 49897)
@@ -140,8 +140,7 @@
 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 @@
 	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,18 +191,23 @@
 
 	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);
+		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 */
+		}
 
-		delta = texres.tin - dmd->midlevel;
-
 		if (dvert) strength *= weight;
 
 		delta *= strength;




More information about the Bf-blender-cvs mailing list