681 lines
64 KiB
HTML
Executable File
681 lines
64 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="generator" content="TempleOS V5.03">
|
|
<meta name="viewport" content="width=device-width">
|
|
<link rel="stylesheet" href="/style/templeos.css">
|
|
<script src="/script/templeos.js"></script>
|
|
<style type="text/css">
|
|
.cF0{color:#000000;background-color:#ffffff;}
|
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
|
.cF8{color:#555555;background-color:#ffffff;}
|
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre id="content">
|
|
<a name="l1"></a><span class=cF2>/*</span><span class=cF0>
|
|
<a name="l2"></a></span><span class=cF2>There is a coarse and a fine-grained.</span><span class=cF0>
|
|
<a name="l3"></a></span><span class=cF2>The coarse gets flood-filled but the</span><span class=cF0>
|
|
<a name="l4"></a></span><span class=cF2>fine grained is only outlines.</span><span class=cF0>
|
|
<a name="l5"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l6"></a>
|
|
<a name="l7"></a></span><span class=cF1>class</span><span class=cF0> Photon
|
|
<a name="l8"></a>{
|
|
<a name="l9"></a> Photon *next,*last;
|
|
<a name="l10"></a> </span><span class=cF9>CD3</span><span class=cF0> p,v,n,p_normal_inhibit;
|
|
<a name="l11"></a>} p_root[</span><span class=cFB>mp_cnt</span><span class=cF0>];
|
|
<a name="l12"></a></span><span class=cF9>I64</span><span class=cF0> p_root_locks;
|
|
<a name="l13"></a>
|
|
<a name="l14"></a>#</span><span class=cF1>define</span><span class=cF0> ANIMATE_JIFFIES (</span><span class=cF3>JIFFY_FREQ</span><span class=cF0>*0.01)
|
|
<a name="l15"></a></span><span class=cF9>I64</span><span class=cF0> master_sleep_jiffy;
|
|
<a name="l16"></a></span><span class=cF9>CTask</span><span class=cF0> *animate_tasks[</span><span class=cFB>mp_cnt</span><span class=cF0>];
|
|
<a name="l17"></a>
|
|
<a name="l18"></a>#</span><span class=cF1>define</span><span class=cF0> LENS_COLOR </span><span class=cF3>WHITE</span><span class=cF0>
|
|
<a name="l19"></a>#</span><span class=cF1>define</span><span class=cF0> MIRROR_COLOR </span><span class=cF3>DKGRAY</span><span class=cF0>
|
|
<a name="l20"></a></span><span class=cF9>CDC</span><span class=cF0> *map;
|
|
<a name="l21"></a>
|
|
<a name="l22"></a></span><span class=cF9>I64</span><span class=cF0> photon_cnt,mirror_cnt,snell_cnt,normal_inhibit,zero_normal;
|
|
<a name="l23"></a></span><span class=cF1>Bool</span><span class=cF0> full_speed,show_normals;
|
|
<a name="l24"></a>
|
|
<a name="l25"></a></span><span class=cF1>U8</span><span class=cF0> *bmp_refract,*bmp_reflect;
|
|
<a name="l26"></a></span><span class=cF1>F64</span><span class=cF0> bmp_scale,find_normal_dist_sqr;
|
|
<a name="l27"></a></span><span class=cF9>I64</span><span class=cF0> bmp_mem,bmp_width,bmp_height,bmp_norm_radius;
|
|
<a name="l28"></a>
|
|
<a name="l29"></a>#</span><span class=cF1>define</span><span class=cF0> BORDER 10
|
|
<a name="l30"></a></span><span class=cF9>I64</span><span class=cF0> BmpPeek(</span><span class=cF1>U8</span><span class=cF0> *bmp,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y)
|
|
<a name="l31"></a>{
|
|
<a name="l32"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Bt</span><span class=cF0>(bmp,y*bmp_width+x);
|
|
<a name="l33"></a>}
|
|
<a name="l34"></a>
|
|
<a name="l35"></a></span><span class=cF1>U0</span><span class=cF0> BmpPlot(</span><span class=cF1>U8</span><span class=cF0> *bmp,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l36"></a>{
|
|
<a name="l37"></a> </span><span class=cF1>if</span><span class=cF0> (0<=x<bmp_width && 0<=y<bmp_height)
|
|
<a name="l38"></a> </span><span class=cF5>Bts</span><span class=cF0>(bmp,y*bmp_width+x);
|
|
<a name="l39"></a>}
|
|
<a name="l40"></a>
|
|
<a name="l41"></a></span><span class=cF1>U0</span><span class=cF0> BmpLine(</span><span class=cF1>U8</span><span class=cF0> *bmp,</span><span class=cF1>F64</span><span class=cF0> x1,</span><span class=cF1>F64</span><span class=cF0> y1,</span><span class=cF1>F64</span><span class=cF0> x2,</span><span class=cF1>F64</span><span class=cF0> y2)
|
|
<a name="l42"></a>{
|
|
<a name="l43"></a> </span><span class=cF5>Line</span><span class=cF0>(bmp,x1*bmp_scale,y1*bmp_scale,0,x2*bmp_scale,y2*bmp_scale,0,&BmpPlot);
|
|
<a name="l44"></a>}
|
|
<a name="l45"></a>
|
|
<a name="l46"></a>Photon *PhotonNew()
|
|
<a name="l47"></a>{
|
|
<a name="l48"></a> </span><span class=cF9>I64</span><span class=cF0> num=photon_cnt++%</span><span class=cFB>mp_cnt</span><span class=cF0>;
|
|
<a name="l49"></a> Photon *res=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Photon</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l50"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&p_root_locks,num</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l51"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l52"></a> </span><span class=cF5>QueIns</span><span class=cF0>(res,p_root[num].last);
|
|
<a name="l53"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&p_root_locks,num);
|
|
<a name="l54"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l55"></a>}
|
|
<a name="l56"></a>
|
|
<a name="l57"></a>#</span><span class=cF1>define</span><span class=cF0> VECTOR 20
|
|
<a name="l58"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DrawIt</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *,</span><span class=cF9>CDC</span><span class=cF0> *dc)
|
|
<a name="l59"></a>{
|
|
<a name="l60"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l61"></a> Photon *tmpp;
|
|
<a name="l62"></a> </span><span class=cF5>GrBlot</span><span class=cF0>(dc,0,0,map);
|
|
<a name="l63"></a> dc->color=</span><span class=cF3>WHITE</span><span class=cF0>;
|
|
<a name="l64"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,0,0,</span><span class=cF6>"Mem:0x%X %,dMeg Scale:%0.3f (%d,%d)-->(%d,%d)"</span><span class=cF0>,
|
|
<a name="l65"></a> bmp_mem,bmp_mem/1024/1024,bmp_scale,
|
|
<a name="l66"></a> map->width,map->height,bmp_width,bmp_height);
|
|
<a name="l67"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,0,</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>,
|
|
<a name="l68"></a> </span><span class=cF6>"PhotonCnt:%d MirrorCnt:%d SnellCnt:%d SnellInhibit:%d ZeroNormal:%d"</span><span class=cF0>,
|
|
<a name="l69"></a> photon_cnt,mirror_cnt,snell_cnt,normal_inhibit,zero_normal);
|
|
<a name="l70"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<</span><span class=cFB>mp_cnt</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l71"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&p_root_locks,i</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l72"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l73"></a> tmpp=p_root[i].next;
|
|
<a name="l74"></a> </span><span class=cF1>while</span><span class=cF0> (tmpp!=&p_root[i]) {
|
|
<a name="l75"></a> dc->color=</span><span class=cF3>LTRED</span><span class=cF0>;
|
|
<a name="l76"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,tmpp->p.x-VECTOR*tmpp->v.x,tmpp->p.y-VECTOR*tmpp->v.y,
|
|
<a name="l77"></a> tmpp->p.x,tmpp->p.y);
|
|
<a name="l78"></a> </span><span class=cF1>if</span><span class=cF0> (show_normals) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l79"></a> dc->color=</span><span class=cF3>LTGREEN</span><span class=cF0>;
|
|
<a name="l80"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,tmpp->p.x,tmpp->p.y,
|
|
<a name="l81"></a> tmpp->p.x+VECTOR*tmpp->n.x,tmpp->p.y+VECTOR*tmpp->n.y);
|
|
<a name="l82"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l83"></a> tmpp=tmpp->next;
|
|
<a name="l84"></a> }
|
|
<a name="l85"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&p_root_locks,i);
|
|
<a name="l86"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l87"></a>}
|
|
<a name="l88"></a>
|
|
<a name="l89"></a>#</span><span class=cF1>define</span><span class=cF0> WING 9
|
|
<a name="l90"></a>
|
|
<a name="l91"></a></span><span class=cF1>U0</span><span class=cF0> RayBurst(</span><span class=cF9>I64</span><span class=cF0> x1,</span><span class=cF9>I64</span><span class=cF0> y1,</span><span class=cF9>I64</span><span class=cF0> x2,</span><span class=cF9>I64</span><span class=cF0> y2)
|
|
<a name="l92"></a>{
|
|
<a name="l93"></a> </span><span class=cF9>CD3</span><span class=cF0> p,v,n,n2;
|
|
<a name="l94"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l95"></a> Photon *tmpp;
|
|
<a name="l96"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>x1!=x2 || y1!=y2</span><span class=cF7>)</span><span class=cF0> && BORDER+WING<x2<map->width-BORDER-WING &&
|
|
<a name="l97"></a> BORDER+WING<y2<map->height-BORDER-WING) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l98"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&p,x2,y2);
|
|
<a name="l99"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&v,x2-x1,y2-y1);
|
|
<a name="l100"></a> </span><span class=cF5>D3Unit</span><span class=cF0>(&v);
|
|
<a name="l101"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&n,v.y,-v.x);
|
|
<a name="l102"></a>
|
|
<a name="l103"></a> tmpp=PhotonNew;
|
|
<a name="l104"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&tmpp->p,&p);
|
|
<a name="l105"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&tmpp->v,&v);
|
|
<a name="l106"></a>
|
|
<a name="l107"></a> </span><span class=cF1>for</span><span class=cF0> (i=2;i<=WING;i+=3) {
|
|
<a name="l108"></a> </span><span class=cF5>D3Mul</span><span class=cF0>(&n2,i,&n);
|
|
<a name="l109"></a>
|
|
<a name="l110"></a> tmpp=PhotonNew;
|
|
<a name="l111"></a> </span><span class=cF5>D3Add</span><span class=cF0>(&tmpp->p,&p,&n2);
|
|
<a name="l112"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&tmpp->v,&v);
|
|
<a name="l113"></a>
|
|
<a name="l114"></a> tmpp=PhotonNew;
|
|
<a name="l115"></a> </span><span class=cF5>D3Sub</span><span class=cF0>(&tmpp->p,&p,&n2);
|
|
<a name="l116"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&tmpp->v,&v);
|
|
<a name="l117"></a> }
|
|
<a name="l118"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l119"></a>}
|
|
<a name="l120"></a>
|
|
<a name="l121"></a></span><span class=cF1>U0</span><span class=cF0> RandomBurst()
|
|
<a name="l122"></a>{
|
|
<a name="l123"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l124"></a> </span><span class=cF1>F64</span><span class=cF0> theta;
|
|
<a name="l125"></a> Photon *tmpp;
|
|
<a name="l126"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<256;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l127"></a> tmpp=PhotonNew;
|
|
<a name="l128"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&tmpp->p,</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>->pix_width-BORDER*2</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF5>Rand</span><span class=cF0>+BORDER,
|
|
<a name="l129"></a> </span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>->pix_height-BORDER*2</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF5>Rand</span><span class=cF0>+BORDER);
|
|
<a name="l130"></a> theta=2*</span><span class=cF3>pi</span><span class=cF0>*</span><span class=cF5>Rand</span><span class=cF0>;
|
|
<a name="l131"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&tmpp->v,</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l132"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l133"></a>}
|
|
<a name="l134"></a>
|
|
<a name="l135"></a></span><span class=cF1>U0</span><span class=cF0> FindNormal(</span><span class=cF1>U8</span><span class=cF0> *bmp,Photon *tmpp)
|
|
<a name="l136"></a>{
|
|
<a name="l137"></a> </span><span class=cF9>CD3</span><span class=cF0> p,p1,p2;
|
|
<a name="l138"></a> </span><span class=cF1>F64</span><span class=cF0> step,x,y,theta=</span><span class=cF5>Arg</span><span class=cF0>(tmpp->v.x,tmpp->v.y),phi;
|
|
<a name="l139"></a> </span><span class=cF9>I64</span><span class=cF0> state;
|
|
<a name="l140"></a>
|
|
<a name="l141"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&tmpp->p_normal_inhibit,&tmpp->p);
|
|
<a name="l142"></a>
|
|
<a name="l143"></a> </span><span class=cF2>//Coarse grains has black and white filled-in BSplines.</span><span class=cF0>
|
|
<a name="l144"></a> </span><span class=cF2>//Fine grained has only white outline without being filled-in.</span><span class=cF0>
|
|
<a name="l145"></a>
|
|
<a name="l146"></a> </span><span class=cF2>//Back-up a step and move fwd to get a fined-grained value</span><span class=cF0>
|
|
<a name="l147"></a> </span><span class=cF2>//for the point of contact.</span><span class=cF0>
|
|
<a name="l148"></a> </span><span class=cF5>D3SubEqu</span><span class=cF0>(&tmpp->p,&tmpp->v);
|
|
<a name="l149"></a> </span><span class=cF5>D3Mul</span><span class=cF0>(&p,bmp_scale,&tmpp->p);
|
|
<a name="l150"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&p1,&p);
|
|
<a name="l151"></a> </span><span class=cF1>while</span><span class=cF0> (BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp,p1.x,p1.y</span><span class=cF7>)</span><span class=cF0>==</span><span class=cF3>BLACK</span><span class=cF0> &&
|
|
<a name="l152"></a> </span><span class=cF5>D3DistSqr</span><span class=cF7>(</span><span class=cF0>&p,&p1</span><span class=cF7>)</span><span class=cF0><find_normal_dist_sqr)
|
|
<a name="l153"></a> </span><span class=cF5>D3AddEqu</span><span class=cF0>(&p1,&tmpp->v);
|
|
<a name="l154"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&p,&p1);
|
|
<a name="l155"></a> </span><span class=cF5>D3Div</span><span class=cF0>(&tmpp->p,&p,bmp_scale);
|
|
<a name="l156"></a>
|
|
<a name="l157"></a> </span><span class=cF2>//Draw an arc one direction, finding point of contact.</span><span class=cF0>
|
|
<a name="l158"></a> </span><span class=cF1>for</span><span class=cF0> (step=1.0;step>=0.01;step/=4) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l159"></a> </span><span class=cF1>for</span><span class=cF0> (phi=0;phi<=</span><span class=cF3>pi</span><span class=cF0>/4;phi+=step*</span><span class=cF3>pi</span><span class=cF0>/bmp_norm_radius) {
|
|
<a name="l160"></a> x=p.x+bmp_norm_radius*</span><span class=cF5>Cos</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>-</span><span class=cF3>pi</span><span class=cF0>/4-phi);
|
|
<a name="l161"></a> y=p.y+bmp_norm_radius*</span><span class=cF5>Sin</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>-</span><span class=cF3>pi</span><span class=cF0>/4-phi);
|
|
<a name="l162"></a> </span><span class=cF1>if</span><span class=cF0> (state=BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp,x,y</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l163"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p1;
|
|
<a name="l164"></a> x=p.x+bmp_norm_radius*</span><span class=cF5>Cos</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>-</span><span class=cF3>pi</span><span class=cF0>/4+phi);
|
|
<a name="l165"></a> y=p.y+bmp_norm_radius*</span><span class=cF5>Sin</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>-</span><span class=cF3>pi</span><span class=cF0>/4+phi);
|
|
<a name="l166"></a> </span><span class=cF1>if</span><span class=cF0> (state=BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp,x,y</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l167"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p1;
|
|
<a name="l168"></a> }
|
|
<a name="l169"></a> </span><span class=cF1>for</span><span class=cF0> (;phi<=3*</span><span class=cF3>pi</span><span class=cF0>/4;phi+=step*</span><span class=cF3>pi</span><span class=cF0>/bmp_norm_radius) {
|
|
<a name="l170"></a> x=p.x+bmp_norm_radius*</span><span class=cF5>Cos</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>-</span><span class=cF3>pi</span><span class=cF0>/4-phi);
|
|
<a name="l171"></a> y=p.y+bmp_norm_radius*</span><span class=cF5>Sin</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>-</span><span class=cF3>pi</span><span class=cF0>/4-phi);
|
|
<a name="l172"></a> </span><span class=cF1>if</span><span class=cF0> (state=BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp,x,y</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l173"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p1;
|
|
<a name="l174"></a> }
|
|
<a name="l175"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l176"></a>fn_p1:
|
|
<a name="l177"></a> </span><span class=cF1>if</span><span class=cF0> (state)
|
|
<a name="l178"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&p1,x,y);
|
|
<a name="l179"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l180"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&p1,&tmpp->p);
|
|
<a name="l181"></a>
|
|
<a name="l182"></a> </span><span class=cF2>//Draw an arc other direction, finding point of contact.</span><span class=cF0>
|
|
<a name="l183"></a> </span><span class=cF1>for</span><span class=cF0> (step=1.0;step>=0.01;step/=4) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l184"></a> </span><span class=cF1>for</span><span class=cF0> (phi=0;phi<=</span><span class=cF3>pi</span><span class=cF0>/4;phi+=step*</span><span class=cF3>pi</span><span class=cF0>/bmp_norm_radius) {
|
|
<a name="l185"></a> x=p.x+bmp_norm_radius*</span><span class=cF5>Cos</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>+</span><span class=cF3>pi</span><span class=cF0>/4+phi);
|
|
<a name="l186"></a> y=p.y+bmp_norm_radius*</span><span class=cF5>Sin</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>+</span><span class=cF3>pi</span><span class=cF0>/4+phi);
|
|
<a name="l187"></a> </span><span class=cF1>if</span><span class=cF0> (state=BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp,x,y</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l188"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p2;
|
|
<a name="l189"></a> x=p.x+bmp_norm_radius*</span><span class=cF5>Cos</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>+</span><span class=cF3>pi</span><span class=cF0>/4-phi);
|
|
<a name="l190"></a> y=p.y+bmp_norm_radius*</span><span class=cF5>Sin</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>+</span><span class=cF3>pi</span><span class=cF0>/4-phi);
|
|
<a name="l191"></a> </span><span class=cF1>if</span><span class=cF0> (state=BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp,x,y</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l192"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p2;
|
|
<a name="l193"></a> }
|
|
<a name="l194"></a> </span><span class=cF1>for</span><span class=cF0> (;phi<=3*</span><span class=cF3>pi</span><span class=cF0>/4;phi+=step*</span><span class=cF3>pi</span><span class=cF0>/bmp_norm_radius) {
|
|
<a name="l195"></a> x=p.x+bmp_norm_radius*</span><span class=cF5>Cos</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>+</span><span class=cF3>pi</span><span class=cF0>/4+phi);
|
|
<a name="l196"></a> y=p.y+bmp_norm_radius*</span><span class=cF5>Sin</span><span class=cF0>(theta+</span><span class=cF3>pi</span><span class=cF0>+</span><span class=cF3>pi</span><span class=cF0>/4+phi);
|
|
<a name="l197"></a> </span><span class=cF1>if</span><span class=cF0> (state=BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp,x,y</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l198"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p2;
|
|
<a name="l199"></a> }
|
|
<a name="l200"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l201"></a>fn_p2:
|
|
<a name="l202"></a> </span><span class=cF1>if</span><span class=cF0> (state)
|
|
<a name="l203"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&p2,x,y);
|
|
<a name="l204"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l205"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&p2,&tmpp->p);
|
|
<a name="l206"></a>
|
|
<a name="l207"></a> </span><span class=cF5>D3Sub</span><span class=cF0>(&p,&p1,&p2);
|
|
<a name="l208"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>D3NormSqr</span><span class=cF7>(</span><span class=cF0>&p</span><span class=cF7>)</span><span class=cF0><0.01) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l209"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&tmpp->n,</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l210"></a> </span><span class=cF1>lock</span><span class=cF0> {zero_normal++;}
|
|
<a name="l211"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l212"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&tmpp->n,p.y,-p.x);
|
|
<a name="l213"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>D3Dot</span><span class=cF7>(</span><span class=cF0>&tmpp->n,&tmpp->v</span><span class=cF7>)</span><span class=cF0><0)
|
|
<a name="l214"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&tmpp->n,-p.y,p.x);
|
|
<a name="l215"></a> </span><span class=cF5>D3Unit</span><span class=cF0>(&tmpp->n);
|
|
<a name="l216"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l217"></a>}
|
|
<a name="l218"></a>
|
|
<a name="l219"></a></span><span class=cF1>U0</span><span class=cF0> Mirror(Photon *tmpp)
|
|
<a name="l220"></a>{</span><span class=cF2>/*</span><span class=cFA><1>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l221"></a>
|
|
<a name="l222"></a>
|
|
<a name="l223"></a>
|
|
<a name="l224"></a>
|
|
<a name="l225"></a>
|
|
<a name="l226"></a>
|
|
<a name="l227"></a>
|
|
<a name="l228"></a>
|
|
<a name="l229"></a>
|
|
<a name="l230"></a>
|
|
<a name="l231"></a></span><span class=cF2>thetaout = pi+thetan - (thetain-thetan)</span><span class=cF0>
|
|
<a name="l232"></a>
|
|
<a name="l233"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l234"></a> </span><span class=cF1>F64</span><span class=cF0> theta=</span><span class=cF5>Arg</span><span class=cF0>(tmpp->v.x,tmpp->v.y),thetan;
|
|
<a name="l235"></a> FindNormal(bmp_reflect,tmpp);
|
|
<a name="l236"></a> thetan=</span><span class=cF5>Arg</span><span class=cF0>(tmpp->n.x,tmpp->n.y);
|
|
<a name="l237"></a>
|
|
<a name="l238"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&tmpp->v,</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>2*thetan+</span><span class=cF3>pi</span><span class=cF0>-theta</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>2*thetan+</span><span class=cF3>pi</span><span class=cF0>-theta</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l239"></a> </span><span class=cF1>lock</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>mirror_cnt++;</span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l240"></a>}
|
|
<a name="l241"></a>
|
|
<a name="l242"></a></span><span class=cF1>U0</span><span class=cF0> SnellsLaw(Photon *tmpp,</span><span class=cF9>I64</span><span class=cF0> last,</span><span class=cF9>I64</span><span class=cF0> next)
|
|
<a name="l243"></a>{
|
|
<a name="l244"></a></span><span class=cF2>//n1 and n2 are refraction index.</span><span class=cF0>
|
|
<a name="l245"></a></span><span class=cF2>//n1 Sin(theta1) == n2 Sin(theta2)</span><span class=cF0>
|
|
<a name="l246"></a> </span><span class=cF1>F64</span><span class=cF0> theta=</span><span class=cF5>Arg</span><span class=cF0>(tmpp->v.x,tmpp->v.y),thetan,n1,n2,theta1,theta2;
|
|
<a name="l247"></a> </span><span class=cF1>if</span><span class=cF0> (last==LENS_COLOR)
|
|
<a name="l248"></a> n1=1.5;
|
|
<a name="l249"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l250"></a> n1=1.0;
|
|
<a name="l251"></a> </span><span class=cF1>if</span><span class=cF0> (next==LENS_COLOR)
|
|
<a name="l252"></a> n2=1.5;
|
|
<a name="l253"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l254"></a> n2=1.0;
|
|
<a name="l255"></a> FindNormal(bmp_refract,tmpp);
|
|
<a name="l256"></a> thetan=</span><span class=cF5>Arg</span><span class=cF0>(tmpp->n.x,tmpp->n.y);
|
|
<a name="l257"></a>
|
|
<a name="l258"></a> </span><span class=cF2>//Dot=m1m2Cos(theta);</span><span class=cF0>
|
|
<a name="l259"></a> theta1=</span><span class=cF5>ACos</span><span class=cF0>(</span><span class=cF5>D3Dot</span><span class=cF7>(</span><span class=cF0>&tmpp->n,&tmpp->v</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l260"></a> theta2=</span><span class=cF5>ASin</span><span class=cF0>(n1*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta1</span><span class=cF7>)</span><span class=cF0>/n2);
|
|
<a name="l261"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Wrap</span><span class=cF7>(</span><span class=cF0>theta-thetan</span><span class=cF7>)</span><span class=cF0>>=0)
|
|
<a name="l262"></a> theta=thetan+theta2;
|
|
<a name="l263"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l264"></a> theta=thetan-theta2;
|
|
<a name="l265"></a>
|
|
<a name="l266"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&tmpp->v,</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l267"></a> </span><span class=cF1>lock</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>snell_cnt++;</span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l268"></a>}
|
|
<a name="l269"></a>
|
|
<a name="l270"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l271"></a>{
|
|
<a name="l272"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l273"></a> master_sleep_jiffy+=ANIMATE_JIFFIES;
|
|
<a name="l274"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>cnts</span><span class=cF0>.jiffies>=master_sleep_jiffy)
|
|
<a name="l275"></a> master_sleep_jiffy=</span><span class=cFB>cnts</span><span class=cF0>.jiffies+ANIMATE_JIFFIES;
|
|
<a name="l276"></a> </span><span class=cF5>SleepUntil</span><span class=cF0>(master_sleep_jiffy);
|
|
<a name="l277"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l278"></a>}
|
|
<a name="l279"></a>
|
|
<a name="l280"></a>#</span><span class=cF1>define</span><span class=cF0> BABY_STEPS 4
|
|
<a name="l281"></a>
|
|
<a name="l282"></a></span><span class=cF1>U0</span><span class=cF0> MPAnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l283"></a>{
|
|
<a name="l284"></a> </span><span class=cF9>I64</span><span class=cF0> i,last_master_jiffy=0,
|
|
<a name="l285"></a> timeout_jiffy=master_sleep_jiffy+ANIMATE_JIFFIES,
|
|
<a name="l286"></a> last,next;
|
|
<a name="l287"></a> </span><span class=cF1>Bool</span><span class=cF0> inhibit;
|
|
<a name="l288"></a> </span><span class=cF9>CD3</span><span class=cF0> step;
|
|
<a name="l289"></a> Photon *tmpp,*root=&p_root[</span><span class=cF5>Gs</span><span class=cF0>->num];
|
|
<a name="l290"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l291"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&p_root_locks,</span><span class=cF5>Gs</span><span class=cF0>->num</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l292"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l293"></a> tmpp=root->next;
|
|
<a name="l294"></a> </span><span class=cF1>while</span><span class=cF0> (tmpp!=root) {
|
|
<a name="l295"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<BABY_STEPS;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l296"></a> last=</span><span class=cF5>GrPeek</span><span class=cF0>(map,tmpp->p.x,tmpp->p.y);
|
|
<a name="l297"></a> </span><span class=cF5>D3Div</span><span class=cF0>(&step,&tmpp->v,BABY_STEPS);
|
|
<a name="l298"></a> </span><span class=cF5>D3AddEqu</span><span class=cF0>(&tmpp->p,&step);
|
|
<a name="l299"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp->p.x<BORDER) {
|
|
<a name="l300"></a> tmpp->p.x=2*BORDER-tmpp->p.x;
|
|
<a name="l301"></a> tmpp->v.x=-tmpp->v.x;
|
|
<a name="l302"></a> }
|
|
<a name="l303"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp->p.x>=map->width-BORDER) {
|
|
<a name="l304"></a> tmpp->p.x-=tmpp->p.x-map->width+BORDER;
|
|
<a name="l305"></a> tmpp->v.x=-tmpp->v.x;
|
|
<a name="l306"></a> }
|
|
<a name="l307"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp->p.y<BORDER) {
|
|
<a name="l308"></a> tmpp->p.y=2*BORDER-tmpp->p.y;
|
|
<a name="l309"></a> tmpp->v.y=-tmpp->v.y;
|
|
<a name="l310"></a> }
|
|
<a name="l311"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp->p.y>=map->height-BORDER) {
|
|
<a name="l312"></a> tmpp->p.y-=tmpp->p.y-map->height+BORDER;
|
|
<a name="l313"></a> tmpp->v.y=-tmpp->v.y;
|
|
<a name="l314"></a> }
|
|
<a name="l315"></a> next=</span><span class=cF5>GrPeek</span><span class=cF0>(map,tmpp->p.x,tmpp->p.y);
|
|
<a name="l316"></a>
|
|
<a name="l317"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>D3DistSqr</span><span class=cF7>(</span><span class=cF0>&tmpp->p_normal_inhibit,&tmpp->p</span><span class=cF7>)</span><span class=cF0><4.0)
|
|
<a name="l318"></a> inhibit=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l319"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l320"></a> inhibit=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l321"></a>
|
|
<a name="l322"></a> </span><span class=cF1>if</span><span class=cF0> (last!=next) {
|
|
<a name="l323"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>last==</span><span class=cF3>BLACK</span><span class=cF0> && next==LENS_COLOR</span><span class=cF7>)</span><span class=cF0> ||
|
|
<a name="l324"></a> </span><span class=cF7>(</span><span class=cF0>last==LENS_COLOR && next==</span><span class=cF3>BLACK</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l325"></a> </span><span class=cF1>if</span><span class=cF0> (inhibit)
|
|
<a name="l326"></a> </span><span class=cF1>lock</span><span class=cF0> {normal_inhibit++;}
|
|
<a name="l327"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l328"></a> SnellsLaw(tmpp,last,next);
|
|
<a name="l329"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (last==</span><span class=cF3>BLACK</span><span class=cF0> && next==MIRROR_COLOR) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l330"></a> </span><span class=cF1>if</span><span class=cF0> (inhibit)
|
|
<a name="l331"></a> </span><span class=cF1>lock</span><span class=cF0> {normal_inhibit++;}
|
|
<a name="l332"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l333"></a> Mirror(tmpp);
|
|
<a name="l334"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!inhibit)
|
|
<a name="l335"></a> </span><span class=cF5>D3Zero</span><span class=cF0>(&tmpp->p_normal_inhibit);
|
|
<a name="l336"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!inhibit)
|
|
<a name="l337"></a> </span><span class=cF5>D3Zero</span><span class=cF0>(&tmpp->p_normal_inhibit);
|
|
<a name="l338"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l339"></a>
|
|
<a name="l340"></a> tmpp=tmpp->next;
|
|
<a name="l341"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>cnts</span><span class=cF0>.jiffies>=timeout_jiffy)
|
|
<a name="l342"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l343"></a> }
|
|
<a name="l344"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&p_root_locks,</span><span class=cF5>Gs</span><span class=cF0>->num);
|
|
<a name="l345"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>cnts</span><span class=cF0>.jiffies>=timeout_jiffy) {
|
|
<a name="l346"></a> </span><span class=cF5>Sleep</span><span class=cF0>(1);
|
|
<a name="l347"></a> timeout_jiffy=master_sleep_jiffy+ANIMATE_JIFFIES;
|
|
<a name="l348"></a> }
|
|
<a name="l349"></a> </span><span class=cF1>if</span><span class=cF0> (!full_speed) {
|
|
<a name="l350"></a> </span><span class=cF1>while</span><span class=cF0> (master_sleep_jiffy==last_master_jiffy)
|
|
<a name="l351"></a> </span><span class=cF5>Sleep</span><span class=cF0>(1);
|
|
<a name="l352"></a> last_master_jiffy=master_sleep_jiffy;
|
|
<a name="l353"></a> </span><span class=cF5>SleepUntil</span><span class=cF0>(master_sleep_jiffy);
|
|
<a name="l354"></a> timeout_jiffy=master_sleep_jiffy+ANIMATE_JIFFIES;
|
|
<a name="l355"></a> }
|
|
<a name="l356"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l357"></a>}
|
|
<a name="l358"></a>
|
|
<a name="l359"></a></span><span class=cF1>U0</span><span class=cF0> Init()
|
|
<a name="l360"></a>{
|
|
<a name="l361"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l362"></a> master_sleep_jiffy=</span><span class=cFB>cnts</span><span class=cF0>.jiffies;
|
|
<a name="l363"></a> full_speed=show_normals=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l364"></a> photon_cnt=mirror_cnt=snell_cnt=normal_inhibit=zero_normal=0;
|
|
<a name="l365"></a> map=</span><span class=cF5>DCNew</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->pix_width,</span><span class=cF5>Fs</span><span class=cF0>->pix_height);
|
|
<a name="l366"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<</span><span class=cFB>mp_cnt</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l367"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&p_root_locks,i</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l368"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l369"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&p_root[i]);
|
|
<a name="l370"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&p_root_locks,i);
|
|
<a name="l371"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l372"></a></span><span class=cF2>//x*y=bmp_mem*8</span><span class=cF0>
|
|
<a name="l373"></a> </span><span class=cF2>//x/y=640/480</span><span class=cF0>
|
|
<a name="l374"></a> </span><span class=cF2>//x=640/480*y</span><span class=cF0>
|
|
<a name="l375"></a> </span><span class=cF2>//640/480*y^2=bmp_mem*8</span><span class=cF0>
|
|
<a name="l376"></a> </span><span class=cF2>//y=Sqrt(bmp_mem*8*480/640)</span><span class=cF0>
|
|
<a name="l377"></a> </span><span class=cF2>//bmp_scale=Sqrt(bmp_mem*8*480/640)/480</span><span class=cF0>
|
|
<a name="l378"></a> bmp_scale=</span><span class=cF5>Sqrt</span><span class=cF0>(bmp_mem/2*8*</span><span class=cF5>Fs</span><span class=cF0>->pix_height/</span><span class=cF5>Fs</span><span class=cF0>->pix_width)/</span><span class=cF5>Fs</span><span class=cF0>->pix_height;
|
|
<a name="l379"></a>
|
|
<a name="l380"></a> find_normal_dist_sqr=2*</span><span class=cF5>Sqr</span><span class=cF0>(bmp_scale);
|
|
<a name="l381"></a>#</span><span class=cF1>assert</span><span class=cF0> </span><span class=cF5>Sqrt</span><span class=cF0>(2)<=BORDER
|
|
<a name="l382"></a>
|
|
<a name="l383"></a> bmp_width =bmp_scale*</span><span class=cF5>Fs</span><span class=cF0>->pix_width;
|
|
<a name="l384"></a> bmp_height=bmp_scale*</span><span class=cF5>Fs</span><span class=cF0>->pix_height;
|
|
<a name="l385"></a> bmp_refract=</span><span class=cF5>CAlloc</span><span class=cF0>(bmp_width*bmp_height/8);
|
|
<a name="l386"></a> bmp_reflect=</span><span class=cF5>CAlloc</span><span class=cF0>(bmp_width*bmp_height/8);
|
|
<a name="l387"></a> bmp_norm_radius=</span><span class=cF5>Min</span><span class=cF0>(10*bmp_scale,250);
|
|
<a name="l388"></a>#</span><span class=cF1>assert</span><span class=cF0> 10<=BORDER
|
|
<a name="l389"></a>}
|
|
<a name="l390"></a>
|
|
<a name="l391"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
|
|
<a name="l392"></a>{
|
|
<a name="l393"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l394"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<</span><span class=cFB>mp_cnt</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l395"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&p_root_locks,i</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l396"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l397"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&p_root[i],</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l398"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&p_root_locks,i);
|
|
<a name="l399"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l400"></a> </span><span class=cF5>DCDel</span><span class=cF0>(map);
|
|
<a name="l401"></a> </span><span class=cF5>Free</span><span class=cF0>(bmp_refract);
|
|
<a name="l402"></a> </span><span class=cF5>Free</span><span class=cF0>(bmp_reflect);
|
|
<a name="l403"></a>}
|
|
<a name="l404"></a>
|
|
<a name="l405"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_REFLECT_LINE 0
|
|
<a name="l406"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_REFLECT_SPLINE 1
|
|
<a name="l407"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_REFRACT_LINE 2
|
|
<a name="l408"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_REFRACT_SPLINE 3
|
|
<a name="l409"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_REFRACT_FLOOD_FILL 4
|
|
<a name="l410"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_TEST_RAY 5
|
|
<a name="l411"></a>
|
|
<a name="l412"></a></span><span class=cF1>U0</span><span class=cF0> LTMenuSet(</span><span class=cF9>I64</span><span class=cF0> mode)
|
|
<a name="l413"></a>{
|
|
<a name="l414"></a> </span><span class=cF9>CMenuEntry</span><span class=cF0> *entry=</span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_menu,</span><span class=cF6>"View/ToggleNormals"</span><span class=cF0>);
|
|
<a name="l415"></a> </span><span class=cF1>if</span><span class=cF0> (show_normals)
|
|
<a name="l416"></a> entry->checked=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l417"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l418"></a> entry->checked=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l419"></a>
|
|
<a name="l420"></a> entry=</span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_menu,</span><span class=cF6>"Mode/ReflectLine"</span><span class=cF0>);
|
|
<a name="l421"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_REFLECT_LINE)
|
|
<a name="l422"></a> entry->checked=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l423"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l424"></a> entry->checked=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l425"></a> entry=</span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_menu,</span><span class=cF6>"Mode/ReflectSpline"</span><span class=cF0>);
|
|
<a name="l426"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_REFLECT_SPLINE)
|
|
<a name="l427"></a> entry->checked=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l428"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l429"></a> entry->checked=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l430"></a> entry=</span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_menu,</span><span class=cF6>"Mode/RefractLine"</span><span class=cF0>);
|
|
<a name="l431"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_REFRACT_LINE)
|
|
<a name="l432"></a> entry->checked=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l433"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l434"></a> entry->checked=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l435"></a> entry=</span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_menu,</span><span class=cF6>"Mode/RefractSpline"</span><span class=cF0>);
|
|
<a name="l436"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_REFRACT_SPLINE)
|
|
<a name="l437"></a> entry->checked=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l438"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l439"></a> entry->checked=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l440"></a> entry=</span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_menu,</span><span class=cF6>"Mode/RefractFloodFill"</span><span class=cF0>);
|
|
<a name="l441"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_REFRACT_FLOOD_FILL)
|
|
<a name="l442"></a> entry->checked=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l443"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l444"></a> entry->checked=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l445"></a> entry=</span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_menu,</span><span class=cF6>"Mode/TestRay"</span><span class=cF0>);
|
|
<a name="l446"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_TEST_RAY)
|
|
<a name="l447"></a> entry->checked=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l448"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l449"></a> entry->checked=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l450"></a>}
|
|
<a name="l451"></a>
|
|
<a name="l452"></a>#</span><span class=cF1>define</span><span class=cF0> PTS_NUM 1024
|
|
<a name="l453"></a></span><span class=cF1>U0</span><span class=cF0> LightTable()
|
|
<a name="l454"></a>{
|
|
<a name="l455"></a> </span><span class=cF9>I64</span><span class=cF0> msg_code,mode=LTM_REFLECT_LINE,i,cnt,arg1,arg2,x1,y1,x2,y2;
|
|
<a name="l456"></a> </span><span class=cF9>CD3I32</span><span class=cF0> *c=</span><span class=cF5>MAlloc</span><span class=cF0>(PTS_NUM*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l457"></a>
|
|
<a name="l458"></a> p_root_locks=0;
|
|
<a name="l459"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
|
|
<a name="l460"></a> </span><span class=cF6>"File {"</span><span class=cF0>
|
|
<a name="l461"></a> </span><span class=cF6>" Restart(,'\n');"</span><span class=cF0>
|
|
<a name="l462"></a> </span><span class=cF6>" Abort(,CH_SHIFT_ESC);"</span><span class=cF0>
|
|
<a name="l463"></a> </span><span class=cF6>" Exit(,CH_ESC);"</span><span class=cF0>
|
|
<a name="l464"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l465"></a> </span><span class=cF6>"Mode {"</span><span class=cF0>
|
|
<a name="l466"></a> </span><span class=cF6>" ReflectLine(,'0');"</span><span class=cF0>
|
|
<a name="l467"></a> </span><span class=cF6>" ReflectSpline(,'1');"</span><span class=cF0>
|
|
<a name="l468"></a> </span><span class=cF6>" RefractLine(,'2');"</span><span class=cF0>
|
|
<a name="l469"></a> </span><span class=cF6>" RefractSpline(,'3');"</span><span class=cF0>
|
|
<a name="l470"></a> </span><span class=cF6>" RefractFloodFill(,'4');"</span><span class=cF0>
|
|
<a name="l471"></a> </span><span class=cF6>" TestRay(,'5');"</span><span class=cF0>
|
|
<a name="l472"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l473"></a> </span><span class=cF6>"Play {"</span><span class=cF0>
|
|
<a name="l474"></a> </span><span class=cF6>" RandomBurst(,'r');"</span><span class=cF0>
|
|
<a name="l475"></a> </span><span class=cF6>" ElapseTime(,'e');"</span><span class=cF0>
|
|
<a name="l476"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l477"></a> </span><span class=cF6>"View {"</span><span class=cF0>
|
|
<a name="l478"></a> </span><span class=cF6>" ToggleNormals(,'n');"</span><span class=cF0>
|
|
<a name="l479"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l480"></a> );
|
|
<a name="l481"></a> LTMenuSet(mode);
|
|
<a name="l482"></a>
|
|
<a name="l483"></a> </span><span class=cF5>MemBIOSRep</span><span class=cF0>;
|
|
<a name="l484"></a> bmp_mem=</span><span class=cF5>GetI64</span><span class=cF0>(</span><span class=cF6>"\n\n\nHow much memory for the high resolution\n"</span><span class=cF0>
|
|
<a name="l485"></a> </span><span class=cF6>"shadow bitmap that helps improve the\n"</span><span class=cF0>
|
|
<a name="l486"></a> </span><span class=cF6>"accuracy of the normal vector estimate?\n"</span><span class=cF0>
|
|
<a name="l487"></a> </span><span class=cF6>"You can choose up to the largest\n"</span><span class=cF0>
|
|
<a name="l488"></a> </span><span class=cF6>"contiguous chunk of physical memory.\n\n"</span><span class=cF0>
|
|
<a name="l489"></a> </span><span class=cF6>"Mem (0x%0X):"</span><span class=cF0>,1024*1024*16);
|
|
<a name="l490"></a>
|
|
<a name="l491"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="/Wb/Adam/TaskSettings.HC.HTML#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
|
|
<a name="l492"></a> </span><span class=cF5>Fs</span><span class=cF0>->win_inhibit=</span><span class=cF3>WIG_TASK_DFT</span><span class=cF0>-</span><span class=cF3>WIF_SELF_FOCUS</span><span class=cF0>-
|
|
<a name="l493"></a> </span><span class=cF3>WIF_SELF_BORDER</span><span class=cF0>-</span><span class=cF3>WIF_FOCUS_TASK_MENU</span><span class=cF0>;
|
|
<a name="l494"></a> </span><span class=cF5>Fs</span><span class=cF0>->text_attr=</span><span class=cF3>BLACK</span><span class=cF0><<4+</span><span class=cF3>WHITE</span><span class=cF0>; </span><span class=cF2>//Current </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3271"><span class=cF4>CTask</span></a><span class=cF2> is Fs segment register.</span><span class=cF0>
|
|
<a name="l495"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
|
|
<a name="l496"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
|
|
<a name="l497"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
|
|
<a name="l498"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
|
|
<a name="l499"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l500"></a> Init;
|
|
<a name="l501"></a> </span><span class=cF5>Fs</span><span class=cF0>->draw_it=&</span><span class=cF5>DrawIt</span><span class=cF0>;
|
|
<a name="l502"></a> </span><span class=cF5>Fs</span><span class=cF0>->animate_task=</span><span class=cF5>Spawn</span><span class=cF0>(&AnimateTask,</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF6>"Animate"</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l503"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<</span><span class=cFB>mp_cnt</span><span class=cF0>;i++)
|
|
<a name="l504"></a> animate_tasks[i]=</span><span class=cF5>Spawn</span><span class=cF0>(&MPAnimateTask,</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF6>"MPAnimate"</span><span class=cF0>,i);
|
|
<a name="l505"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l506"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
|
|
<a name="l507"></a> msg_code=</span><span class=cF5>GetMsg</span><span class=cF0>(&arg1,&arg2,
|
|
<a name="l508"></a> 1<<</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>+1<<</span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>+1<<</span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>+1<<</span><span class=cF3>MSG_MS_R_UP</span><span class=cF0>);
|
|
<a name="l509"></a>lt_restart:
|
|
<a name="l510"></a> </span><span class=cF1>switch</span><span class=cF0> (msg_code) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l511"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>:
|
|
<a name="l512"></a> </span><span class=cF5>Sweep</span><span class=cF0>(100,90,100);
|
|
<a name="l513"></a> x2=arg1; y2=arg2;
|
|
<a name="l514"></a> </span><span class=cF1>switch</span><span class=cF0> (mode) {
|
|
<a name="l515"></a> </span><span class=cF1>case</span><span class=cF0> LTM_REFRACT_FLOOD_FILL:
|
|
<a name="l516"></a> map->color=LENS_COLOR;
|
|
<a name="l517"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(map,x2,y2);
|
|
<a name="l518"></a> mode=LTM_REFLECT_LINE;
|
|
<a name="l519"></a> LTMenuSet(mode);
|
|
<a name="l520"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l521"></a> </span><span class=cF1>case</span><span class=cF0> LTM_TEST_RAY:
|
|
<a name="l522"></a> RayBurst(x1,y1,x2,y2);
|
|
<a name="l523"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l524"></a> }
|
|
<a name="l525"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l526"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>:
|
|
<a name="l527"></a> x1=arg1; y1=arg2;
|
|
<a name="l528"></a> </span><span class=cF1>switch</span><span class=cF0> (mode) {
|
|
<a name="l529"></a> </span><span class=cF1>case</span><span class=cF0> LTM_REFLECT_LINE:
|
|
<a name="l530"></a> </span><span class=cF1>case</span><span class=cF0> LTM_REFRACT_LINE:
|
|
<a name="l531"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_REFLECT_LINE)
|
|
<a name="l532"></a> map->color=</span><span class=cF3>ROP_XOR</span><span class=cF0>+MIRROR_COLOR;
|
|
<a name="l533"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l534"></a> map->color=</span><span class=cF3>ROP_XOR</span><span class=cF0>+LENS_COLOR;
|
|
<a name="l535"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l536"></a> x2=arg1; y2=arg2;
|
|
<a name="l537"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map,x1,y1,x2,y2);
|
|
<a name="l538"></a> msg_code=</span><span class=cF5>GetMsg</span><span class=cF0>(&arg1,&arg2,
|
|
<a name="l539"></a> 1<<</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>+1<<</span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>+1<<</span><span class=cF3>MSG_MS_MOVE</span><span class=cF0>);
|
|
<a name="l540"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map,x1,y1,x2,y2);
|
|
<a name="l541"></a> </span><span class=cF1>if</span><span class=cF0> (msg_code==</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>)
|
|
<a name="l542"></a> </span><span class=cF1>goto</span><span class=cF0> lt_restart;
|
|
<a name="l543"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (msg_code==</span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>) {
|
|
<a name="l544"></a> </span><span class=cF5>Sweep</span><span class=cF0>(100,90,100);
|
|
<a name="l545"></a> x2=arg1; y2=arg2;
|
|
<a name="l546"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l547"></a> }
|
|
<a name="l548"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l549"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_REFLECT_LINE)
|
|
<a name="l550"></a> map->color=MIRROR_COLOR;
|
|
<a name="l551"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l552"></a> map->color=LENS_COLOR;
|
|
<a name="l553"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map,x1,y1,x2,y2);
|
|
<a name="l554"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_REFLECT_LINE)
|
|
<a name="l555"></a> BmpLine(bmp_reflect,x1,y1,x2,y2);
|
|
<a name="l556"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l557"></a> BmpLine(bmp_refract,x1,y1,x2,y2);
|
|
<a name="l558"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l559"></a> </span><span class=cF1>case</span><span class=cF0> LTM_REFLECT_SPLINE:
|
|
<a name="l560"></a> </span><span class=cF1>case</span><span class=cF0> LTM_REFRACT_SPLINE:
|
|
<a name="l561"></a> cnt=0;
|
|
<a name="l562"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_REFLECT_SPLINE)
|
|
<a name="l563"></a> map->color=</span><span class=cF3>ROP_XOR</span><span class=cF0>+MIRROR_COLOR;
|
|
<a name="l564"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l565"></a> map->color=</span><span class=cF3>ROP_XOR</span><span class=cF0>+LENS_COLOR;
|
|
<a name="l566"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l567"></a> c[cnt].x=arg1; c[cnt].y=arg2; c[cnt].z=0;
|
|
<a name="l568"></a> </span><span class=cF5>Gr2BSpline</span><span class=cF0>(map,c,cnt+1);
|
|
<a name="l569"></a> msg_code=</span><span class=cF5>GetMsg</span><span class=cF0>(&arg1,&arg2,1<<</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>+1<<</span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>+
|
|
<a name="l570"></a> 1<<</span><span class=cF3>MSG_MS_MOVE</span><span class=cF0>+1<<</span><span class=cF3>MSG_MS_R_UP</span><span class=cF0>);
|
|
<a name="l571"></a> </span><span class=cF5>Gr2BSpline</span><span class=cF0>(map,c,cnt+1);
|
|
<a name="l572"></a> </span><span class=cF1>if</span><span class=cF0> (msg_code==</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>)
|
|
<a name="l573"></a> </span><span class=cF1>goto</span><span class=cF0> lt_restart;
|
|
<a name="l574"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (msg_code==</span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>) {
|
|
<a name="l575"></a> </span><span class=cF5>Sweep</span><span class=cF0>(100,90,100);
|
|
<a name="l576"></a> cnt++;
|
|
<a name="l577"></a> }
|
|
<a name="l578"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (cnt<PTS_NUM-1 && msg_code!=</span><span class=cF3>MSG_MS_R_UP</span><span class=cF0>);
|
|
<a name="l579"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_REFLECT_SPLINE)
|
|
<a name="l580"></a> map->color=MIRROR_COLOR;
|
|
<a name="l581"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l582"></a> map->color=LENS_COLOR;
|
|
<a name="l583"></a> </span><span class=cF5>Gr2BSpline3</span><span class=cF0>(map,c,cnt);
|
|
<a name="l584"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<cnt;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l585"></a> c[i].x*=bmp_scale;
|
|
<a name="l586"></a> c[i].y*=bmp_scale;
|
|
<a name="l587"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l588"></a> </span><span class=cF1>if</span><span class=cF0> (mode==LTM_REFLECT_SPLINE)
|
|
<a name="l589"></a> </span><span class=cF5>BSpline2</span><span class=cF0>(bmp_reflect,c,cnt,&BmpPlot);
|
|
<a name="l590"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l591"></a> </span><span class=cF5>BSpline2</span><span class=cF0>(bmp_refract,c,cnt,&BmpPlot);
|
|
<a name="l592"></a> mode=LTM_REFLECT_LINE;
|
|
<a name="l593"></a> LTMenuSet(mode);
|
|
<a name="l594"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l595"></a> }
|
|
<a name="l596"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l597"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_R_UP</span><span class=cF0>:
|
|
<a name="l598"></a> i=</span><span class=cF5>PopUpPickLst</span><span class=cF0>(</span><span class=cF6>"Reflect Line\0Reflect Spline\0Refract Line\0"</span><span class=cF0>
|
|
<a name="l599"></a> </span><span class=cF6>"Refract Spline\0Refract Flood Fill\0TestRay\0"</span><span class=cF0>);
|
|
<a name="l600"></a> </span><span class=cF1>if</span><span class=cF0> (i>=0) {
|
|
<a name="l601"></a> mode=i;
|
|
<a name="l602"></a> LTMenuSet(mode);
|
|
<a name="l603"></a> }
|
|
<a name="l604"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l605"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>:
|
|
<a name="l606"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1) {
|
|
<a name="l607"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
|
|
<a name="l608"></a> CleanUp;
|
|
<a name="l609"></a> Init;
|
|
<a name="l610"></a> mode=LTM_REFLECT_LINE;
|
|
<a name="l611"></a> LTMenuSet(mode);
|
|
<a name="l612"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l613"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'r'</span><span class=cF0>:
|
|
<a name="l614"></a> RandomBurst;
|
|
<a name="l615"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l616"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'e'</span><span class=cF0>:
|
|
<a name="l617"></a> full_speed=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l618"></a> </span><span class=cF5>Sleep</span><span class=cF0>(1500);
|
|
<a name="l619"></a> </span><span class=cF5>FlushMsgs</span><span class=cF0>;
|
|
<a name="l620"></a> full_speed=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l621"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l622"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'n'</span><span class=cF0>:
|
|
<a name="l623"></a> show_normals=!show_normals;
|
|
<a name="l624"></a> LTMenuSet(mode);
|
|
<a name="l625"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l626"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'0'</span><span class=cF0>...</span><span class=cF6>'5'</span><span class=cF0>:
|
|
<a name="l627"></a> mode=arg1-</span><span class=cF6>'0'</span><span class=cF0>;
|
|
<a name="l628"></a> LTMenuSet(mode);
|
|
<a name="l629"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l630"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
|
|
<a name="l631"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
|
|
<a name="l632"></a> </span><span class=cF1>goto</span><span class=cF0> lt_done;
|
|
<a name="l633"></a> }
|
|
<a name="l634"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l635"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l636"></a> }
|
|
<a name="l637"></a>lt_done:
|
|
<a name="l638"></a> </span><span class=cF5>GetMsg</span><span class=cF0>(,,1<<</span><span class=cF3>MSG_KEY_UP</span><span class=cF0>);
|
|
<a name="l639"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l640"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
|
|
<a name="l641"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
|
|
<a name="l642"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
|
|
<a name="l643"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<</span><span class=cFB>mp_cnt</span><span class=cF0>;i++)
|
|
<a name="l644"></a> </span><span class=cF5>Kill</span><span class=cF0>(animate_tasks[i]);
|
|
<a name="l645"></a> CleanUp;
|
|
<a name="l646"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
|
|
<a name="l647"></a>}
|
|
<a name="l648"></a>
|
|
<a name="l649"></a>LightTable;
|
|
</span></pre></body>
|
|
</html>
|