metaforce/Runtime/Character/CPoseAsTransforms.cpp

60 lines
1.9 KiB
C++
Raw Normal View History

#include "Runtime/Character/CPoseAsTransforms.hpp"
#include "Runtime/Character/CCharLayoutInfo.hpp"
2021-04-10 08:42:06 +00:00
namespace metaforce {
CPoseAsTransforms::CPoseAsTransforms(u8 boneCount)
: x1_count(boneCount), xd0_transformArr(std::make_unique<zeus::CTransform[]>(boneCount)) {}
2018-12-08 05:30:43 +00:00
bool CPoseAsTransforms::ContainsDataFor(const CSegId& id) const {
const std::pair<CSegId, CSegId>& link = x8_links[id];
return link.first.IsValid() || link.second.IsValid();
}
2018-12-08 05:30:43 +00:00
void CPoseAsTransforms::Clear() {
x8_links.fill({});
2018-12-08 05:30:43 +00:00
xd4_lastInserted = 0;
x0_nextId = 0;
}
2018-12-08 05:30:43 +00:00
void CPoseAsTransforms::AccumulateScaledTransform(const CSegId& id, zeus::CMatrix3f& rotation, float scale) const {
rotation.addScaledMatrix(GetRotation(id), scale);
}
2018-12-08 05:30:43 +00:00
const zeus::CTransform& CPoseAsTransforms::GetTransform(const CSegId& id) const {
const std::pair<CSegId, CSegId>& link = x8_links[id];
assert(link.second.IsValid());
return xd0_transformArr[link.second];
}
2018-12-08 05:30:43 +00:00
const zeus::CVector3f& CPoseAsTransforms::GetOffset(const CSegId& id) const {
const std::pair<CSegId, CSegId>& link = x8_links[id];
assert(link.second.IsValid());
return xd0_transformArr[link.second].origin;
}
2018-12-08 05:30:43 +00:00
const zeus::CMatrix3f& CPoseAsTransforms::GetRotation(const CSegId& id) const {
const std::pair<CSegId, CSegId>& link = x8_links[id];
assert(link.second.IsValid());
return xd0_transformArr[link.second].basis;
}
void CPoseAsTransforms::Insert(const CSegId& id, const zeus::CMatrix3f& rotation, const zeus::CVector3f& offset) {
xd0_transformArr[x0_nextId] = zeus::CTransform(rotation, offset);
2016-09-06 05:52:51 +00:00
2018-12-08 05:30:43 +00:00
std::pair<CSegId, CSegId>& link = x8_links[id];
link.first = xd4_lastInserted;
link.second = x0_nextId;
xd4_lastInserted = id;
++x0_nextId;
}
CSegId CPoseAsTransforms::GetParent(const CSegId& id) const {
const std::pair<CSegId, CSegId>& link = x8_links[id];
assert(link.first.IsValid());
return link.first;
}
2021-04-10 08:42:06 +00:00
} // namespace metaforce