| 643 | } |
| 644 | |
| 645 | void LevelEditorLayer::addObject(GameObject* obj) { |
| 646 | int section = sectionForPos(obj->getPositionX()); |
| 647 | |
| 648 | obj->setDontTransform(false); |
| 649 | |
| 650 | obj->_uniqueID = _pObjects.size(); |
| 651 | |
| 652 | if (obj->getPositionX() > m_lastObjXPos) { |
| 653 | m_lastObjXPos = obj->getPositionX(); |
| 654 | } |
| 655 | |
| 656 | _allObjects.push_back(obj); |
| 657 | _pObjects.push_back(obj); |
| 658 | |
| 659 | if ((_sectionObjects.size()) < (section + 1)) { |
| 660 | int i = 0; |
| 661 | int req_size = (section - _sectionObjects.size()) + 1; |
| 662 | while (i < req_size) { |
| 663 | _sectionObjects.push_back({}); |
| 664 | |
| 665 | i++; |
| 666 | } |
| 667 | |
| 668 | _sectionObjects.push_back({}); |
| 669 | } |
| 670 | |
| 671 | _sectionObjects[section].push_back(obj); |
| 672 | |
| 673 | std::string key = fmt::format("{}x{}", obj->getPositionX(), obj->getPositionY()); |
| 674 | |
| 675 | _objectPositionCache[key] = obj; |
| 676 | } |
| 677 | |
| 678 | GameObject *LevelEditorLayer::findObject(float x, float y) { |
| 679 | std::string key = fmt::format("{}x{}", x, y); |
nothing calls this directly
no test coverage detected