All pastes #462006 Raw Edit

Something

public text v1 · immutable
#462006 ·published 2007-04-27 23:59 UTC
rendered paste body
Hit intersectObjects(Scene *world, Ray *ray) {
   Hit tempHit;
   Scalar closest = 1000000; // The closest so far
   Scalar t;
   tempHit.obj = NULL;
   node_t *node = world->objects->head;
   while (node != NULL) {
      assert(node->data);
      Object *temp = (Object *)(node->data);
      t = temp->hits(temp, ray);

      if(t > THRESHOLD && t < closest) {
         tempHit.obj = temp;
         tempHit.t = t;
         closest = t;
      }
      node = node->next;
   }
   return tempHit;
} // intersectObjects