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

Comparing ray/src/rt/initotypes.c (file contents):
Revision 2.23 by greg, Thu Nov 8 00:54:07 2018 UTC vs.
Revision 2.30 by greg, Mon Feb 1 16:19:49 2021 UTC

# Line 95 | Line 95 | initotypes(void)                       /* initialize ofun array */
95  
96  
97   int
98 < o_default(OBJREC *o, RAY *r)                    /* default action is error */
98 > o_default(OBJREC *o, RAY *r)            /* default action is error */
99   {
100          objerror(o, CONSISTENCY, "unexpected object call");
101 <                                /* unused call to load freeobjmem.o */
101 >                                        /* unused call to load freeobjmem.o */
102          free_objs(0, 0);
103          return(0);
104   }
105  
106  
107 <
108 < OBJREC *                        /* find an object's actual material */
109 < findmaterial(OBJREC *o)
107 > OBJREC *        
108 > findmaterial(OBJREC *o)                 /* find an object's actual material */
109   {
110 +        OBJECT  obj = OVOID;
111 +
112          while (!ismaterial(o->otype)) {
113                  if (o->otype == MOD_ALIAS && o->oargs.nsargs) {
114 <                        OBJECT  aobj;
115 <                        OBJREC  *ao;
116 <                        aobj = lastmod(objndx(o), o->oargs.sarg[0]);
117 <                        if (aobj < 0)
118 <                                objerror(o, USER, "bad reference");
119 <                                /* recursive check on alias branch */
120 <                        if ((ao = findmaterial(objptr(aobj))) != NULL)
114 >                        OBJREC  *ao = o;
115 >                        if (obj == OVOID)
116 >                                obj = objndx(o);
117 >                        do {
118 >                                if (!ao->oargs.nsargs)
119 >                                        obj = ao->omod;
120 >                                else
121 >                                        obj = lastmod(obj, ao->oargs.sarg[0]);
122 >                                if (obj == OVOID)
123 >                                        objerror(ao, USER, "bad reference");
124 >                                ao = objptr(obj);
125 >                        } while (ao->otype == MOD_ALIAS);
126 >                                        /* check if aliased to material */
127 >                        if (ismaterial(ao->otype))
128                                  return(ao);
129                  }
130 <                if (o->omod == OVOID)
131 <                        return(NULL);
132 <                o = objptr(o->omod);
130 >                if (o->omod == OVOID) {
131 >                                        /* void mixture de facto material? */
132 >                        if (ismixture(o->otype))
133 >                                break;
134 >                        return(NULL);   /* else no material found */
135 >                }
136 >                obj = o->omod;
137 >                o = objptr(obj);
138          }
139 <        return(o);              /* XXX: material mixtures will return NULL */
139 >        return(o);
140   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines