--- ray/src/rt/virtuals.c 2003/02/22 02:07:29 2.7 +++ ray/src/rt/virtuals.c 2004/03/30 16:13:01 2.14 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: virtuals.c,v 2.7 2003/02/22 02:07:29 greg Exp $"; +static const char RCSid[] = "$Id: virtuals.c,v 2.14 2004/03/30 16:13:01 schorsch Exp $"; #endif /* * Routines for simulating virtual light sources @@ -8,62 +8,7 @@ static const char RCSid[] = "$Id: virtuals.c,v 2.7 200 * External symbols declared in source.h */ -/* ==================================================================== - * 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" #include "ray.h" @@ -81,8 +26,8 @@ static OBJECT *vobject; /* virtual source objects */ static int nvobjects = 0; /* number of virtual source objects */ -void -markvirtuals() /* find and mark virtual sources */ +extern void +markvirtuals(void) /* find and mark virtual sources */ { register OBJREC *o; register int i; @@ -90,7 +35,7 @@ markvirtuals() /* find and mark virtual sources */ if (directrelay <= 0) return; /* find virtual source objects */ - for (i = 0; i < nobjects; i++) { + for (i = 0; i < nsceneobjs; i++) { o = objptr(i); if (!issurface(o->otype) || o->omod == OVOID) continue; @@ -104,7 +49,7 @@ markvirtuals() /* find and mark virtual sources */ if (nvobjects == 0) vobject = (OBJECT *)malloc(sizeof(OBJECT)); else - vobject = (OBJECT *)realloc((char *)vobject, + vobject = (OBJECT *)realloc((void *)vobject, (unsigned)(nvobjects+1)*sizeof(OBJECT)); if (vobject == NULL) error(SYSTEM, "out of memory in addvirtuals"); @@ -124,10 +69,11 @@ markvirtuals() /* find and mark virtual sources */ } -void -addvirtuals(sn, nr) /* add virtuals associated with source */ -int sn; -int nr; +extern void +addvirtuals( /* add virtuals associated with source */ + int sn, + int nr +) { register int i; /* check relay limit first */ @@ -142,11 +88,12 @@ int nr; } -void -vproject(o, sn, n) /* create projected source(s) if they exist */ -OBJREC *o; -int sn; -int n; +extern void +vproject( /* create projected source(s) if they exist */ + OBJREC *o, + int sn, + int n +) { register int i; register VSMATERIAL *vsmat; @@ -170,15 +117,18 @@ int n; } -OBJREC * -vsmaterial(o) /* get virtual source material pointer */ -OBJREC *o; +extern OBJREC * +vsmaterial( /* get virtual source material pointer */ + OBJREC *o +) { register int i; register OBJREC *m; i = o->omod; - m = objptr(i); + m = findmaterial(objptr(i)); + if (m == NULL) + return(objptr(i)); if (m->otype != MAT_ILLUM || m->oargs.nsargs < 1 || !strcmp(m->oargs.sarg[0], VOIDID) || (i = lastmod(objndx(m), m->oargs.sarg[0])) == OVOID) @@ -187,11 +137,12 @@ OBJREC *o; } -int -makevsrc(op, sn, pm) /* make virtual source if reasonable */ -OBJREC *op; -register int sn; -MAT4 pm; +extern int +makevsrc( /* make virtual source if reasonable */ + OBJREC *op, + register int sn, + MAT4 pm +) { FVECT nsloc, nsnorm, ocent, v; double maxrad2, d; @@ -249,7 +200,7 @@ MAT4 pm; else nsflags &= ~SSPOT; if (source[sn].sflags & SSPOT) { - copystruct(&theirspot, source[sn].sl.s); + theirspot = *(source[sn].sl.s); multv3(theirspot.aim, source[sn].sl.s->aim, pm); normalize(theirspot.aim); if (nsflags & SSPOT) { @@ -259,7 +210,7 @@ MAT4 pm; return(-1); /* no overlap */ } else { nsflags |= SSPOT; - copystruct(&ourspot, &theirspot); + ourspot = theirspot; d = 2.*ourspot.siz; } if (ourspot.siz < d-FTINY) { /* it shrunk */ @@ -299,7 +250,7 @@ MAT4 pm; if (nsflags & SSPOT) { if ((source[i].sl.s = (SPOT *)malloc(sizeof(SPOT))) == NULL) goto memerr; - copystruct(source[i].sl.s, &ourspot); + *(source[i].sl.s) = ourspot; } if (nsflags & SPROX) source[i].sl.prox = source[sn].sl.prox; @@ -308,14 +259,16 @@ MAT4 pm; return(i); memerr: error(SYSTEM, "out of memory in makevsrc"); + return -1; /* pro forma return */ } -double -getdisk(oc, op, sn) /* get visible object disk */ -FVECT oc; -OBJREC *op; -register int sn; +extern double +getdisk( /* get visible object disk */ + FVECT oc, + OBJREC *op, + register int sn +) { double rad2, roffs, offs, d, rd, rdoto; FVECT rnrm, nrm; @@ -343,13 +296,14 @@ register int sn; } -int -vstestvis(f, o, oc, or2, sn) /* pretest source visibility */ -int f; /* virtual source flags */ -OBJREC *o; /* relay object */ -FVECT oc; /* relay object center */ -double or2; /* relay object radius squared */ -register int sn; /* target source number */ +extern int +vstestvis( /* pretest source visibility */ + int f, /* virtual source flags */ + OBJREC *o, /* relay object */ + FVECT oc, /* relay object center */ + double or2, /* relay object radius squared */ + register int sn /* target source number */ +) { RAY sr; FVECT onorm; @@ -450,10 +404,11 @@ register int sn; /* target source number */ #ifdef DEBUG -void -virtverb(sn, fp) /* print verbose description of virtual source */ -register int sn; -FILE *fp; +extern void +virtverb( /* print verbose description of virtual source */ + register int sn, + FILE *fp +) { register int i;