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:
Diffstat (limited to 'source/blender/blenkernel/intern/anim.c')
-rw-r--r--source/blender/blenkernel/intern/anim.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 8cb88cdb786..bd779935d55 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -280,17 +280,27 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat,
if (quat) {
float totfac, q1[4], q2[4];
+ /* checks for totfac are needed when 'fac' is 1.0 key_curve_position_weights can assign zero
+ * to more then one index in data which can give divide by zero error */
+/*
totfac= data[0]+data[1];
- QuatInterpol(q1, p0->quat, p1->quat, data[0] / totfac);
+ if(totfac>0.000001) QuatInterpol(q1, p0->quat, p1->quat, data[0] / totfac);
+ else QUATCOPY(q1, p1->quat);
+
NormalQuat(q1);
totfac= data[2]+data[3];
- QuatInterpol(q2, p2->quat, p3->quat, data[2] / totfac);
+ if(totfac>0.000001) QuatInterpol(q2, p2->quat, p3->quat, data[2] / totfac);
+ else QUATCOPY(q1, p3->quat);
NormalQuat(q2);
totfac = data[0]+data[1]+data[2]+data[3];
- QuatInterpol(quat, q1, q2, (data[0]+data[1]) / totfac);
+ if(totfac>0.000001) QuatInterpol(quat, q1, q2, (data[0]+data[1]) / totfac);
+ else QUATCOPY(quat, q2);
NormalQuat(quat);
+ */
+ // XXX - find some way to make quat interpolation work correctly, above code fails in rare but nasty cases.
+ QUATCOPY(quat, p1->quat);
}
if(radius)
@@ -766,12 +776,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
GroupObject *go;
Object *ob=0, **oblist=0, obcopy, *obcopylist=0;
DupliObject *dob;
+ ParticleSimulationData sim = {scene, par, psys, psys_get_modifier(par, psys)};
ParticleSettings *part;
ParticleData *pa;
ChildParticle *cpa=0;
ParticleKey state;
ParticleCacheKey *cache;
- ParticleSystemModifierData *psmd;
float ctime, pa_time, scale = 1.0f;
float tmat[4][4], mat[4][4], pamat[4][4], size=0.0;
float (*obmat)[4], (*oldobmat)[4];
@@ -784,7 +794,6 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
if(level>MAX_DUPLI_RECUR) return;
part=psys->part;
- psmd= psys_get_modifier(par, psys);
if(part==0)
return;
@@ -816,7 +825,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
totpart = psys->totcached;
}
- psys->lattice = psys_get_lattice(scene, par, psys);
+ psys->lattice = psys_get_lattice(&sim);
/* gather list of objects or single object */
if(part->ren_as==PART_DRAW_GR) {
@@ -887,11 +896,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
/* hair we handle separate and compute transform based on hair keys */
if(a < totpart) {
cache = psys->pathcache[a];
- psys_get_dupli_path_transform(par, psys, psmd, pa, 0, cache, pamat, &scale);
+ psys_get_dupli_path_transform(&sim, pa, 0, cache, pamat, &scale);
}
else {
cache = psys->childcache[a-totpart];
- psys_get_dupli_path_transform(par, psys, psmd, 0, cpa, cache, pamat, &scale);
+ psys_get_dupli_path_transform(&sim, 0, cpa, cache, pamat, &scale);
}
VECCOPY(pamat[3], cache->co);
@@ -901,7 +910,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
else {
/* first key */
state.time = ctime;
- if(psys_get_particle_state(scene, par, psys, a, &state, 0) == 0)
+ if(psys_get_particle_state(&sim, a, &state, 0) == 0)
continue;
QuatToMat4(state.rot, pamat);
@@ -921,7 +930,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated);
Mat4CpyMat4(dob->omat, obcopylist[b].obmat);
if(G.rendering)
- psys_get_dupli_texture(par, part, psmd, pa, cpa, dob->uv, dob->orco);
+ psys_get_dupli_texture(par, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
}
}
else {
@@ -940,7 +949,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
dob= new_dupli_object(lb, ob, mat, ob->lay, counter, OB_DUPLIPARTS, animated);
Mat4CpyMat4(dob->omat, oldobmat);
if(G.rendering)
- psys_get_dupli_texture(par, part, psmd, pa, cpa, dob->uv, dob->orco);
+ psys_get_dupli_texture(par, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
}
}