...
 
Commits (6)
......@@ -5,11 +5,12 @@ namespace urde {
zeus::CVector3f CCharLayoutInfo::GetFromParentUnrotated(const CSegId& id) const {
const CCharLayoutNode::Bone& bone = x0_node->GetBoneMap()[id];
if (!x0_node->GetBoneMap().HasElement(bone.x0_parentId))
if (x0_node->GetBoneMap().HasElement(bone.x0_parentId)) {
const CCharLayoutNode::Bone& parent = x0_node->GetBoneMap()[bone.x0_parentId];
return bone.x4_origin - parent.x4_origin;
} else {
return bone.x4_origin;
else {
const CCharLayoutNode::Bone& pBone = x0_node->GetBoneMap()[bone.x0_parentId];
return bone.x4_origin - pBone.x4_origin;
}
}
......@@ -19,9 +20,11 @@ zeus::CVector3f CCharLayoutInfo::GetFromRootUnrotated(const CSegId& id) const {
}
CSegId CCharLayoutInfo::GetSegIdFromString(std::string_view name) const {
auto it = x18_segIdMap.find(name.data());
if (it == x18_segIdMap.end())
const auto it = x18_segIdMap.find(name);
if (it == x18_segIdMap.cend()) {
return {};
}
return it->second;
}
......@@ -30,26 +33,29 @@ void CCharLayoutNode::Bone::read(CInputStream& in) {
x0_parentId = CSegId(in);
x4_origin.readBig(in);
u32 chCount = in.readUint32Big();
const u32 chCount = in.readUint32Big();
x10_children.reserve(chCount);
for (u32 i = 0; i < chCount; ++i)
for (u32 i = 0; i < chCount; ++i) {
x10_children.emplace_back(in);
}
}
CCharLayoutNode::CCharLayoutNode(CInputStream& in) : x0_boneMap(in.readUint32Big()) {
u32 cap = x0_boneMap.GetCapacity();
const u32 cap = x0_boneMap.GetCapacity();
for (u32 i = 0; i < cap; ++i) {
u32 thisId = in.readUint32Big();
const u32 thisId = in.readUint32Big();
Bone& bone = x0_boneMap[thisId];
bone.read(in);
}
}
CCharLayoutInfo::CCharLayoutInfo(CInputStream& in) : x0_node(std::make_shared<CCharLayoutNode>(in)), x8_segIdList(in) {
atUint32 mapCount = in.readUint32Big();
const atUint32 mapCount = in.readUint32Big();
for (atUint32 i = 0; i < mapCount; ++i) {
std::string key = in.readString();
x18_segIdMap.emplace(key, in);
x18_segIdMap.emplace(std::move(key), in);
}
}
......
......@@ -28,17 +28,17 @@ private:
TSegIdMap<Bone> x0_boneMap;
public:
CCharLayoutNode(CInputStream& in);
explicit CCharLayoutNode(CInputStream& in);
const TSegIdMap<Bone>& GetBoneMap() const { return x0_boneMap; }
};
class CCharLayoutInfo {
std::shared_ptr<CCharLayoutNode> x0_node;
CSegIdList x8_segIdList;
std::map<std::string, CSegId> x18_segIdMap;
std::map<std::string, CSegId, std::less<>> x18_segIdMap;
public:
CCharLayoutInfo(CInputStream& in);
explicit CCharLayoutInfo(CInputStream& in);
const std::shared_ptr<CCharLayoutNode>& GetRootNode() const { return x0_node; }
const CSegIdList& GetSegIdList() const { return x8_segIdList; }
zeus::CVector3f GetFromParentUnrotated(const CSegId& id) const;
......