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

Reviewers: sergey

Differential Revision: https://developer.blender.org/D7853
This commit is contained in:
Jacques Lucke
2020-05-27 16:15:06 +02:00
parent 28d9368538
commit 735119dd0f

View File

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