23 occluders_.push_back(occ);
28 if (((inter.
x() >= box_min.
x()) && (inter.
x() < box_max.
x())) &&
29 ((inter.
y() >= box_min.
y()) && (inter.
y() < box_max.
y())) &&
30 ((inter.
z() >= box_min.
z()) && (inter.
z() < box_max.
z())))
43 Vec3d normal((occ)->getNormal());
46 double tmp_u, tmp_v, tmp_t;
47 if ((occ)->rayIntersect(ray_org_, ray_dir_, tmp_t, tmp_u, tmp_v)) {
48 if (
fabs(ray_dir_ * normal) > 0.0001) {
50 if (
inBox(ray_org_ + tmp_t * ray_dir_ / ray_dir_.norm(),
51 current_cell_->getOrigin(),
52 current_cell_->getOrigin() + cell_size_))
55 Vec3d bboxdiag(_scene3d->bbox().getMax() - _scene3d->bbox().getMin());
56 if ((t > 1.0e-06 * (
min(
min(bboxdiag.
x(), bboxdiag.
y()), bboxdiag.
z()))) &&
109 double min = DBL_MAX;
112 for (
int i = 0;
i < 3; ++
i) {
122 throw std::runtime_error(
"Warning: the 3D grid has more than one null dimension");
124 tmpSize[index] =
min;
128 real cell_vol = grid_vol / nb;
130 real edge =
pow(cell_vol, 1.0 / 3.0);
134 for (
i = 0;
i < 3;
i++) {
140 for (
i = 0;
i < 3;
i++) {
147 const vector<Vec3r> vertices = occluder->
getVertices();
148 if (vertices.empty()) {
170 vector<Vec3r>::const_iterator it;
173 if (vertices.size() == 3) {
176 for (it = vertices.begin(); it != vertices.end(); it++) {
181 Vec3r boxmin, boxmax;
183 for (
z = imin[2];
z <= imax[2];
z++) {
184 for (
y = imin[1];
y <= imax[1];
y++) {
185 for (
x = imin[0];
x <= imax[0];
x++) {
192 Vec3r boxcenter((boxmin + boxmax) / 2.0);
199 cell =
new Cell(boxmin);
209 for (
z = imin[2];
z <= imax[2];
z++) {
210 for (
y = imin[1];
y <= imax[1];
y++) {
211 for (
x = imin[0];
x <= imax[0];
x++) {
219 cell =
new Cell(orig);
231 next_cell = current_cell;
241 for (
i = 0;
i < 3;
i++) {
267 if (next_cell[coord] >=
_cells_nb[coord]) {
272 int tmp = next_cell[coord] - 1;
310 const Vec3r &orig,
const Vec3r &dir,
double &t,
double &u,
double &
v,
uint timestamp)
367 real tmin(-1.0), tmax(-1.0);
A class to hold a bounding box.
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
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
bool inside(const Point &p)
void addOccluder(Polygon3r *o)
void getBBox(Point &min, Point &max) const
const vector< Point > & getVertices() const
void getCellCoordinates(const Vec3r &p, Vec3u &res)
void castInfiniteRay(const Vec3r &orig, const Vec3r &dir, OccludersSet &occluders, uint timestamp)
void getCellBox(const Vec3u &cell_coord, Vec3r &min_out, Vec3r &max_out)
void addOccluder(Polygon3r *occluder)
bool nextRayCell(Vec3u ¤t_cell, Vec3u &next_cell)
virtual void configure(const Vec3r &orig, const Vec3r &size, uint nb)
void getCellOrigin(const Vec3u &cell_coord, Vec3r &orig)
bool initInfiniteRay(const Vec3r &orig, const Vec3r &dir, uint timestamp)
virtual void fillCell(const Vec3u &coord, Cell &cell)=0
Polygon3r * castRayToFindFirstIntersection(const Vec3r &orig, const Vec3r &dir, double &t, double &u, double &v, uint timestamp)
void insertOccluder(Polygon3r *occluder)
void castRayInternal(GridVisitor &visitor)
void castRay(const Vec3r &orig, const Vec3r &end, OccludersSet &occluders, uint timestamp)
virtual Cell * getCell(const Vec3u &coord)=0
void initRay(const Vec3r &orig, const Vec3r &end, uint timestamp)
virtual void examineOccluder(Polygon3r *occ)
virtual void examineOccluder(Polygon3r *occ)
ccl_device_inline float2 fabs(const float2 a)
bool overlapTriangleBox(const Vec3r &boxcenter, const Vec3r &boxhalfsize, const Vec3r triverts[3])
bool intersectRayBBox(const Vec3r &orig, const Vec3r &dir, const Vec3r &boxMin, const Vec3r &boxMax, real t0, real t1, real &tmin, real &tmax, real)
VecMat::Vec3< uint > Vec3u
VecMat::Vec3< double > Vec3d
VecMat::Vec3< real > Vec3r
vector< Polygon3r * > OccludersSet
static bool inBox(const Vec3r &inter, const Vec3r &box_min, const Vec3r &box_max)