Avoid redundant normal calculation in heat-weight

This commit is contained in:
Campbell Barton
2015-08-20 15:09:25 +10:00
parent a2c9d87a99
commit 6b53b4afb9
2 changed files with 11 additions and 8 deletions

View File

@@ -545,7 +545,7 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
v2=mvert[mface->v2].co;
v3=mvert[mface->v3].co;
if (isect_ray_tri_v3(co, nor, v2, v3, v1, &cur_d, 0)) {
if (isect_ray_tri_v3(co, nor, v2, v3, v1, &cur_d, NULL)) {
if (cur_d<min_d) {
min_d=cur_d;
pa->foffset=cur_d*0.5f; /* to the middle of volume */
@@ -555,7 +555,7 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
if (mface->v4) {
v4=mvert[mface->v4].co;
if (isect_ray_tri_v3(co, nor, v4, v1, v3, &cur_d, 0)) {
if (isect_ray_tri_v3(co, nor, v4, v1, v3, &cur_d, NULL)) {
if (cur_d<min_d) {
min_d=cur_d;
pa->foffset=cur_d*0.5f; /* to the middle of volume */

View File

@@ -386,18 +386,21 @@ static void bvh_callback(void *userdata, int index, const BVHTreeRay *UNUSED(ray
const MLoop *mloop = data->sys->heat.mloop;
float (*verts)[3] = data->sys->heat.verts;
const float *vtri_co[3];
float lambda, uv[2], n[3], dir[3];
float lambda, dir[3];
mul_v3_v3fl(dir, data->vec, hit->dist);
vtri_co[0] = verts[mloop[lt->tri[0]].v];
vtri_co[1] = verts[mloop[lt->tri[1]].v];
vtri_co[2] = verts[mloop[lt->tri[2]].v];
if (isect_ray_tri_v3(data->start, dir, UNPACK3(vtri_co), &lambda, uv)) {
normal_tri_v3(n, UNPACK3(vtri_co));
if (lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) {
hit->index = index;
hit->dist *= lambda;
if (isect_ray_tri_v3(data->start, dir, UNPACK3(vtri_co), &lambda, NULL)) {
if (lambda < 1.0f) {
float n[3];
normal_tri_v3(n, UNPACK3(vtri_co));
if (dot_v3v3(n, data->vec) < -1e-5f) {
hit->index = index;
hit->dist *= lambda;
}
}
}
}