2016-04-12 22:28:08 +00:00
|
|
|
#include "CPoseAsTransforms.hpp"
|
2016-09-06 05:52:51 +00:00
|
|
|
#include "CCharLayoutInfo.hpp"
|
2016-04-12 22:28:08 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2016-04-12 22:28:08 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CPoseAsTransforms::CPoseAsTransforms(u8 boneCount) : x1_count(boneCount), xd0_transformArr(new Transform[boneCount]) {}
|
2016-04-12 22:28:08 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CPoseAsTransforms::ContainsDataFor(const CSegId& id) const {
|
|
|
|
const std::pair<CSegId, CSegId>& link = x8_links[id];
|
2019-10-27 01:53:11 +00:00
|
|
|
return link.first.IsValid() || link.second.IsValid();
|
2016-04-12 22:28:08 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPoseAsTransforms::Clear() {
|
|
|
|
for (u32 i = 0; i < 100; ++i)
|
|
|
|
x8_links[i] = std::make_pair(CSegId(), CSegId());
|
|
|
|
xd4_lastInserted = 0;
|
|
|
|
x0_nextId = 0;
|
2016-04-12 22:28:08 +00:00
|
|
|
}
|
|
|
|
|
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);
|
2016-04-12 22:28:08 +00:00
|
|
|
}
|
|
|
|
|
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];
|
2019-10-27 01:53:11 +00:00
|
|
|
assert(link.second.IsValid());
|
2018-12-08 05:30:43 +00:00
|
|
|
return xd0_transformArr[link.second].m_originToAccum;
|
2016-09-06 05:52:51 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
const zeus::CTransform& CPoseAsTransforms::GetRestToAccumTransform(const CSegId& id) const {
|
|
|
|
const std::pair<CSegId, CSegId>& link = x8_links[id];
|
2019-10-27 01:53:11 +00:00
|
|
|
assert(link.second.IsValid());
|
2018-12-08 05:30:43 +00:00
|
|
|
return xd0_transformArr[link.second].m_restPoseToAccum;
|
2016-04-12 22:28:08 +00:00
|
|
|
}
|
|
|
|
|
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];
|
2019-10-27 01:53:11 +00:00
|
|
|
assert(link.second.IsValid());
|
2018-12-08 05:30:43 +00:00
|
|
|
return xd0_transformArr[link.second].m_originToAccum.origin;
|
2016-04-12 22:28:08 +00:00
|
|
|
}
|
|
|
|
|
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];
|
2019-10-27 01:53:11 +00:00
|
|
|
assert(link.second.IsValid());
|
2018-12-08 05:30:43 +00:00
|
|
|
return xd0_transformArr[link.second].m_originToAccum.basis;
|
2016-04-12 22:28:08 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPoseAsTransforms::Insert(const CSegId& id, const zeus::CMatrix3f& rotation, const zeus::CVector3f& offset,
|
|
|
|
const zeus::CVector3f& restOffset) {
|
|
|
|
Transform& xfOut = xd0_transformArr[x0_nextId];
|
|
|
|
xfOut.m_originToAccum = zeus::CTransform(rotation, offset);
|
|
|
|
xfOut.m_restPoseToAccum = xfOut.m_originToAccum * zeus::CTransform::Translate(-restOffset);
|
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;
|
2016-04-12 22:28:08 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|