Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored remaining Vec2 uses to use Vector2 #48

Open
wants to merge 1 commit into
base: v2.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/Box2D.Window/DrawPhysics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ public DrawPhysics(IWindow window)
this.window = window;
}

public override void DrawPolygon(in Vec2[] vertices, int vertexCount, in Color color)
public override void DrawPolygon(in Vector2[] vertices, int vertexCount, in Color color)
{
window.DrawPolygon(vertices, vertexCount, color);
}

public override void DrawSolidPolygon(in Vec2[] vertices, int vertexCount, in Color color)
public override void DrawSolidPolygon(in Vector2[] vertices, int vertexCount, in Color color)
{
window.DrawSolidPolygon(vertices, vertexCount, color);
}

public override void DrawCircle(in Vec2 center, float radius, in Color color)
public override void DrawCircle(in Vector2 center, float radius, in Color color)
{
window.DrawCircle(center, radius, color);
}

public override void DrawSolidCircle(in Vec2 center, float radius, in Vec2 axis, in Color color)
public override void DrawSolidCircle(in Vector2 center, float radius, in Vector2 axis, in Color color)
{
window.DrawSolidCircle(center, radius, axis, color);
}

public override void DrawSegment(in Vec2 p1, in Vec2 p2, in Color color)
public override void DrawSegment(in Vector2 p1, in Vector2 p2, in Color color)
{
window.DrawSegment(p1, p2, color);
}
Expand Down
11 changes: 6 additions & 5 deletions examples/Box2D.Window/IWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
Window Simulation Copyright © Ben Ukhanov 2020
*/

using System.Numerics;
using Box2D.NetStandard.Common;
using Color = Box2D.NetStandard.Dynamics.World.Color;

namespace Box2D.Window
{
public interface IWindow
{
void DrawPolygon(Vec2[] vertices, int vertexCount, Color color);
void DrawPolygon(Vector2[] vertices, int vertexCount, Color color);

void DrawSolidPolygon(Vec2[] vertices, int vertexCount, Color color);
void DrawSolidPolygon(Vector2[] vertices, int vertexCount, Color color);

void DrawCircle(Vec2 center, float radius, Color color);
void DrawCircle(Vector2 center, float radius, Color color);

void DrawSolidCircle(Vec2 center, float radius, Vec2 axis, Color color);
void DrawSolidCircle(Vector2 center, float radius, Vector2 axis, Color color);

void DrawSegment(Vec2 p1, Vec2 p2, Color color);
void DrawSegment(Vector2 p1, Vector2 p2, Color color);

void DrawXForm(Transform xf);
}
Expand Down
14 changes: 7 additions & 7 deletions examples/Box2D.Window/SimulationWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public float GetVertical()
return vertical;
}

public void DrawPolygon(Vec2[] vertices, int vertexCount, Color color)
public void DrawPolygon(System.Numerics.Vector2[] vertices, int vertexCount, Color color)
{
drawActions.Enqueue(() =>
{
Expand All @@ -198,7 +198,7 @@ public void DrawPolygon(Vec2[] vertices, int vertexCount, Color color)
});
}

public void DrawSolidPolygon(Vec2[] vertices, int vertexCount, Color color)
public void DrawSolidPolygon(System.Numerics.Vector2[] vertices, int vertexCount, Color color)
{
drawActions.Enqueue(() =>
{
Expand All @@ -216,7 +216,7 @@ public void DrawSolidPolygon(Vec2[] vertices, int vertexCount, Color color)
});
}

