27 |
|
RAY *r; |
28 |
|
{ |
29 |
|
OBJECT aobj; |
30 |
+ |
OBJREC *aop; |
31 |
|
OBJREC arec; |
32 |
+ |
int rval; |
33 |
|
/* straight replacement? */ |
34 |
|
if (!m->oargs.nsargs) |
35 |
|
return(rayshade(r, m->omod)); |
39 |
|
aobj = lastmod(objndx(m), m->oargs.sarg[0]); |
40 |
|
if (aobj < 0) |
41 |
|
objerror(m, USER, "bad reference"); |
42 |
< |
arec = *objptr(aobj); |
42 |
> |
aop = objptr(aobj); |
43 |
> |
arec = *aop; |
44 |
|
/* irradiance hack */ |
45 |
|
if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) && |
46 |
|
m->otype != MAT_CLIP && |
55 |
|
/* substitute modifier */ |
56 |
|
arec.omod = m->omod; |
57 |
|
/* replacement shader */ |
58 |
< |
return((*ofun[arec.otype].funp)(&arec, r)); |
58 |
> |
rval = (*ofun[arec.otype].funp)(&arec, r); |
59 |
> |
/* save allocated struct */ |
60 |
> |
if (arec.os != aop->os) { |
61 |
> |
if (aop->os != NULL) /* should never happen */ |
62 |
> |
free_os(aop); |
63 |
> |
aop->os = arec.os; |
64 |
> |
} |
65 |
> |
return(rval); |
66 |
|
} |