mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-11 06:27:52 +00:00
IAnimReader: Make use of size_t for capacity and iterators
Allows using container sizes and capacities without needing to cast them, allowing for dehardcoding of array sizes in some scenarios.
This commit is contained in:
@@ -36,22 +36,24 @@ bool CPOINode::operator>(const CPOINode& other) const { return x1c_time < other.
|
||||
bool CPOINode::operator<(const CPOINode& other) const { return x1c_time > other.x1c_time; }
|
||||
|
||||
template <class T>
|
||||
u32 _getPOIList(const CCharAnimTime& time, T* listOut, u32 capacity, u32 iterator, u32 unk1,
|
||||
const std::vector<T>& stream, const CCharAnimTime& curTime, const IAnimSourceInfo& animInfo,
|
||||
u32 passedCount) {
|
||||
u32 ret = 0;
|
||||
size_t _getPOIList(const CCharAnimTime& time, T* listOut, size_t capacity, size_t iterator, u32 unk1,
|
||||
const std::vector<T>& stream, const CCharAnimTime& curTime, const IAnimSourceInfo& animInfo,
|
||||
size_t passedCount) {
|
||||
size_t ret = 0;
|
||||
if (animInfo.HasPOIData() && stream.size()) {
|
||||
CCharAnimTime dur = animInfo.GetAnimationDuration();
|
||||
const CCharAnimTime dur = animInfo.GetAnimationDuration();
|
||||
CCharAnimTime targetTime = curTime + time;
|
||||
if (targetTime >= dur)
|
||||
if (targetTime >= dur) {
|
||||
targetTime = dur;
|
||||
}
|
||||
|
||||
if (passedCount >= stream.size())
|
||||
if (passedCount >= stream.size()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
CCharAnimTime nodeTime = stream[passedCount].GetTime();
|
||||
while (passedCount < stream.size() && nodeTime <= targetTime) {
|
||||
u32 idx = iterator + ret;
|
||||
const size_t idx = iterator + ret;
|
||||
if (idx < capacity) {
|
||||
listOut[idx] = T::CopyNodeMinusStartTime(stream[passedCount], curTime);
|
||||
++ret;
|
||||
@@ -65,17 +67,18 @@ u32 _getPOIList(const CCharAnimTime& time, T* listOut, u32 capacity, u32 iterato
|
||||
}
|
||||
|
||||
template <class T>
|
||||
u32 _getPOIList(const CCharAnimTime& time, T* listOut, u32 capacity, u32 iterator, u32 unk1,
|
||||
const std::vector<T>& stream, const CCharAnimTime& curTime) {
|
||||
u32 ret = 0;
|
||||
size_t _getPOIList(const CCharAnimTime& time, T* listOut, size_t capacity, size_t iterator, u32 unk1,
|
||||
const std::vector<T>& stream, const CCharAnimTime& curTime) {
|
||||
size_t ret = 0;
|
||||
|
||||
CCharAnimTime targetTime = curTime + time;
|
||||
const CCharAnimTime targetTime = curTime + time;
|
||||
|
||||
for (u32 it = iterator; it < stream.size(); ++it) {
|
||||
CCharAnimTime nodeTime = stream[it].GetTime();
|
||||
if (nodeTime > targetTime)
|
||||
for (size_t it = iterator; it < stream.size(); ++it) {
|
||||
const CCharAnimTime nodeTime = stream[it].GetTime();
|
||||
if (nodeTime > targetTime) {
|
||||
return ret;
|
||||
u32 idx = iterator + ret;
|
||||
}
|
||||
const size_t idx = iterator + ret;
|
||||
if (nodeTime >= curTime && idx < capacity) {
|
||||
listOut[idx] = T::CopyNodeMinusStartTime(stream[it], curTime);
|
||||
++ret;
|
||||
@@ -85,32 +88,36 @@ u32 _getPOIList(const CCharAnimTime& time, T* listOut, u32 capacity, u32 iterato
|
||||
return ret;
|
||||
}
|
||||
|
||||
template u32 _getPOIList<CBoolPOINode>(const CCharAnimTime& time, CBoolPOINode* listOut, u32 capacity, u32 iterator,
|
||||
u32 unk1, const std::vector<CBoolPOINode>& stream, const CCharAnimTime& curTime,
|
||||
const IAnimSourceInfo& animInfo, u32 passedCount);
|
||||
template u32 _getPOIList<CBoolPOINode>(const CCharAnimTime& time, CBoolPOINode* listOut, u32 capacity, u32 iterator,
|
||||
u32 unk1, const std::vector<CBoolPOINode>& stream, const CCharAnimTime& curTime);
|
||||
template size_t _getPOIList<CBoolPOINode>(const CCharAnimTime& time, CBoolPOINode* listOut, size_t capacity,
|
||||
size_t iterator, u32 unk1, const std::vector<CBoolPOINode>& stream,
|
||||
const CCharAnimTime& curTime, const IAnimSourceInfo& animInfo,
|
||||
size_t passedCount);
|
||||
template size_t _getPOIList<CBoolPOINode>(const CCharAnimTime& time, CBoolPOINode* listOut, size_t capacity,
|
||||
size_t iterator, u32 unk1, const std::vector<CBoolPOINode>& stream,
|
||||
const CCharAnimTime& curTime);
|
||||
|
||||
template u32 _getPOIList<CInt32POINode>(const CCharAnimTime& time, CInt32POINode* listOut, u32 capacity, u32 iterator,
|
||||
u32 unk1, const std::vector<CInt32POINode>& stream,
|
||||
const CCharAnimTime& curTime, const IAnimSourceInfo& animInfo, u32 passedCount);
|
||||
template u32 _getPOIList<CInt32POINode>(const CCharAnimTime& time, CInt32POINode* listOut, u32 capacity, u32 iterator,
|
||||
u32 unk1, const std::vector<CInt32POINode>& stream,
|
||||
const CCharAnimTime& curTime);
|
||||
|
||||
template u32 _getPOIList<CParticlePOINode>(const CCharAnimTime& time, CParticlePOINode* listOut, u32 capacity,
|
||||
u32 iterator, u32 unk1, const std::vector<CParticlePOINode>& stream,
|
||||
template size_t _getPOIList<CInt32POINode>(const CCharAnimTime& time, CInt32POINode* listOut, size_t capacity,
|
||||
size_t iterator, u32 unk1, const std::vector<CInt32POINode>& stream,
|
||||
const CCharAnimTime& curTime, const IAnimSourceInfo& animInfo,
|
||||
u32 passedCount);
|
||||
template u32 _getPOIList<CParticlePOINode>(const CCharAnimTime& time, CParticlePOINode* listOut, u32 capacity,
|
||||
u32 iterator, u32 unk1, const std::vector<CParticlePOINode>& stream,
|
||||
size_t passedCount);
|
||||
template size_t _getPOIList<CInt32POINode>(const CCharAnimTime& time, CInt32POINode* listOut, size_t capacity,
|
||||
size_t iterator, u32 unk1, const std::vector<CInt32POINode>& stream,
|
||||
const CCharAnimTime& curTime);
|
||||
|
||||
template u32 _getPOIList<CSoundPOINode>(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator,
|
||||
u32 unk1, const std::vector<CSoundPOINode>& stream,
|
||||
const CCharAnimTime& curTime, const IAnimSourceInfo& animInfo, u32 passedCount);
|
||||
template u32 _getPOIList<CSoundPOINode>(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator,
|
||||
u32 unk1, const std::vector<CSoundPOINode>& stream,
|
||||
const CCharAnimTime& curTime);
|
||||
template size_t _getPOIList<CParticlePOINode>(const CCharAnimTime& time, CParticlePOINode* listOut, size_t capacity,
|
||||
size_t iterator, u32 unk1, const std::vector<CParticlePOINode>& stream,
|
||||
const CCharAnimTime& curTime, const IAnimSourceInfo& animInfo,
|
||||
size_t passedCount);
|
||||
template size_t _getPOIList<CParticlePOINode>(const CCharAnimTime& time, CParticlePOINode* listOut, size_t capacity,
|
||||
size_t iterator, u32 unk1, const std::vector<CParticlePOINode>& stream,
|
||||
const CCharAnimTime& curTime);
|
||||
|
||||
template size_t _getPOIList<CSoundPOINode>(const CCharAnimTime& time, CSoundPOINode* listOut, size_t capacity,
|
||||
size_t iterator, u32 unk1, const std::vector<CSoundPOINode>& stream,
|
||||
const CCharAnimTime& curTime, const IAnimSourceInfo& animInfo,
|
||||
size_t passedCount);
|
||||
template size_t _getPOIList<CSoundPOINode>(const CCharAnimTime& time, CSoundPOINode* listOut, size_t capacity,
|
||||
size_t iterator, u32 unk1, const std::vector<CSoundPOINode>& stream,
|
||||
const CCharAnimTime& curTime);
|
||||
|
||||
} // namespace urde
|
||||
|
||||
Reference in New Issue
Block a user