public void DrawCircle(Vec2 center, float radius, Color color)
public void DrawCircle(System.Numerics.Vector2 center, float radius, Color color)
{
drawActions.Enqueue(() =>
{
Expand All @@ -234,7 +234,7 @@ public void DrawCircle(Vec2 center, float radius, Color color)
{
var x = (float)Math.Cos(theta);
var y = (float)Math.Sin(theta);
var vertex = center + (radius * new Vec2(x, y));
var vertex = center + (radius * new System.Numerics.Vector2(x, y));

GL.Vertex2(vertex.X, vertex.Y);

Expand All @@ -245,7 +245,7 @@ public void DrawCircle(Vec2 center, float radius, Color color)
});
}

public void DrawSolidCircle(Vec2 center, float radius, Vec2 axis, Color color)
public void DrawSolidCircle(System.Numerics.Vector2 center, float radius, System.Numerics.Vector2 axis, Color color)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just just Vector2 instead of longer System.Numerics.Vector2 because it helps to keep it shorter line here. It's up to you to decide! :)

{
drawActions.Enqueue(() =>
{
Expand All @@ -263,7 +263,7 @@ public void DrawSolidCircle(Vec2 center, float radius, Vec2 axis, Color color)
{
var x = (float)Math.Cos(theta);
var y = (float)Math.Sin(theta);
var vertex = center + (radius * new Vec2(x, y));
var vertex = center + (radius * new System.Numerics.Vector2(x, y));

GL.Vertex2(vertex.X, vertex.Y);

Expand All @@ -276,7 +276,7 @@ public void DrawSolidCircle(Vec2 center, float radius, Vec2 axis, Color color)
});
}

public void DrawSegment(Vec2 p1, Vec2 p2, Color color)
public void DrawSegment(System.Numerics.Vector2 p1, System.Numerics.Vector2 p2, Color color)
{
drawActions.Enqueue(() =>
{
Expand Down
160 changes: 90 additions & 70 deletions examples/box2d-examples-window.sln
Original file line number Diff line number Diff line change
@@ -1,72 +1,92 @@

Copy link
Owner

@codingben codingben Jan 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, sorry. Why box2d-examples-window.sln was changed? It works by keeping it as is. Do you use dotnet build from CLI?

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29926.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Box2D.WindowTests", "Box2D.WindowTests\Box2D.WindowTests.csproj", "{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Box2D.Window", "Box2D.Window\Box2D.Window.csproj", "{78472121-1376-471D-8801-6C67882B28AD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Box2D.WorldTests", "Box2D.WorldTests\Box2D.WorldTests.csproj", "{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{CFFED500-BB9F-11EA-AA17-6D586A78C909}"
EndProject
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DEC97AC1-1CC5-4EBF-9C1C-D828FA639573}
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|x64.ActiveCfg = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|x64.Build.0 = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|x86.ActiveCfg = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|x86.Build.0 = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|Any CPU.Build.0 = Release|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|x64.ActiveCfg = Release|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|x64.Build.0 = Release|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|x86.ActiveCfg = Release|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|x86.Build.0 = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|x64.ActiveCfg = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|x64.Build.0 = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|x86.ActiveCfg = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|x86.Build.0 = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|Any CPU.Build.0 = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|x64.ActiveCfg = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|x64.Build.0 = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|x86.ActiveCfg = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|x86.Build.0 = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|x64.ActiveCfg = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|x64.Build.0 = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|x86.ActiveCfg = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|x86.Build.0 = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|Any CPU.Build.0 = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|x64.ActiveCfg = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|x64.Build.0 = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|x86.ActiveCfg = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C} = {CFFED500-BB9F-11EA-AA17-6D586A78C909}

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29926.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Box2D.WindowTests", "Box2D.WindowTests\Box2D.WindowTests.csproj", "{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Box2D.Window", "Box2D.Window\Box2D.Window.csproj", "{78472121-1376-471D-8801-6C67882B28AD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Box2D.WorldTests", "Box2D.WorldTests\Box2D.WorldTests.csproj", "{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{CFFED500-BB9F-11EA-AA17-6D586A78C909}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Box2D.NetStandard", "..\src\box2dx\Box2D.NetStandard\Box2D.NetStandard.csproj", "{19A91C82-AF22-4BE9-8904-E6D6D371DC45}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{28D959E6-5CA9-435D-8990-70A1E4BB1F77}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "box2dx", "box2dx", "{A2E36F60-8750-46B5-B7BE-81AF0B75E594}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|x64.ActiveCfg = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|x64.Build.0 = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|x86.ActiveCfg = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Debug|x86.Build.0 = Debug|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|Any CPU.Build.0 = Release|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|x64.ActiveCfg = Release|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|x64.Build.0 = Release|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|x86.ActiveCfg = Release|Any CPU
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA}.Release|x86.Build.0 = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|x64.ActiveCfg = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|x64.Build.0 = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|x86.ActiveCfg = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Debug|x86.Build.0 = Debug|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|Any CPU.Build.0 = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|x64.ActiveCfg = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|x64.Build.0 = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|x86.ActiveCfg = Release|Any CPU
{78472121-1376-471D-8801-6C67882B28AD}.Release|x86.Build.0 = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|x64.ActiveCfg = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|x64.Build.0 = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|x86.ActiveCfg = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Debug|x86.Build.0 = Debug|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|Any CPU.Build.0 = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|x64.ActiveCfg = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|x64.Build.0 = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|x86.ActiveCfg = Release|Any CPU
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C}.Release|x86.Build.0 = Release|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Debug|x64.ActiveCfg = Debug|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Debug|x64.Build.0 = Debug|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Debug|x86.ActiveCfg = Debug|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Debug|x86.Build.0 = Debug|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Release|Any CPU.Build.0 = Release|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Release|x64.ActiveCfg = Release|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Release|x64.Build.0 = Release|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Release|x86.ActiveCfg = Release|Any CPU
{19A91C82-AF22-4BE9-8904-E6D6D371DC45}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C7CCB31C-2A88-416E-B449-0A13D9CE84AA} = {CFFED500-BB9F-11EA-AA17-6D586A78C909}
{78472121-1376-471D-8801-6C67882B28AD} = {CFFED500-BB9F-11EA-AA17-6D586A78C909}
EndGlobalSection
EndGlobal
{D20B0AE3-3FC0-4B04-923F-61A2A928F97C} = {CFFED500-BB9F-11EA-AA17-6D586A78C909}
{19A91C82-AF22-4BE9-8904-E6D6D371DC45} = {A2E36F60-8750-46B5-B7BE-81AF0B75E594}
{A2E36F60-8750-46B5-B7BE-81AF0B75E594} = {28D959E6-5CA9-435D-8990-70A1E4BB1F77}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DEC97AC1-1CC5-4EBF-9C1C-D828FA639573}
EndGlobalSection
EndGlobal
Loading