[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52023] trunk/blender: add a distance limit to the shrinkwrap modifiers project mode,

Campbell Barton ideasman42 at gmail.com
Fri Nov 9 05:20:22 CET 2012


Revision: 52023
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52023
Author:   campbellbarton
Date:     2012-11-09 04:20:17 +0000 (Fri, 09 Nov 2012)
Log Message:
-----------
add a distance limit to the shrinkwrap modifiers project mode,
it was problematic for vertices to fire rays out and hit some unrelated-far-off geometry which is often not what users want.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py
    trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c
    trunk/blender/source/blender/makesdna/DNA_modifier_types.h
    trunk/blender/source/blender/makesrna/intern/rna_modifier.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-11-09 04:01:19 UTC (rev 52022)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py	2012-11-09 04:20:17 UTC (rev 52023)
@@ -625,6 +625,7 @@
         col.prop(md, "wrap_method", text="")
 
         if md.wrap_method == 'PROJECT':
+            col.prop(md, "project_limit", text="Limit")
             split = layout.split(percentage=0.25)
 
             col = split.column()
@@ -642,8 +643,7 @@
             col.label(text="Cull Faces:")
             col.prop(md, "cull_face", expand=True)
 
-            layout.label(text="Auxiliary Target:")
-            layout.prop(md, "auxiliary_target", text="")
+            layout.prop(md, "auxiliary_target")
 
         elif md.wrap_method == 'NEAREST_SURFACEPOINT':
             layout.prop(md, "use_keep_above_surface")

Modified: trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c	2012-11-09 04:01:19 UTC (rev 52022)
+++ trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c	2012-11-09 04:20:17 UTC (rev 52023)
@@ -277,6 +277,7 @@
 
 	/* Options about projection direction */
 	const char use_normal   = calc->smd->shrinkOpts;
+	const float proj_limit_squared = calc->smd->projLimit * calc->smd->projLimit;
 	float proj_axis[3]      = {0.0f, 0.0f, 0.0f};
 
 	/* Raycast and tree stuff */
@@ -393,6 +394,13 @@
 				                                 treeData.raycast_callback, &treeData);
 			}
 
+			/* don't set the initial dist (which is more efficient),
+			 * because its calculated in the targets space, we want the dist in our own space */
+			if (proj_limit_squared != 0.0f) {
+				if (len_squared_v3v3(hit.co, co) > proj_limit_squared) {
+					hit.index = -1;
+				}
+			}
 
 			if (hit.index != -1) {
 				madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist);

Modified: trunk/blender/source/blender/makesdna/DNA_modifier_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_modifier_types.h	2012-11-09 04:01:19 UTC (rev 52022)
+++ trunk/blender/source/blender/makesdna/DNA_modifier_types.h	2012-11-09 04:20:17 UTC (rev 52023)
@@ -665,7 +665,8 @@
 	float keepDist;			/* distance offset to keep from mesh/projection point */
 	short shrinkType;		/* shrink type projection */
 	short shrinkOpts;		/* shrink options */
-	char projAxis;			/* axis to project over */
+	float projLimit;		/* limit the projection ray cast */
+	char  projAxis;			/* axis to project over */
 
 	/*
 	 * if using projection over vertex normal this controls the
@@ -674,7 +675,7 @@
 	 */
 	char subsurfLevels;
 
-	char pad[6];
+	char pad[2];
 
 } ShrinkwrapModifierData;
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_modifier.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_modifier.c	2012-11-09 04:01:19 UTC (rev 52022)
+++ trunk/blender/source/blender/makesrna/intern/rna_modifier.c	2012-11-09 04:20:17 UTC (rev 52023)
@@ -2400,6 +2400,13 @@
 	RNA_def_property_ui_text(prop, "Offset", "Distance to keep from the target");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+	prop = RNA_def_property(srna, "project_limit", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "projLimit");
+	RNA_def_property_range(prop, 0.0, FLT_MAX);
+	RNA_def_property_ui_range(prop, 0, 100, 1, 2);
+	RNA_def_property_ui_text(prop, "Project Limit", "Limit the distance used for projection (zero disables)");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
 	prop = RNA_def_property(srna, "use_project_x", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "projAxis", MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS);
 	RNA_def_property_ui_text(prop, "X", "");




More information about the Bf-blender-cvs mailing list