Nightly update (ISO SHA-1 77cbcdd)
This commit is contained in:
1 parent
18616c6b0c
commit
3636fdb41e
14 files changed
+298
-194
No files matched your search
@@ -62,7 +62,7 @@ $ID,-2$$TR,"Titanium"$
|
||||
$ID,2$I64 best_score=16469;
|
||||
$ID,-2$$TR,"TOSRegen"$
|
||||
$ID,2$progress1_tf=0.000;progress2_tf=0.000;
|
||||
progress3_tf=0.000;progress4_tf=196.181;
|
||||
progress3_tf=0.000;progress4_tf=199.123;
|
||||
$ID,-2$$ID,-2$$TR,"Once"$
|
||||
$ID,2$$TR,"Adam"$
|
||||
$ID,2$$ID,-2$$TR,"User"$
|
||||
|
||||
@@ -7,7 +7,7 @@ fine grained is only outlines.
|
||||
class Photon
|
||||
{
|
||||
Photon *next,*last;
|
||||
CD3 p,v,p_snell_inhibit;
|
||||
CD3 p,v,n,p_snell_inhibit;
|
||||
} p_root[mp_cnt];
|
||||
I64 p_root_locks;
|
||||
|
||||
@@ -17,11 +17,11 @@ CTask *animate_tasks[mp_cnt];
|
||||
|
||||
|
||||
CDC *map;
|
||||
I64 photon_cnt,snell_cnt;
|
||||
Bool full_speed;
|
||||
I64 photon_cnt,snell_cnt,snell_inhibit,zero_normal;
|
||||
Bool full_speed,show_normals;
|
||||
|
||||
U8 *bmp;
|
||||
F64 bmp_scale,bmp_scale_sqr;
|
||||
F64 bmp_scale,find_normal_dist_sqr;
|
||||
I64 bmp_mem,bmp_width,bmp_height,bmp_norm_radius;
|
||||
|
||||
I64 BmpPeek(I64 x,I64 y)
|
||||
@@ -41,6 +41,13 @@ U0 BmpPlot(U8 *bmp,I64 x,I64 y,I64)
|
||||
Bts(bmp,y*bmp_width+x);
|
||||
}
|
||||
|
||||
U0 DualLine(F64 x1,F64 y1,F64 x2,F64 y2)
|
||||
{
|
||||
map->color=WHITE;
|
||||
GrLine(map,x1,y1,x2,y2);
|
||||
Line(bmp,x1*bmp_scale,y1*bmp_scale,0,x2*bmp_scale,y2*bmp_scale,0,&BmpPlot);
|
||||
}
|
||||
|
||||
Photon *PhotonNew()
|
||||
{
|
||||
I64 num=photon_cnt++%mp_cnt;
|
||||
@@ -52,7 +59,7 @@ Photon *PhotonNew()
|
||||
return res;
|
||||
}
|
||||
|
||||
#define TAIL 20
|
||||
#define VECTOR 20
|
||||
U0 DrawIt(CTask *,CDC *dc)
|
||||
{
|
||||
I64 i;
|
||||
@@ -62,15 +69,22 @@ U0 DrawIt(CTask *,CDC *dc)
|
||||
GrPrint(dc,0,0,"Mem:0x%X %,dMeg Scale:%0.3f (%d,%d)-->(%d,%d)",
|
||||
bmp_mem,bmp_mem/1024/1024,bmp_scale,
|
||||
map->width,map->height,bmp_width,bmp_height);
|
||||
GrPrint(dc,0,FONT_HEIGHT,"PhotonCnt:%d SnellCnt:%d",photon_cnt,snell_cnt);
|
||||
GrPrint(dc,0,FONT_HEIGHT,
|
||||
"PhotonCnt:%d SnellCnt:%d SnellInhibit:%d ZeroNormal:%d",
|
||||
photon_cnt,snell_cnt,snell_inhibit,zero_normal);
|
||||
for (i=0;i<mp_cnt;i++) {
|
||||
while (LBts(&p_root_locks,i))
|
||||
Yield;
|
||||
tmpp=p_root[i].next;
|
||||
while (tmpp!=&p_root[i]) {
|
||||
dc->color=LTRED;
|
||||
GrLine(dc,tmpp->p.x-TAIL*tmpp->v.x,tmpp->p.y-TAIL*tmpp->v.y,
|
||||
GrLine(dc,tmpp->p.x-VECTOR*tmpp->v.x,tmpp->p.y-VECTOR*tmpp->v.y,
|
||||
tmpp->p.x,tmpp->p.y);
|
||||
if (show_normals) {
|
||||
dc->color=LTGREEN;
|
||||
GrLine(dc,tmpp->p.x,tmpp->p.y,
|
||||
tmpp->p.x+VECTOR*tmpp->n.x,tmpp->p.y+VECTOR*tmpp->n.y);
|
||||
}
|
||||
tmpp=tmpp->next;
|
||||
}
|
||||
LBtr(&p_root_locks,i);
|
||||
@@ -117,7 +131,7 @@ U0 RandomBurst()
|
||||
}
|
||||
}
|
||||
|
||||
U0 FindNormal(Photon *tmpp,CD3 *_normal)
|
||||
U0 FindNormal(Photon *tmpp)
|
||||
{
|
||||
CD3 p,p1,p2,v,s;
|
||||
F64 é=Arg(tmpp->v.x,tmpp->v.y),è;
|
||||
@@ -132,7 +146,7 @@ U0 FindNormal(Photon *tmpp,CD3 *_normal)
|
||||
D3SubEqu(&tmpp->p,&tmpp->v);
|
||||
D3Mul(&p,bmp_scale,&tmpp->p);
|
||||
D3Copy(&p1,&p);
|
||||
while (BmpPeek(p1.x,p1.y)==BLACK && D3DistSqr(&p,&p1)<bmp_scale_sqr*2)
|
||||
while (BmpPeek(p1.x,p1.y)==BLACK && D3DistSqr(&p,&p1)<find_normal_dist_sqr)
|
||||
D3AddEqu(&p1,&tmpp->v);
|
||||
D3Copy(&p,&p1);
|
||||
D3Div(&tmpp->p,&p,bmp_scale);
|
||||
@@ -148,7 +162,7 @@ U0 FindNormal(Photon *tmpp,CD3 *_normal)
|
||||
if (BmpPeek(p1.x,p1.y)!=WHITE)
|
||||
D3Copy(&p1,&tmpp->p);
|
||||
|
||||
//Draw an arc other direction, finding point of contact.
|
||||
//Draw an arc other direction, finding point of contact.
|
||||
for (è=0;è<ã/2;è+=ã/bmp_norm_radius) {
|
||||
D3Equ(&s,Cos(é+ã+ã/4+è),Sin(é+ã+ã/4+è));
|
||||
D3Mul(&v,bmp_norm_radius,&s);
|
||||
@@ -158,13 +172,17 @@ U0 FindNormal(Photon *tmpp,CD3 *_normal)
|
||||
}
|
||||
if (BmpPeek(p2.x,p2.y)!=WHITE)
|
||||
D3Copy(&p2,&tmpp->p);
|
||||
|
||||
D3Sub(&s,&p1,&p2);
|
||||
D3Equ(_normal,s.y,-s.x);
|
||||
if (D3Dot(_normal,&tmpp->v)<0)
|
||||
D3Equ(_normal,-s.y,s.x);
|
||||
|
||||
D3Unit(_normal);
|
||||
D3Sub(&s,&p1,&p2);
|
||||
if (D3NormSqr(&s)<1.0) {
|
||||
D3Equ(&tmpp->n,Cos(é),Sin(é));
|
||||
lock {zero_normal++;}
|
||||
} else {
|
||||
D3Equ(&tmpp->n,s.y,-s.x);
|
||||
if (D3Dot(&tmpp->n,&tmpp->v)<0)
|
||||
D3Equ(&tmpp->n,-s.y,s.x);
|
||||
D3Unit(&tmpp->n);
|
||||
}
|
||||
}
|
||||
|
||||
U0 SnellsLaw(Photon *tmpp,I64 last,I64 next)
|
||||
@@ -172,7 +190,6 @@ U0 SnellsLaw(Photon *tmpp,I64 last,I64 next)
|
||||
//n1 and n2 are refraction index.
|
||||
//n1 Sin(é1) == n2 Sin(é2)
|
||||
F64 é=Arg(tmpp->v.x,tmpp->v.y),én,n1,n2,é1,é2,éa,éb;
|
||||
CD3 normal;
|
||||
if (last==WHITE)
|
||||
n1=1.5;
|
||||
else
|
||||
@@ -181,10 +198,10 @@ U0 SnellsLaw(Photon *tmpp,I64 last,I64 next)
|
||||
n2=1.5;
|
||||
else
|
||||
n2=1.0;
|
||||
FindNormal(tmpp,&normal);
|
||||
én=Arg(normal.x,normal.y);
|
||||
FindNormal(tmpp);
|
||||
én=Arg(tmpp->n.x,tmpp->n.y);
|
||||
//dot=m1m2Cos(é);
|
||||
é1=ACos(D3Dot(&normal,&tmpp->v));
|
||||
é1=ACos(D3Dot(&tmpp->n,&tmpp->v));
|
||||
é2=ASin(n1*Sin(é1)/n2);
|
||||
//é --> (én+é1)
|
||||
//é <-- (én+é2)
|
||||
@@ -213,6 +230,7 @@ U0 MPAnimateTask(I64)
|
||||
I64 last_master_jiffy=0,
|
||||
timeout_jiffy=master_sleep_jiffy+ANIMATE_JIFFIES,
|
||||
last,next;
|
||||
Bool inhibit;
|
||||
Photon *tmpp,*root=&p_root[Gs->num];
|
||||
while (TRUE) {
|
||||
while (LBts(&p_root_locks,Gs->num))
|
||||
@@ -238,11 +256,21 @@ U0 MPAnimateTask(I64)
|
||||
tmpp->v.y=-tmpp->v.y;
|
||||
}
|
||||
next=GrPeek(map,tmpp->p.x,tmpp->p.y);
|
||||
|
||||
if (D3DistSqr(&tmpp->p_snell_inhibit,&tmpp->p)<4.0)
|
||||
inhibit=TRUE;
|
||||
else
|
||||
inhibit=FALSE;
|
||||
|
||||
if (last!=next && (last==BLACK && next==WHITE) ||
|
||||
(last==WHITE && next==BLACK) &&
|
||||
//Don't do a snell operation too close to the last. Just ignore it.
|
||||
D3DistSqr(&tmpp->p_snell_inhibit,&tmpp->p)>=4.0)
|
||||
SnellsLaw(tmpp,last,next);
|
||||
(last==WHITE && next==BLACK)) {
|
||||
if (inhibit)
|
||||
lock {snell_inhibit++;}
|
||||
else
|
||||
SnellsLaw(tmpp,last,next);
|
||||
} else if (!inhibit)
|
||||
D3Zero(&tmpp->p_snell_inhibit);
|
||||
|
||||
tmpp=tmpp->next;
|
||||
if (cnts.jiffies>=timeout_jiffy)
|
||||
break;
|
||||
@@ -266,8 +294,8 @@ U0 Init()
|
||||
{
|
||||
I64 i;
|
||||
master_sleep_jiffy=cnts.jiffies;
|
||||
full_speed=FALSE;
|
||||
photon_cnt=snell_cnt=0;
|
||||
full_speed=show_normals=FALSE;
|
||||
photon_cnt=snell_cnt=snell_inhibit=zero_normal=0;
|
||||
map=DCNew(Fs->pix_width,Fs->pix_height);
|
||||
for (i=0;i<mp_cnt;i++) {
|
||||
while (LBts(&p_root_locks,i))
|
||||
@@ -282,7 +310,7 @@ U0 Init()
|
||||
//y=Sqrt(bmp_mem*8*480/640)
|
||||
//bmp_scale=Sqrt(bmp_mem*8*480/640)/480
|
||||
bmp_scale=Sqrt(bmp_mem*8*Fs->pix_height/Fs->pix_width)/Fs->pix_height;
|
||||
bmp_scale_sqr=Sqr(bmp_scale);
|
||||
find_normal_dist_sqr=2*Sqr(bmp_scale);
|
||||
bmp_width =bmp_scale*Fs->pix_width;
|
||||
bmp_height=bmp_scale*Fs->pix_height;
|
||||
bmp=CAlloc(bmp_width*bmp_height/8);
|
||||
@@ -302,10 +330,45 @@ U0 CleanUp()
|
||||
Free(bmp);
|
||||
}
|
||||
|
||||
#define LTM_LINE 0
|
||||
#define LTM_SPLINE 1
|
||||
#define LTM_FLOOD_FILL 2
|
||||
#define LTM_TEST_RAY 3
|
||||
|
||||
U0 LTMenuSet(I64 mode)
|
||||
{
|
||||
CMenuEntry *entry=MenuEntryFind(Fs->cur_menu,"View/ToggleNormals");
|
||||
if (show_normals)
|
||||
entry->checked=TRUE;
|
||||
else
|
||||
entry->checked=FALSE;
|
||||
|
||||
entry=MenuEntryFind(Fs->cur_menu,"Mode/LineMode");
|
||||
if (mode==LTM_LINE)
|
||||
entry->checked=TRUE;
|
||||
else
|
||||
entry->checked=FALSE;
|
||||
entry=MenuEntryFind(Fs->cur_menu,"Mode/SplineMode");
|
||||
if (mode==LTM_SPLINE)
|
||||
entry->checked=TRUE;
|
||||
else
|
||||
entry->checked=FALSE;
|
||||
entry=MenuEntryFind(Fs->cur_menu,"Mode/FloodFill");
|
||||
if (mode==LTM_FLOOD_FILL)
|
||||
entry->checked=TRUE;
|
||||
else
|
||||
entry->checked=FALSE;
|
||||
entry=MenuEntryFind(Fs->cur_menu,"Mode/TestRay");
|
||||
if (mode==LTM_TEST_RAY)
|
||||
entry->checked=TRUE;
|
||||
else
|
||||
entry->checked=FALSE;
|
||||
}
|
||||
|
||||
#define PTS_NUM 1024
|
||||
U0 LightTable()
|
||||
{
|
||||
I64 msg_code,i,cnt,arg1,arg2,ray_x1,ray_y1,ray_x2,ray_y2;
|
||||
I64 msg_code,mode=LTM_LINE,i,cnt,arg1,arg2,x1,y1,x2,y2;
|
||||
CD3I32 *c=MAlloc(PTS_NUM*sizeof(CD3I32));
|
||||
|
||||
p_root_locks=0;
|
||||
@@ -315,14 +378,21 @@ U0 LightTable()
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Edit {"
|
||||
" Fill(,CH_SPACE);"
|
||||
"Mode {"
|
||||
" LineMode(,'0');"
|
||||
" SplineMode(,'1');"
|
||||
" FloodFill(,'2');"
|
||||
" TestRay(,'3');"
|
||||
"}"
|
||||
"Play {"
|
||||
" RandomBurst(,'r');"
|
||||
" ElapseTime(,'e');"
|
||||
"}"
|
||||
"View {"
|
||||
" ToggleNormals(,'n');"
|
||||
"}"
|
||||
);
|
||||
LTMenuSet(mode);
|
||||
|
||||
MemBIOSRep;
|
||||
bmp_mem=GetI64("\n\n\nHow much memory for the high resolution\n"
|
||||
@@ -332,11 +402,6 @@ U0 LightTable()
|
||||
"contiguous chunk of physical memory.\n\n"
|
||||
"Mem (0x%0X):",1024*1024*16);
|
||||
|
||||
PopUpOk(
|
||||
"Draw splines with $$GREEN$${Left-click}$$FG$$.\n\n"
|
||||
"Fill lens with $$GREEN$$<SPACE>$$FG$$.\n\n"
|
||||
"$$GREEN$${Right-drag}$$FG$$ to fire rays.\n"
|
||||
);
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-
|
||||
WIF_SELF_BORDER-WIF_FOCUS_TASK_MENU;
|
||||
@@ -354,45 +419,78 @@ U0 LightTable()
|
||||
try {
|
||||
while (TRUE) {
|
||||
msg_code=GetMsg(&arg1,&arg2,
|
||||
1<<MSG_KEY_DOWN+1<<MSG_MS_L_DOWN+1<<MSG_MS_R_DOWN+1<<MSG_MS_R_UP);
|
||||
1<<MSG_KEY_DOWN+1<<MSG_MS_L_DOWN+1<<MSG_MS_L_UP+1<<MSG_MS_R_UP);
|
||||
lt_restart:
|
||||
switch (msg_code) {
|
||||
case MSG_MS_R_DOWN:
|
||||
ray_x1=arg1; ray_y1=arg2;
|
||||
break;
|
||||
case MSG_MS_R_UP:
|
||||
ray_x2=arg1; ray_y2=arg2;
|
||||
RayBurst(ray_x1,ray_y1,ray_x2,ray_y2);
|
||||
case MSG_MS_L_UP:
|
||||
Sweep(100,90,100);
|
||||
x2=arg1; y2=arg2;
|
||||
switch (mode) {
|
||||
case LTM_FLOOD_FILL:
|
||||
GrFloodFill(map,x2,y2);
|
||||
mode=LTM_LINE;
|
||||
LTMenuSet(mode);
|
||||
break;
|
||||
case LTM_TEST_RAY:
|
||||
RayBurst(x1,y1,x2,y2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MSG_MS_L_DOWN:
|
||||
cnt=0;
|
||||
map->color=ROP_XOR+WHITE;
|
||||
do {
|
||||
c[cnt].x=arg1; c[cnt].y=arg2; c[cnt].z=0;
|
||||
Gr2BSpline(map,c,cnt+1);
|
||||
msg_code=GetMsg(&arg1,&arg2,
|
||||
1<<MSG_KEY_DOWN+1<<MSG_MS_L_UP+1<<MSG_MS_MOVE+1<<MSG_MS_R_UP);
|
||||
Gr2BSpline(map,c,cnt+1);
|
||||
if (msg_code==MSG_KEY_DOWN)
|
||||
goto lt_restart;
|
||||
else if (msg_code==MSG_MS_L_UP) {
|
||||
Sweep(100,70,100);
|
||||
cnt++;
|
||||
}
|
||||
} while (cnt<PTS_NUM-1 && msg_code!=MSG_MS_R_UP);
|
||||
map->color=WHITE;
|
||||
Gr2BSpline3(map,c,cnt);
|
||||
for (i=0;i<cnt;i++) {
|
||||
c[i].x*=bmp_scale;
|
||||
c[i].y*=bmp_scale;
|
||||
x1=arg1; y1=arg2;
|
||||
switch (mode) {
|
||||
case LTM_LINE:
|
||||
map->color=ROP_XOR+WHITE;
|
||||
while (TRUE) {
|
||||
x2=arg1; y2=arg2;
|
||||
GrLine(map,x1,y1,x2,y2);
|
||||
msg_code=GetMsg(&arg1,&arg2,
|
||||
1<<MSG_KEY_DOWN+1<<MSG_MS_L_UP+1<<MSG_MS_MOVE);
|
||||
GrLine(map,x1,y1,x2,y2);
|
||||
if (msg_code==MSG_KEY_DOWN)
|
||||
goto lt_restart;
|
||||
else if (msg_code==MSG_MS_L_UP) {
|
||||
Sweep(100,90,100);
|
||||
x2=arg1; y2=arg2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DualLine(x1,y1,x2,y2);
|
||||
break;
|
||||
case LTM_SPLINE:
|
||||
cnt=0;
|
||||
map->color=ROP_XOR+WHITE;
|
||||
do {
|
||||
c[cnt].x=arg1; c[cnt].y=arg2; c[cnt].z=0;
|
||||
Gr2BSpline(map,c,cnt+1);
|
||||
msg_code=GetMsg(&arg1,&arg2,1<<MSG_KEY_DOWN+1<<MSG_MS_L_UP+
|
||||
1<<MSG_MS_MOVE+1<<MSG_MS_R_UP);
|
||||
Gr2BSpline(map,c,cnt+1);
|
||||
if (msg_code==MSG_KEY_DOWN)
|
||||
goto lt_restart;
|
||||
else if (msg_code==MSG_MS_L_UP) {
|
||||
Sweep(100,90,100);
|
||||
cnt++;
|
||||
}
|
||||
} while (cnt<PTS_NUM-1 && msg_code!=MSG_MS_R_UP);
|
||||
map->color=WHITE;
|
||||
Gr2BSpline3(map,c,cnt);
|
||||
for (i=0;i<cnt;i++) {
|
||||
c[i].x*=bmp_scale;
|
||||
c[i].y*=bmp_scale;
|
||||
}
|
||||
BSpline2(bmp,c,cnt,&BmpPlot);
|
||||
mode=LTM_LINE;
|
||||
LTMenuSet(mode);
|
||||
break;
|
||||
}
|
||||
BSpline2(bmp,c,cnt,&BmpPlot);
|
||||
break;
|
||||
case MSG_MS_R_UP:
|
||||
mode=PopUpPickLst("Line\0Spline\0FloodFill\0TestRay\0");
|
||||
LTMenuSet(mode);
|
||||
break;
|
||||
case MSG_KEY_DOWN:
|
||||
switch (arg1) {
|
||||
case CH_SPACE:
|
||||
GrFloodFill(map,ms.pos.x-Fs->pix_left,ms.pos.y-Fs->pix_top);
|
||||
break;
|
||||
case '\n':
|
||||
CleanUp;
|
||||
Init;
|
||||
@@ -406,6 +504,14 @@ lt_restart:
|
||||
FlushMsgs;
|
||||
full_speed=FALSE;
|
||||
break;
|
||||
case 'n':
|
||||
show_normals=!show_normals;
|
||||
LTMenuSet(mode);
|
||||
break;
|
||||
case '0'...'3':
|
||||
mode=arg1-'0';
|
||||
LTMenuSet(mode);
|
||||
break;
|
||||
case CH_ESC:
|
||||
case CH_SHIFT_ESC:
|
||||
goto lt_done;
|
||||
|
||||
Reference in new issue
Block a user