| 51 |
|
} RAYPAR; |
| 52 |
|
|
| 53 |
|
static int openholo(char *fname, int append); |
| 54 |
< |
static void addray(RAYPAR *rp); |
| 54 |
> |
static int addray(RAYPAR *rp); |
| 55 |
|
static int readval(RREAL *v, int n, FILE *fp); |
| 56 |
|
static void readrays(FILE *fp); |
| 57 |
|
static int writeval(RREAL *v, int n, FILE *fp); |
| 228 |
|
return(n); |
| 229 |
|
} |
| 230 |
|
|
| 231 |
< |
void |
| 231 |
> |
int |
| 232 |
|
addray( /* add a ray to our output holodeck */ |
| 233 |
|
RAYPAR *rp |
| 234 |
|
) |
| 241 |
|
double d0, d1; |
| 242 |
|
unsigned dc; |
| 243 |
|
RAYVAL *rv; |
| 244 |
+ |
int nsects = 0; |
| 245 |
|
/* check each output section */ |
| 246 |
|
for (sn = nholosects; sn--; ) { |
| 247 |
|
hp = hdlist[sn]; |
| 272 |
|
rv->r[0][0] = rr[0][0]; rv->r[0][1] = rr[0][1]; |
| 273 |
|
rv->r[1][0] = rr[1][0]; rv->r[1][1] = rr[1][1]; |
| 274 |
|
copycolr(rv->v, rp->cv); |
| 275 |
+ |
++nsects; |
| 276 |
|
} |
| 277 |
+ |
return nsects; |
| 278 |
|
} |
| 279 |
|
|
| 280 |
|
/* Read n-vector from file stream */ |
| 328 |
|
static void |
| 329 |
|
readrays(FILE *fp) |
| 330 |
|
{ |
| 331 |
+ |
unsigned long nread=0, ngood=0; |
| 332 |
+ |
|
| 333 |
|
if (iofmt != 'a') |
| 334 |
|
SET_FILE_BINARY(fp); |
| 335 |
|
#ifdef getc_unlocked |
| 384 |
|
if (!flags) /* got nothing, so may be normal EOF */ |
| 385 |
|
return; |
| 386 |
|
} |
| 387 |
+ |
++nread; |
| 388 |
|
if (flags & (BAD_DIR|BAD_LEN)) |
| 389 |
|
continue; /* just a bad ray is all -- skip */ |
| 390 |
|
if (!(flags & GOT_VAL)) |
| 402 |
|
} else |
| 403 |
|
goto missingData; |
| 404 |
|
} |
| 405 |
< |
addray(&ryp); /* add our ray to holodeck */ |
| 405 |
> |
ngood += (addray(&ryp) > 0); /* add our ray to holodeck */ |
| 406 |
|
} |
| 407 |
|
return; |
| 408 |
|
missingData: |
| 409 |
< |
sprintf(errmsg, "insufficient data or read error for -i%s", rspec); |
| 409 |
> |
sprintf(errmsg, "insufficient data or read error with -i%s after %lu rays read (%lu used)", |
| 410 |
> |
rspec, nread, ngood); |
| 411 |
|
error(USER, errmsg); |
| 412 |
|
} |
| 413 |
|
|
| 534 |
|
hdbcoord(gc, hp, bq[bi]); |
| 535 |
|
rv = hdbray(bp); |
| 536 |
|
for (k = bp->nrm; k--; rv++) { |
| 537 |
+ |
RREAL hitd = hddepth(hp, rv->d); |
| 538 |
|
ryp.d = hdray(ryp.ro, ryp.rd, hp, gc, rv->r); |
| 539 |
|
if (*(int *)hp->priv & H_OBSF) |
| 540 |
|
VSUM(ryp.ro, ryp.ro, ryp.rd, ryp.d); |
| 541 |
< |
else |
| 542 |
< |
ryp.d = 0.; |
| 543 |
< |
ryp.d = hddepth(hp, rv->d) - ryp.d; |
| 541 |
> |
else if (*(int *)hp->priv & H_OBST) |
| 542 |
> |
ryp.d = 0; |
| 543 |
> |
else if (hitd < ryp.d) { |
| 544 |
> |
ryp.d = 0.97*hitd; |
| 545 |
> |
VSUM(ryp.ro, ryp.ro, ryp.rd, ryp.d); |
| 546 |
> |
} else |
| 547 |
> |
ryp.d = 0; |
| 548 |
> |
ryp.d = hitd - ryp.d; |
| 549 |
|
copycolr(ryp.cv, rv->v); |
| 550 |
|
if (!write_ray(&ryp, fp)) { |
| 551 |
|
free(bq); |