[Bf-blender-cvs] [3cb9ec1] gooseberry: New option "use signed distance" for force fields with "surface" shape.
Lukas Tönne
noreply at git.blender.org
Wed Feb 18 12:25:36 CET 2015
Commit: 3cb9ec18440c3309d9404d9a1cb4e36097c6ccbd
Author: Lukas Tönne
Date: Wed Feb 18 12:22:59 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB3cb9ec18440c3309d9404d9a1cb4e36097c6ccbd
New option "use signed distance" for force fields with "surface" shape.
By default a surface-based force will push things away from the surface
in both directions, regardless of whether a point is "inside" or
"outside" (judging by the surface normal). The new option makes a force
field always push things away in the direction of the normal, so that
it becomes less likely to get points "trapped" inside a mesh object.
===================================================================
M release/scripts/startup/bl_ui/properties_physics_common.py
M source/blender/blenkernel/intern/effect.c
M source/blender/makesdna/DNA_object_force.h
M source/blender/makesrna/intern/rna_object_force.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py
index bb0f0cf..19533d2 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -315,5 +315,8 @@ def basic_force_field_falloff_ui(self, context, field):
sub.active = field.use_max_distance
sub.prop(field, "distance_max", text="Maximum")
+ if field.shape == 'SURFACE':
+ layout.prop(field, "use_signed_distance")
+
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 76a39fe..a9bf499 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -831,6 +831,10 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
}
copy_v3_v3(force, efd->vec_to_point);
+ if (pd->shape == PFIELD_SHAPE_SURFACE && (pd->flag & PFIELD_USE_SIGNED_DISTANCE)) {
+ if (dot_v3v3(efd->vec_to_point, efd->nor) < 0.0f)
+ mul_v3_fl(force, -1.0f);
+ }
switch (pd->forcefield) {
case PFIELD_WIND:
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index 5cc56d8..fac8443 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -370,6 +370,7 @@ typedef struct SoftBody {
#define PFIELD_DO_ROTATION (1<<15)
#define PFIELD_GUIDE_PATH_WEIGHT (1<<16) /* apply curve weights */
#define PFIELD_SMOKE_DENSITY (1<<17) /* multiply smoke force by density */
+#define PFIELD_USE_SIGNED_DISTANCE (1<<18) /* surface shape: use negative distance on the interior */
/* pd->falloff */
#define PFIELD_FALL_SPHERE 0
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 4cc098f..ac74c7e 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -1337,6 +1337,11 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Use Max", "Use a maximum distance for the field to work");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
+ prop = RNA_def_property(srna, "use_signed_distance", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USE_SIGNED_DISTANCE);
+ RNA_def_property_ui_text(prop, "Use Signed Distance", "Use negative distance on the interior of surface shapes");
+ RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
+
prop = RNA_def_property(srna, "use_radial_min", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMINR);
RNA_def_property_ui_text(prop, "Use Min", "Use a minimum radial distance for the field's fall-off");
More information about the Bf-blender-cvs
mailing list