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:
authorJanne Karhu <jhkarh@gmail.com>2009-12-21 14:19:07 +0300
committerJanne Karhu <jhkarh@gmail.com>2009-12-21 14:19:07 +0300
commit5832f2fb7bd396e45690b1765103d4136694845a (patch)
tree588cc073378aac2f8b145921d89e31ecb32be64d /source
parent0c859f836ba0df60d19a23568c044f17807d227d (diff)
* Rest length parameter for harmonic force springs. Implementation is a slightly modified version of the patch provided by Raúl Fernández Hernández (Farsthary).
* Also added a "multiple springs" option to use every effector point as a harmonic spring instead of just one.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/effect.c10
-rw-r--r--source/blender/makesdna/DNA_object_force.h3
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c11
3 files changed, 21 insertions, 3 deletions
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 */