10 #define BOX_GRID_LOGGING 0
22 #include "../geometry/BBox.h"
23 #include "../geometry/GridHelpers.h"
24 #include "../geometry/Polygon.h"
26 #include "../system/PointerSequence.h"
28 #include "../winged_edge/WEdge.h"
32 #ifdef WITH_CXX_GUARDEDALLOC
51 #ifdef WITH_CXX_GUARDEDALLOC
52 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:BoxGrid:OccluderData")
62 explicit Cell() =
default;
72 vector<OccluderData *>
faces;
104 bool testOccluder(
bool wantOccludee);
105 void markCurrentOccludeeCandidate(
real depth);
112 vector<OccluderData *>::iterator _current, _occludeeCandidate;
114 #ifdef WITH_CXX_GUARDEDALLOC
115 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:BoxGrid:Iterator")
157 void getCellCoordinates(
const Vec3r &
point,
unsigned &
x,
unsigned &
y);
162 unsigned _cellsX, _cellsY;
164 float _cellOrigin[2];
170 #ifdef WITH_CXX_GUARDEDALLOC
171 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:BoxGrid")
177 _current = _cell->faces.begin();
178 while (_current != _cell->faces.end() && !testOccluder(
false)) {
185 if (_foundOccludee) {
188 std::cout <<
"\tStarting occludee search from occludeeCandidate at depth " << _occludeeDepth
192 _current = _occludeeCandidate;
198 std::cout <<
"\tStarting occludee search from current position" << std::endl;
202 while (_current != _cell->faces.end() && !testOccluder(
true)) {
207 inline bool BoxGrid::Iterator::testOccluder(
bool wantOccludee)
210 if (_current == _cell->faces.end()) {
217 std::cout <<
"\tTesting occluder " << (*_current)->poly.getVertices()[0];
218 for (
unsigned int i = 1; i < (*_current)->poly.getVertices().
size(); ++i) {
219 std::cout <<
", " << (*_current)->poly.getVertices()[i];
221 std::cout <<
" from shape " << (*_current)->face->GetVertex(0)->shape()->GetId() << std::endl;
226 if (_foundOccludee && (*_current)->shallowest > _occludeeDepth) {
229 std::cout <<
"\t\tAborting: shallowest > occludeeCandidate->deepest" << std::endl;
232 _current = _cell->faces.end();
240 if ((*_current)->deepest < _target[2]) {
243 std::cout <<
"\t\tSkipping: shallower than target while looking for occludee" << std::endl;
250 if ((*_current)->shallowest > _target[2]) {
253 std::cout <<
"\t\tStopping: deeper than target while looking for occluder" << std::endl;
264 (*_current)->poly.getBBox(bbMin, bbMax);
265 if (_target[0] < bbMin[0] || _target[0] > bbMax[0] || _target[1] < bbMin[1] ||
266 _target[1] > bbMax[1]) {
269 std::cout <<
"\t\tSkipping: bounding box violation" << std::endl;
284 real depth = -(origin + (u *
t))[2];
287 std::cout <<
"\t\tReporting depth of occluder/ee: " << depth;
290 if (depth > _target[2]) {
293 std::cout <<
" is deeper than target" << std::endl;
297 if (!_foundOccludee || _occludeeDepth > depth) {
298 markCurrentOccludeeCandidate(depth);
304 std::cout << std::endl;
312 if (_current != _cell->faces.end()) {
315 }
while (_current != _cell->faces.end() && !testOccluder(
false));
321 if (_current != _cell->faces.end()) {
324 }
while (_current != _cell->faces.end() && !testOccluder(
true));
330 return _current != _cell->faces.end() && (*_current)->shallowest <= _target[2];
335 return _current != _cell->faces.end();
338 inline void BoxGrid::Iterator::markCurrentOccludeeCandidate(
real depth)
342 std::cout <<
"\t\tFound occludeeCandidate at depth " << depth << std::endl;
345 _occludeeCandidate = _current;
346 _occludeeDepth = depth;
347 _foundOccludee =
true;
352 return (*_current)->face;
357 return &((*_current)->cameraSpacePolygon);
361 : poly(p), cameraSpacePolygon(source.getCameraSpacePolygon()), face(source.getWFace())
375 if (occluder ==
NULL) {
380 faces.push_back(occluder);
392 unsigned startX, startY, endX, endY;
393 getCellCoordinates(bbMin, startX, startY);
394 getCellCoordinates(bbMax, endX, endY);
396 for (
unsigned int i = startX; i <= endX; ++i) {
397 for (
unsigned int j = startY; j <= endY; ++j) {
398 if (_cells[i * _cellsY + j] !=
NULL) {
399 _cells[i * _cellsY + j]->checkAndInsert(source, poly, occluder);
404 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.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
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)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken density("density", pxr::TfToken::Immortal)
Polygon3r cameraSpacePolygon
OccluderData(OccluderSource &source, Polygon3r &p)