void CollisionMap::mergeAdjacentTiles(std::vector<CollisionRect> &rects, std::vector<sf::FloatRect> &ret) { std::vector<sf::FloatRect> rectangles; auto it = rects.begin(); while (it != rects.end()) { if (!isInteractable(it->blockType) && it->rotation == 0.f) { rectangles.push_back(it->rect); it = rects.erase(it); } else ++it; } // join individual rects sort(rectangles.begin(), rectangles.end(), compareRectsHorizontally); mergeHelper(rectangles, true); // join rows together sort(rectangles.begin(), rectangles.end(), compareRectsVertically); mergeHelper(rectangles, false); // add back to returning list for (auto &mergedRect : rectangles) rects.emplace_back(mergedRect, 0.f); }
int SLInsertIndex(SortedListPtr list, void *newObj) { //Create new node. SLNode newNode = SLCreateNode(newObj); //Set the next of the new node, to be the head of the current list. newNode->next = list->headOfList; list->headOfList = newNode; //Sort the list list = mergeHelper(list); //printList(list); return 1; }