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
 bool init() {
     iheap.build();
     if (checkHead() == false) next();        
     if (iheap.time() == INTERSECTION_INFINIT_TIME) {
         return false;        
     } else {
         hitobject = parent;
         return true;
     }
 }
Esempio n. 3
0
void swapByLinks(){
	struct reply *r = NULL,*r1 = NULL;
	temp = NULL;
	struct node *temp1 = NULL;
	int x = getInput();
	int y = getInput();
	r = searchRecursively(head,x);
	r1 = searchRecursively(head,y);
	if(r->response == 1 && r1->response == 1){
		temp = r1->ptr->next;
		temp1 = r1->prevptr;
		if(abs(r->data - r1->data) > 1){
			r1->ptr->next = r->ptr->next;
			r->ptr->next = temp;
			if(r->prevptr != NULL)
				r->prevptr->next = r1->ptr;
			if(temp1!=NULL)
				temp1->next = r->ptr;
			if(checkHead(x))
				head = r1->ptr;
			else if(checkHead(y))
				head = r->ptr;
		}else if(abs(r->data - r1->data) == 1){
			r1->ptr->next = r->ptr;
			r->ptr->next = temp;
			if(r->prevptr != NULL)
				r->prevptr->next = r1->ptr;
			/*if(temp1!=NULL)
				temp1->next = r->ptr;*/
			if(checkHead(x))
				head = r1->ptr;
			else if(checkHead(y))
				head = r->ptr;
		}
		else{
			printf("\n1st element should appear before 2nd element in LL.\n");
		}
	}else{
		printf("\nElement not found.\n");
	}
	display();
}
Esempio n. 4
0
    bool init() {
        iheap.build();

        if (checkHead() == false) next();
        if (iheap.time() == INTERSECTION_INFINIT_TIME) {
            return false;
        } else {
            hitobject = iheap.intersection()->hitObject();
            return true;
        }
    }