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.
This commit is contained in:
Campbell Barton
2012-11-09 04:20:17 +00:00
parent 11a5c909f8
commit 56ae13be99
4 changed files with 20 additions and 4 deletions

View File

@@ -625,6 +625,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
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 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
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")

View File

@@ -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);

View File

@@ -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;

View File

@@ -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", "");