diff options
Diffstat (limited to 'source/blender/freestyle/intern/geometry/Grid.cpp')
-rw-r--r-- | source/blender/freestyle/intern/geometry/Grid.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/source/blender/freestyle/intern/geometry/Grid.cpp b/source/blender/freestyle/intern/geometry/Grid.cpp index ad45ab4eb42..e0e3af0fe47 100644 --- a/source/blender/freestyle/intern/geometry/Grid.cpp +++ b/source/blender/freestyle/intern/geometry/Grid.cpp @@ -93,7 +93,7 @@ void Grid::clear() //_ray_occluders.clear(); } -void Grid::configure(const Vec3r &orig, const Vec3r &size, unsigned nb) +void Grid::configure(const Vec3r &orig, const Vec3r &size, uint nb) { _orig = orig; Vec3r tmpSize = size; @@ -125,9 +125,9 @@ void Grid::configure(const Vec3r &orig, const Vec3r &size, unsigned nb) real edge = pow(cell_vol, 1.0 / 3.0); // We compute the number of cells par edge such as we cover at least the whole box. - unsigned i; + uint i; for (i = 0; i < 3; i++) { - _cells_nb[i] = (unsigned)floor(tmpSize[i] / edge) + 1; + _cells_nb[i] = uint(floor(tmpSize[i] / edge)) + 1; } _size = tmpSize; @@ -161,7 +161,7 @@ void Grid::insertOccluder(Polygon3r *occluder) // overlapping with the triangle in order to only fill in the ones really overlapping the // triangle. - unsigned i, x, y, z; + uint i, x, y, z; vector<Vec3r>::const_iterator it; Vec3u coord; @@ -225,10 +225,10 @@ bool Grid::nextRayCell(Vec3u ¤t_cell, Vec3u &next_cell) { next_cell = current_cell; real t_min, t; - unsigned i; + uint i; - t_min = FLT_MAX; // init tmin with handle of the case where one or 2 _u[i] = 0. - unsigned coord = 0; // predominant coord(0=x, 1=y, 2=z) + t_min = FLT_MAX; // init tmin with handle of the case where one or 2 _u[i] = 0. + uint coord = 0; // predominant coord(0=x, 1=y, 2=z) // using a parametric equation of a line : B = A + t u, we find the tx, ty and tz respectively // corresponding to the intersections with the plans: @@ -280,10 +280,7 @@ bool Grid::nextRayCell(Vec3u ¤t_cell, Vec3u &next_cell) return true; } -void Grid::castRay(const Vec3r &orig, - const Vec3r &end, - OccludersSet &occluders, - unsigned timestamp) +void Grid::castRay(const Vec3r &orig, const Vec3r &end, OccludersSet &occluders, uint timestamp) { initRay(orig, end, timestamp); allOccludersGridVisitor visitor(occluders); @@ -293,7 +290,7 @@ void Grid::castRay(const Vec3r &orig, void Grid::castInfiniteRay(const Vec3r &orig, const Vec3r &dir, OccludersSet &occluders, - unsigned timestamp) + uint timestamp) { Vec3r end = Vec3r(orig + FLT_MAX * dir / dir.norm()); bool inter = initInfiniteRay(orig, dir, timestamp); @@ -305,7 +302,7 @@ void Grid::castInfiniteRay(const Vec3r &orig, } Polygon3r *Grid::castRayToFindFirstIntersection( - const Vec3r &orig, const Vec3r &dir, double &t, double &u, double &v, unsigned timestamp) + const Vec3r &orig, const Vec3r &dir, double &t, double &u, double &v, uint timestamp) { Polygon3r *occluder = nullptr; Vec3r end = Vec3r(orig + FLT_MAX * dir / dir.norm()); @@ -325,7 +322,7 @@ Polygon3r *Grid::castRayToFindFirstIntersection( return occluder; } -void Grid::initRay(const Vec3r &orig, const Vec3r &end, unsigned timestamp) +void Grid::initRay(const Vec3r &orig, const Vec3r &end, uint timestamp) { _ray_dir = end - orig; _t_end = _ray_dir.norm(); @@ -333,15 +330,15 @@ void Grid::initRay(const Vec3r &orig, const Vec3r &end, unsigned timestamp) _ray_dir.normalize(); _timestamp = timestamp; - for (unsigned i = 0; i < 3; i++) { - _current_cell[i] = (unsigned)floor((orig[i] - _orig[i]) / _cell_size[i]); + for (uint i = 0; i < 3; i++) { + _current_cell[i] = uint(floor((orig[i] - _orig[i]) / _cell_size[i])); // soc unused - unsigned u = _current_cell[i]; _pt[i] = orig[i] - _orig[i] - _current_cell[i] * _cell_size[i]; } //_ray_occluders.clear(); } -bool Grid::initInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timestamp) +bool Grid::initInfiniteRay(const Vec3r &orig, const Vec3r &dir, uint timestamp) { _ray_dir = dir; _t_end = FLT_MAX; @@ -367,7 +364,7 @@ bool Grid::initInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timesta BLI_assert(tmin != -1.0); Vec3r newOrig = orig + tmin * _ray_dir; for (uint i = 0; i < 3; i++) { - _current_cell[i] = (unsigned)floor((newOrig[i] - _orig[i]) / _cell_size[i]); + _current_cell[i] = uint(floor((newOrig[i] - _orig[i]) / _cell_size[i])); if (_current_cell[i] == _cells_nb[i]) { _current_cell[i] = _cells_nb[i] - 1; } |