--- ray/src/rt/m_alias.c 2003/09/09 03:28:43 2.3 +++ ray/src/rt/m_alias.c 2004/03/30 16:13:01 2.5 @@ -1,13 +1,15 @@ #ifndef lint -static const char RCSid[] = "$Id: m_alias.c,v 2.3 2003/09/09 03:28:43 greg Exp $"; +static const char RCSid[] = "$Id: m_alias.c,v 2.5 2004/03/30 16:13:01 schorsch Exp $"; #endif /* * Handler for modifier alias */ #include "copyright.h" + #include "ray.h" #include "otypes.h" +#include "rtotypes.h" #include "otspecial.h" /* @@ -21,13 +23,16 @@ static const char RCSid[] = "$Id: m_alias.c,v 2.3 2003 * chain at all. */ -int -m_alias(m, r) /* transfer shading to alias target */ -OBJREC *m; -RAY *r; +extern int +m_alias( /* transfer shading to alias target */ + OBJREC *m, + RAY *r +) { OBJECT aobj; + OBJREC *aop; OBJREC arec; + int rval; /* straight replacement? */ if (!m->oargs.nsargs) return(rayshade(r, m->omod)); @@ -37,7 +42,8 @@ RAY *r; aobj = lastmod(objndx(m), m->oargs.sarg[0]); if (aobj < 0) objerror(m, USER, "bad reference"); - arec = *objptr(aobj); + aop = objptr(aobj); + arec = *aop; /* irradiance hack */ if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) && m->otype != MAT_CLIP && @@ -52,5 +58,12 @@ RAY *r; /* substitute modifier */ arec.omod = m->omod; /* replacement shader */ - return((*ofun[arec.otype].funp)(&arec, r)); + rval = (*ofun[arec.otype].funp)(&arec, r); + /* save allocated struct */ + if (arec.os != aop->os) { + if (aop->os != NULL) /* should never happen */ + free_os(aop); + aop->os = arec.os; + } + return(rval); }