slideshow/source/engine/box2dtools.cxx | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)
New commits: commit c72cfece6a514cde1ccc79b855bc175bda4d0edf Author: Ashwani5009 <ashwani1235ku...@gmail.com> AuthorDate: Sun Apr 7 10:30:31 2024 +0530 Commit: Hossein <hoss...@libreoffice.org> CommitDate: Wed Apr 17 08:55:12 2024 +0200 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 <hoss...@libreoffice.org> Tested-by: Hossein <hoss...@libreoffice.org> diff --git a/slideshow/source/engine/box2dtools.cxx b/slideshow/source/engine/box2dtools.cxx index f747786d78a2..656e002137f0 100644 --- a/slideshow/source/engine/box2dtools.cxx +++ b/slideshow/source/engine/box2dtools.cxx @@ -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) {