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).
This commit is contained in:
Brecht Van Lommel
2008-02-26 11:48:12 +00:00
parent 931ac1cebd
commit 5380bd48d7
3 changed files with 28 additions and 15 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -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);
if(psys->part->rotmode) {
if(!pa)
pa= psys->particles+cpa->pa[0];
Mat4One(mat);
VECCOPY(mat[0], vec);
VECCOPY(mat[1], side);
VECCOPY(mat[2], nor);
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;
}