From 8d128b01cef76cccff4bceed62c997e45a544631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Leclaire-Fournier?= Date: Sat, 10 Feb 2024 16:42:48 -0500 Subject: [PATCH] =?UTF-8?q?R=C3=A9pare=20compl=C3=A8tement=20le=20fonction?= =?UTF-8?q?nement=20de=20warping/mirror?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GPA675Lab1GOL/GOLTeamH.cpp | 8 ++++---- GPA675Lab1GOL/GridTeamH.cpp | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/GPA675Lab1GOL/GOLTeamH.cpp b/GPA675Lab1GOL/GOLTeamH.cpp index 1104c63..bca57ba 100644 --- a/GPA675Lab1GOL/GOLTeamH.cpp +++ b/GPA675Lab1GOL/GOLTeamH.cpp @@ -673,14 +673,14 @@ size_t GOLTeamH::countNeighbors(const uint8_t* cellPtr) const // Petit lambda pour simplifier les opérations. auto putInBounds = [width, height, bm, firstGridPtr, lastGridPtr](const uint8_t* ptr) { if (ptr < firstGridPtr) - ptr += width * ((bm == GOL::BorderManagement::mirror) ? 2 : (height - 1)); + ptr += width * ((bm == GOL::BorderManagement::mirror) ? 2 : height); else if (ptr > lastGridPtr) - ptr -= width * ((bm == GOL::BorderManagement::mirror) ? 2 : (height - 1)); + ptr -= width * ((bm == GOL::BorderManagement::mirror) ? 2 : height); if ((ptr - firstGridPtr) % width == 0) - ptr -= ((bm == GOL::BorderManagement::mirror) ? 2 : (width - 1)); + ptr -= ((bm == GOL::BorderManagement::mirror) ? 2 : width); else if ((ptr - firstGridPtr) % width == width - 1) - ptr += ((bm == GOL::BorderManagement::mirror) ? 2 : (width - 1)); + ptr += ((bm == GOL::BorderManagement::mirror) ? 2 : width); return ptr; }; diff --git a/GPA675Lab1GOL/GridTeamH.cpp b/GPA675Lab1GOL/GridTeamH.cpp index 4d2ddf6..747e991 100644 --- a/GPA675Lab1GOL/GridTeamH.cpp +++ b/GPA675Lab1GOL/GridTeamH.cpp @@ -274,7 +274,5 @@ void GridTeamH::fillBorderOperation(DataType ptr, CellType value) const void GridTeamH::switchToIntermediate() { // Swap pour la performance. - auto* temp{ mData }; - mData = mIntermediateData; - mIntermediateData = temp; + std::swap(mData, mIntermediateData); }