--- ray/src/rt/rtrace.c 2003/02/22 02:07:29 2.27 +++ ray/src/rt/rtrace.c 2003/09/24 14:55:54 2.34 @@ -1,66 +1,11 @@ #ifndef lint -static const char RCSid[] = "$Id: rtrace.c,v 2.27 2003/02/22 02:07:29 greg Exp $"; +static const char RCSid[] = "$Id: rtrace.c,v 2.34 2003/09/24 14:55:54 greg Exp $"; #endif /* * rtrace.c - program and variables for individual ray tracing. */ -/* ==================================================================== - * The Radiance Software License, Version 1.0 - * - * Copyright (c) 1990 - 2002 The Regents of the University of California, - * through Lawrence Berkeley National Laboratory. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes Radiance software - * (http://radsite.lbl.gov/) - * developed by the Lawrence Berkeley National Laboratory - * (http://www.lbl.gov/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Radiance," "Lawrence Berkeley National Laboratory" - * and "The Regents of the University of California" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact radiance@radsite.lbl.gov. - * - * 5. Products derived from this software may not be called "Radiance", - * nor may "Radiance" appear in their name, without prior written - * permission of Lawrence Berkeley National Laboratory. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of Lawrence Berkeley National Laboratory. For more - * information on Lawrence Berkeley National Laboratory, please see - * . - */ +#include "copyright.h" /* * Input is in the form: @@ -76,10 +21,11 @@ static const char RCSid[] = "$Id: rtrace.c,v 2.27 2003 * irradiance values are desired. */ -#include "ray.h" +#include +#include "platform.h" +#include "ray.h" #include "otypes.h" - #include "resolu.h" CUBE thescene; /* our scene */ @@ -128,16 +74,16 @@ double specjitter = 1.; /* specular sampling jitter int backvis = 1; /* back face visibility */ -int maxdepth = 6; /* maximum recursion depth */ -double minweight = 4e-3; /* minimum ray weight */ +int maxdepth = 8; /* maximum recursion depth */ +double minweight = 2e-3; /* minimum ray weight */ char *ambfile = NULL; /* ambient file name */ COLOR ambval = BLKCOLOR; /* ambient value */ int ambvwt = 0; /* initial weight for ambient value */ -double ambacc = 0.2; /* ambient accuracy */ -int ambres = 128; /* ambient resolution */ -int ambdiv = 512; /* ambient divisions */ -int ambssamp = 0; /* ambient super-samples */ +double ambacc = 0.1; /* ambient accuracy */ +int ambres = 256; /* ambient resolution */ +int ambdiv = 1024; /* ambient divisions */ +int ambssamp = 512; /* ambient super-samples */ int ambounce = 0; /* ambient bounces */ char *amblist[128]; /* ambient include/exclude list */ int ambincl = -1; /* include == 1, exclude == 0 */ @@ -145,7 +91,7 @@ int ambincl = -1; /* include == 1, exclude == 0 */ static RAY thisray; /* for our convenience */ -static void oputo(), oputd(), oputv(), oputl(), oputL(), +static void oputo(), oputd(), oputv(), oputl(), oputL(), oputc(), oputp(), oputn(), oputN(), oputs(), oputw(), oputm(); static void ourtrace(), tabin(); @@ -163,7 +109,7 @@ void quit(code) /* quit program */ int code; { -#ifndef NIX +#ifndef NON_POSIX /* XXX we don't clean up elsewhere? */ headclean(); /* delete header file */ pfclean(); /* clean up persist files */ #endif @@ -201,9 +147,9 @@ char *fname; sprintf(errmsg, "cannot open input file \"%s\"", fname); error(SYSTEM, errmsg); } -#ifdef MSDOS +#ifdef _WIN32 if (inform != 'a') - setmode(fileno(fp), O_BINARY); + SET_FILE_BINARY(fp); #endif /* set up output */ setoutput(outvals); @@ -289,6 +235,9 @@ register char *vs; *table++ = oputl; castonly = 0; break; + case 'c': /* local coordinates */ + *table++ = oputc; + break; case 'L': /* single ray length */ *table++ = oputL; break; @@ -336,12 +285,13 @@ double dmax; thisray.rmax = dmax; rayorigin(&thisray, NULL, PRIMARY, 1.0); if (castonly) { - if (!localhit(&thisray, &thescene)) + if (!localhit(&thisray, &thescene)) { if (thisray.ro == &Aftplane) { /* clipped */ thisray.ro = NULL; thisray.rot = FHUGE; } else sourcehit(&thisray); + } } else rayvalue(&thisray); printvals(&thisray); @@ -484,7 +434,7 @@ RAY *r; static void oputo(r) /* print origin */ -register RAY *r; +RAY *r; { (*putreal)(r->rorg[0]); (*putreal)(r->rorg[1]); @@ -494,7 +444,7 @@ register RAY *r; static void oputd(r) /* print direction */ -register RAY *r; +RAY *r; { (*putreal)(r->rdir[0]); (*putreal)(r->rdir[1]); @@ -504,7 +454,7 @@ register RAY *r; static void oputv(r) /* print value */ -register RAY *r; +RAY *r; { COLR cout; @@ -523,7 +473,7 @@ register RAY *r; static void oputl(r) /* print effective distance */ -register RAY *r; +RAY *r; { (*putreal)(r->rt); } @@ -531,15 +481,24 @@ register RAY *r; static void oputL(r) /* print single ray length */ -register RAY *r; +RAY *r; { (*putreal)(r->rot); } static void +oputc(r) /* print local coordinates */ +RAY *r; +{ + (*putreal)(r->uv[0]); + (*putreal)(r->uv[1]); +} + + +static void oputp(r) /* print point */ -register RAY *r; +RAY *r; { if (r->rot < FHUGE) { (*putreal)(r->rop[0]); @@ -555,7 +514,7 @@ register RAY *r; static void oputN(r) /* print unperturbed normal */ -register RAY *r; +RAY *r; { if (r->rot < FHUGE) { (*putreal)(r->ron[0]); @@ -590,7 +549,7 @@ RAY *r; static void oputs(r) /* print name */ -register RAY *r; +RAY *r; { if (r->ro != NULL) fputs(r->ro->oname, stdout); @@ -602,7 +561,7 @@ register RAY *r; static void oputw(r) /* print weight */ -register RAY *r; +RAY *r; { (*putreal)(r->rweight); } @@ -610,7 +569,7 @@ register RAY *r; static void oputm(r) /* print modifier */ -register RAY *r; +RAY *r; { if (r->ro != NULL) if (r->ro->omod != OVOID)