MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / addObject

Method addObject

Source/LevelEditorLayer.cpp:645–676  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643}
644
645void 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
678GameObject *LevelEditorLayer::findObject(float x, float y) {
679 std::string key = fmt::format("{}x{}", x, y);

Callers

nothing calls this directly

Calls 2

setDontTransformMethod · 0.80
sizeMethod · 0.80

Tested by

no test coverage detected