Blender  V3.3
Grid.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 #include <stdexcept>
9 
10 #include "BBox.h"
11 #include "Grid.h"
12 
13 #include "BLI_utildefines.h"
14 
15 namespace Freestyle {
16 
17 // Grid Visitors
20 {
21  occluders_.push_back(occ);
22 }
23 
24 static bool inBox(const Vec3r &inter, const Vec3r &box_min, const Vec3r &box_max)
25 {
26  if (((inter.x() >= box_min.x()) && (inter.x() < box_max.x())) &&
27  ((inter.y() >= box_min.y()) && (inter.y() < box_max.y())) &&
28  ((inter.z() >= box_min.z()) && (inter.z() < box_max.z()))) {
29  return true;
30  }
31  return false;
32 }
33 
35 {
36  // check whether the edge and the polygon plane are coincident:
37  //-------------------------------------------------------------
38  // first let us compute the plane equation.
39  Vec3r v1(((occ)->getVertices())[0]);
40  Vec3d normal((occ)->getNormal());
41  // soc unused - double d = -(v1 * normal);
42 
43  double tmp_u, tmp_v, tmp_t;
44  if ((occ)->rayIntersect(ray_org_, ray_dir_, tmp_t, tmp_u, tmp_v)) {
45  if (fabs(ray_dir_ * normal) > 0.0001) {
46  // Check whether the intersection is in the cell:
47  if (inBox(ray_org_ + tmp_t * ray_dir_ / ray_dir_.norm(),
48  current_cell_->getOrigin(),
49  current_cell_->getOrigin() + cell_size_)) {
50 #if 0
51  Vec3d bboxdiag(_scene3d->bbox().getMax() - _scene3d->bbox().getMin());
52  if ((t > 1.0e-06 * (min(min(bboxdiag.x(), bboxdiag.y()), bboxdiag.z()))) &&
53  (t < raylength)) {
54 #else
55  if (tmp_t < t_) {
56 #endif
57  occluder_ = occ;
58  u_ = tmp_u;
59  v_ = tmp_v;
60  t_ = tmp_t;
61  }
62  }
63  else {
64  occ->userdata2 = nullptr;
65  }
66  }
67 }
68 } // namespace Freestyle
69 
71 {
72  if (occluder_) {
73  return true;
74  }
75  return false;
76 }
77 
78 // Grid
81 {
82  if (!_occluders.empty()) {
83  for (OccludersSet::iterator it = _occluders.begin(); it != _occluders.end(); it++) {
84  delete (*it);
85  }
86  _occluders.clear();
87  }
88 
89  _size = Vec3r(0, 0, 0);
90  _cell_size = Vec3r(0, 0, 0);
91  _orig = Vec3r(0, 0, 0);
92  _cells_nb = Vec3u(0, 0, 0);
93  //_ray_occluders.clear();
94 }
95 
96 void Grid::configure(const Vec3r &orig, const Vec3r &size, unsigned nb)
97 {
98  _orig = orig;
99  Vec3r tmpSize = size;
100  // Compute the volume of the desired grid
101  real grid_vol = size[0] * size[1] * size[2];
102 
103  if (grid_vol == 0) {
104  double min = DBL_MAX;
105  int index = 0;
106  int nzeros = 0;
107  for (int i = 0; i < 3; ++i) {
108  if (size[i] == 0) {
109  ++nzeros;
110  index = i;
111  }
112  if ((size[i] != 0) && (min > size[i])) {
113  min = size[i];
114  }
115  }
116  if (nzeros > 1) {
117  throw std::runtime_error("Warning: the 3D grid has more than one null dimension");
118  }
119  tmpSize[index] = min;
120  _orig[index] = _orig[index] - min / 2;
121  }
122  // Compute the desired volume of a single cell
123  real cell_vol = grid_vol / nb;
124  // The edge of such a cubic cell is cubic root of cellVolume
125  real edge = pow(cell_vol, 1.0 / 3.0);
126 
127  // We compute the number of cells par edge such as we cover at least the whole box.
128  unsigned i;
129  for (i = 0; i < 3; i++) {
130  _cells_nb[i] = (unsigned)floor(tmpSize[i] / edge) + 1;
131  }
132 
133  _size = tmpSize;
134 
135  for (i = 0; i < 3; i++) {
136  _cell_size[i] = _size[i] / _cells_nb[i];
137  }
138 }
139 
141 {
142  const vector<Vec3r> vertices = occluder->getVertices();
143  if (vertices.empty()) {
144  return;
145  }
146 
147  // add this occluder to the grid's occluders list
148  addOccluder(occluder);
149 
150  // find the bbox associated to this polygon
151  Vec3r min, max;
152  occluder->getBBox(min, max);
153 
154  // Retrieve the cell x, y, z coordinates associated with these min and max
155  Vec3u imax, imin;
156  getCellCoordinates(max, imax);
157  getCellCoordinates(min, imin);
158 
159  // We are now going to fill in the cells overlapping with the polygon bbox.
160  // If the polygon is a triangle (most of cases), we also check for each of these cells if it is
161  // overlapping with the triangle in order to only fill in the ones really overlapping the
162  // triangle.
163 
164  unsigned i, x, y, z;
165  vector<Vec3r>::const_iterator it;
166  Vec3u coord;
167 
168  if (vertices.size() == 3) { // Triangle case
169  Vec3r triverts[3];
170  i = 0;
171  for (it = vertices.begin(); it != vertices.end(); it++) {
172  triverts[i] = Vec3r(*it);
173  i++;
174  }
175 
176  Vec3r boxmin, boxmax;
177 
178  for (z = imin[2]; z <= imax[2]; z++) {
179  for (y = imin[1]; y <= imax[1]; y++) {
180  for (x = imin[0]; x <= imax[0]; x++) {
181  coord[0] = x;
182  coord[1] = y;
183  coord[2] = z;
184  // We retrieve the box coordinates of the current cell
185  getCellBox(coord, boxmin, boxmax);
186  // We check whether the triangle and the box ovewrlap:
187  Vec3r boxcenter((boxmin + boxmax) / 2.0);
188  Vec3r boxhalfsize(_cell_size / 2.0);
189  if (GeomUtils::overlapTriangleBox(boxcenter, boxhalfsize, triverts)) {
190  // We must then create the Cell and add it to the cells list if it does not exist yet.
191  // We must then add the occluder to the occluders list of this cell.
192  Cell *cell = getCell(coord);
193  if (!cell) {
194  cell = new Cell(boxmin);
195  fillCell(coord, *cell);
196  }
197  cell->addOccluder(occluder);
198  }
199  }
200  }
201  }
202  }
203  else { // The polygon is not a triangle, we add all the cells overlapping the polygon bbox.
204  for (z = imin[2]; z <= imax[2]; z++) {
205  for (y = imin[1]; y <= imax[1]; y++) {
206  for (x = imin[0]; x <= imax[0]; x++) {
207  coord[0] = x;
208  coord[1] = y;
209  coord[2] = z;
210  Cell *cell = getCell(coord);
211  if (!cell) {
212  Vec3r orig;
213  getCellOrigin(coord, orig);
214  cell = new Cell(orig);
215  fillCell(coord, *cell);
216  }
217  cell->addOccluder(occluder);
218  }
219  }
220  }
221  }
222 }
223 
224 bool Grid::nextRayCell(Vec3u &current_cell, Vec3u &next_cell)
225 {
226  next_cell = current_cell;
227  real t_min, t;
228  unsigned i;
229 
230  t_min = FLT_MAX; // init tmin with handle of the case where one or 2 _u[i] = 0.
231  unsigned coord = 0; // predominant coord(0=x, 1=y, 2=z)
232 
233  // using a parametric equation of a line : B = A + t u, we find the tx, ty and tz respectively
234  // corresponding to the intersections with the plans:
235  // x = _cell_size[0], y = _cell_size[1], z = _cell_size[2]
236  for (i = 0; i < 3; i++) {
237  if (_ray_dir[i] == 0) {
238  continue;
239  }
240  if (_ray_dir[i] > 0) {
241  t = (_cell_size[i] - _pt[i]) / _ray_dir[i];
242  }
243  else {
244  t = -_pt[i] / _ray_dir[i];
245  }
246  if (t < t_min) {
247  t_min = t;
248  coord = i;
249  }
250  }
251 
252  // We use the parametric line equation and the found t (tamx) to compute the B coordinates:
253  Vec3r pt_tmp(_pt);
254  _pt = pt_tmp + t_min * _ray_dir;
255 
256  // We express B coordinates in the next cell coordinates system. We just have to
257  // set the coordinate coord of B to 0 of _CellSize[coord] depending on the sign of _u[coord]
258  if (_ray_dir[coord] > 0) {
259  next_cell[coord]++;
260  _pt[coord] -= _cell_size[coord];
261  // if we are out of the grid, we must stop
262  if (next_cell[coord] >= _cells_nb[coord]) {
263  return false;
264  }
265  }
266  else {
267  int tmp = next_cell[coord] - 1;
268  _pt[coord] = _cell_size[coord];
269  if (tmp < 0) {
270  return false;
271  }
272  next_cell[coord]--;
273  }
274 
275  _t += t_min;
276  if (_t >= _t_end) {
277  return false;
278  }
279 
280  return true;
281 }
282 
283 void Grid::castRay(const Vec3r &orig,
284  const Vec3r &end,
285  OccludersSet &occluders,
286  unsigned timestamp)
287 {
288  initRay(orig, end, timestamp);
289  allOccludersGridVisitor visitor(occluders);
290  castRayInternal(visitor);
291 }
292 
293 void Grid::castInfiniteRay(const Vec3r &orig,
294  const Vec3r &dir,
295  OccludersSet &occluders,
296  unsigned timestamp)
297 {
298  Vec3r end = Vec3r(orig + FLT_MAX * dir / dir.norm());
299  bool inter = initInfiniteRay(orig, dir, timestamp);
300  if (!inter) {
301  return;
302  }
303  allOccludersGridVisitor visitor(occluders);
304  castRayInternal(visitor);
305 }
306 
308  const Vec3r &orig, const Vec3r &dir, double &t, double &u, double &v, unsigned timestamp)
309 {
310  Polygon3r *occluder = nullptr;
311  Vec3r end = Vec3r(orig + FLT_MAX * dir / dir.norm());
312  bool inter = initInfiniteRay(orig, dir, timestamp);
313  if (!inter) {
314  return nullptr;
315  }
316  firstIntersectionGridVisitor visitor(orig, dir, _cell_size);
317  castRayInternal(visitor);
318  // ARB: This doesn't work, because occluders are unordered within any cell
319  // visitor.occluder() will be an occluder, but we have no guarantee it will be the *first*
320  // occluder. I assume that is the reason this code is not actually used for FindOccludee.
321  occluder = visitor.occluder();
322  t = visitor.t_;
323  u = visitor.u_;
324  v = visitor.v_;
325  return occluder;
326 }
327 
328 void Grid::initRay(const Vec3r &orig, const Vec3r &end, unsigned timestamp)
329 {
330  _ray_dir = end - orig;
331  _t_end = _ray_dir.norm();
332  _t = 0;
333  _ray_dir.normalize();
334  _timestamp = timestamp;
335 
336  for (unsigned i = 0; i < 3; i++) {
337  _current_cell[i] = (unsigned)floor((orig[i] - _orig[i]) / _cell_size[i]);
338  // soc unused - unsigned u = _current_cell[i];
339  _pt[i] = orig[i] - _orig[i] - _current_cell[i] * _cell_size[i];
340  }
341  //_ray_occluders.clear();
342 }
343 
344 bool Grid::initInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timestamp)
345 {
346  _ray_dir = dir;
347  _t_end = FLT_MAX;
348  _t = 0;
349  _ray_dir.normalize();
350  _timestamp = timestamp;
351 
352  // check whether the origin is in or out the box:
353  Vec3r boxMin(_orig);
354  Vec3r boxMax(_orig + _size);
355  BBox<Vec3r> box(boxMin, boxMax);
356  if (box.inside(orig)) {
357  for (unsigned int i = 0; i < 3; i++) {
358  _current_cell[i] = (unsigned int)floor((orig[i] - _orig[i]) / _cell_size[i]);
359  // soc unused - unsigned u = _current_cell[i];
360  _pt[i] = orig[i] - _orig[i] - _current_cell[i] * _cell_size[i];
361  }
362  }
363  else {
364  // is the ray intersecting the box?
365  real tmin(-1.0), tmax(-1.0);
366  if (GeomUtils::intersectRayBBox(orig, _ray_dir, boxMin, boxMax, 0, _t_end, tmin, tmax)) {
367  BLI_assert(tmin != -1.0);
368  Vec3r newOrig = orig + tmin * _ray_dir;
369  for (unsigned int i = 0; i < 3; i++) {
370  _current_cell[i] = (unsigned)floor((newOrig[i] - _orig[i]) / _cell_size[i]);
371  if (_current_cell[i] == _cells_nb[i]) {
372  _current_cell[i] = _cells_nb[i] - 1;
373  }
374  // soc unused - unsigned u = _current_cell[i];
375  _pt[i] = newOrig[i] - _orig[i] - _current_cell[i] * _cell_size[i];
376  }
377  }
378  else {
379  return false;
380  }
381  }
382  //_ray_occluders.clear();
383 
384  return true;
385 }
386 
387 } /* namespace Freestyle */
A class to hold a bounding box.
#define BLI_assert(a)
Definition: BLI_assert.h:46
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Base class to define a cell grid surrounding the bounding box of the scene.
ATTR_WARN_UNUSED_RESULT const BMVert * v
const btVector3 * getVertices() const
Definition: btBox2dShape.h:145
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
bool inside(const Point &p)
Definition: BBox.h:107
void addOccluder(Polygon3r *o)
Definition: Grid.h:51
const Vec3r & getOrigin()
Definition: Grid.h:58
const vector< Point > & getVertices() const
Definition: Polygon.h:67
void getBBox(Point &min, Point &max) const
Definition: Polygon.h:72
void initRay(const Vec3r &orig, const Vec3r &end, unsigned timestamp)
Definition: Grid.cpp:328
bool nextRayCell(Vec3u &current_cell, Vec3u &next_cell)
Definition: Grid.cpp:224
bool initInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timestamp)
Definition: Grid.cpp:344
virtual void configure(const Vec3r &orig, const Vec3r &size, unsigned nb)
Definition: Grid.cpp:96
void castInfiniteRay(const Vec3r &orig, const Vec3r &dir, OccludersSet &occluders, unsigned timestamp)
Definition: Grid.cpp:293
Polygon3r * castRayToFindFirstIntersection(const Vec3r &orig, const Vec3r &dir, double &t, double &u, double &v, unsigned timestamp)
Definition: Grid.cpp:307
virtual void clear()
Definition: Grid.cpp:80
void insertOccluder(Polygon3r *occluder)
Definition: Grid.cpp:140
void castRay(const Vec3r &orig, const Vec3r &end, OccludersSet &occluders, unsigned timestamp)
Definition: Grid.cpp:283
value_type x() const
Definition: VecMat.h:518
value_type z() const
Definition: VecMat.h:538
value_type y() const
Definition: VecMat.h:528
value_type norm() const
Definition: VecMat.h:95
Vec< T, N > & normalize()
Definition: VecMat.h:105
virtual void examineOccluder(Polygon3r *occ)
Definition: Grid.cpp:19
virtual void examineOccluder(Polygon3r *occ)
Definition: Grid.cpp:34
IconTextureDrawCall normal
ccl_device_inline float2 fabs(const float2 &a)
Definition: math_float2.h:222
ccl_device_inline float3 pow(float3 v, float e)
Definition: math_float3.h:533
bool overlapTriangleBox(Vec3r &boxcenter, Vec3r &boxhalfsize, Vec3r triverts[3])
Definition: GeomUtils.cpp:345
bool intersectRayBBox(const Vec3r &orig, const Vec3r &dir, const Vec3r &boxMin, const Vec3r &boxMax, real t0, real t1, real &tmin, real &tmax, real)
Definition: GeomUtils.cpp:524
VecMat::Vec3< unsigned > Vec3u
Definition: Geom.h:24
VecMat::Vec3< real > Vec3r
Definition: Geom.h:28
inherits from class Rep
Definition: AppCanvas.cpp:18
static unsigned x[3]
Definition: RandGen.cpp:73
vector< Polygon3r * > OccludersSet
Definition: Grid.h:33
static bool inBox(const Vec3r &inter, const Vec3r &box_min, const Vec3r &box_max)
Definition: Grid.cpp:24
double real
Definition: Precision.h:12
T floor(const T &a)
#define min(a, b)
Definition: sort.c:35
float max