Exemplo n.º 1
0
void Octree::_FattenedRayLookup(int nindex,const Ray3D& ray,Real radius,vector<int>& nodeindices) const
{
  const OctreeNode& node = nodes[nindex];
  //this is kinda slower than it needs to be... can determine intersecting
  //children directly without testing all bb's
  if(IsLeaf(node)) {
    //fine grained test
    if(ray.distance(node.bb) <= radius)
      nodeindices.push_back(nindex);
  }
  else {
    vector<pair<Real,int> > children;
    for(int i=0;i<8;i++) {
      Real tmin = 0;
      Real tmax = Inf;
      AABB3D fattened = nodes[node.childIndices[i]].bb;
      fattened.bmin -= Vector3(radius);
      fattened.bmax += Vector3(radius);
      if(ray.intersects(fattened,tmin,tmax))
	children.push_back(pair<Real,int>(tmin,node.childIndices[i]));
    }
    //loop through children, sorted by distance
    sort(children.begin(),children.end());
    for(size_t i=0;i<children.size();i++)
      _FattenedRayLookup(children[i].second,ray,radius,nodeindices);
  }
}
Exemplo n.º 2
0
void Octree::RayLookup(const Ray3D& ray,vector<int>& nodeindices) const
{
  nodeindices.resize(0);
  Real tmin=0,tmax=Inf;
  if(!ray.intersects(nodes[0].bb,tmin,tmax)) 
    return;
  _RayLookup(0,ray,nodeindices);
}
Exemplo n.º 3
0
void Octree::FattenedRayLookup(const Ray3D& ray,Real radius,vector<int>& nodeindices) const
{
  nodeindices.resize(0);
  Real tmin=0,tmax=Inf;
  AABB3D fattened = nodes[0].bb;
  fattened.bmin -= Vector3(radius);
  fattened.bmax += Vector3(radius);
  if(!ray.intersects(fattened,tmin,tmax)) 
    return;
  _FattenedRayLookup(0,ray,radius,nodeindices);
}
Exemplo n.º 4
0
void Octree::_RayLookup(int nindex,const Ray3D& ray,vector<int>& nodeindices) const
{
  const OctreeNode& node = nodes[nindex];
  //this is kinda slower than it needs to be... can determine intersecting
  //children directly without testing all bb's
  if(IsLeaf(node)) nodeindices.push_back(nindex);
  else {
    vector<pair<Real,int> > children;
    for(int i=0;i<8;i++) {
      Real tmin = 0;
      Real tmax = Inf;
      if(ray.intersects(nodes[node.childIndices[i]].bb,tmin,tmax))
	children.push_back(pair<Real,int>(tmin,node.childIndices[i]));
    }
    //loop through children, sorted by distance
    sort(children.begin(),children.end());
    for(size_t i=0;i<children.size();i++)
      _RayLookup(children[i].second,ray,nodeindices);
  }
}