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
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2011-02-27 09:19:40 +0300
committerJoseph Eagar <joeedh@gmail.com>2011-02-27 09:19:40 +0300
commitf01261d040be27337db9f9996d648a279c89b7c4 (patch)
treec448230939b3c90d53ce8852dd00925d6052e3a4 /source/blender/blenkernel/intern/effect.c
parentdcaeda5c4e3a0687251b8511de4f2e8b85ef75c0 (diff)
parent2198cfdb2deec8b2e85e242c74a032f43d0b26ca (diff)
merge with/from trunk at r35190
Diffstat (limited to 'source/blender/blenkernel/intern/effect.c')
-rw-r--r--source/blender/blenkernel/intern/effect.c63
1 files changed, 41 insertions, 22 deletions
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index fba96d2fd8f..5d8401d7a43 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -29,6 +29,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <math.h>
@@ -58,6 +59,7 @@
#include "BLI_listbase.h"
#include "BLI_noise.h"
#include "BLI_rand.h"
+#include "BLI_utildefines.h"
#include "PIL_time.h"
@@ -85,8 +87,7 @@
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_scene.h"
-#include "BKE_screen.h"
-#include "BKE_utildefines.h"
+
#include "RE_render_ext.h"
#include "RE_shader_ext.h"
@@ -165,7 +166,7 @@ PartEff *give_parteff(Object *ob)
if(paf->type==EFF_PARTICLE) return paf;
paf= paf->next;
}
- return 0;
+ return NULL;
}
void free_effect(Effect *eff)
@@ -264,6 +265,9 @@ static void add_object_to_effectors(ListBase **effectors, Scene *scene, Effector
eff = new_effector_cache(scene, ob, NULL, ob->pd);
+ /* make sure imat is up to date */
+ invert_m4_m4(ob->imat, ob->obmat);
+
BLI_addtail(*effectors, eff);
}
static void add_particles_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src)
@@ -410,7 +414,7 @@ void pd_point_from_soft(Scene *scene, float *loc, float *vel, int index, Effecte
/************************************************/
// triangle - ray callback function
-static void eff_tri_ray_hit(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
+static void eff_tri_ray_hit(void *UNUSED(userData), int UNUSED(index), const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit)
{
// whenever we hit a bounding box, we don't check further
hit->dist = -1;
@@ -429,7 +433,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
return visibility;
if(!colls)
- colls = get_collider_cache(eff->scene, NULL, NULL);
+ colls = get_collider_cache(eff->scene, eff->ob, NULL);
if(!colls)
return visibility;
@@ -515,7 +519,7 @@ static float falloff_func_rad(PartDeflect *pd, float fac)
return falloff_func(fac, pd->flag&PFIELD_USEMINR, pd->minrad, pd->flag&PFIELD_USEMAXR, pd->maxrad, pd->f_power_r);
}
-float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, EffectorWeights *weights)
+float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNUSED(point), EffectorWeights *weights)
{
float temp[3];
float falloff = weights ? weights->weight[0] * weights->weight[eff->pd->forcefield] : 1.0f;
@@ -625,7 +629,6 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
}
}
else if(eff->psys) {
- ParticleSimulationData sim = {eff->scene, eff->ob, eff->psys, NULL, NULL};
ParticleData *pa = eff->psys->particles + *efd->index;
ParticleKey state;
@@ -633,6 +636,11 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
if(eff->psys == point->psys && *efd->index == point->index)
;
else {
+ ParticleSimulationData sim= {NULL};
+ sim.scene= eff->scene;
+ sim.ob= eff->ob;
+ sim.psys= eff->psys;
+
/* TODO: time from actual previous calculated frame (step might not be 1) */
state.time = cfra - 1.0;
ret = psys_get_particle_state(&sim, *efd->index, &state, 0);
@@ -643,11 +651,15 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
// eff->flag |= PE_VELOCITY_TO_IMPULSE;
//}
- VECCOPY(efd->loc, state.co);
- VECCOPY(efd->nor, state.vel);
- if(real_velocity) {
- VECCOPY(efd->vel, state.vel);
- }
+ copy_v3_v3(efd->loc, state.co);
+
+ /* rather than use the velocity use rotated x-axis (defaults to velocity) */
+ efd->nor[0] = 1.f;
+ efd->nor[1] = efd->nor[2] = 0.f;
+ mul_qt_v3(state.rot, efd->nor);
+
+ if(real_velocity)
+ copy_v3_v3(efd->vel, state.vel);
efd->size = pa->size;
}
@@ -667,10 +679,10 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
/* for vortex the shape chooses between old / new force */
if(eff->pd && eff->pd->shape == PFIELD_SHAPE_PLANE) {
/* efd->loc is closes point on effector xy-plane */
- float temp[3];
+ float temp[3], translate[3];
sub_v3_v3v3(temp, point->loc, ob->obmat[3]);
- project_v3_v3v3(efd->loc, temp, efd->nor);
- sub_v3_v3v3(efd->loc, point->loc, efd->loc);
+ project_v3_v3v3(translate, temp, efd->nor);
+ add_v3_v3v3(efd->loc, ob->obmat[3], translate);
}
else {
VECCOPY(efd->loc, ob->obmat[3]);
@@ -712,7 +724,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
return ret;
}
-static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int *tot, int *p)
+static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int *tot, int *p, int *step)
{
if(eff->pd->shape == PFIELD_SHAPE_POINTS) {
efd->index = p;
@@ -745,6 +757,13 @@ static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoin
*p= point->index % eff->psys->totpart;
*tot= *p + 1;
}
+
+ if(eff->psys->part->effector_amount) {
+ int totpart = eff->psys->totpart;
+ int amount = eff->psys->part->effector_amount;
+
+ *step = (totpart > amount) ? totpart/amount : 1;
+ }
}
else {
*p = 0;
@@ -762,7 +781,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
if(!eff->pd->tex)
return;
- result[0].nor = result[1].nor = result[2].nor = result[3].nor = 0;
+ result[0].nor = result[1].nor = result[2].nor = result[3].nor = NULL;
strength= eff->pd->f_strength * efd->falloff;
@@ -774,7 +793,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
}
if(eff->pd->flag & PFIELD_TEX_OBJECT) {
- mul_m4_v3(eff->ob->obmat, tex_co);
+ mul_m4_v3(eff->ob->imat, tex_co);
}
hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL,NULL, 0, result);
@@ -826,7 +845,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
add_v3_v3(total_force, force);
}
-void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force)
+static void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force)
{
PartDeflect *pd = eff->pd;
RNG *rng = pd->rng;
@@ -982,7 +1001,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we
*/
EffectorCache *eff;
EffectorData efd;
- int p=0, tot = 1;
+ int p=0, tot = 1, step = 1;
/* 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) */
@@ -990,9 +1009,9 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we
if(effectors) for(eff = effectors->first; eff; eff=eff->next) {
/* object effectors were fully checked to be OK to evaluate! */
- get_effector_tot(eff, &efd, point, &tot, &p);
+ get_effector_tot(eff, &efd, point, &tot, &p, &step);
- for(; p<tot; p++) {
+ for(; p<tot; p+=step) {
if(get_effector_data(eff, &efd, point, 0)) {
efd.falloff= effector_falloff(eff, &efd, point, weights);