diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-11-13 18:05:17 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-20 11:30:07 +0300 |
commit | a754c0af4088aaa7d1799351db1d03b9250a0d2e (patch) | |
tree | 113d17f6d87c03c66c103999c75a2484053978d6 /source/blender | |
parent | 9c660f18aca5d86a7e2f5818beabe9b3e0bc7ec7 (diff) |
Another fix for off-by-one hair grid resolution errors.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 12 | ||||
-rw-r--r-- | source/blender/physics/intern/hair_volume.cpp | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index da075419890..109dc10bcab 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5255,22 +5255,22 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv UI_ThemeColorShadeAlpha(TH_WIRE, 0, -100); glEnable(GL_BLEND); glBegin(GL_LINES); - for (i = 1; i < res[0]; ++i) { - float f = interpf(b[0], a[0], (float)i / (float)(res[0])); + for (i = 1; i < res[0]-1; ++i) { + float f = interpf(b[0], a[0], (float)i / (float)(res[0]-1)); glVertex3f(f, a[1], a[2]); glVertex3f(f, b[1], a[2]); glVertex3f(f, b[1], a[2]); glVertex3f(f, b[1], b[2]); glVertex3f(f, b[1], b[2]); glVertex3f(f, a[1], b[2]); glVertex3f(f, a[1], b[2]); glVertex3f(f, a[1], a[2]); } - for (i = 1; i < res[1]; ++i) { - float f = interpf(b[1], a[1], (float)i / (float)(res[1])); + for (i = 1; i < res[1]-1; ++i) { + float f = interpf(b[1], a[1], (float)i / (float)(res[1]-1)); glVertex3f(a[0], f, a[2]); glVertex3f(b[0], f, a[2]); glVertex3f(b[0], f, a[2]); glVertex3f(b[0], f, b[2]); glVertex3f(b[0], f, b[2]); glVertex3f(a[0], f, b[2]); glVertex3f(a[0], f, b[2]); glVertex3f(a[0], f, a[2]); } - for (i = 1; i < res[2]; ++i) { - float f = interpf(b[2], a[2], (float)i / (float)(res[2])); + for (i = 1; i < res[2]-1; ++i) { + float f = interpf(b[2], a[2], (float)i / (float)(res[2]-1)); glVertex3f(a[0], a[1], f); glVertex3f(b[0], a[1], f); glVertex3f(b[0], a[1], f); glVertex3f(b[0], b[1], f); glVertex3f(b[0], b[1], f); glVertex3f(a[0], b[1], f); 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) { |