Simplify nested for loops
Nested for loops are replaced with direct distance checking between triangle vertices. The goal is to improve the code readability and efficiency in AddTriangleVectorToBody() function. Change-Id: I753253031738d49e7910f20110da7da07a10cb1b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165863 Reviewed-by: Hossein <hossein@libreoffice.org> Tested-by: Hossein <hossein@libreoffice.org>
This commit is contained in:
@@ -92,24 +92,10 @@ void addTriangleVectorToBody(const basegfx::triangulator::B2DTriangleVector& rTr
|
||||
convertB2DPointToBox2DVec2(aTriangle.getB(), fScaleFactor),
|
||||
convertB2DPointToBox2DVec2(aTriangle.getC(), fScaleFactor) };
|
||||
|
||||
bool bValidPointDistance = true;
|
||||
|
||||
// check whether the triangle has degenerately close points
|
||||
for (int nPointIndexA = 0; nPointIndexA < 3; nPointIndexA++)
|
||||
{
|
||||
for (int nPointIndexB = 0; nPointIndexB < 3; nPointIndexB++)
|
||||
{
|
||||
if (nPointIndexA == nPointIndexB)
|
||||
continue;
|
||||
|
||||
if (b2DistanceSquared(aTriangleVertices[nPointIndexA],
|
||||
aTriangleVertices[nPointIndexB])
|
||||
< 0.003f)
|
||||
{
|
||||
bValidPointDistance = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool bValidPointDistance
|
||||
= b2DistanceSquared(aTriangleVertices[0], aTriangleVertices[1]) > 0.003f
|
||||
&& b2DistanceSquared(aTriangleVertices[0], aTriangleVertices[2]) > 0.003f
|
||||
&& b2DistanceSquared(aTriangleVertices[1], aTriangleVertices[2]) > 0.003f;
|
||||
|
||||
if (bValidPointDistance)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user