Skip to content

Commit 15ec47c

Browse files
authored
Merge pull request #85 from LunaKampling/feature/grid_60
Support for 6.0 physics and 6.0 sols. Crazy.
2 parents a28a0b3 + 8605ae4 commit 15ec47c

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

src/Game/Physics/SimulationGridStatic.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,33 @@ public static List<CellLocation> GetGridPositions(Vector2d linestart, Vector2d l
8585
{
8686
ret = GetGridPositions61(linestart, lineend);
8787
}
88+
else if (gridversion == 60)
89+
{
90+
Vector2d line_normal_unit = diff.Normalized().PerpendicularLeft; // Does not depend on flipped
91+
Vector2d line_halfway = 0.5 * new Vector2d(Math.Abs(diff.X), Math.Abs(diff.Y));
92+
Vector2d line_midpoint = linestart + diff * 0.5;
93+
Vector2d absolute_normal = new Vector2d(Math.Abs(line_normal_unit.X), Math.Abs(line_normal_unit.Y));
94+
95+
for (int cell_x = p1X; cell_x <= p2X; cell_x++)
96+
{
97+
for (int cell_y = p1Y; cell_y <= p2Y; cell_y++)
98+
{
99+
Vector2d curr_pos = CellSize * new Vector2d(cell_x + 0.5, cell_y + 0.5);
100+
CellLocation next_cell_pos = CellInfo(curr_pos.X, curr_pos.Y);
101+
Vector2d dist_between_centers = line_midpoint - curr_pos;
102+
double dist_from_cell_center = Vector2d.Dot(absolute_normal, next_cell_pos.Remainder);
103+
double cell_overlap_into_hitbox = Vector2d.Dot(new Vector2d(dist_from_cell_center, dist_from_cell_center), absolute_normal);
104+
double norm_dist_between_centers = Vector2d.Dot(line_normal_unit, dist_between_centers);
105+
double dist_from_line = Math.Abs(norm_dist_between_centers * line_normal_unit.X) + Math.Abs(norm_dist_between_centers * line_normal_unit.Y);
106+
if (line_halfway.X + next_cell_pos.Remainder.X >= Math.Abs(dist_between_centers.X)
107+
&& line_halfway.Y + next_cell_pos.Remainder.Y >= Math.Abs(dist_between_centers.Y)
108+
&& cell_overlap_into_hitbox >= dist_from_line)
109+
{
110+
ret.Add(next_cell_pos);
111+
}
112+
}
113+
}
114+
}
88115
return ret;
89116
}
90117
[MethodImpl(MethodImplOptions.AggressiveInlining)]

src/IO/SOLLoader.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ public static Track LoadTrack(sol_track trackdata)
3434
Dictionary<int, StandardLine> addedlines = new Dictionary<int, StandardLine>(buffer.Count);
3535
string version = trackdata.data.First(x => x.name == "version").data as string;
3636

37-
if (version == "6.1")
37+
if (version == "6.2")
38+
{
39+
ret.SetVersion(62);
40+
}
41+
else if (version == "6.1")
3842
{
3943
ret.SetVersion(61);
4044
}
4145
else
4246
{
43-
ret.SetVersion(62);
47+
ret.SetVersion(60);
4448
}
4549
try
4650
{

0 commit comments

Comments
 (0)