diff --git a/src/OrientatedItemFactory.php b/src/OrientatedItemFactory.php index 2f1a7492..a878ba47 100644 --- a/src/OrientatedItemFactory.php +++ b/src/OrientatedItemFactory.php @@ -138,11 +138,15 @@ public function getPossibleOrientations( $isSame = false; if ($prevItem) { - $itemADimensions = [$item->getWidth(), $item->getLength(), $item->getDepth()]; - $itemBDimensions = [$prevItem->getWidth(), $prevItem->getLength(), $prevItem->getDepth()]; - sort($itemADimensions); - sort($itemBDimensions); - $isSame = ($itemADimensions === $itemBDimensions); + if ($item === $prevItem->getItem()) { + $isSame = true; + } else { + $itemADimensions = [$item->getWidth(), $item->getLength(), $item->getDepth()]; + $itemBDimensions = [$prevItem->getWidth(), $prevItem->getLength(), $prevItem->getDepth()]; + sort($itemADimensions); + sort($itemBDimensions); + $isSame = ($itemADimensions === $itemBDimensions); + } } //Special case items that are the same as what we just packed - keep orientation diff --git a/src/VolumePacker.php b/src/VolumePacker.php index 99f4fa05..7e5c69d4 100644 --- a/src/VolumePacker.php +++ b/src/VolumePacker.php @@ -392,6 +392,9 @@ protected function getCurrentPackedDepth(): int */ protected static function isSameDimensions(Item $itemA, Item $itemB): bool { + if ($itemA === $itemB) { + return true; + } $itemADimensions = [$itemA->getWidth(), $itemA->getLength(), $itemA->getDepth()]; $itemBDimensions = [$itemB->getWidth(), $itemB->getLength(), $itemB->getDepth()]; sort($itemADimensions);