ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/m_alias.c
(Generate patch)

Comparing ray/src/rt/m_alias.c (file contents):
Revision 2.1 by greg, Tue Mar 11 19:29:05 2003 UTC vs.
Revision 2.10 by greg, Wed Dec 5 02:12:23 2018 UTC

# Line 6 | Line 6 | static const char RCSid[] = "$Id$";
6   */
7  
8   #include "copyright.h"
9 +
10   #include "ray.h"
11   #include "otypes.h"
12 + #include "rtotypes.h"
13   #include "otspecial.h"
14  
15   /*
# Line 22 | Line 24 | static const char RCSid[] = "$Id$";
24   */
25  
26   int
27 < m_alias(m, r)                   /* transfer shading to alias target */
28 < OBJREC  *m;
29 < RAY     *r;
27 > m_alias(                        /* transfer shading to alias target */
28 >        OBJREC  *m,
29 >        RAY     *r
30 > )
31   {
32          OBJECT  aobj;
33 +        OBJREC  *aop;
34          OBJREC  arec;
35 +        int     rval;
36                                          /* straight replacement? */
37          if (!m->oargs.nsargs)
38                  return(rayshade(r, m->omod));
39 <                                        /* else replace alias */
40 <        if (m->oargs.nsargs != 1)
41 <                objerror(m, INTERNAL, "bad # string arguments");
42 <        aobj = lastmod(objndx(m), m->oargs.sarg[0]);
43 <        if (aobj < 0)
44 <                objerror(m, USER, "bad reference");
45 <        copystruct(&arec, objptr(aobj));
46 <                                        /* irradiance hack */
47 <        if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) &&
48 <                        (ofun[arec.otype].flags & (T_M|T_X))) {
49 <                if (irr_ignore(arec.otype)) {
50 <                        raytrans(r);
51 <                        return(1);
52 <                }
53 <                if (!islight(arec.otype))
54 <                        return((*ofun[Lamb.otype].funp)(&Lamb, r));
50 <        }
39 >
40 >        aop = m;                        /* else look it up */
41 >        aobj = objndx(aop);
42 >        do {                            /* follow entire alias trail */
43 >                if (!aop->oargs.nsargs)
44 >                        aobj = aop->omod;
45 >                else if (aop->oargs.nsargs == 1)
46 >                        aobj = lastmod(aobj, aop->oargs.sarg[0]);
47 >                else
48 >                        objerror(aop, INTERNAL, "bad # string arguments");
49 >                if (aobj < 0)
50 >                        objerror(aop, USER, "bad reference");
51 >                aop = objptr(aobj);
52 >        } while (aop->otype == MOD_ALIAS);
53 >                                        /* copy struct */
54 >        arec = *aop;
55                                          /* substitute modifier */
56          arec.omod = m->omod;
57 +                                        /* irradiance hack */
58 +        if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) && raytirrad(&arec, r))
59 +                return(1);
60                                          /* replacement shader */
61 <        return((*ofun[arec.otype].funp)(&arec, r));
61 >        rval = (*ofun[arec.otype].funp)(&arec, r);
62 >                                        /* save allocated struct */
63 >        if (arec.os != aop->os) {
64 >                if (aop->os != NULL)    /* should never happen */
65 >                        free_os(aop);
66 >                aop->os = arec.os;
67 >        }
68 >        return(rval);
69   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines