# HG changeset patch # User sheepluva # Date 1277788195 -7200 # Node ID 39570d86de571a9b9dbcd60aac012c489067fb95 # Parent 7c05f2e0a8b53da585e723f1ca90455c97c04a38 rope: optimization, should save up to ~3 million hwFloat multiplications per second diff -r 7c05f2e0a8b5 -r 39570d86de57 hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Tue Jun 29 06:27:59 2010 +0200 +++ b/hedgewars/GSHandlers.inc Tue Jun 29 07:09:55 2010 +0200 @@ -1155,21 +1155,22 @@ // check whether rope needs dividing len := Gear^.Elasticity - _5; + nx := Gear^.X + mdX * len; + ny := Gear^.Y + mdY * len; + tx := mdX * _0_3; // should be the same as increase step + ty := mdY * _0_3; + while len > _3 do begin - lx := hwRound(Gear^.X + mdX * len); - ly := hwRound(Gear^.Y + mdY * len); + lx := hwRound(nx); + ly := hwRound(ny); if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0 ) then begin - // calculate those the first time we have to divide the rope - if not haveDivided then - begin ny := _1 / Distance(ropeDx, ropeDy); // old rope pos nx := ropeDx * ny; ny := ropeDy * ny; - end; with RopePoints.ar[RopePoints.Count] do begin @@ -1194,6 +1195,8 @@ haveDivided := true; break end; + nx := nx - tx; + ny := ny - ty; len := len - _0_3 // should be the same as increase step end;