10 #define SPHERICAL_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:SphericalGrid:OccluderData")
62 explicit Cell() =
default;
72 vector<OccluderData *>
faces;
105 bool testOccluder(
bool wantOccludee);
106 void markCurrentOccludeeCandidate(
real depth);
113 vector<OccluderData *>::iterator _current, _occludeeCandidate;
115 #ifdef WITH_CXX_GUARDEDALLOC
116 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:SphericalGrid:Iterator")
158 void getCellCoordinates(
const Vec3r &
point,
unsigned &
x,
unsigned &
y);
163 unsigned _cellsX, _cellsY;
165 float _cellOrigin[2];
171 #ifdef WITH_CXX_GUARDEDALLOC
172 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:SphericalGrid")
178 _current = _cell->faces.begin();
179 while (_current != _cell->faces.end() && !testOccluder(
false)) {
186 if (_foundOccludee) {
187 #if SPHERICAL_GRID_LOGGING
189 std::cout <<
"\tStarting occludee search from occludeeCandidate at depth " << _occludeeDepth
193 _current = _occludeeCandidate;
197 #if SPHERICAL_GRID_LOGGING
199 std::cout <<
"\tStarting occludee search from current position" << std::endl;
203 while (_current != _cell->faces.end() && !testOccluder(
true)) {
208 inline bool SphericalGrid::Iterator::testOccluder(
bool wantOccludee)
211 if (_current == _cell->faces.end()) {
216 #if SPHERICAL_GRID_LOGGING
218 std::cout <<
"\tTesting occluder " << (*_current)->poly.getVertices()[0];
219 for (
unsigned int i = 1; i < (*_current)->poly.getVertices().
size(); ++i) {
220 std::cout <<
", " << (*_current)->poly.getVertices()[i];
222 std::cout <<
" from shape " << (*_current)->face->GetVertex(0)->shape()->GetId() << std::endl;
227 if (_foundOccludee && (*_current)->shallowest > _occludeeDepth) {
228 #if SPHERICAL_GRID_LOGGING
230 std::cout <<
"\t\tAborting: shallowest > occludeeCandidate->deepest" << std::endl;
233 _current = _cell->faces.end();
241 if ((*_current)->deepest < _target[2]) {
242 #if SPHERICAL_GRID_LOGGING
244 std::cout <<
"\t\tSkipping: shallower than target while looking for occludee" << std::endl;
251 if ((*_current)->shallowest > _target[2]) {
252 #if SPHERICAL_GRID_LOGGING
254 std::cout <<
"\t\tStopping: deeper than target while looking for occluder" << std::endl;
265 (*_current)->poly.getBBox(bbMin, bbMax);
266 if (_target[0] < bbMin[0] || _target[0] > bbMax[0] || _target[1] < bbMin[1] ||
267 _target[1] > bbMax[1]) {
268 #if SPHERICAL_GRID_LOGGING
270 std::cout <<
"\t\tSkipping: bounding box violation" << std::endl;
288 #if SPHERICAL_GRID_LOGGING
290 std::cout <<
"\t\tReporting depth of occluder/ee: " << depth;
293 if (depth > _target[2]) {
294 #if SPHERICAL_GRID_LOGGING
296 std::cout <<
" is deeper than target" << std::endl;
300 if (!_foundOccludee || _occludeeDepth > depth) {
301 markCurrentOccludeeCandidate(depth);
305 #if SPHERICAL_GRID_LOGGING
307 std::cout << std::endl;
315 if (_current != _cell->faces.end()) {
318 }
while (_current != _cell->faces.end() && !testOccluder(
false));
324 if (_current != _cell->faces.end()) {
327 }
while (_current != _cell->faces.end() && !testOccluder(
true));
333 return _current != _cell->faces.end() && (*_current)->shallowest <= _target[2];
338 return _current != _cell->faces.end();
341 inline void SphericalGrid::Iterator::markCurrentOccludeeCandidate(
real depth)
343 #if SPHERICAL_GRID_LOGGING
345 std::cout <<
"\t\tFound occludeeCandidate at depth " << depth << std::endl;
348 _occludeeCandidate = _current;
349 _occludeeDepth = depth;
350 _foundOccludee =
true;
355 return (*_current)->face;
360 return &((*_current)->cameraSpacePolygon);
364 : poly(p), cameraSpacePolygon(source.getCameraSpacePolygon()), face(source.getWFace())
374 for (
unsigned int i = 0; i < 2; ++i) {
382 inline void SphericalGrid::Cell::checkAndInsert(
OccluderSource &source,
387 if (occluder ==
NULL) {
392 faces.push_back(occluder);
404 unsigned startX, startY, endX, endY;
405 getCellCoordinates(bbMin, startX, startY);
406 getCellCoordinates(bbMax, endX, endY);
408 for (
unsigned int i = startX; i <= endX; ++i) {
409 for (
unsigned int j = startY; j <= endY; ++j) {
410 if (_cells[i * _cellsY + j] !=
NULL) {
411 _cells[i * _cellsY + j]->checkAndInsert(source, poly, occluder);
416 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)
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
const vector< Point > & getVertices() const
void getBBox(Point &min, Point &max) const
Polygon3r & getGridSpacePolygon()
void reportDepth(Vec3r origin, Vec3r u, real t)
Iterator(SphericalGrid &grid, Vec3r ¢er, real epsilon=1.0e-06)
Polygon3r * getCameraSpacePolygon()
void assignCells(OccluderSource &source, GridDensityProvider &density, ViewMap *viewMap)
const Vec3r & viewpoint() const
bool orthographicProjection() const
Cell * findCell(const Vec3r &point)
void distributePolygons(OccluderSource &source)
bool insertOccluder(OccluderSource &source, OccluderData *&occluder)
VecMat::Vec3< real > Vec3r
real distancePointToPolygon(const Vec3r &point, const Polygon3r &poly)
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)