Commit: 735119dd0f91b60c827278947afc8544446a7658
Author: Jacques Lucke
Date:   Wed May 27 16:15:06 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB735119dd0f91b60c827278947afc8544446a7658

Fix T75096: Crash when using liquid simulation as dynamic paint brush

Reviewers: sergey

Differential Revision: https://developer.blender.org/D7853

===================================================================

M       source/blender/blenkernel/intern/dynamicpaint.c

===================================================================

diff --git a/source/blender/blenkernel/intern/dynamicpaint.c 
b/source/blender/blenkernel/intern/dynamicpaint.c
index a704e199007..79f0aacc3f8 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -2701,15 +2701,16 @@ static void dynamic_paint_find_island_border(const 
DynamicPaintCreateUVSurfaceDa
       }
     }
 
+    const int final_tri_index = tempPoints[final_index].tri_index;
     /* If found pixel still lies on wrong face ( mesh has smaller than pixel 
sized faces) */
-    if (tempPoints[final_index].tri_index != target_tri) {
+    if (final_tri_index != target_tri && final_tri_index != -1) {
       /* Check if it's close enough to likely touch the intended triangle. Any 
triangle
        * becomes thinner than a pixel at its vertices, so robustness requires 
some margin. */
       const float final_pt[2] = {((final_index % w) + 0.5f) / w, ((final_index 
/ w) + 0.5f) / h};
       const float threshold = square_f(0.7f) / (w * h);
 
-      if (dist_squared_to_looptri_uv_edges(
-              mlooptri, mloopuv, tempPoints[final_index].tri_index, final_pt) 
> threshold) {
+      if (dist_squared_to_looptri_uv_edges(mlooptri, mloopuv, final_tri_index, 
final_pt) >
+          threshold) {
         continue;
       }
     }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to