Skip to content

Commit

Permalink
refactory CheckIfSoflanChanged2() use while()
Browse files Browse the repository at this point in the history
  • Loading branch information
MikiraSora committed Oct 29, 2024
1 parent bcd7a85 commit 1541f8a
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,22 @@ void CheckIfSoflanChanged2(double totalTGrid, bool isVailed)
Check if there is any SoflanPoint before connectable object
If exist, just interpolate a new point to insert
*/
if (affectedSoflanPoints.Count == 0)
return;
while (affectedSoflanPoints.Count > 0)
{
var checkTGrid = affectedSoflanPoints[^1].TGrid;
var diff = checkTGrid.TotalUnit - totalTGrid;

var checkTGrid = affectedSoflanPoints[^1].TGrid;
var diff = checkTGrid.TotalUnit - totalTGrid;
if (diff > 0)
return;

if (diff > 0)
return;
if (diff < 0)
{
var xGrid = start.CalulateXGrid(checkTGrid);
PostPoint(checkTGrid, xGrid, isVailed);
}

if (diff < 0)
{
var xGrid = start.CalulateXGrid(checkTGrid);
PostPoint(checkTGrid, xGrid, isVailed);
affectedSoflanPoints.RemoveAt(affectedSoflanPoints.Count - 1);
}

affectedSoflanPoints.RemoveAt(affectedSoflanPoints.Count - 1);
//check again
CheckIfSoflanChanged2(totalTGrid, isVailed);
}

foreach (var childObj in start.Children)
Expand Down

0 comments on commit 1541f8a

Please sign in to comment.