Esempio n. 1
0
void CSGIntersectIntersection::next() {

    do{

        if (iheap.intersection() == 0) {

            // we had only the boundingbox intersection with this object so far
            Intersection* ci = iheap.object()->intersectLimitedTime(ray,tmax);
            if (ci) {
                DBL t = ci->currentTime();
                iheap.intersection() = ci;
                iheap.time() = t;
            } else iheap.time() = INTERSECTION_INFINIT_TIME;

        } else {
            iheap.intersection()->next();
            iheap.time() = iheap.intersection()->currentTime();
        }

        iheap.reassureHeap();
        if (iheap.time() == INTERSECTION_INFINIT_TIME) return;

    } while (checkHead()==false);

}
Esempio n. 2
0
Intersection* CSGIntersect::intersectLocalLimitedTime(const Ray &shoot, DBL tmax) const {

    assert(isclosed);
    stat.eval();
    CSGIntersectIntersection* i = 0;

    // fill Array with initial values
    for(unsigned int j=0; j<objects->listsize; j++) {

        Object3D* current = static_cast<Object3D*>(objects->list[j]);
        
        double t;
        if ( (t=current->intersectBounding(shoot,tmax))!=INTERSECTION_TIME_EPSILON ) {

            if (t > INTERSECTION_TIME_EPSILON) {
                // boundingbox hit
                if (i == 0)  i = new CSGIntersectIntersection(this,shoot,tmax);
                i->put(0,t,current);
                continue;
            }

        } else {

            // there is no boundingbox or we are inside
            Intersection* ci = current->intersectLimitedTime(shoot,tmax);

            if (ci) {
                if (i == 0)  i = new CSGIntersectIntersection(this,shoot,tmax);
                i->put(ci,ci->currentTime(),current);
                continue;
            }

        }

        // no intersection with that object, test if we are inside
        Vector3 testpoint = Vector3::add( shoot.getOrigin(), shoot.getDirection() );
        if (static_cast<const Object3D*>(current)->isInsideAtBounded(testpoint)==false) {delete(i); return 0;}
        
    }

    if (i) {
        // build up structure 
        if (i->init() == false) {delete(i); return 0;}
        stat.success();
    }
    
    return i;

}
Esempio n. 3
0
Intersection* CSGUnion::intersectLocalLimitedTime(const Ray &shoot, DBL tmax) const {

    assert(isclosed);
    stat.eval();
    CSGUnionIntersection* i = 0;

    // fill Array with initial values
    for(unsigned int j=0; j<objects->listsize; j++) {

        Object3D* current = static_cast<Object3D*>(objects->list[j]);

        double t;
        if ( (t=current->intersectBounding(shoot,tmax))!=INTERSECTION_TIME_EPSILON ) {
            
            if (t > INTERSECTION_TIME_EPSILON) {
                // boundingbox hit
                if (i == 0)  i = new CSGUnionIntersection(this,shoot,tmax);
                i->put(0,t,current);
            } 

        } else {
            
            // there is no boundingbox or we are inside
            Intersection* ci = current->intersectLimitedTime(shoot,tmax);
            
            if (ci) {
                if (i == 0)  i = new CSGUnionIntersection(this,shoot,tmax);
                i->put(ci,ci->currentTime(),current);
            }
            
        }
        
    }

    if (i) {
        // build up structure 
        if (i->init() == false) {delete(i); return 0;}
        stat.success();
    }

    return i;

}