Skip to content

Commit 9a166ac

Browse files
committed
Make UpdateList a separate entity
1 parent cddbd2e commit 9a166ac

File tree

3 files changed

+4
-100
lines changed

3 files changed

+4
-100
lines changed

rts/Rendering/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ set(sources_engine_Rendering
123123
"${CMAKE_CURRENT_SOURCE_DIR}/Common/ModelDrawerData.cpp"
124124
"${CMAKE_CURRENT_SOURCE_DIR}/Common/ModelDrawerState.cpp"
125125
"${CMAKE_CURRENT_SOURCE_DIR}/Common/ModelDrawerHelpers.cpp"
126+
"${CMAKE_CURRENT_SOURCE_DIR}/Common/UpdateList.cpp"
126127
"${CMAKE_CURRENT_SOURCE_DIR}/Features/FeatureDrawerData.cpp"
127128
"${CMAKE_CURRENT_SOURCE_DIR}/Features/FeatureDrawer.cpp"
128129
"${CMAKE_CURRENT_SOURCE_DIR}/Units/UnitDrawerData.cpp"

rts/Rendering/Env/Decals/GroundDecalHandler.cpp

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ CR_REG_METADATA_SUB(CGroundDecalHandler, UnitMinMaxHeight,
6969
CR_MEMBER(max)
7070
))
7171

