Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
MikiraSora committed Oct 29, 2024
1 parent e341611 commit 9470833
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,29 +129,30 @@ void CheckIfSoflanChanged2(double totalTGrid, bool isVailed)
}

//optimze vertices
for (var i = 0; i < tempVertices.Count - 3; i++)
var idx = 0;
for (; idx < tempVertices.Count - 3; idx++)
{
var a1 = tempVertices[i];
var a2 = tempVertices[i + 1];
var b1 = tempVertices[i + 2];
var b2 = tempVertices[i + 3];
var a1 = tempVertices[idx];
var a2 = tempVertices[idx + 1];
var b1 = tempVertices[idx + 2];
var b2 = tempVertices[idx + 3];

if (!(a1 == b1 && a2 == b2))
outVertices.Add(a1);

if ((a1.Point.X == a2.Point.X && a2.Point.X == b1.Point.X) || (a1.Point.Y == a2.Point.Y && a2.Point.Y == b1.Point.Y))
{
outVertices.Add(b1);
i += 2;
idx += 2;
}
else if (a1.Point == a2.Point)
{
i += 1;
idx += 1;
}
}

//add remain vertices
outVertices.AddRange(tempVertices.Skip(tempVertices.Count - 3));
outVertices.AddRange(tempVertices.Skip(idx));

ObjectPool<List<SoflanPoint>>.Return(affectedSoflanPoints);
ObjectPool<List<LineVertex>>.Return(tempVertices);
Expand Down

0 comments on commit 9470833

Please sign in to comment.