--- ray/src/rt/m_alias.c 2003/03/11 19:29:05 2.1 +++ ray/src/rt/m_alias.c 2004/01/20 22:16:53 2.4 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: m_alias.c,v 2.1 2003/03/11 19:29:05 greg Exp $"; +static const char RCSid[] = "$Id: m_alias.c,v 2.4 2004/01/20 22:16:53 greg Exp $"; #endif /* * Handler for modifier alias @@ -27,7 +27,9 @@ OBJREC *m; RAY *r; { OBJECT aobj; + OBJREC *aop; OBJREC arec; + int rval; /* straight replacement? */ if (!m->oargs.nsargs) return(rayshade(r, m->omod)); @@ -37,9 +39,11 @@ RAY *r; aobj = lastmod(objndx(m), m->oargs.sarg[0]); if (aobj < 0) objerror(m, USER, "bad reference"); - copystruct(&arec, objptr(aobj)); + aop = objptr(aobj); + arec = *aop; /* irradiance hack */ if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) && + m->otype != MAT_CLIP && (ofun[arec.otype].flags & (T_M|T_X))) { if (irr_ignore(arec.otype)) { raytrans(r); @@ -51,5 +55,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); }