anchor.diff:  
     //Mapp all map tiles to its polygons
     TieUpTilesWithPolygons();
  -end;
  -
  -
  -procedure TKMNavMesh.GenerateTileOutline(out aTileOutlines: TKMShapesArray);
  -var
  -  I, K: Integer;
  -  Tmp: TKMByte2Array;
  -begin
  -  SetLength(Tmp, gTerrain.MapY-1, gTerrain.MapX-1);
  -
  -  //Copy map to temp array as 0/1 (generator uses other byte values for its needs)
  -  //0 - no obstacle
  -  //1 - obstacle
  -  for I := 0 to gTerrain.MapY - 2 do
  -  for K := 0 to gTerrain.MapX - 2 do
  -    Tmp[I,K] := 1 - Byte(tpOwn in gTerrain.Land[I+1,K+1].Passability);
  -
  -  GenerateOutline(Tmp, 12, aTileOutlines);
  -
  -  //GenerateOutline is 0 based for versatility purposes, but Terrain in 1 based
  -  //because of legacy reasons. Do the conversion
  -  for I := 0 to aTileOutlines.Count - 1 do
  -  for K := 0 to aTileOutlines.Shape[I].Count - 1 do
  -  begin
  -    aTileOutlines.Shape[I].Nodes[K].X := aTileOutlines.Shape[I].Nodes[K].X + 1;
  -    aTileOutlines.Shape[I].Nodes[K].Y := aTileOutlines.Shape[I].Nodes[K].Y + 1;
  -  end;
   end;
   
   
  
positive.code: var
    I, K, J: Integer;
    T1, T2: TKMPointF;
    //Col, Col2: Cardinal;
    //Sz: Single;
    Outline1, Outline2: TKMWeightSegments;
  begin
    if not AI_GEN_NAVMESH then Exit;
  
    //Raw obstacle outlines
    if OVERLAY_NAVMESH then
      for I := 0 to fRawOutlines.Count - 1 do
      for K := 0 to fRawOutlines.Shape[I].Count - 1 do
      with fRawOutlines.Shape[I] do
        gRenderAux.LineOnTerrain(Nodes[K], Nodes[(K + 1) mod Count], $FFFF00FF);
  
    //NavMesh polys coverage
    if OVERLAY_NAVMESH then
      for I := 0 to fPolyCount - 1 do
        gRenderAux.TriangleOnTerrain(
  
negative.code:     procedure Paint(aRect: TKMRect);
    end;
  
  const
    NAVMESH_DENSITY = 3; // Density of NavMesh (affect count and size of points)
  
  
  implementation
  uses
  