12#define BOX_GRID_LOGGING 0
34#ifdef WITH_CXX_GUARDEDALLOC
53#ifdef WITH_CXX_GUARDEDALLOC
54 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:BoxGrid:OccluderData")
64 explicit Cell() =
default;
74 vector<OccluderData *>
faces;
106 bool testOccluder(
bool wantOccludee);
107 void markCurrentOccludeeCandidate(
real depth);
114 vector<OccluderData *>::iterator _current, _occludeeCandidate;
116#ifdef WITH_CXX_GUARDEDALLOC
117 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:BoxGrid:Iterator")
130 BoxGrid(
const BoxGrid &other);
131 BoxGrid &operator=(
const BoxGrid &other);
164 uint _cellsX, _cellsY;
166 float _cellOrigin[2];
167 cellContainer _cells;
168 occluderContainer _faces;
172#ifdef WITH_CXX_GUARDEDALLOC
173 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:BoxGrid")
179 _current = _cell->faces.begin();
180 while (_current != _cell->faces.end() && !testOccluder(
false)) {
187 if (_foundOccludee) {
190 std::cout <<
"\tStarting occludee search from occludeeCandidate at depth " << _occludeeDepth
194 _current = _occludeeCandidate;
200 std::cout <<
"\tStarting occludee search from current position" << std::endl;
204 while (_current != _cell->faces.end() && !testOccluder(
true)) {
209inline bool BoxGrid::Iterator::testOccluder(
bool wantOccludee)
212 if (_current == _cell->faces.end()) {
219 std::cout <<
"\tTesting occluder " << (*_current)->poly.getVertices()[0];
220 for (
uint i = 1; i < (*_current)->poly.getVertices().
size(); ++i) {
221 std::cout <<
", " << (*_current)->poly.getVertices()[i];
223 std::cout <<
" from shape " << (*_current)->face->GetVertex(0)->shape()->GetId() << std::endl;
228 if (_foundOccludee && (*_current)->shallowest > _occludeeDepth) {
231 std::cout <<
"\t\tAborting: shallowest > occludeeCandidate->deepest" << std::endl;
234 _current = _cell->faces.end();
242 if ((*_current)->deepest < _target[2]) {
245 std::cout <<
"\t\tSkipping: shallower than target while looking for occludee" << std::endl;
252 if ((*_current)->shallowest > _target[2]) {
255 std::cout <<
"\t\tStopping: deeper than target while looking for occluder" << std::endl;
266 (*_current)->poly.getBBox(bbMin, bbMax);
267 if (_target[0] < bbMin[0] || _target[0] > bbMax[0] || _target[1] < bbMin[1] ||
268 _target[1] > bbMax[1])
272 std::cout <<
"\t\tSkipping: bounding box violation" << std::endl;
287 real depth = -(origin + (u * t))[2];
290 std::cout <<
"\t\tReporting depth of occluder/ee: " << depth;
293 if (depth > _target[2]) {
296 std::cout <<
" is deeper than target" << std::endl;
300 if (!_foundOccludee || _occludeeDepth > depth) {
301 markCurrentOccludeeCandidate(depth);
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();
341inline void BoxGrid::Iterator::markCurrentOccludeeCandidate(
real depth)
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);
378 if (occluder ==
nullptr) {
383 faces.push_back(occluder);
395 uint startX, startY, endX, endY;
396 getCellCoordinates(bbMin, startX, startY);
397 getCellCoordinates(bbMax, endX, endY);
399 for (
uint i = startX; i <= endX; ++i) {
400 for (
uint j = startY; j <= endY; ++j) {
401 if (_cells[i * _cellsY + j] !=
nullptr) {
402 _cells[i * _cellsY + j]->checkAndInsert(source, poly, occluder);
407 return occluder !=
nullptr;
A class to hold a bounding box.
Class to define a cell grid surrounding the projected image of a scene.
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 Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture 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.
Simple RAII wrappers for std:: sequential containers.
Class to define a polygon.
Classes to define a View Map (ViewVertex, ViewEdge, etc.)
Classes to define a Winged Edge data structure.
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()
local_group_size(16, 16) .push_constant(Type b
VecMat::Vec3< real > Vec3r
bool insideProscenium(const real proscenium[4], const Polygon3r &polygon)
Polygon3r cameraSpacePolygon
OccluderData(OccluderSource &source, Polygon3r &p)