--- ray/src/util/ranimove1.c 2003/02/22 02:07:30 3.1
+++ ray/src/util/ranimove1.c 2003/10/21 19:19:29 3.7
@@ -1,5 +1,5 @@
#ifndef lint
-static const char RCSid[] = "$Id: ranimove1.c,v 3.1 2003/02/22 02:07:30 greg Exp $";
+static const char RCSid[] = "$Id: ranimove1.c,v 3.7 2003/10/21 19:19:29 schorsch Exp $";
#endif
/*
* ranimove1.c
@@ -9,63 +9,11 @@ static const char RCSid[] = "$Id: ranimove1.c,v 3.1 20
* Created by Gregory Ward on Wed Jan 08 2003.
*/
-/* ====================================================================
- * 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
+
+#include "platform.h"
#include "ranimove.h"
#include "otypes.h"
#include "random.h"
@@ -131,9 +79,9 @@ next_frame() /* prepare next frame buffer */
char *err;
/* get previous view */
if (vw.type != 0)
- copystruct(&vwprev, &vw);
+ vwprev = vw;
else if (fcur > 1 && (fv = getview(fcur-1)) != NULL) {
- copystruct(&vwprev, fv);
+ vwprev = *fv;
if (setview(&vwprev) != NULL)
vwprev.type = 0;
}
@@ -142,7 +90,7 @@ next_frame() /* prepare next frame buffer */
sprintf(errmsg, "cannot get view for frame %d", fcur);
error(USER, errmsg);
}
- copystruct(&vw, fv);
+ vw = *fv;
if ((err = setview(&vw)) != NULL) {
sprintf(errmsg, "view error at frame %d: %s", fcur, err);
error(USER, errmsg);
@@ -158,7 +106,7 @@ next_frame() /* prepare next frame buffer */
pixaspect = 1.;
/* fall through */
case 3:
- if ((hres > 0 & vres > 0))
+ if ((hres > 0) & (vres > 0))
break;
/* fall through */
default:
@@ -177,11 +125,11 @@ next_frame() /* prepare next frame buffer */
zprev = (float *)malloc(sizeof(float)*hres*vres);
oprev = (OBJECT *)malloc(sizeof(OBJECT)*hres*vres);
aprev = (BYTE *)malloc(sizeof(BYTE)*hres*vres);
- if ((cbuffer==NULL | zbuffer==NULL | obuffer==NULL |
- xmbuffer==NULL | ymbuffer==NULL |
- abuffer==NULL | sbuffer==NULL |
- cprev==NULL | zprev == NULL |
- oprev==NULL | aprev==NULL))
+ if ((cbuffer==NULL) | (zbuffer==NULL) | (obuffer==NULL) |
+ (xmbuffer==NULL) | (ymbuffer==NULL) |
+ (abuffer==NULL) | (sbuffer==NULL) |
+ (cprev==NULL) | (zprev == NULL) |
+ (oprev==NULL) | (aprev==NULL))
error(SYSTEM, "out of memory in init_frame");
frm_stop = getTime() + rtperfrm;
} else {
@@ -193,8 +141,8 @@ next_frame() /* prepare next frame buffer */
fp = zprev; zprev = zbuffer; zbuffer = fp;
op = oprev; oprev = obuffer; obuffer = op;
bp = aprev; aprev = abuffer; abuffer = bp;
- bzero(abuffer, sizeof(BYTE)*hres*vres);
- bzero(sbuffer, sizeof(BYTE)*hres*vres);
+ memset(abuffer, '\0', sizeof(BYTE)*hres*vres);
+ memset(sbuffer, '\0', sizeof(BYTE)*hres*vres);
frm_stop += rtperfrm;
}
cerrmap = NULL;
@@ -238,7 +186,9 @@ sample_wt(xo, yo) /* compute interpolant sample weigh
int xo, yo;
{
static double etab[400];
- int rad2 = xo*xo + yo*yo;
+ /* we can't use the name rad2 here, for some reason Visual C
+ thinks that is a constant (compiler bug?) */
+ int rad_2 = xo*xo + yo*yo;
int i;
if (etab[0] <= FTINY) /* initialize exponent table */
@@ -246,7 +196,7 @@ int xo, yo;
etab[i] = exp(-0.1*i);
/* look up Gaussian */
- i = (int)((10.*3./(double)SAMPDIST2)*rad2 + .5);
+ i = (int)((10.*3./(double)SAMPDIST2)*rad_2 + .5);
if (i >= 400)
return(0.0);
return(etab[i]);
@@ -276,8 +226,8 @@ int x, y;
/* get our object number */
myobj = obuffer[fndx(x, y)];
/* special case for borders */
- if ((x < SAMPDIST | x >= hres-SAMPDIST |
- y < SAMPDIST | y >= vres-SAMPDIST)) {
+ if ((x < SAMPDIST) | (x >= hres-SAMPDIST) |
+ (y < SAMPDIST) | (y >= vres-SAMPDIST)) {
int tndx[NSCHECK][2];
nf = 0;
for (j = y - SAMPDIST; j <= y + SAMPDIST; j++) {
@@ -289,7 +239,7 @@ int x, y;
i0 = fndx(i, j);
if (!sbuffer[i0])
continue;
- if ((myobj != OVOID & obuffer[i0] != myobj))
+ if ((myobj != OVOID) & (obuffer[i0] != myobj))
continue;
tndx[nf][0] = (i-x)*(i-x) + (j-y)*(j-y);
tndx[nf][1] = i0;
@@ -304,7 +254,7 @@ int x, y;
return(nf);
}
/* initialize offset array */
- if ((hres != hro | vres != vro)) {
+ if ((hres != hro) | (vres != vro)) {
int toffs[NSCHECK][2];
i0 = fndx(SAMPDIST, SAMPDIST);
nf = 0;
@@ -323,9 +273,9 @@ int x, y;
}
/* find up to nc neighbors */
i0 = fndx(x, y);
- for (j = 0, nf = 0; (j < NSCHECK & nf < nc); j++) {
+ for (j = 0, nf = 0; (j < NSCHECK) & (nf < nc); j++) {
i = i0 + ioffs[j];
- if (sbuffer[i] && (myobj == OVOID | obuffer[i] == myobj))
+ if (sbuffer[i] && (myobj == OVOID) | (obuffer[i] == myobj))
iarr[nf++] = i;
}
/* return number found */
@@ -361,12 +311,12 @@ FVECT wpos;
yp = (int)(ovp[1]*vres);
xmbuffer[n] = xp - (n % hres);
ymbuffer[n] = yp - (n / hres);
- if ((xp < 0 | xp >= hres))
+ if ((xp < 0) | (xp >= hres))
return;
- if ((yp < 0 | yp >= vres))
+ if ((yp < 0) | (yp >= vres))
return;
n = fndx(xp, yp);
- if ((zprev[n] < 0.97*ovp[2] | zprev[n] > 1.03*ovp[2]))
+ if ((zprev[n] < 0.97*ovp[2]) | (zprev[n] > 1.03*ovp[2]))
oprev[n] = OVOID; /* assume it's a bad match */
}
@@ -459,11 +409,11 @@ init_frame_sample() /* sample our initial frame */
n = fndx(x, y);
if ((obj = obuffer[n]) == OVOID)
continue;
- if ((obuffer[n+1] != OVOID & obuffer[n+1] != obj)) {
+ if ((obuffer[n+1] != OVOID) & (obuffer[n+1] != obj)) {
obuffer[n] = OVOID;
obuffer[n+1] = OVOID;
}
- if ((obuffer[n+hres] != OVOID & obuffer[n+hres] != obj)) {
+ if ((obuffer[n+hres] != OVOID) & (obuffer[n+hres] != obj)) {
obuffer[n] = OVOID;
obuffer[n+hres] = OVOID;
}
@@ -484,7 +434,7 @@ int obj;
if (obj == OVOID)
return(0);
op = objptr(obj);
- if ((op->otype == OBJ_INSTANCE & op->omod == OVOID))
+ if ((op->otype == OBJ_INSTANCE) & (op->omod == OVOID))
return(0);
/* search for material */
do {
@@ -581,7 +531,7 @@ int ns0;
/* add together samples */
setcolor(csum, 0., 0., 0.);
setcolor(csum2, 0., 0., 0.);
- for (i = 0, ns = 0; (i < nc & ns < NSAMPOK); i++) {
+ for (i = 0, ns = 0; (i < nc) & (ns < NSAMPOK); i++) {
n = neigh[i];
addcolor(csum, cbuffer[n]);
if (val2map != NULL) {
@@ -633,7 +583,7 @@ comp_frame_error() /* initialize frame error values *
for (y = vres; y--; )
for (x = hres; x--; ) {
n = fndx(x, y);
- if ((abuffer[n] != ALOWQ | obuffer[n] == OVOID))
+ if ((abuffer[n] != ALOWQ) | (obuffer[n] == OVOID))
continue;
if (!getambcolor(objamb, obuffer[n]))
continue;
@@ -692,11 +642,12 @@ init_frame() /* render base (low quality) frame */
restart = (!nobjects || vdef(MOVE));
if (!restart && curparams != &lorendparams && nprocs > 1)
restart = -1;
- if (restart > 0)
+ if (restart > 0) {
if (nprocs > 1)
ray_pdone(1);
else
ray_done(1);
+ }
/* post low quality parameters */
if (curparams != &lorendparams)
ray_restore(curparams = &lorendparams);
@@ -811,8 +762,8 @@ write_map(cerrmap, "outcmap.pic");
int n2;
int cnt;
/* sum in motion streaks */
- bzero(outbuffer, sizeof(COLOR)*hres*vres);
- bzero(wbuffer, sizeof(float)*hres*vres);
+ memset(outbuffer, '\0', sizeof(COLOR)*hres*vres);
+ memset(wbuffer, '\0', sizeof(float)*hres*vres);
for (y = vres; y--; )
for (x = hres; x--; ) {
n = fndx(x, y);
@@ -841,8 +792,8 @@ write_map(cerrmap, "outcmap.pic");
scalecolor(cval, w);
while (cnt)
if (rise2 >= run2) {
- if ((xl >= 0 & xl < hres &
- yl >= 0 & yl < vres)) {
+ if ((xl >= 0) & (xl < hres) &
+ (yl >= 0) & (yl < vres)) {
n2 = fndx(xl, yl);
addcolor(outbuffer[n2],
cval);
@@ -862,8 +813,8 @@ write_map(cerrmap, "outcmap.pic");
scalecolor(cval, w);
while (cnt)
if (run2 >= rise2) {
- if ((xl >= 0 & xl < hres &
- yl >= 0 & yl < vres)) {
+ if ((xl >= 0) & (xl < hres) &
+ (yl >= 0) & (yl < vres)) {
n2 = fndx(xl, yl);
addcolor(outbuffer[n2],
cval);
@@ -896,7 +847,7 @@ for (n = hres*vres; n--; )
setcolor(outbuffer[n], 0., 0., 0.);
*/
/* adjust exposure */
- if ((expval < 0.99 | expval > 1.01))
+ if ((expval < 0.99) | (expval > 1.01))
for (n = hres*vres; n--; )
scalecolor(outbuffer[n], expval);
return;
@@ -928,9 +879,7 @@ send_frame() /* send frame to destination */
sprintf(errmsg, "cannot open output frame \"%s\"", pfname);
error(SYSTEM, errmsg);
}
-#ifdef MSDOS
- setmode(fileno(fp), O_BINARY);
-#endif
+ SET_FILE_BINARY(fp);
if (!silent) {
printf("\tWriting to \"%s\"\n", pfname);
fflush(stdout);
@@ -943,10 +892,10 @@ send_frame() /* send frame to destination */
fputnow(fp);
fputs(VIEWSTR, fp); fprintview(&vw, fp); fputc('\n', fp);
d = expspec_val(getexp(fcur));
- if ((d < 0.99 | d > 1.01))
+ if ((d < 0.99) | (d > 1.01))
fputexpos(d, fp);
d = viewaspect(&vw) * hres / vres;
- if ((d < 0.99 | d > 1.01))
+ if ((d < 0.99) | (d > 1.01))
fputaspect(d, fp);
fputformat(COLRFMT, fp);
fputc('\n', fp); /* end header */