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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-02-26 14:48:12 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-02-26 14:48:12 +0300
commit5380bd48d7176d8f6f242c5a30c76205487a338e (patch)
treef15f08c7d3ba8336c95615471dc7df366139f158
parent931ac1cebdc9b24bbe523a02d09babf1f3e1d1c3 (diff)
Hair particles with object or group visualisation didn't take the
rotation settings into account. Now if rotation is not set to None, instead of automatically deriving it from the particle path (which is useful for feathers), it uses the rotation settings (useful for distributing twigs randomly).
-rw-r--r--source/blender/blenkernel/BKE_particle.h2
-rw-r--r--source/blender/blenkernel/intern/anim.c5
-rw-r--r--source/blender/blenkernel/intern/particle.c38
3 files changed, 29 insertions, 16 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 9ac3c148345..e0b935fc106 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -249,7 +249,7 @@ float psys_get_child_size(struct ParticleSystem *psys, struct ChildParticle *cpa
void psys_get_particle_on_path(struct Object *ob, struct ParticleSystem *psys, int pa_num, struct ParticleKey *state, int vel);
int psys_get_particle_state(struct Object *ob, struct ParticleSystem *psys, int p, struct ParticleKey *state, int always);
void psys_get_dupli_texture(struct Object *ob, struct ParticleSettings *part, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, float *uv, float *orco);
-void psys_get_dupli_path_transform(struct Object *ob, struct ParticleSettings *part, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, struct ParticleCacheKey *cache, float mat[][4], float *scale);
+void psys_get_dupli_path_transform(struct Object *ob, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, struct ParticleCacheKey *cache, float mat[][4], float *scale);
ParticleThread *psys_threads_create(struct Object *ob, struct ParticleSystem *psys, int totthread);
int psys_threads_init_distribution(ParticleThread *threads, struct DerivedMesh *dm, int from);
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index a2c4470b358..21b50cd01b2 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -844,11 +844,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_
if(hair) {
if(a < totpart) {
cache = psys->pathcache[a];
- psys_get_dupli_path_transform(par, part, psmd, pa, 0, cache, pamat, &scale);
+ psys_get_dupli_path_transform(par, psys, psmd, pa, 0, cache, pamat, &scale);
}
else {
cache = psys->childcache[a-totpart];
- psys_get_dupli_path_transform(par, part, psmd, 0, cpa, cache, pamat, &scale);
+ psys_get_dupli_path_transform(par, psys, psmd, 0, cpa, cache, pamat, &scale);
}
VECCOPY(pamat[3], cache->co);
@@ -894,7 +894,6 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_
q = vectoquat(xvec, ob->trackflag, ob->upflag);
QuatToMat4(q, obrotmat);
obrotmat[3][3]= 1.0f;
-
Mat4MulMat4(mat, obrotmat, pamat);
}
else
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index f1937620f3b..93d9d972b80 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3737,28 +3737,42 @@ void psys_get_dupli_texture(Object *ob, ParticleSettings *part, ParticleSystemMo
}
}
-void psys_get_dupli_path_transform(Object *ob, ParticleSettings *part, ParticleSystemModifierData *psmd, ParticleData *pa, ChildParticle *cpa, ParticleCacheKey *cache, float mat[][4], float *scale)
+void psys_get_dupli_path_transform(Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd, ParticleData *pa, ChildParticle *cpa, ParticleCacheKey *cache, float mat[][4], float *scale)
{
- float loc[3], nor[3], vec[3], side[3], len;
+ float loc[3], nor[3], vec[3], side[3], len, obrotmat[4][4], qmat[4][4];
+ float xvec[3] = {-1.0, 0.0, 0.0}, *q;
VecSubf(vec, (cache+cache->steps-1)->co, cache->co);
len= Normalize(vec);
if(pa)
- psys_particle_on_emitter(ob,psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0);
+ psys_particle_on_emitter(ob,psmd,psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0);
else
psys_particle_on_emitter(ob, psmd,
- (part->childtype == PART_CHILD_FACES)? PART_FROM_FACE: PART_FROM_PARTICLE,
+ (psys->part->childtype == PART_CHILD_FACES)? PART_FROM_FACE: PART_FROM_PARTICLE,
cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,nor,0,0,0,0);
- Crossf(side, nor, vec);
- Normalize(side);
- Crossf(nor, vec, side);
-
- Mat4One(mat);
- VECCOPY(mat[0], vec);
- VECCOPY(mat[1], side);
- VECCOPY(mat[2], nor);
+ if(psys->part->rotmode) {
+ if(!pa)
+ pa= psys->particles+cpa->pa[0];
+
+ q = vectoquat(xvec, ob->trackflag, ob->upflag);
+ QuatToMat4(q, obrotmat);
+ obrotmat[3][3]= 1.0f;
+
+ QuatToMat4(pa->state.rot, qmat);
+ Mat4MulMat4(mat, obrotmat, qmat);
+ }
+ else {
+ Crossf(side, nor, vec);
+ Normalize(side);
+ Crossf(nor, vec, side);
+
+ Mat4One(mat);
+ VECCOPY(mat[0], vec);
+ VECCOPY(mat[1], side);
+ VECCOPY(mat[2], nor);
+ }
*scale= len;
}