2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/Character/CPOINode.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/Character/CAnimSourceReader.hpp"
|
|
|
|
#include "Runtime/Character/CBoolPOINode.hpp"
|
|
|
|
#include "Runtime/Character/CInt32POINode.hpp"
|
|
|
|
#include "Runtime/Character/CParticlePOINode.hpp"
|
|
|
|
#include "Runtime/Character/CSoundPOINode.hpp"
|
2016-04-11 07:10:28 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
CPOINode::CPOINode(std::string_view name, EPOIType type, const CCharAnimTime& time, s32 index, bool unique,
|
|
|
|
float weight, s32 e, s32 f)
|
|
|
|
: x4_(1)
|
|
|
|
, x8_name(name)
|
|
|
|
, x18_type(type)
|
|
|
|
, x1c_time(time)
|
|
|
|
, x24_index(index)
|
|
|
|
, x28_unique(unique)
|
|
|
|
, x2c_weight(weight)
|
|
|
|
, x30_charIdx(e)
|
|
|
|
, x34_flags(f) {}
|
2016-04-11 07:10:28 +00:00
|
|
|
|
|
|
|
CPOINode::CPOINode(CInputStream& in)
|
2018-12-08 05:30:43 +00:00
|
|
|
: x4_(in.readUint16Big())
|
|
|
|
, x8_name(in.readString())
|
|
|
|
, x18_type(EPOIType(in.readUint16Big()))
|
|
|
|
, x1c_time(in)
|
|
|
|
, x24_index(in.readInt32Big())
|
|
|
|
, x28_unique(in.readBool())
|
|
|
|
, x2c_weight(in.readFloatBig())
|
|
|
|
, x30_charIdx(in.readInt32Big())
|
|
|
|
, x34_flags(in.readInt32Big()) {}
|
2016-09-11 18:40:33 +00:00
|
|
|
|
2020-08-24 22:42:43 +00:00
|
|
|
bool CPOINode::operator>(const CPOINode& other) const { return x1c_time > other.x1c_time; }
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-08-24 22:42:43 +00:00
|
|
|
bool CPOINode::operator<(const CPOINode& other) const { return x1c_time < other.x1c_time; }
|
2016-09-11 18:40:33 +00:00
|
|
|
|
2016-08-27 21:16:44 +00:00
|
|
|
template <class T>
|
2020-04-10 21:18:09 +00:00
|
|
|
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;
|
2018-12-08 05:30:43 +00:00
|
|
|
if (animInfo.HasPOIData() && stream.size()) {
|
2020-04-10 21:18:09 +00:00
|
|
|
const CCharAnimTime dur = animInfo.GetAnimationDuration();
|
2018-12-08 05:30:43 +00:00
|
|
|
CCharAnimTime targetTime = curTime + time;
|
2020-04-10 21:18:09 +00:00
|
|
|
if (targetTime >= dur) {
|
2018-12-08 05:30:43 +00:00
|
|
|
targetTime = dur;
|
2020-04-10 21:18:09 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-10 21:18:09 +00:00
|
|
|
if (passedCount >= stream.size()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return ret;
|
2020-04-10 21:18:09 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
CCharAnimTime nodeTime = stream[passedCount].GetTime();
|
|
|
|
while (passedCount < stream.size() && nodeTime <= targetTime) {
|
2020-04-10 21:18:09 +00:00
|
|
|
const size_t idx = iterator + ret;
|
2018-12-08 05:30:43 +00:00
|
|
|
if (idx < capacity) {
|
|
|
|
listOut[idx] = T::CopyNodeMinusStartTime(stream[passedCount], curTime);
|
|
|
|
++ret;
|
|
|
|
}
|
|
|
|
++passedCount;
|
|
|
|
if (passedCount < stream.size())
|
|
|
|
nodeTime = stream[passedCount].GetTime();
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
return ret;
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
2020-04-10 21:18:09 +00:00
|
|
|
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;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-10 21:18:09 +00:00
|
|
|
const CCharAnimTime targetTime = curTime + time;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-10 21:18:09 +00:00
|
|
|
for (size_t it = iterator; it < stream.size(); ++it) {
|
|
|
|
const CCharAnimTime nodeTime = stream[it].GetTime();
|
|
|
|
if (nodeTime > targetTime) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return ret;
|
2020-04-10 21:18:09 +00:00
|
|
|
}
|
|
|
|
const size_t idx = iterator + ret;
|
2018-12-08 05:30:43 +00:00
|
|
|
if (nodeTime >= curTime && idx < capacity) {
|
|
|
|
listOut[idx] = T::CopyNodeMinusStartTime(stream[it], curTime);
|
|
|
|
++ret;
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-08-27 21:16:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return ret;
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 21:18:09 +00:00
|
|
|
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 size_t _getPOIList<CInt32POINode>(const CCharAnimTime& time, CInt32POINode* listOut, size_t capacity,
|
|
|
|
size_t iterator, u32 unk1, const std::vector<CInt32POINode>& stream,
|
2018-12-08 05:30:43 +00:00
|
|
|
const CCharAnimTime& curTime, const IAnimSourceInfo& animInfo,
|
2020-04-10 21:18:09 +00:00
|
|
|
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,
|
2016-08-27 21:16:44 +00:00
|
|
|
const CCharAnimTime& curTime);
|
|
|
|
|
2020-04-10 21:18:09 +00:00
|
|
|
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);
|
2016-08-27 21:16:44 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|