Skip to content

Commit

Permalink
fix(rcontrib): Added a check that the number of color samples doesn't…
Browse files Browse the repository at this point in the history
… change after the first modifier is specified
  • Loading branch information
Gregungory committed Oct 23, 2024
1 parent 8e0047b commit 814b611
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
8 changes: 6 additions & 2 deletions doc/man/man1/rcontrib.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" RCSid "$Id: rcontrib.1,v 1.23 2023/12/12 16:31:45 greg Exp $"
.\" RCSid "$Id: rcontrib.1,v 1.24 2024/10/23 23:51:20 greg Exp $"
.TH RCONTRIB 1 5/25/05 RADIANCE
.SH NAME
rcontrib - compute contribution coefficients in a RADIANCE scene
Expand Down Expand Up @@ -208,7 +208,11 @@ and
.I \-o
options to the left of each
.I \-m
setting are the ones used for that modifier.
name are the ones used for that modifier.
Any
.I \-cs
option changing the number of spectral color
samples must appear before the first modifier.
The ordering of other options is unimportant, except for
.I \-x
and
Expand Down
20 changes: 13 additions & 7 deletions src/rt/rcontrib.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: rcontrib.c,v 2.45 2024/08/21 20:42:20 greg Exp $";
static const char RCSid[] = "$Id: rcontrib.c,v 2.46 2024/10/23 23:51:20 greg Exp $";
#endif
/*
* Accumulate ray contributions for a set of materials
Expand Down Expand Up @@ -91,11 +91,17 @@ formstr( /* return format identifier */
MODCONT *
addmodifier(char *modn, char *outf, char *prms, char *binv, int bincnt)
{
LUENT *lep = lu_find(&modconttab,modn);
MODCONT *mp;
EPNODE *ebinv;
int i;

static int lastNCS = 0;
LUENT *lep = lu_find(&modconttab,modn);
MODCONT *mp;
EPNODE *ebinv;
int i;

if (!lastNCS)
lastNCS = NCSAMP;
else if (NCSAMP != lastNCS)
error(INTERNAL,
"number of spectral samples must be set before first modifier");
if (lep->data != NULL) {
sprintf(errmsg, "duplicate modifier '%s'", modn);
error(USER, errmsg);
Expand All @@ -111,7 +117,7 @@ addmodifier(char *modn, char *outf, char *prms, char *binv, int bincnt)
else
modname = (char **)realloc(modname, modasiz*sizeof(char *));
if (modname == NULL)
error(SYSTEM, "Out of memory in addmodifier()");
error(SYSTEM, "out of memory in addmodifier()");
}
modname[nmods++] = modn; /* XXX assumes static string */
lep->key = modn; /* XXX assumes static string */
Expand Down

0 comments on commit 814b611

Please sign in to comment.