16Bit_Felix
16Bit_Felix
CC#
Created by 16Bit_Felix on 12/8/2023 in #help
Scuffed polygon collision detection (SAT)
For example if i input in vertices, that form a box, the detection treats it as a hexagon
3 replies
CC#
Created by 16Bit_Felix on 12/8/2023 in #help
Scuffed polygon collision detection (SAT)
private bool PolygonToPolygon(Vector2[] verticesA, Vector2[] verticesB)
{

for(int i = 0; i < verticesA.Length; i++)
{
Vector2 va = verticesA[i];
Vector2 vb = verticesA[(i + 1) % verticesA.Length];

Vector2 edge = vb - va;
Vector2 axis = new Vector2(-edge.Y, edge.X);

ProjectVertices(verticesA, axis, out float minA, out float maxA);
ProjectVertices(verticesB, axis, out float minB, out float maxB);

if(minA >= maxB || minB >= maxA)
{
return false;
}
}

for (int i = 0; i < verticesB.Length; i++)
{
Vector2 va = verticesB[i];
Vector2 vb = verticesB[(i + 1) % verticesB.Length];

Vector2 edge = vb - va;
Vector2 axis = new Vector2(-edge.Y, edge.X);
axis = Vector2.Normalize(axis);

ProjectVertices(verticesA, axis, out float minA, out float maxA);
ProjectVertices(verticesB, axis, out float minB, out float maxB);

if (minA >= maxB || minB >= maxA)
{
return false;
}
}

return true;
}


private void ProjectVertices(Vector2[] vertices, Vector2 axis,
out float min, out float max)
{
min = float.MaxValue;
max = float.MinValue;

for(int i = 0; i < vertices.Length; i++)
{
Vector2 v = vertices[i];
float proj = v.X * axis.X + v.Y * axis.Y;

if(proj < min) { min = proj; }
if(proj > max) { max = proj; }
}
}
private bool PolygonToPolygon(Vector2[] verticesA, Vector2[] verticesB)
{

for(int i = 0; i < verticesA.Length; i++)
{
Vector2 va = verticesA[i];
Vector2 vb = verticesA[(i + 1) % verticesA.Length];

Vector2 edge = vb - va;
Vector2 axis = new Vector2(-edge.Y, edge.X);

ProjectVertices(verticesA, axis, out float minA, out float maxA);
ProjectVertices(verticesB, axis, out float minB, out float maxB);

if(minA >= maxB || minB >= maxA)
{
return false;
}
}

for (int i = 0; i < verticesB.Length; i++)
{
Vector2 va = verticesB[i];
Vector2 vb = verticesB[(i + 1) % verticesB.Length];

Vector2 edge = vb - va;
Vector2 axis = new Vector2(-edge.Y, edge.X);
axis = Vector2.Normalize(axis);

ProjectVertices(verticesA, axis, out float minA, out float maxA);
ProjectVertices(verticesB, axis, out float minB, out float maxB);

if (minA >= maxB || minB >= maxA)
{
return false;
}
}

return true;
}


private void ProjectVertices(Vector2[] vertices, Vector2 axis,
out float min, out float max)
{
min = float.MaxValue;
max = float.MinValue;

for(int i = 0; i < vertices.Length; i++)
{
Vector2 v = vertices[i];
float proj = v.X * axis.X + v.Y * axis.Y;

if(proj < min) { min = proj; }
if(proj > max) { max = proj; }
}
}
3 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
Thanks for telling, I'll check these out
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
Holy god, that seems like THE binding for engine development in c#
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
Just a little, why?
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
@ZP ░▒▓█├■̶˾̶͞■┤█▓▒░ I was having a "persistent" reference at another object to a pointer that was made out with the "fixed" operator from the transform struct. I now made it that the "persistent" reference is updated every update call. But thanks for into looking into it nonetheless and the feedback you gave me for the files
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
Alright, found the problem
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
Other than that, did you notice anything else?
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
Alright
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
No pre built version was in use
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
But the error appeared when i runned it directly with the "dotnet run" command
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
Okay
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
The error seems to be originating from the transform class from the Utility/Transforming.cs file
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
https://github.com/32BitFelix/FinderEngine here's the link to the repo
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
The problem seems to be originating from the transform struct in the transforming file
31 replies
CC#
Created by 16Bit_Felix on 10/26/2023 in #help
❔ Value types keep on changing??
Here's the zipped version
31 replies
CC#
Created by 16Bit_Felix on 10/24/2023 in #help
❔ Structure keeps on nulling a field
because of pointers
6 replies
CC#
Created by 16Bit_Felix on 10/24/2023 in #help
❔ Structure keeps on nulling a field
6 replies
CC#
Created by 16Bit_Felix on 10/24/2023 in #help
❔ Structure keeps on nulling a field
The source code:
6 replies