anchor.diff:    Col, Col2: Cardinal;
     Sz: Single;
     Outline1, Outline2: TKMWeightSegments;
  +
  +
  +  W: Word;
  +  Owner: TKMHandIndex;
  +  Point: TKMPoint;
  +  DefLines: TKMDefenceLines;
  +  FFF: TForwardFF;
  +  DefencePosArr: TKMDefencePosArr;
  +
   begin
     if not AI_GEN_NAVMESH then Exit;
  +
  +  //{ Test defences
  +  // Show this defences only in case that show combat AI is not enabled;
  +  // when it is we need existing results not the actual (defences are updated each 1 min so it may be different)
  +  if OVERLAY_NAVMESH AND OVERLAY_DEFENCES AND not OVERLAY_AI_COMBAT then
  +  begin
  +    FFF := TForwardFF.Create(true);
  +    Owner := gMySpectator.HandIndex;
  +    try
  +
  +      FFF.FindDefenceLines(Owner, DefLines);
  +      for K := 0 to DefLines.Count - 1 do
  +      begin
  +        I := DefLines.Lines[K].Polygon;
  +        gRenderAux.TriangleOnTerrain(
  +          fNodes[fPolygons[I].Indices[0]].Loc.X,
  +          fNodes[fPolygons[I].Indices[0]].Loc.Y,
  +          fNodes[fPolygons[I].Indices[1]].Loc.X,
  +          fNodes[fPolygons[I].Indices[1]].Loc.Y,
  +          fNodes[fPolygons[I].Indices[2]].Loc.X,
  +          fNodes[fPolygons[I].Indices[2]].Loc.Y, $300000FF);
  +      end;
  +
  +      W := 20;
  +      FFF.FindDefensivePolygons(Owner, W, DefencePosArr);
  +      for K := 0 to Length(DefencePosArr) - 1 do
  +      begin
  +        Point := DefencePosArr[K].DirPoint.Loc;
  +        gRenderAux.CircleOnTerrain(Point.X, Point.Y, 2, $0900FFFF, $FFFFFFFF);
  +      end;
  +
  +      //PolygonArr := FFF.D_FF_INIT_ARR;
  +      //for K := 0 to Length(PolygonArr) - 1 do
  +      //begin
  +      //  I := PolygonArr[K];
  +      //  gRenderAux.TriangleOnTerrain(
  +      //    fNodes[fPolygons[I].Indices[0]].Loc.X,
  +      //    fNodes[fPolygons[I].Indices[0]].Loc.Y,
  +      //    fNodes[fPolygons[I].Indices[1]].Loc.X,
  +      //    fNodes[fPolygons[I].Indices[1]].Loc.Y,
  +      //    fNodes[fPolygons[I].Indices[2]].Loc.X,
  +      //    fNodes[fPolygons[I].Indices[2]].Loc.Y, $900000FF);
  +      //end;
  +
  +      //PolygonArr := FFF.D_FF_INIT_FLOOD;
  +      //for K := 0 to Length(PolygonArr) - 1 do
  +      //begin
  +      //  I := PolygonArr[K];
  +      //  gRenderAux.TriangleOnTerrain(
  +      //    fNodes[fPolygons[I].Indices[0]].Loc.X,
  +      //    fNodes[fPolygons[I].Indices[0]].Loc.Y,
  +      //    fNodes[fPolygons[I].Indices[1]].Loc.X,
  +      //    fNodes[fPolygons[I].Indices[1]].Loc.Y,
  +      //    fNodes[fPolygons[I].Indices[2]].Loc.X,
  +      //    fNodes[fPolygons[I].Indices[2]].Loc.Y, $9000FF00);
  +      //end;
  +    finally
  +      FFF.Free;
  +    end;
  +  end;//}
   
     //{Raw obstacle outlines
     if OVERLAY_NAVMESH then
  
positive.code:   KM_PolySimplify,
    KM_CommonClasses, KM_CommonTypes, KM_Defaults, KM_Points,
    KM_NavMeshDefences,
    KromUtils, KM_CommonUtils;// TimeGet
  
  
  type
  
negative.code:       fPolygons[aIdx].NearbyPoints[I] := KMPointAverage(fNodes[ Indices[0] ].Loc, fNodes[ Indices[1] ].Loc);
      end;
    end;
  var
    AlreadyInTriangle: Boolean;
    I, i1, i2, i3: Word;
    X, Y: Integer;
    MinPoint, MaxPoint: TKMPoint;
    v1, v2, v3: TKMPointF;
    WordArr: TKMWord2Array;
  begin
    SetLength(fPoint2PolygonArr, gTerrain.MapY, gTerrain.MapX);
    for Y := Low(fPoint2PolygonArr) to High(fPoint2PolygonArr) do
  