@@ -188,10 +188,10 @@ public void Update()
188188 public void ZoomReset ( DrawTrackDB drawTrackDB )
189189 {
190190 if ( drawTrackDB == null ) return ;
191- float minX = drawTrackDB . MinTileX * 2048 - 1024f ;
192- float minZ = drawTrackDB . MinTileZ * 2048 - 1024f ;
193- float maxX = drawTrackDB . MaxTileX * 2048 + 1024f ;
194- float maxZ = drawTrackDB . MaxTileZ * 2048 + 1024f ;
191+ double minX = drawTrackDB . MinTileX * WorldLocation . TileSize - 1024f ;
192+ double minZ = drawTrackDB . MinTileZ * WorldLocation . TileSize - 1024f ;
193+ double maxX = drawTrackDB . MaxTileX * WorldLocation . TileSize + 1024f ;
194+ double maxZ = drawTrackDB . MaxTileZ * WorldLocation . TileSize + 1024f ;
195195 SetDrawArea ( minX , maxX , minZ , maxZ ) ;
196196 }
197197
@@ -202,10 +202,10 @@ public void ZoomReset(DrawTrackDB drawTrackDB)
202202 /// <param name="maxX">maximal real world X location</param>
203203 /// <param name="minZ">minimal real world Z location</param>
204204 /// <param name="maxZ">maximal real world Z location</param>
205- void SetDrawArea ( float minX , float maxX , float minZ , float maxZ )
205+ void SetDrawArea ( double minX , double maxX , double minZ , double maxZ )
206206 {
207- float scaleX = AreaW / ( maxX - minX ) ;
208- float scaleY = AreaH / ( maxZ - minZ ) ;
207+ double scaleX = AreaW / ( maxX - minX ) ;
208+ double scaleY = AreaH / ( maxZ - minZ ) ;
209209 //make square tiles
210210 Scale = Math . Min ( scaleX , scaleY ) ;
211211 metersPerPixel . ApproximateTo ( 1.0f / Scale ) ;
@@ -297,7 +297,7 @@ private void ZoomAround(Vector2 fixedAreaLocation, int scaleSteps)
297297 // fixedX = scale_old * (worldX - offsetX_old) = scale_new * (worldX - offsetX_new)
298298 // fixedX/scale_old + offsetX_old = fixedX/scale_new + offsetX_new = worldX
299299 // offsetX_new = offsetX_old + fixedX * (scale_new/scale_old - 1) / scale_new
300- float scaleFactor = 1.0f / ( float ) metersPerPixel . AddStep ( scaleSteps ) ; // 1.0/xxx because scale is inverse of metersPerPixel
300+ double scaleFactor = 1.0 / metersPerPixel . AddStep ( scaleSteps ) ; // 1.0/xxx because scale is inverse of metersPerPixel
301301 Scale = metersPerPixel . InverseScaleValue ;
302302 OffsetX += fixedAreaLocation . X * ( scaleFactor - 1 ) / Scale ;
303303 OffsetZ += ( AreaH - fixedAreaLocation . Y ) * ( scaleFactor - 1 ) / Scale ;
@@ -311,8 +311,8 @@ public void ZoomToTile()
311311 {
312312 //normal equation: areaX = scale * (worldX - offsetX)
313313 //zoom to tile: screenW = scale_new * 2048
314- double scaleX = AreaW / 2048.0 ;
315- double scaleY = AreaH / 2048.0 ;
314+ double scaleX = AreaW / WorldLocation . TileSize ;
315+ double scaleY = AreaH / WorldLocation . TileSize ;
316316 double newScale = Math . Min ( scaleX , scaleY ) ;
317317 int stepsNeeded = metersPerPixel . StepsNeededForRatio ( Scale / newScale ) ;
318318 ZoomAroundMouse ( stepsNeeded ) ;
@@ -323,8 +323,8 @@ public void ZoomToTile()
323323 /// </summary>
324324 public void ZoomToTileCentered ( )
325325 {
326- double scaleX = AreaW / 2048.0 ;
327- double scaleY = AreaH / 2048.0 ;
326+ double scaleX = AreaW / WorldLocation . TileSize ;
327+ double scaleY = AreaH / WorldLocation . TileSize ;
328328 double newScale = Math . Min ( scaleX , scaleY ) ;
329329 ZoomCentered ( metersPerPixel . StepsNeededForRatio ( Scale / newScale ) ) ;
330330 }
@@ -420,8 +420,8 @@ public void ShiftToLocation(WorldLocation location)
420420 // Basic equation areaX = scale * (worldX - offsetX)
421421 // We want middle of screen to shift to new worldX, so areaW/2 = scale * (worldX - offsetX)
422422 // Similarly
423- double worldX = location . TileX * 2048 + location . Location . X ;
424- double worldZ = location . TileZ * 2048 + location . Location . Z ;
423+ double worldX = location . TileX * WorldLocation . TileSize + location . Location . X ;
424+ double worldZ = location . TileZ * WorldLocation . TileSize + location . Location . Z ;
425425 OffsetX = worldX - AreaW / ( 2 * Scale ) ;
426426 OffsetZ = worldZ - AreaH / ( 2 * Scale ) ;
427427 }
@@ -446,8 +446,8 @@ private float GetWindowSize(float worldSize)
446446 /// <returns>location on the drawing area in a 2d vector (in pixels)</returns>
447447 private Vector2 GetAreaVector ( WorldLocation location )
448448 {
449- double x = location . TileX * 2048 + location . Location . X ;
450- double y = location . TileZ * 2048 + location . Location . Z ;
449+ double x = location . TileX * WorldLocation . TileSize + location . Location . X ;
450+ double y = location . TileZ * WorldLocation . TileSize + location . Location . Z ;
451451 return new Vector2 ( ( float ) ( Scale * ( x - OffsetX ) ) ,
452452 ( float ) ( AreaH - Scale * ( y - OffsetZ ) ) ) ;
453453 }
@@ -486,13 +486,7 @@ private WorldLocation GetWorldLocation(int areaX, int areaY)
486486 {
487487 double x = ( OffsetX + ( areaX ) / Scale ) ;
488488 double z = ( OffsetZ + ( AreaH - areaY ) / Scale ) ;
489- //WorldLocation location = new WorldLocation(0, 0, cornerIndexX, 0, cornerIndexZ);
490- //we now do pre-normalization. This normalization is more efficient than Coordinates.normalization
491- int tileX = ( int ) x / 2048 ;
492- x -= ( tileX * 2048 ) ;
493- int tileZ = ( int ) z / 2048 ;
494- z -= tileZ * 2048 ;
495- WorldLocation location = new WorldLocation ( tileX , tileZ , ( float ) x , 0 , ( float ) z ) ;
489+ WorldLocation location = new WorldLocation ( 0 , 0 , ( float ) x , 0 , ( float ) z ) ;
496490 location . Normalize ( ) ;
497491 return location ;
498492 }
0 commit comments