Skip to content

Commit

Permalink
fix(geom): fix code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenatlas committed Feb 2, 2024
1 parent 12e301e commit 9766459
Showing 1 changed file with 25 additions and 32 deletions.
57 changes: 25 additions & 32 deletions core/src/geom/intersections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CUBOS_REFLECT_IMPL(cubos::core::geom::Intersect)
void getAxes(const Box& box, const glm::mat4& localToWorld, glm::vec3 axes[])
{
glm::vec3 normals[6];
box.normals(normals);
cubos::core::geom::Box::normals(normals);

for (int i = 0; i < 6; i++)
{
Expand Down Expand Up @@ -51,15 +51,19 @@ glm::vec2 project(const Box& box, glm::vec3 axis, const glm::mat4& localToWorld)

bool overlap(glm::vec2 p1, glm::vec2 p2)
{
if (((p1.x < p2.x) && (p2.x < p1.y) && (p1.y < p2.y)) || ((p2.x < p1.x) && (p1.x < p2.y) && (p2.y < p1.y)))
if ((p1.x < p2.x) && (p2.x < p1.y) && (p1.y < p2.y))
{
return true;
}
else if ((p1.x < p2.x) && (p2.y < p1.y))
if ((p2.x < p1.x) && (p1.x < p2.y) && (p2.y < p1.y))
{
return true;
}
else if ((p2.x < p1.x) && (p1.y < p2.y))
if ((p1.x < p2.x) && (p2.y < p1.y))
{
return true;
}
if ((p2.x < p1.x) && (p1.y < p2.y))
{
return true;
}
Expand All @@ -74,21 +78,15 @@ float getOverlap(glm::vec2 p1, glm::vec2 p2)
{
return glm::abs(p2.y - p1.x);
}
else // (p1.y < p2.y)
{
return glm::abs(p1.y - p1.x);
}
return glm::abs(p1.y - p1.x);
}
else if (p1.x < p2.x)
{
if (p1.y < p2.y)
{
return glm::abs(p1.y - p2.x);
}
else // (p2.y < p1.y)
{
return glm::abs(p2.y - p2.x);
}
return glm::abs(p2.y - p2.x);
}
return 0.0F;
}
Expand All @@ -111,17 +109,14 @@ bool cubos::core::geom::intersects(const Box& box1, const glm::mat4& localToWorl
// then we can guarantee that the shapes do not overlap
return false;
}
else
// get the overlap
float o = getOverlap(p1, p2);
// check for minimum
if (o < intersect.penetration)
{
// get the overlap
float o = getOverlap(p1, p2);
// check for minimum
if (o < intersect.penetration)
{
// then set this one as the smallest
intersect.penetration = o;
intersect.normal = axis;
}
// then set this one as the smallest
intersect.penetration = o;
intersect.normal = axis;
}
}

Expand All @@ -135,17 +130,15 @@ bool cubos::core::geom::intersects(const Box& box1, const glm::mat4& localToWorl
// then we can guarantee that the shapes do not overlap
return false;
}
else

// get the overlap
float o = getOverlap(p1, p2);
// check for minimum
if (o < intersect.penetration)
{
// get the overlap
float o = getOverlap(p1, p2);
// check for minimum
if (o < intersect.penetration)
{
// then set this one as the smallest
intersect.penetration = o;
intersect.normal = -axis;
}
// then set this one as the smallest
intersect.penetration = o;
intersect.normal = -axis;
}
}

Expand Down

0 comments on commit 9766459

Please sign in to comment.