Paste P530

Fix for T52732
ActivePublic

Authored by Sergey Sharybin (sergey) on Sep 14 2017, 11:26 AM.
Tags
None
Subscribers
None
1diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
2index fe84504327c..1ef4d005f0d 100644
3--- a/source/blender/blenkernel/intern/particle_distribute.c
4+++ b/source/blender/blenkernel/intern/particle_distribute.c
5@@ -39,6 +39,7 @@
6​ #include "BLI_jitter.h"
7​ #include "BLI_kdtree.h"
8​ #include "BLI_math.h"
9+#include "BLI_math_geom.h"
10​ #include "BLI_rand.h"
11​ #include "BLI_sort.h"
12​ #include "BLI_task.h"
13@@ -213,14 +214,22 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
14​ copy_v3_v3(co2, co1);
15​ co2[a] += delta[a] + 0.001f*d;
16​ co1[a] -= 0.001f*d;
17-
18+
19+ struct IsectRayPrecalc isect_precalc;
20+ float ray_direction[3];
21+ sub_v3_v3v3(ray_direction, co2, co1);
22+ isect_ray_tri_watertight_v3_precalc(&isect_precalc, ray_direction);
23+
24​ /* lets intersect the faces */
25​ for (i=0; i<totface; i++,mface++) {
26​ copy_v3_v3(v1, mvert[mface->v1].co);
27​ copy_v3_v3(v2, mvert[mface->v2].co);
28​ copy_v3_v3(v3, mvert[mface->v3].co);
29
30- bool intersects_tri = isect_axial_line_segment_tri_v3(a, co1, co2, v2, v3, v1, &lambda);
31+ bool intersects_tri = isect_ray_tri_watertight_v3(co1,
32+ &isect_precalc,
33+ v1, v2, v3,
34+ &lambda, NULL);
35​ if (intersects_tri) {
36​ if (from==PART_FROM_FACE)
37​ (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
38@@ -231,7 +240,10 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
39​ if (mface->v4 && (!intersects_tri || from==PART_FROM_VOLUME)) {
40​ copy_v3_v3(v4, mvert[mface->v4].co);
41
42- if (isect_axial_line_segment_tri_v3(a, co1, co2, v4, v1, v3, &lambda)) {
43+ if (isect_ray_tri_watertight_v3(co1,
44+ &isect_precalc,
45+ v1, v2, v3,
46+ &lambda, NULL)) {
47​ if (from==PART_FROM_FACE)
48​ (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
49​ else