--- ray/src/util/glaresrc.c 2003/02/22 02:07:30 2.4 +++ ray/src/util/glaresrc.c 2022/11/29 20:45:21 2.7 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: glaresrc.c,v 2.4 2003/02/22 02:07:30 greg Exp $"; +static const char RCSid[] = "$Id: glaresrc.c,v 2.7 2022/11/29 20:45:21 greg Exp $"; #endif /* * Gather samples and compute glare sources. @@ -14,14 +14,32 @@ static const char RCSid[] = "$Id: glaresrc.c,v 2.4 200 struct source *curlist = NULL; /* current source list */ struct source *donelist = NULL; /* finished sources */ +void pict_stats(void); -struct srcspan * -newspan(l, r, v, sb) /* allocate a new source span */ -int l, r, v; -float *sb; +static struct srcspan * newspan(int l, int r, int v, float *sb); +static void addindirect(int h, int v, double br); +static void addsrcspan(struct srcspan *nss); +static void mergesource(struct source *sp, struct source *ap); +static void close_sources(int v); +static void close_allsrcs(void); +static struct srcspan * splitspan(struct srcspan *sso, double h, double v, double m); +static struct source * splitsource(struct source *so); +static void donesource(struct source *sp); +static struct source * findbuddy(struct source *s, struct source *l); +static void absorb(struct source *s); +static void freespans(struct source *sp); + + +static struct srcspan * +newspan( /* allocate a new source span */ + int l, + int r, + int v, + float *sb +) { - register struct srcspan *ss; - register int i; + struct srcspan *ss; + int i; ss = (struct srcspan *)malloc(sizeof(struct srcspan)); if (ss == NULL) @@ -36,7 +54,8 @@ float *sb; } -analyze() /* analyze our scene */ +void +analyze(void) /* analyze our scene */ { int h, v; int left; @@ -83,13 +102,16 @@ analyze() /* analyze our scene */ } -addindirect(h, v, br) /* add brightness to indirect illuminances */ -int h, v; -double br; +static void +addindirect( /* add brightness to indirect illuminances */ + int h, + int v, + double br +) { double tanb, d; int hl; - register int i; + int i; hl = hlim(v); if (h <= -hl) { /* left region */ @@ -131,7 +153,8 @@ double br; } -comp_thresh() /* compute glare threshold */ +void +comp_thresh(void) /* compute glare threshold */ { int h, v; int nsamps; @@ -170,11 +193,13 @@ comp_thresh() /* compute glare threshold */ } -addsrcspan(nss) /* add new source span to our list */ -struct srcspan *nss; +static void +addsrcspan( /* add new source span to our list */ + struct srcspan *nss +) { struct source *last, *cs, *this; - register struct srcspan *ss; + struct srcspan *ss; cs = NULL; for (this = curlist; this != NULL; this = this->next) { @@ -208,11 +233,14 @@ struct srcspan *nss; } -mergesource(sp, ap) /* merge source ap into source sp */ -struct source *sp, *ap; +static void +mergesource( /* merge source ap into source sp */ + struct source *sp, + struct source *ap +) { struct srcspan head; - register struct srcspan *alp, *prev, *tp; + struct srcspan *alp, *prev, *tp; head.next = sp->first; prev = &head; @@ -242,11 +270,13 @@ struct source *sp, *ap; } -close_sources(v) /* close sources above v */ -int v; +static void +close_sources( /* close sources above v */ + int v +) { struct source head; - register struct source *last, *this; + struct source *last, *this; head.next = curlist; last = &head; @@ -261,9 +291,10 @@ int v; } -close_allsrcs() /* done with everything */ +static void +close_allsrcs(void) /* done with everything */ { - register struct source *this, *next; + struct source *this, *next; this = curlist; while (this != NULL) { @@ -275,12 +306,15 @@ close_allsrcs() /* done with everything */ } -struct srcspan * -splitspan(sso, h, v, m) /* divide source span at point */ -register struct srcspan *sso; -double h, v, m; +static struct srcspan * +splitspan( /* divide source span at point */ + struct srcspan *sso, + double h, + double v, + double m +) { - register struct srcspan *ssn; + struct srcspan *ssn; double d; int hs; @@ -303,13 +337,14 @@ double h, v, m; } -struct source * -splitsource(so) /* divide source in two if it's big and long */ -struct source *so; +static struct source * +splitsource( /* divide source in two if it's big and long */ + struct source *so +) { LRSUM lr; LRLIN fit; - register struct srcspan *ss, *ssn; + struct srcspan *ss, *ssn; struct srcspan *ssl, *ssnl, head; int h; double mh, mv; @@ -355,11 +390,13 @@ struct source *so; } -donesource(sp) /* finished with this source */ -register struct source *sp; +static void +donesource( /* finished with this source */ + struct source *sp +) { struct source *newsrc; - register struct srcspan *ss; + struct srcspan *ss; int h, n; double hsum, vsum, d; @@ -396,9 +433,11 @@ register struct source *sp; } -struct source * -findbuddy(s, l) /* find close enough source to s in l*/ -register struct source *s, *l; +static struct source * +findbuddy( /* find close enough source to s in l*/ + struct source *s, + struct source *l +) { struct source *bestbuddy = NULL; double d, r, mindist = MAXBUDDY; @@ -415,10 +454,11 @@ register struct source *s, *l; } -absorb_specks() /* eliminate too-small sources */ +void +absorb_specks(void) /* eliminate too-small sources */ { struct source head, *buddy; - register struct source *last, *this; + struct source *last, *this; if (verbose) fprintf(stderr, "%s: absorbing small sources...\n", progname); @@ -439,12 +479,14 @@ absorb_specks() /* eliminate too-small sources */ } -absorb(s) /* absorb a source into indirect */ -register struct source *s; +static void +absorb( /* absorb a source into indirect */ + struct source *s +) { FVECT dir; double d; - register int i; + int i; for (i = 0; i < nglardirs; i++) { spinvector(dir, ourview.vdir, ourview.vup, indirect[i].theta); @@ -459,10 +501,12 @@ register struct source *s; } -freespans(sp) /* free spans associated with source */ -struct source *sp; +static void +freespans( /* free spans associated with source */ + struct source *sp +) { - register struct srcspan *ss; + struct srcspan *ss; while ((ss = sp->first) != NULL) { sp->first = ss->next;