7#include <Common/assertion.h>
26 std::size_t numWorkers,
28 std::size_t tileSize);
31 std::size_t numWorkers,
47 std::size_t m_currentCycles;
48 std::size_t m_currentSteps;
50 void scheduleOne(
WorkUnit* out_workUnit)
override;
61 , m_headFacing (EFacing::POSITIVE_X)
67 const std::size_t numWorkers,
69 const std::size_t tileSize) :
78 const std::size_t numWorkers,
84 m_headSize (tileSize),
85 m_headPos (totalWorkUnit.getRegion().getCenter().sub(m_headSize / 2)),
86 m_headFacing (EFacing::POSITIVE_X),
91inline void SpiralScheduler::scheduleOne(
WorkUnit*
const out_workUnit)
93 PH_ASSERT(out_workUnit);
95 Region headRegion(m_headPos, m_headPos.
add(m_headSize));
97 if(headRegion.isArea())
103 *out_workUnit = WorkUnit();
108 const std::size_t maxSteps = m_currentCycles * 2;
114 case EFacing::POSITIVE_X:
115 m_headPos.
x() += m_headSize.
x();
116 if(m_currentSteps >= maxSteps)
118 m_headFacing = EFacing::POSITIVE_Y;
124 case EFacing::POSITIVE_Y:
125 if(m_currentSteps < maxSteps)
127 m_headPos.
y() += m_headSize.
y();
131 m_headPos.
x() -= m_headSize.
x();
132 m_headFacing = EFacing::NEGATIVE_X;
137 case EFacing::NEGATIVE_X:
138 if(m_currentSteps < maxSteps)
140 m_headPos.
x() -= m_headSize.
x();
144 m_headPos.
y() -= m_headSize.
y();
145 m_headFacing = EFacing::NEGATIVE_Y;
150 case EFacing::NEGATIVE_Y:
151 if(m_currentSteps < maxSteps)
153 m_headPos.
y() -= m_headSize.
y();
157 m_headPos.
x() += m_headSize.
x();
158 m_headFacing = EFacing::POSITIVE_X;
Definition SpiralScheduler.h:21
SpiralScheduler()
Definition SpiralScheduler.h:55
A manager that distributes a fixed amount of work to workers.
Definition WorkScheduler.h:21
WorkUnit m_totalWorkUnit
Definition WorkScheduler.h:55
Represents some amount of work.
Definition WorkUnit.h:17
Region getRegion() const
Definition WorkUnit.h:72
std::size_t getDepth() const
Definition WorkUnit.h:77
T & x()
Definition TVector2.ipp:38
T & y()
Definition TVector2.ipp:44
Derived add(const Derived &rhs) const
Definition TArithmeticArrayBase.ipp:26
Miscellaneous math utilities.
The root for all renderer implementations.
Definition EEngineProject.h:6