72-
CR_BIND(CGroundDecalHandler::DecalUpdateList, )
73-
CR_REG_METADATA_SUB(CGroundDecalHandler, DecalUpdateList,
74-
(
75-
CR_MEMBER(updateList),
76-
CR_MEMBER(changed)
77-
))
78-
7972
CR_BIND_DERIVED(CGroundDecalHandler, IGroundDecalDrawer, )
8073
CR_REG_METADATA(CGroundDecalHandler, (
8174
CR_MEMBER_UN(maxUniqueScars),
@@ -1673,64 +1666,4 @@ void CGroundDecalHandler::FeatureMoved(const CFeature* feature, const float3& ol
16731666
void CGroundDecalHandler::UnitLoaded(const CUnit* unit, const CUnit* transport) { ForceRemoveSolidObject(unit); }
16741667
void CGroundDecalHandler::UnitUnloaded(const CUnit* unit, const CUnit* transport) { AddSolidObject(unit); }
16751668

1676-
void CGroundDecalHandler::UnitMoved(const CUnit* unit) { AddTrack(unit, unit->pos); }
1677-
1678-
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1679-
1680-
void CGroundDecalHandler::DecalUpdateList::SetNeedUpdateAll()
1681-
{
1682-
RECOIL_DETAILED_TRACY_ZONE;
1683-
std::fill(updateList.begin(), updateList.end(), true);
1684-
changed = true;
1685-
}
1686-
1687-
void CGroundDecalHandler::DecalUpdateList::ResetNeedUpdateAll()
1688-
{
1689-
RECOIL_DETAILED_TRACY_ZONE;
1690-
std::fill(updateList.begin(), updateList.end(), false);
1691-
changed = false;
1692-
}
1693-
1694-
void CGroundDecalHandler::DecalUpdateList::SetUpdate(const CGroundDecalHandler::DecalUpdateList::IteratorPair& it)
1695-
{
1696-
RECOIL_DETAILED_TRACY_ZONE;
1697-
std::fill(it.first, it.second, true);
1698-
changed = true;
1699-
}
1700-
1701-
void CGroundDecalHandler::DecalUpdateList::SetUpdate(size_t offset)
1702-
{
1703-
RECOIL_DETAILED_TRACY_ZONE;
1704-
assert(offset < updateList.size());
1705-
updateList[offset] = true;
1706-
changed = true;
1707-
}
1708-
1709-
void CGroundDecalHandler::DecalUpdateList::EmplaceBackUpdate()
1710-
{
1711-
RECOIL_DETAILED_TRACY_ZONE;
1712-
updateList.emplace_back(true);
1713-
changed = true;
1714-
}
1715-
1716-
std::optional<CGroundDecalHandler::DecalUpdateList::IteratorPair> CGroundDecalHandler::DecalUpdateList::GetNext(const std::optional<CGroundDecalHandler::DecalUpdateList::IteratorPair>& prev)
1717-
{
1718-
RECOIL_DETAILED_TRACY_ZONE;
1719-
auto beg = prev.has_value() ? prev.value().second : updateList.begin();
1720-
beg = std::find(beg, updateList.end(), true);
1721-
auto end = std::find(beg, updateList.end(), false);
1722-
1723-
if (beg == end)
1724-
return std::nullopt;
1725-
1726-
return std::make_optional(std::make_pair(beg, end));
1727-
}
1728-
1729-
std::pair<size_t, size_t> CGroundDecalHandler::DecalUpdateList::GetOffsetAndSize(const CGroundDecalHandler::DecalUpdateList::IteratorPair& it)
1730-
{
1731-
RECOIL_DETAILED_TRACY_ZONE;
1732-
return std::make_pair(
1733-
std::distance(updateList.begin(), it.first ),
1734-
std::distance(it.first , it.second)
1735-
);
1736-
}
1669+
void CGroundDecalHandler::UnitMoved(const CUnit* unit) { AddTrack(unit, unit->pos); }

rts/Rendering/Env/Decals/GroundDecalHandler.h

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "Rendering/GL/VAO.h"
1515
#include "Rendering/DepthBufferCopy.h"
1616
#include "Rendering/Textures/TextureRenderAtlas.h"
17+
#include "Rendering/Common/UpdateList.h"
1718
#include "System/EventClient.h"
1819
#include "System/UnorderedMap.hpp"
1920
#include "System/creg/creg.h"
@@ -36,37 +37,6 @@ class CGroundDecalHandler: public IGroundDecalDrawer, public CEventClient, publi
3637
{
3738
CR_DECLARE_DERIVED(CGroundDecalHandler)
3839
CR_DECLARE_SUB(UnitMinMaxHeight)
39-
CR_DECLARE_SUB(DecalUpdateList)
40-
public:
41-
class DecalUpdateList {
42-
CR_DECLARE_STRUCT(DecalUpdateList)
43-
public:
44-
using IteratorPair = std::pair<std::vector<bool>::iterator, std::vector<bool>::iterator>;
45-
public:
46-
DecalUpdateList()
47-
: updateList()
48-
, changed(true)
49-
{}
50-
51-
void Resize(size_t newSize) { updateList.resize(newSize); SetNeedUpdateAll(); }
52-
void Reserve(size_t reservedSize) { updateList.reserve(reservedSize); }
53-
54-
void SetUpdate(const IteratorPair& it);
55-
void SetUpdate(size_t offset);
56-
57-
void SetNeedUpdateAll();
58-
void ResetNeedUpdateAll();
59-
60-
void EmplaceBackUpdate();
61-
62-
bool NeedUpdate() const { return changed; }
63-
64-
std::optional<IteratorPair> GetNext(const std::optional<IteratorPair>& prev = std::nullopt);
65-
std::pair<size_t, size_t> GetOffsetAndSize(const IteratorPair& it);
66-
private:
67-
std::vector<bool> updateList;
68-
bool changed;
69-
};
7040
public:
7141
CGroundDecalHandler();
7242
~CGroundDecalHandler() override;
@@ -195,7 +165,7 @@ class CGroundDecalHandler: public IGroundDecalDrawer, public CEventClient, publi
195165
spring::unordered_map<uint32_t, size_t> idToPos;
196166
spring::unordered_map<uint32_t, std::tuple<const CColorMap*, std::pair<size_t, size_t>>> idToCmInfo;
197167

198-
DecalUpdateList decalsUpdateList;
168+
UpdateList decalsUpdateList;
199169

200170
uint32_t nextId;
201171
std::vector<uint32_t> freeIds;

0 commit comments

Comments
 (0)