+ struct hit *hita, *hitb, *lasthit, tmp;
+
+ hita = ray_intersect(ray, o->sub.a);
+ hitb = ray_intersect(ray, o->sub.b);
+
+ if(!hita) return 0;
+ if(!hitb) return hita;
+
+ if(first(hita)->t < first(hitb)->t) {
+ free_hit_list(hitb);
+ return hita;
+ }
+ if(first(hita)->t < (lasthit = last(hitb))->t) {
+ /* overlapping */
+ tmp = *hitb;
+ *hitb = *lasthit;
+
+ free_hit_list(tmp.next);
+
+ hitb->nx = -hitb->nx;
+ hitb->ny = -hitb->ny;
+ hitb->nz = -hitb->nz;
+
+ free_hit_list(hita);
+ return hitb;
+ }
+
+ free_hit_list(hitb);
+ return hita;