Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-11-09 08:20:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-09 08:20:17 +0400
commit56ae13be991ea652e90c06737ba59c5975bbee14 (patch)
tree17743bf516da0d492207122ec96cb96be93311d5 /source
parent11a5c909f86e26ff00883be4b1dfcdac1f699717 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c8
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h5
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c7
3 files changed, 18 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index c71de01103f..72db34d339c 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -277,6 +277,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
/* 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 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
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);
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index c9e929ce41b..2c896e4893f 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -665,7 +665,8 @@ typedef struct ShrinkwrapModifierData {
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 @@ typedef struct ShrinkwrapModifierData {
*/
char subsurfLevels;
- char pad[6];
+ char pad[2];
} ShrinkwrapModifierData;
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index d421eb697a3..2e3f8feda44 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -2400,6 +2400,13 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna)
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", "");