<div dir="ltr">? so the goal was not to limit dx2 and dy2 in interval [-2.0,2.0] ?<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014/1/5 <span dir="ltr"><<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
tim Rowledge uploaded a new version of VMMaker to project VM Maker:<br>
<a href="http://source.squeak.org/VMMaker/VMMaker-tpr.335.mcz" target="_blank">http://source.squeak.org/VMMaker/VMMaker-tpr.335.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker-tpr.335<br>
Author: tpr<br>
Time: 4 January 2014, 5:11:00.292 pm<br>
UUID: d8a65973-094c-419c-857d-ab70497a0c86<br>
Ancestors: VMMaker-dtl.334<br>
<br>
fix typo bug in ScratchPlugin>primitiveWaterRipples1<br>
<br>
=============== Diff against VMMaker-dtl.334 ===============<br>
<br>
Item was changed:<br>
----- Method: ScratchPlugin>>primitiveWaterRipples1 (in category 'other filters') -----<br>
primitiveWaterRipples1<br>
<br>
| in out aArray bArray ripply temp pix dx dy dist inOop outOop width allPix aArOop bArOop height t1 blops x y power val val2 dx2 dy2 newLoc |<br>
<export: true><br>
<var: 'in' declareC: 'unsigned int *in'><br>
<var: 'out' declareC: 'unsigned int *out'><br>
<var: 'aArray' declareC: 'double *aArray'><br>
<var: 'bArray' declareC: 'double *bArray'><br>
<var: 'ripply' declareC: 'int ripply'><br>
<var: 'temp' declareC: 'double temp'><br>
<var: 'pix' declareC: 'unsigned int pix'><br>
<var: 'dist' declareC: 'double dist'><br>
<var: 'dx2' declareC: 'double dx2'><br>
<var: 'dy2' declareC: 'double dy2'><br>
<br>
inOop := interpreterProxy stackValue: 5.<br>
outOop := interpreterProxy stackValue: 4.<br>
width := interpreterProxy stackIntegerValue: 3.<br>
in := self checkedUnsignedIntPtrOf: inOop.<br>
out := self checkedUnsignedIntPtrOf: outOop.<br>
allPix := interpreterProxy stSizeOf: inOop.<br>
ripply := interpreterProxy stackIntegerValue: 2.<br>
aArOop := interpreterProxy stackValue: 1.<br>
bArOop := interpreterProxy stackValue: 0.<br>
aArray := self checkedFloatPtrOf: aArOop.<br>
bArray := self checkedFloatPtrOf: bArOop.<br>
interpreterProxy success: ((interpreterProxy stSizeOf: outOop) = allPix).<br>
interpreterProxy failed ifTrue: [^ nil].<br>
<br>
height := allPix // width.<br>
<br>
t1 := self cCode: 'rand()'.<br>
blops := t1 \\ ripply -1.<br>
0 to: blops /2-1 do: [:t |<br>
t1 := self cCode: 'rand()'.<br>
x := t1 \\ width.<br>
t1 := self cCode: 'rand()'.<br>
y := t1 \\ height.<br>
t1 := self cCode: 'rand()'.<br>
power := t1 \\ 8.<br>
-4 to: 4 do: [:g |<br>
-4 to: 4 do: [:h |<br>
dist := ((g*g) + (h*h)) asFloat.<br>
((dist < 25) and: [dist > 0]) ifTrue: [<br>
dx := (x + g) asInteger.<br>
dy := (y + h) asInteger.<br>
((dx >0) and: [(dy>0) and: [(dy < height) and: [dx < width]]]) ifTrue: [<br>
aArray at: ((dy)*width + dx) put: (power *(1.0 asFloat -(dist/(25.0 asFloat))) asFloat).<br>
].<br>
].<br>
].<br>
].<br>
].<br>
<br>
1 to: width -2 do: [:f |<br>
1 to: height -2 do: [:d |<br>
val := (d)*width + f.<br>
aArray at: val put: (((<br>
(bArray at: (val+1)) + (bArray at: (val-1)) + (bArray at: (val + width)) + (bArray at: (val - width)) +<br>
((bArray at: (val -1 -width))/2) + ((bArray at: (val-1+width))/2) + ((bArray at: (val+1-width))/2) + ((bArray at: (val+1+width))/2)) /4) - (aArray at: (val))).<br>
aArray at: (val) put: ((aArray at: (val))*(0.9 asFloat)).<br>
].<br>
].<br>
<br>
"temp := bArray.<br>
bArray := aArray.<br>
aArray := temp."<br>
0 to: width*height do: [:q |<br>
temp := bArray at: q.<br>
bArray at: q put: (aArray at: q).<br>
aArray at: q put: temp.<br>
].<br>
<br>
0 to: height-1 do: [:j |<br>
0 to: width-1 do: [:i |<br>
((i > 1) and: [(i<(width-1)) and: [(j>1) and: [(j<(height-1))]]]) ifTrue: [<br>
val2 := (j)*width + i.<br>
dx2 := ((((aArray at: (val2)) - (aArray at: (val2-1))) + ((aArray at: (val2+1)) - (aArray at: (val2)))) *64) asFloat.<br>
dy2 := ((((aArray at: (val2)) - (aArray at: (val2-width))) + ((aArray at: (val2+width)) - (aArray at: (val2)))) /64) asFloat.<br>
+ (dx2<2) ifTrue: [dx2 := -2].<br>
- (dx2<-2) ifTrue: [dx2 := -2].<br>
(dx2>2) ifTrue: [dx2 := 2].<br>
+ (dy2<2) ifTrue: [dy2 := -2].<br>
- (dy2<-2) ifTrue: [dy2 := -2].<br>
(dy2>2) ifTrue: [dy2 := 2].<br>
newLoc := ((j+dy2)*width + (i+dx2)) asInteger.<br>
((newLoc < (width*height)) and: [newLoc >=0]) ifTrue: [<br>
pix := in at: newLoc]<br>
ifFalse: [<br>
pix := in at: (i +(j*width)) ].<br>
]<br>
ifFalse: [<br>
pix := in at: (i +(j*width)) ].<br>
out at: (i + (j*width)) put: pix.<br>
]].<br>
<br>
interpreterProxy pop: 6. "pop args, leave rcvr on stack"<br>
^ 0<br>
!<br>
<br>
</blockquote></div><br></div>