Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Desired functionality: Loop through all elements in the std::unordered_set container (ObjectStack)
- // and run the PhysicsTick() function on each object
- // I can't make a simple range-based for loop though because the PhysicsTick() function sometimes deletes objects
- // and then it throws errors.
- // So my solution is to break after it deletes an object and then start a new loop at the next iterator
- // (I make it recursive to achieve this)
- // This solution probably isn't optimal though
- void QuadTree::RunPhysicsTick(unsigned int StartingPoint)
- {
- int hacky_iterator = 0;
- for (Object* it : ObjectStack)
- {
- if (hacky_iterator >= StartingPoint)
- {
- it->PhysicsTick();
- if (!IsExisting(it))
- {
- cout << "Breaking because !IsExisting(it) = " << !IsExisting(it) << endl;
- break;
- RunPhysicsTick(hacky_iterator);
- return;
- }
- }
- hacky_iterator++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement