ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/m_alias.c
Revision: 2.1
Committed: Tue Mar 11 19:29:05 2003 UTC (21 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Log Message:
Changed alias handling to allow tracking, fixed freeobjects() and do_irrad bugs

File Contents

# User Rev Content
1 greg 2.1 #ifndef lint
2     static const char RCSid[] = "$Id$";
3     #endif
4     /*
5     * Handler for modifier alias
6     */
7    
8     #include "copyright.h"
9     #include "ray.h"
10     #include "otypes.h"
11     #include "otspecial.h"
12    
13     /*
14     * If the alias has a single string argument, it's the
15     * name of the target modifier, and we must substitute the
16     * target and its arguments in place of this alias. The
17     * only difference is that we use our modifier rather than
18     * theirs.
19     * If the alias has no string arguments, then we simply
20     * pass through to our modifier as if we weren't in the
21     * chain at all.
22     */
23    
24     int
25     m_alias(m, r) /* transfer shading to alias target */
26     OBJREC *m;
27     RAY *r;
28     {
29     OBJECT aobj;
30     OBJREC arec;
31     /* straight replacement? */
32     if (!m->oargs.nsargs)
33     return(rayshade(r, m->omod));
34     /* else replace alias */
35     if (m->oargs.nsargs != 1)
36     objerror(m, INTERNAL, "bad # string arguments");
37     aobj = lastmod(objndx(m), m->oargs.sarg[0]);
38     if (aobj < 0)
39     objerror(m, USER, "bad reference");
40     copystruct(&arec, objptr(aobj));
41     /* irradiance hack */
42     if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) &&
43     (ofun[arec.otype].flags & (T_M|T_X))) {
44     if (irr_ignore(arec.otype)) {
45     raytrans(r);
46     return(1);
47     }
48     if (!islight(arec.otype))
49     return((*ofun[Lamb.otype].funp)(&Lamb, r));
50     }
51     /* substitute modifier */
52     arec.omod = m->omod;
53     /* replacement shader */
54     return((*ofun[arec.otype].funp)(&arec, r));
55     }