Пример #1
0
bool Sculptor::intersect(Array<int, VertexP> * d, const Ray & ray)
{
	if(!d) return false;
    const int ndst = m_active->vertices->size();
	Vector3F pop;
	float tt;
	d->begin();
	while(!d->end() ) {
		Vector3F & p = *(d->value()->index->t1);
		pop = ray.closetPointOnRay(p, &tt);
/// select here
		if(p.distanceTo(pop) < selectRadius()) {
			VertexP * vert = d->value();
			
			float d = p.distanceTo(ray.m_origin);
			m_active->updateMinDepth(d);
			
			if(d - m_active->minDepth() < 2.f * selectRadius()) {
				addToStage(vert);
				addToActive(vert);
			}
		}
		d->next();
	}
	
	return m_active->vertices->size() > ndst;
}
Пример #2
0
bool PlantSelection::touchCell(const Ray & incident, const sdb::Coord3 & c, 
								Vector3F & pnt)
{
	sdb::Array<int, Plant> * cell = m_grid->findCell(c);
	if(!cell) return false;
	if(cell->isEmpty() ) return false;
	float tt;
	cell->begin();
	while(!cell->end()) {
		PlantData * d = cell->value()->index;
		pnt = incident.closetPointOnRay(d->t1->getTranslation(), &tt );
		if(tt < -1.f 
			&& pnt.distanceTo(d->t1->getTranslation() ) < m_radius)
            return true;
		
		cell->next();
	}
	return false;
}