diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2018-07-08 13:47:26 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2018-10-01 15:47:03 +0300 |
commit | e38a0b3748683a35601c256053f716ad8b57002f (patch) | |
tree | 940e008c1259316cf58921538b96b208fce84da0 /source/blender/makesrna/intern | |
parent | be0e58d980d963c60869c412ada86641baaa2e48 (diff) |
Shrinkwrap Constraint: implement projection features from the modifier.
Allow raycasting in two directions and culling front or back faces.
Also implement a new Invert Cull option in both constraint and
modifier that can be used to aim for faces aligned with the project
axis direction when raycasting both ways.
Reviewers: mont29
Differential Revision: https://developer.blender.org/D3737
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_constraint.c | 40 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 11 |
2 files changed, 47 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 39966983a8a..ba87d08fdac 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -396,6 +396,20 @@ static void rna_SplineIKConstraint_joint_bindings_set(PointerRNA *ptr, const flo memcpy(ikData->points, values, ikData->numpoints * sizeof(float)); } +static int rna_ShrinkwrapConstraint_face_cull_get(PointerRNA *ptr) +{ + bConstraint *con = (bConstraint *)ptr->data; + bShrinkwrapConstraint *swc = (bShrinkwrapConstraint *)con->data; + return swc->flag & CON_SHRINKWRAP_PROJECT_CULL_MASK; +} + +static void rna_ShrinkwrapConstraint_face_cull_set(struct PointerRNA *ptr, int value) +{ + bConstraint *con = (bConstraint *)ptr->data; + bShrinkwrapConstraint *swc = (bShrinkwrapConstraint *)con->data; + swc->flag = (swc->flag & ~CON_SHRINKWRAP_PROJECT_CULL_MASK) | value; +} + static bool rna_Constraint_cameraObject_poll(PointerRNA *ptr, PointerRNA value) { Object *ob = (Object *)value.data; @@ -1916,6 +1930,13 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static const EnumPropertyItem shrink_face_cull_items[] = { + {0, "OFF", 0, "Off", "No culling"}, + {CON_SHRINKWRAP_PROJECT_CULL_FRONTFACE, "FRONT", 0, "Front", "No projection when in front of the face"}, + {CON_SHRINKWRAP_PROJECT_CULL_BACKFACE, "BACK", 0, "Back", "No projection when behind the face"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "ShrinkwrapConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Shrinkwrap Constraint", "Create constraint-based shrinkwrap relationship"); RNA_def_struct_sdna_from(srna, "bShrinkwrapConstraint", "data"); @@ -1965,6 +1986,25 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0.0f, 100.0f, 10, 3); RNA_def_property_ui_text(prop, "Project Distance", "Limit the distance used for projection (zero disables)"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "use_project_opposite", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CON_SHRINKWRAP_PROJECT_OPPOSITE); + RNA_def_property_ui_text(prop, "Project Opposite", "Project in both specified and opposite directions"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "cull_face", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, shrink_face_cull_items); + RNA_def_property_enum_funcs(prop, "rna_ShrinkwrapConstraint_face_cull_get", + "rna_ShrinkwrapConstraint_face_cull_set", NULL); + RNA_def_property_ui_text(prop, "Face Cull", + "Stop vertices from projecting to a face on the target when facing towards/away"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "use_invert_cull", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CON_SHRINKWRAP_PROJECT_INVERT_CULL); + RNA_def_property_ui_text(prop, "Invert Cull", "When projecting in the opposite direction invert the face cull mode"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_damped_track(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 1755a37016a..bbb6eae8945 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -714,15 +714,13 @@ static int rna_MultiresModifier_filepath_length(PointerRNA *ptr) static int rna_ShrinkwrapModifier_face_cull_get(PointerRNA *ptr) { ShrinkwrapModifierData *swm = (ShrinkwrapModifierData *)ptr->data; - return swm->shrinkOpts & (MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE | MOD_SHRINKWRAP_CULL_TARGET_BACKFACE); + return swm->shrinkOpts & MOD_SHRINKWRAP_CULL_TARGET_MASK; } static void rna_ShrinkwrapModifier_face_cull_set(struct PointerRNA *ptr, int value) { ShrinkwrapModifierData *swm = (ShrinkwrapModifierData *)ptr->data; - - swm->shrinkOpts = - (swm->shrinkOpts & ~(MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE | MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) | value; + swm->shrinkOpts = (swm->shrinkOpts & ~MOD_SHRINKWRAP_CULL_TARGET_MASK) | value; } static bool rna_MeshDeformModifier_is_bound_get(PointerRNA *ptr) @@ -3273,6 +3271,11 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Positive", "Allow vertices to move in the positive direction of axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "use_invert_cull", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shrinkOpts", MOD_SHRINKWRAP_INVERT_CULL_TARGET); + RNA_def_property_ui_text(prop, "Invert Cull", "When projecting in the negative direction invert the face cull mode"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "shrinkOpts", MOD_SHRINKWRAP_INVERT_VGROUP); RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence"); |