Répare complètement le fonctionnement de warping/mirror

This commit is contained in:
Timothée Leclaire-Fournier 2024-02-10 16:42:48 -05:00
parent 20498ae56e
commit 8d128b01ce
2 changed files with 5 additions and 7 deletions

View File

@ -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;
};

View File

@ -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);
}