diff options
-rw-r--r-- | release/scripts/ui/properties_physics_common.py | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 10 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_force.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object_force.c | 11 |
4 files changed, 24 insertions, 3 deletions
diff --git a/release/scripts/ui/properties_physics_common.py b/release/scripts/ui/properties_physics_common.py index 26411b227a8..24c822f9ca9 100644 --- a/release/scripts/ui/properties_physics_common.py +++ b/release/scripts/ui/properties_physics_common.py @@ -150,6 +150,7 @@ def basic_force_field_settings_ui(self, context, field): col.prop(field, "flow") elif field.type == 'HARMONIC': col.prop(field, "harmonic_damping", text="Damping") + col.prop(field, "rest_length") elif field.type == 'VORTEX' and field.shape != 'POINT': col.prop(field, "inflow") elif field.type == 'DRAG': @@ -163,6 +164,8 @@ def basic_force_field_settings_ui(self, context, field): col.prop(field, "seed") if field.type == 'TURBULENCE': col.prop(field, "global_coordinates", text="Global") + elif field.type == 'HARMONIC': + col.prop(field, "multiple_springs") split = layout.split() diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 6d63553396d..83f63c9ffb2 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -128,7 +128,6 @@ PartDeflect *object_add_collision_fields(int type) pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128; pd->f_strength = 1.0f; pd->f_damp = 1.0f; - pd->f_size = 1.0f; /* set sensible defaults based on type */ switch(type) { @@ -139,6 +138,9 @@ PartDeflect *object_add_collision_fields(int type) pd->shape = PFIELD_SHAPE_PLANE; pd->f_flow = 1.0f; /* realistic wind behavior */ break; + case PFIELD_TEXTURE: + pd->f_size = 1.0f; + break; } pd->flag = PFIELD_DO_LOCATION|PFIELD_DO_ROTATION; @@ -693,6 +695,10 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin sub_v3_v3v3(efd->vec_to_point, point->loc, efd->loc); efd->distance = len_v3(efd->vec_to_point); + /* rest length for harmonic effector, will have to see later if this could be extended to other effectors */ + if(eff->pd->forcefield == PFIELD_HARMONIC && eff->pd->f_size) + mul_v3_fl(efd->vec_to_point, (efd->distance-eff->pd->f_size)/efd->distance); + if(eff->flag & PE_USE_NORMAL_DATA) { VECCOPY(efd->vec_to_point2, efd->vec_to_point); VECCOPY(efd->nor2, efd->nor); @@ -735,7 +741,7 @@ static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoin */ efd->charge = eff->pd->f_strength; } - else if(eff->pd->forcefield == PFIELD_HARMONIC) { + else if(eff->pd->forcefield == PFIELD_HARMONIC && (eff->pd->flag & PFIELD_MULTIPLE_SPRINGS)==0) { /* every particle is mapped to only one harmonic effector particle */ *p= point->index % eff->psys->totpart; *tot= *p + 1; diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index adccf8893d4..99b8f400a5e 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -71,7 +71,7 @@ typedef struct PartDeflect { float f_flow; /* How much force is converted into "air flow", i.e. */ /* force used as the velocity of surrounding medium. */ - float f_size; + float f_size; /* Noise size for noise effector, restlength for harmonic effector */ /* fall-off */ float f_power; /* The power law - real gravitation is 2 (square) */ @@ -320,6 +320,7 @@ typedef struct SoftBody { #define PFIELD_TEX_OBJECT 64 #define PFIELD_GLOBAL_CO 64 /* used for turbulence */ #define PFIELD_TEX_2D 128 +#define PFIELD_MULTIPLE_SPRINGS 128 /* used for harmonic force */ #define PFIELD_USEMIN 256 #define PFIELD_USEMAXR 512 #define PFIELD_USEMINR 1024 diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 9a57a24e1a7..67c7a9aa078 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -1109,6 +1109,12 @@ static void rna_def_field(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Size", "Size of the noise"); RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); + + prop= RNA_def_property(srna, "rest_length", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "f_size"); + RNA_def_property_range(prop, 0.0f, 1000.0f); + RNA_def_property_ui_text(prop, "Rest Length", "Rest length of the harmonic force"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "falloff_power", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "f_power"); @@ -1221,6 +1227,11 @@ static void rna_def_field(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_VISIBILITY); RNA_def_property_ui_text(prop, "Absorption", "Force gets absorbed by collision objects"); RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); + + prop= RNA_def_property(srna, "multiple_springs", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_MULTIPLE_SPRINGS); + RNA_def_property_ui_text(prop, "Multiple Springs", "Every point is effected by multiple springs"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); /* Pointer */ |