Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Selinux24 committed Aug 8, 2024
1 parent 99f16aa commit 8243d58
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
13 changes: 6 additions & 7 deletions Samples/05 AISamples/Common/Primitives/Polygon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,25 @@ public static IEnumerable<Segment2> Union(Polygon[] polygons)
{
Break(polygons);

var segments = polygons
return polygons
.AsParallel()
.WithDegreeOfParallelism(GameEnvironment.DegreeOfParalelism)
.SelectMany((p, i) =>
{
List<Segment2> segments = [];
List<Segment2> res = [];

foreach (var segment in p.segments)
{
bool keep = KeepSegment(i, segment, polygons);
if (keep)
{
segments.Add(segment);
res.Add(segment);
}
}

return segments;
});

return segments.ToArray();
return res;
})
.ToArray();
}
private static bool KeepSegment(int polyIndex, Segment2 segment, Polygon[] polygons)
{
Expand Down
2 changes: 1 addition & 1 deletion Samples/05 AISamples/Common/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ private void UpdateCars(IGameTime gameTime, ModelInstanced carDrawer)
carDrawer[i].TintColor = car == bestCar ? bestCarColor : carColor;
}

bestCar = cars.Where(c => c.Damaged == false).MaxBy(c => c.FittnessValue);
bestCar = cars.Where(c => !c.Damaged).MaxBy(c => c.FittnessValue);

carDrawer.Visible = cars.Count > 0;
}
Expand Down
18 changes: 9 additions & 9 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Osm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct OsmData
/// <summary>
/// Element list
/// </summary>
public OsmNode[] Elements;
public OsmNode[] Elements { get; set; }
}

/// <summary>
Expand All @@ -29,27 +29,27 @@ struct OsmNode
/// <summary>
/// Node type
/// </summary>
public string Type;
public string Type { get; set; }
/// <summary>
/// Node id
/// </summary>
public long Id;
public long Id { get; set; }
/// <summary>
/// Latitude value
/// </summary>
public float Lat;
public float Lat { get; set; }
/// <summary>
/// Longitud value
/// </summary>
public float Lon;
public float Lon { get; set; }
/// <summary>
/// Node id list
/// </summary>
public long[] Nodes;
public long[] Nodes { get; set; }
/// <summary>
/// Tags
/// </summary>
public OsmTags Tags;
public OsmTags Tags { get; set; }
}

/// <summary>
Expand All @@ -60,11 +60,11 @@ struct OsmTags
/// <summary>
/// Number of lanes
/// </summary>
public string Lanes;
public string Lanes { get; set; }
/// <summary>
/// One way street
/// </summary>
public string OneWay;
public string OneWay { get; set; }
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,8 @@ private void LoadFromOpenStreetMap()

if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var graph = Osm.ParseRoads(dlg.FileName, world.RoadWidth / 3f);
world.GenerateFromGraph(graph);
var osmGraph = Osm.ParseRoads(dlg.FileName, 10f);
world.GenerateFromGraph(osmGraph);
var (start, _) = world.GetStart();
MoveCameraTo(new Vector3(start.X, 0, start.Y));
}
Expand Down

0 comments on commit 8243d58

Please sign in to comment.