From a754c0af4088aaa7d1799351db1d03b9250a0d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Thu, 13 Nov 2014 16:05:17 +0100 Subject: Another fix for off-by-one hair grid resolution errors. --- source/blender/physics/intern/hair_volume.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/physics') diff --git a/source/blender/physics/intern/hair_volume.cpp b/source/blender/physics/intern/hair_volume.cpp index daf362d1f55..5dadd45c154 100644 --- a/source/blender/physics/intern/hair_volume.cpp +++ b/source/blender/physics/intern/hair_volume.cpp @@ -794,18 +794,18 @@ HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize, const float gmin[3] sub_v3_v3v3(extent, gmax, gmin); for (i = 0; i < 3; ++i) { - resmin[i] = (int)(gmin[i] * scale); - resmax[i] = (int)(gmax[i] * scale) + 1; + resmin[i] = floor_int(gmin[i] * scale); + resmax[i] = floor_int(gmax[i] * scale) + 1; /* add margin of 1 cell */ resmin[i] -= 1; resmax[i] += 1; - res[i] = resmax[i] - resmin[i]; + res[i] = resmax[i] - resmin[i] + 1; /* sanity check: avoid null-sized grid */ - if (res[i] < 3) { - res[i] = 3; - resmax[i] = resmin[i] + 3; + if (res[i] < 4) { + res[i] = 4; + resmax[i] = resmin[i] + 4; } /* sanity check: avoid too large grid size */ if (res[i] > MAX_HAIR_GRID_RES) { -- cgit v1.2.3