[Bf-blender-cvs] [001202c] temp_merge_gooseberry_hair: Another fix for off-by-one hair grid resolution errors.
Lukas Tönne
noreply at git.blender.org
Mon Jan 19 20:50:55 CET 2015
Commit: 001202cac5c85a8ab0b537a56d1f83001e942bac
Author: Lukas Tönne
Date: Thu Nov 13 16:05:17 2014 +0100
Branches: temp_merge_gooseberry_hair
https://developer.blender.org/rB001202cac5c85a8ab0b537a56d1f83001e942bac
Another fix for off-by-one hair grid resolution errors.
===================================================================
M source/blender/editors/space_view3d/drawobject.c
M source/blender/physics/intern/hair_volume.cpp
===================================================================
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index d2b6d7a..54063c0 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -5254,22 +5254,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 daf362d..5dadd45 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) {
More information about the Bf-blender-cvs
mailing list