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:
authorDaniel Genrich <daniel.genrich@gmx.net>2008-08-19 15:26:18 +0400
committerDaniel Genrich <daniel.genrich@gmx.net>2008-08-19 15:26:18 +0400
commit7f49f6735288418af81d80c99f6127c31a2ed3d4 (patch)
treeeea4ba67bdda15f0a2d378c1fb340832839c42b6 /source
parenta7f5109f23ea4f362bdf7dbd6c4482634bc65b6b (diff)
Particles now got that force-hiding feature, too --> jahka: please take a look :)
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_effect.h2
-rw-r--r--source/blender/blenkernel/intern/effect.c129
-rw-r--r--source/blender/blenkernel/intern/implicit.c1
-rw-r--r--source/blender/blenkernel/intern/particle_system.c4
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h2
-rw-r--r--source/blender/src/buttons_object.c2
6 files changed, 72 insertions, 68 deletions
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index cc1c8c1d708..5d3a0fba45f 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -66,7 +66,7 @@ void pdEndEffectors(struct ListBase *lb);
void pdDoEffectors(struct ListBase *lb, float *opco, float *force, float *speed, float cur_time, float loc_time, unsigned int flags);
/* required for particle_system.c */
-void do_physical_effector(short type, float force_val, float distance, float falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, struct RNG *rng, float noise_factor);
+void do_physical_effector(Object *ob, float *opco, short type, float force_val, float distance, float falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, struct RNG *rng, float noise_factor);
float effector_falloff(struct PartDeflect *pd, float *eff_velocity, float *vec_to_part);
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 890e488efcd..accc16ea940 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -229,6 +229,60 @@ void pdEndEffectors(ListBase *lb)
/* Effectors */
/************************************************/
+// triangle - ray callback function
+static void eff_tri_ray_hit(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
+{
+ // whenever we hit a bounding box, we don't check further
+ hit->dist = -1;
+ hit->index = 1;
+}
+
+// get visibility of a wind ray
+static float eff_calc_visibility(Object *ob, float *co, float *dir)
+{
+ CollisionModifierData **collobjs = NULL;
+ int numcollobj = 0, i;
+ float norm[3], len = 0.0;
+ float visibility = 1.0;
+
+ collobjs = get_collisionobjects(ob, &numcollobj);
+
+ if(!collobjs)
+ return 0;
+
+ VECCOPY(norm, dir);
+ VecMulf(norm, -1.0);
+ len = Normalize(norm);
+
+ // check all collision objects
+ for(i = 0; i < numcollobj; i++)
+ {
+ CollisionModifierData *collmd = collobjs[i];
+
+ if(collmd->bvhtree)
+ {
+ BVHTreeRayHit hit;
+
+ hit.index = -1;
+ hit.dist = len + FLT_EPSILON;
+
+ // check if the way is blocked
+ if(BLI_bvhtree_ray_cast(collmd->bvhtree, co, norm, &hit, eff_tri_ray_hit, NULL)>=0)
+ {
+ // visibility is only between 0 and 1, calculated from 1-absorption
+ visibility *= MAX2(0.0, MIN2(1.0, (1.0-((float)collmd->absorption)*0.01)));
+
+ if(visibility <= 0.0f)
+ break;
+ }
+ }
+ }
+
+ MEM_freeN(collobjs);
+
+ return visibility;
+}
+
// noise function for wind e.g.
static float wind_func(struct RNG *rng, float strength)
{
@@ -315,12 +369,18 @@ float effector_falloff(PartDeflect *pd, float *eff_velocity, float *vec_to_part)
return falloff;
}
-void do_physical_effector(short type, float force_val, float distance, float falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, struct RNG *rng, float noise_factor)
+void do_physical_effector(Object *ob, float *opco, short type, float force_val, float distance, float falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, struct RNG *rng, float noise_factor)
{
float mag_vec[3]={0,0,0};
float temp[3], temp2[3];
float eff_vel[3];
- float noise = 0;
+ float noise = 0, visibility;
+
+ // calculate visibility
+ visibility = eff_calc_visibility(ob, opco, vec_to_part);
+ if(visibility <= 0.0)
+ return;
+ falloff *= visibility;
VecCopyf(eff_vel,eff_velocity);
Normalize(eff_vel);
@@ -330,7 +390,7 @@ void do_physical_effector(short type, float force_val, float distance, float fal
VECCOPY(mag_vec,eff_vel);
// add wind noise here, only if we have wind
- if((noise_factor> 0.0f) && (force_val > FLT_EPSILON))
+ if((noise_factor > 0.0f) && (force_val > FLT_EPSILON))
noise = wind_func(rng, noise_factor);
VecMulf(mag_vec,(force_val+noise)*falloff);
@@ -393,56 +453,6 @@ void do_physical_effector(short type, float force_val, float distance, float fal
}
}
-
-static void eff_tri_ray_hit(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
-{
- hit->dist = -1;
- hit->index = 1;
-}
-
-float eff_calc_visibility(Object *ob, float *co, float *dir, float cur_time)
-{
- CollisionModifierData **collobjs = NULL;
- int numcollobj = 0, i;
- float norm[3], len = 0.0;
- float visibility = 1.0;
-
- collobjs = get_collisionobjects(ob, &numcollobj);
-
- if(!collobjs)
- return 0;
-
- VECCOPY(norm, dir);
- VecMulf(norm, -1.0);
- len = Normalize(norm);
-
- // check all collision objects
- for(i = 0; i < numcollobj; i++)
- {
- CollisionModifierData *collmd = collobjs[i];
-
- if(collmd->bvhtree)
- {
- BVHTreeRayHit hit;
-
- hit.index = -1;
- hit.dist = len + FLT_EPSILON;
-
-
- // check if the way is blocked
- if(BLI_bvhtree_ray_cast(collmd->bvhtree, co, norm, &hit, eff_tri_ray_hit, NULL)>=0)
- {
- visibility *= MAX2(0.0, MIN2(1.0, (1.0-((float)collmd->absorbation)*0.01)));
- }
- }
- }
-
- MEM_freeN(collobjs);
-
- return visibility;
-}
-
-
/* -------- pdDoEffectors() --------
generic force/speed system, now used for particles and softbodies
lb = listbase with objects that take part in effecting
@@ -478,7 +488,7 @@ void pdDoEffectors(ListBase *lb, float *opco, float *force, float *speed, float
float *obloc;
float distance, vec_to_part[3];
- float falloff, visibility;
+ float falloff;
/* Cycle through collected objects, get total of (1/(gravity_strength * dist^gravity_power)) */
/* Check for min distance here? (yes would be cool to add that, ton) */
@@ -499,20 +509,15 @@ void pdDoEffectors(ListBase *lb, float *opco, float *force, float *speed, float
VecSubf(vec_to_part, opco, ob->obmat[3]);
distance = VecLength(vec_to_part);
- falloff=effector_falloff(pd,ob->obmat[2],vec_to_part);
+ falloff=effector_falloff(pd,ob->obmat[2],vec_to_part);
if(falloff<=0.0f)
- continue;
-
- visibility = eff_calc_visibility(ob, opco, vec_to_part, cur_time);
-
- if((visibility*falloff)<=0.0f)
; /* don't do anything */
else {
float field[3]={0,0,0}, tmp[3];
VECCOPY(field, force);
- do_physical_effector(pd->forcefield,pd->f_strength,distance,
- visibility*falloff,pd->f_dist,pd->f_damp,ob->obmat[2],vec_to_part,
+ do_physical_effector(ob, opco, pd->forcefield,pd->f_strength,distance,
+ falloff,pd->f_dist,pd->f_damp,ob->obmat[2],vec_to_part,
speed,force,pd->flag&PFIELD_PLANAR, pd->rng, pd->f_noise);
// for softbody backward compatibility
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index 47853363e4b..93e35a4db06 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -1405,7 +1405,6 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec
unsigned int numverts = cloth->numverts;
LinkNode *search = cloth->springs;
lfVector *winvec;
- ClothVertex *verts = cloth->verts;
VECCOPY(gravity, clmd->sim_parms->gravity);
mul_fvector_S(gravity, gravity, 0.001f); /* scale gravity force */
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 3fae574b413..8e5b011211b 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -2616,7 +2616,7 @@ void do_effectors(int pa_no, ParticleData *pa, ParticleKey *state, Object *ob, P
pd->flag & PFIELD_TEX_OBJECT, (pd->flag & PFIELD_TEX_ROOTCO) ? rootco : state->co, eob->obmat,
pd->f_strength, falloff, force_field);
} else {
- do_physical_effector(pd->forcefield,pd->f_strength,distance,
+ do_physical_effector(eob, state->co, pd->forcefield,pd->f_strength,distance,
falloff,pd->f_dist,pd->f_damp,eob->obmat[2],vec_to_part,
pa->state.vel,force_field,pd->flag&PFIELD_PLANAR, pd->rng, pd->f_noise);
}
@@ -2665,7 +2665,7 @@ void do_effectors(int pa_no, ParticleData *pa, ParticleKey *state, Object *ob, P
if(falloff<=0.0f)
; /* don't do anything */
else
- do_physical_effector(pd->forcefield,pd->f_strength,distance,
+ do_physical_effector(eob, state->co, pd->forcefield,pd->f_strength,distance,
falloff,epart->size,pd->f_damp,estate.vel,vec_to_part,
state->vel,force_field,0, pd->rng, pd->f_noise);
}
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 70193077b74..d8cc7633fb3 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -390,7 +390,7 @@ typedef struct CollisionModifierData {
unsigned int numverts;
unsigned int numfaces;
- short absorbation; /* used for forces, in % */
+ short absorption; /* used for forces, in % */
short pad;
float time; /* cfra time of modifier */
struct BVHTree *bvhtree; /* bounding volume hierarchy for this cloth object */
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index 521ab83d3a6..98476cb5cd3 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -3306,7 +3306,7 @@ static void object_panel_collision(Object *ob)
// collision options
if(collmd)
{
- uiDefButS(block, NUM, B_FIELD_CHANGE, "Absoption: ", 10,0,150,20, &collmd->absorbation, 0.0, 100, 1, 2, "How much of effector force gets lost during collision with this object (in percent).");
+ uiDefButS(block, NUM, B_FIELD_CHANGE, "Absorption: ", 10,0,150,20, &collmd->absorption, 0.0, 100, 1, 2, "How much of effector force gets lost during collision with this object (in percent).");
}
}
}