Skip to content

Commit

Permalink
improved caching, fixed donut intersect ray for pulls
Browse files Browse the repository at this point in the history
  • Loading branch information
CarnifexOptimus committed Apr 23, 2024
1 parent 9cd2aa6 commit d7f3163
Show file tree
Hide file tree
Showing 10 changed files with 7,783 additions and 146 deletions.
261 changes: 130 additions & 131 deletions BossMod/BossModule/ArenaBounds.cs

Large diffs are not rendered by default.

784 changes: 784 additions & 0 deletions BossMod/ThirdParty/Clipper2Lib/Clipper.Core.cs

Large diffs are not rendered by default.

3,620 changes: 3,620 additions & 0 deletions BossMod/ThirdParty/Clipper2Lib/Clipper.Engine.cs

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions BossMod/ThirdParty/Clipper2Lib/Clipper.Minkowski.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*******************************************************************************
* Author : Angus Johnson *
* Date : 15 October 2022 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2022 *
* Purpose : Minkowski Sum and Difference *
* License : http://www.boost.org/LICENSE_1_0.txt *
*******************************************************************************/

#nullable enable
using System;

namespace Clipper2Lib
{
public class Minkowski
{
private static Paths64 MinkowskiInternal(Path64 pattern, Path64 path, bool isSum, bool isClosed)
{
int delta = isClosed ? 0 : 1;
int patLen = pattern.Count, pathLen = path.Count;
Paths64 tmp = new Paths64(pathLen);

foreach (Point64 pathPt in path)
{
Path64 path2 = new Path64(patLen);
if (isSum)
{
foreach (Point64 basePt in pattern)
path2.Add(pathPt + basePt);
}
else
{
foreach (Point64 basePt in pattern)
path2.Add(pathPt - basePt);
}
tmp.Add(path2);
}

Paths64 result = new Paths64((pathLen - delta) * patLen);
int g = isClosed ? pathLen - 1 : 0;

int h = patLen - 1;
for (int i = delta; i < pathLen; i++)
{
for (int j = 0; j < patLen; j++)
{
Path64 quad = new Path64(4)
{
tmp[g][h], tmp[i][h], tmp[i][j], tmp[g][j]
};
if (!Clipper.IsPositive(quad))
result.Add(Clipper.ReversePath(quad));
else
result.Add(quad);
h = j;
}
g = i;
}
return result;
}

public static Paths64 Sum(Path64 pattern, Path64 path, bool isClosed)
{
return Clipper.Union(MinkowskiInternal(pattern, path, true, isClosed), FillRule.NonZero);
}

public static PathsD Sum(PathD pattern, PathD path, bool isClosed, int decimalPlaces = 2)
{
double scale = Math.Pow(10, decimalPlaces);
Paths64 tmp = Clipper.Union(MinkowskiInternal(Clipper.ScalePath64(pattern, scale),
Clipper.ScalePath64(path, scale), true, isClosed), FillRule.NonZero);
return Clipper.ScalePathsD(tmp, 1 / scale);
}

public static Paths64 Diff(Path64 pattern, Path64 path, bool isClosed)
{
return Clipper.Union(MinkowskiInternal(pattern, path, false, isClosed), FillRule.NonZero);
}

public static PathsD Diff(PathD pattern, PathD path, bool isClosed, int decimalPlaces = 2)
{
double scale = Math.Pow(10, decimalPlaces);
Paths64 tmp = Clipper.Union(MinkowskiInternal(Clipper.ScalePath64(pattern, scale),
Clipper.ScalePath64(path, scale), false, isClosed), FillRule.NonZero);
return Clipper.ScalePathsD(tmp, 1 / scale);
}

}

} // namespace
Loading

0 comments on commit d7f3163

Please sign in to comment.