24 #define BOX_GRID_LOGGING 0
36 #include "../geometry/BBox.h"
37 #include "../geometry/GridHelpers.h"
38 #include "../geometry/Polygon.h"
40 #include "../system/PointerSequence.h"
42 #include "../winged_edge/WEdge.h"
46 #ifdef WITH_CXX_GUARDEDALLOC
65 #ifdef WITH_CXX_GUARDEDALLOC
66 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:BoxGrid:OccluderData")
76 explicit Cell() =
default;
86 vector<OccluderData *>
faces;
118 bool testOccluder(
bool wantOccludee);
119 void markCurrentOccludeeCandidate(
real depth);
126 vector<OccluderData *>::iterator _current, _occludeeCandidate;
128 #ifdef WITH_CXX_GUARDEDALLOC
129 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:BoxGrid:Iterator")
171 void getCellCoordinates(
const Vec3r &point,
unsigned &
x,
unsigned &
y);
176 unsigned _cellsX, _cellsY;
178 float _cellOrigin[2];
184 #ifdef WITH_CXX_GUARDEDALLOC
185 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:BoxGrid")
191 _current = _cell->faces.begin();
192 while (_current != _cell->faces.end() && !testOccluder(
false)) {
199 if (_foundOccludee) {
202 std::cout <<
"\tStarting occludee search from occludeeCandidate at depth " << _occludeeDepth
206 _current = _occludeeCandidate;
212 std::cout <<
"\tStarting occludee search from current position" << std::endl;
216 while (_current != _cell->faces.end() && !testOccluder(
true)) {
221 inline bool BoxGrid::Iterator::testOccluder(
bool wantOccludee)
224 if (_current == _cell->faces.end()) {
231 std::cout <<
"\tTesting occluder " << (*_current)->poly.getVertices()[0];
232 for (
unsigned int i = 1; i < (*_current)->poly.getVertices().
size(); ++i) {
233 std::cout <<
", " << (*_current)->poly.getVertices()[i];
235 std::cout <<
" from shape " << (*_current)->face->GetVertex(0)->shape()->GetId() << std::endl;
240 if (_foundOccludee && (*_current)->shallowest > _occludeeDepth) {
243 std::cout <<
"\t\tAborting: shallowest > occludeeCandidate->deepest" << std::endl;
246 _current = _cell->faces.end();
254 if ((*_current)->deepest < _target[2]) {
257 std::cout <<
"\t\tSkipping: shallower than target while looking for occludee" << std::endl;
264 if ((*_current)->shallowest > _target[2]) {
267 std::cout <<
"\t\tStopping: deeper than target while looking for occluder" << std::endl;
278 (*_current)->poly.getBBox(bbMin, bbMax);
279 if (_target[0] < bbMin[0] || _target[0] > bbMax[0] || _target[1] < bbMin[1] ||
280 _target[1] > bbMax[1]) {
283 std::cout <<
"\t\tSkipping: bounding box violation" << std::endl;
298 real depth = -(origin + (u *
t))[2];
301 std::cout <<
"\t\tReporting depth of occluder/ee: " << depth;
304 if (depth > _target[2]) {
307 std::cout <<
" is deeper than target" << std::endl;
311 if (!_foundOccludee || _occludeeDepth > depth) {
312 markCurrentOccludeeCandidate(depth);
318 std::cout << std::endl;
326 if (_current != _cell->faces.end()) {
329 }
while (_current != _cell->faces.end() && !testOccluder(
false));
335 if (_current != _cell->faces.end()) {
338 }
while (_current != _cell->faces.end() && !testOccluder(
true));
344 return _current != _cell->faces.end() && (*_current)->shallowest <= _target[2];
349 return _current != _cell->faces.end();
352 inline void BoxGrid::Iterator::markCurrentOccludeeCandidate(
real depth)
356 std::cout <<
"\t\tFound occludeeCandidate at depth " << depth << std::endl;
359 _occludeeCandidate = _current;
360 _occludeeDepth = depth;
361 _foundOccludee =
true;
366 return (*_current)->face;
371 return &((*_current)->cameraSpacePolygon);
375 : poly(p), cameraSpacePolygon(source.getCameraSpacePolygon()), face(source.getWFace())
389 if (occluder ==
NULL) {
394 faces.push_back(occluder);
406 unsigned startX, startY, endX, endY;
407 getCellCoordinates(bbMin, startX, startY);
408 getCellCoordinates(bbMax, endX, endY);
410 for (
unsigned int i = startX; i <= endX; ++i) {
411 for (
unsigned int j = startY; j <= endY; ++j) {
412 if (_cells[i * _cellsY + j] !=
NULL) {
413 _cells[i * _cellsY + j]->checkAndInsert(source, poly, occluder);
418 return occluder !=
NULL;
NSNotificationCenter * center
_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
Class to define a cell grid surrounding the projected image of a scene.
Read Guarded memory(de)allocation.
Class to define a cell grid surrounding the projected image of a scene.
Classes to define a View Map (ViewVertex, ViewEdge, etc.)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Polygon3r * getCameraSpacePolygon()
Iterator(BoxGrid &grid, Vec3r ¢er, real epsilon=1.0e-06)
void reportDepth(Vec3r origin, Vec3r u, real t)
void assignCells(OccluderSource &source, GridDensityProvider &density, ViewMap *viewMap)
const Vec3r & viewpoint() const
Cell * findCell(const Vec3r &point)
void distributePolygons(OccluderSource &source)
bool insertOccluder(OccluderSource &source, OccluderData *&occluder)
bool orthographicProjection() const
void getBBox(Point &min, Point &max) const
Polygon3r & getGridSpacePolygon()
VecMat::Vec3< real > Vec3r
bool insideProscenium(const real proscenium[4], const Polygon3r &polygon)
Polygon3r cameraSpacePolygon
OccluderData(OccluderSource &source, Polygon3r &p)