Guest User

boolean weave call

a guest
Aug 27th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.07 KB | None | 0 0
  1.     /* PREAMBLE */
  2.     InitialPart.pt_forw = InitialPart.pt_back = &InitialPart;
  3.  
  4.     BU_LIST_INIT(&waiting_segs.l);
  5.  
  6.     if (BU_LIST_IS_EMPTY(&resp->re_region_ptbl)) {
  7.         BU_ALLOC(regionbits, struct bu_ptbl);
  8.         bu_ptbl_init(regionbits, 7, "rt_shootray() regionbits ptbl");
  9.     } else {
  10.         regionbits = BU_LIST_FIRST(bu_ptbl, &resp->re_region_ptbl);
  11.         BU_LIST_DEQUEUE(&regionbits->l);
  12.         BU_CK_PTBL(regionbits);
  13.     }
  14.  
  15.     /* ...traverse... */
  16.         BU_LIST_INIT(&new_segs.l);
  17.         /* ...shot... */
  18.         /* new_segs contains the results segments for one solid  */
  19.         struct seg *s2;
  20.         while (BU_LIST_WHILE(s2, seg, &(new_segs.l))) {
  21.             BU_LIST_DEQUEUE(&(s2->l));
  22.             /* Restore to original distance */
  23.             s2->seg_in.hit_dist += ss.dist_corr;
  24.             s2->seg_out.hit_dist += ss.dist_corr;
  25.             s2->seg_in.hit_rayp = s2->seg_out.hit_rayp = a_ray;
  26.             BU_LIST_INSERT(&(waiting_segs.l), &(s2->l));
  27.         }
  28.         /* waiting_segs contains the results segments for cell(s) */
  29.  
  30.     if (BU_LIST_NON_EMPTY(&(waiting_segs.l))) {
  31.         rt_boolweave(pfinished_segs, &waiting_segs, &InitialPart, ap);
  32.     }
  33.  
  34.     /* finished_segs chain now has all segments hit by this ray */
  35.     if (BU_LIST_IS_EMPTY(&(pfinished_segs->l))) {
  36.         ap->a_return = 0;
  37.         goto out;
  38.     }
  39.  
  40.     /*
  41.     * All intersections of the ray with the model have been computed.
  42.     * Evaluate the boolean trees over each partition.
  43.     */
  44.     /* Evaluate regions up to end of good segs */
  45.     (void)rt_boolfinal(&InitialPart, pFinalPart, BACKING_DIST, INFINITY, regionbits, ap, solidbits);
  46.  
  47.     if (pFinalPart->pt_forw == pFinalPart) {
  48.         ap->a_return = 0;
  49.         RT_FREE_PT_LIST(&InitialPart, resp);
  50.         goto out;
  51.     }
  52.  
  53.     /*
  54.     * Before recursing, release storage for unused Initial
  55.     * partitions.  finished_segs can not be released yet, because
  56.     * FinalPart partitions will point to hits in those segments.
  57.     */
  58.     RT_FREE_PT_LIST(&InitialPart, resp);
  59.  
  60.     /*
  61.     * finished_segs is only used by special hit routines which don't
  62.     * follow the traditional solid modeling paradigm.
  63.     */
  64.     ap->a_return = 1;
  65.  
  66.     /*
  67.     * Processing of this ray is complete.
  68.     */
  69. out:
  70.     /* Terminate any logging */
  71.     return ap->a_return;
Advertisement
Add Comment
Please, Sign In to add comment