Ejemplo n.º 1
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;

}
Ejemplo n.º 2
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;

}