|
| 1 | +#include "UpdateList.h" |
| 2 | +#include "System/Misc/TracyDefs.h" |
| 3 | + |
| 4 | +#include <algorithm> |
| 5 | + |
| 6 | +CR_BIND(UpdateList, ) |
| 7 | +CR_REG_METADATA(UpdateList, ( |
| 8 | + CR_MEMBER(updateList), |
| 9 | + CR_MEMBER(changed) |
| 10 | +)) |
| 11 | + |
| 12 | + |
| 13 | +void UpdateList::SetNeedUpdateAll() |
| 14 | +{ |
| 15 | + RECOIL_DETAILED_TRACY_ZONE; |
| 16 | + std::fill(updateList.begin(), updateList.end(), true); |
| 17 | + changed = true; |
| 18 | +} |
| 19 | + |
| 20 | +void UpdateList::ResetNeedUpdateAll() |
| 21 | +{ |
| 22 | + RECOIL_DETAILED_TRACY_ZONE; |
| 23 | + std::fill(updateList.begin(), updateList.end(), false); |
| 24 | + changed = false; |
| 25 | +} |
| 26 | + |
| 27 | +void UpdateList::SetUpdate(const UpdateList::IteratorPair& it) |
| 28 | +{ |
| 29 | + RECOIL_DETAILED_TRACY_ZONE; |
| 30 | + std::fill(it.first, it.second, true); |
| 31 | + changed = true; |
| 32 | +} |
| 33 | + |
| 34 | +void UpdateList::SetUpdate(size_t offset) |
| 35 | +{ |
| 36 | + RECOIL_DETAILED_TRACY_ZONE; |
| 37 | + assert(offset < updateList.size()); |
| 38 | + updateList[offset] = true; |
| 39 | + changed = true; |
| 40 | +} |
| 41 | + |
| 42 | +void UpdateList::EmplaceBackUpdate() |
| 43 | +{ |
| 44 | + RECOIL_DETAILED_TRACY_ZONE; |
| 45 | + updateList.emplace_back(true); |
| 46 | + changed = true; |
| 47 | +} |
| 48 | + |
| 49 | +void UpdateList::PopBack() |
| 50 | +{ |
| 51 | + updateList.pop_back(); |
| 52 | + changed = true; |
| 53 | +} |
| 54 | + |
| 55 | +void UpdateList::PopBack(size_t N) |
| 56 | +{ |
| 57 | + while (N-- >= 0) |
| 58 | + updateList.pop_back(); |
| 59 | + |
| 60 | + changed = true; |
| 61 | +} |
| 62 | + |
| 63 | +std::optional<UpdateList::IteratorPair> UpdateList::GetNext(const std::optional<UpdateList::IteratorPair>& prev) |
| 64 | +{ |
| 65 | + RECOIL_DETAILED_TRACY_ZONE; |
| 66 | + auto beg = prev.has_value() ? prev.value().second : updateList.begin(); |
| 67 | + beg = std::find(beg, updateList.end(), true); |
| 68 | + auto end = std::find(beg, updateList.end(), false); |
| 69 | + |
| 70 | + if (beg == end) |
| 71 | + return std::nullopt; |
| 72 | + |
| 73 | + return std::make_optional(std::make_pair(beg, end)); |
| 74 | +} |
| 75 | + |
| 76 | +std::pair<size_t, size_t> UpdateList::GetOffsetAndSize(const UpdateList::IteratorPair& it) |
| 77 | +{ |
| 78 | + RECOIL_DETAILED_TRACY_ZONE; |
| 79 | + return std::make_pair( |
| 80 | + std::distance(updateList.begin(), it.first ), |
| 81 | + std::distance(it.first , it.second) |
| 82 | + ); |
| 83 | +} |
0 commit comments