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:
authorPablo Dobarro <pablodp606@gmail.com>2020-05-13 04:00:34 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-05-13 04:00:34 +0300
commit429841e5fd1c5fa77291ec46f3f0e5170ad30342 (patch)
tree3f4e210ce9b79825397393e3ab6714315c563878 /source/blender/blenkernel/intern/pbvh.c
parentf9d0f59bed4d7fea3622cc01469e225435ad4e56 (diff)
parent9253386dcb14063ba2a4d82fa6d4d58090adfd5b (diff)
Merge branch 'blender-v2.83-release'
Diffstat (limited to 'source/blender/blenkernel/intern/pbvh.c')
-rw-r--r--source/blender/blenkernel/intern/pbvh.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index f72ecd568e2..b65089c7599 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -2155,7 +2155,11 @@ static bool pbvh_faces_node_raycast(PBVH *bvh,
float location[3] = {0.0f};
madd_v3_v3v3fl(location, ray_start, ray_normal, *depth);
for (int j = 0; j < 3; j++) {
- if (len_squared_v3v3(location, co[j]) < len_squared_v3v3(location, nearest_vertex_co)) {
+ /* Always assign nearest_vertex_co in the first iteration to avoid comparison against
+ * uninitialized values. This stores the closest vertex in the current intersecting
+ * triangle. */
+ if (j == 0 ||
+ len_squared_v3v3(location, co[j]) < len_squared_v3v3(location, nearest_vertex_co)) {
copy_v3_v3(nearest_vertex_co, co[j]);
*r_active_vertex_index = mloop[lt->tri[j]].v;
*r_active_face_index = lt->poly;
@@ -2235,8 +2239,11 @@ static bool pbvh_grids_node_raycast(PBVH *bvh,
const int y_it[4] = {0, 0, 1, 1};
for (int j = 0; j < 4; j++) {
- if (len_squared_v3v3(location, co[j]) <
- len_squared_v3v3(location, nearest_vertex_co)) {
+ /* Always assign nearest_vertex_co in the first iteration to avoid comparison against
+ * uninitialized values. This stores the closest vertex in the current intersecting
+ * quad. */
+ if (j == 0 || len_squared_v3v3(location, co[j]) <
+ len_squared_v3v3(location, nearest_vertex_co)) {
copy_v3_v3(nearest_vertex_co, co[j]);
*r_active_vertex_index = gridkey->grid_area * grid_index +