2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-06-04 06:41:20 +00:00
metaforce/Runtime/Character/CCharLayoutInfo.hpp
Lioncash e7b0470f55 CCharLayoutInfo: Use heterogenous lookup with std::map
Allows using std::string_view with std::map without the need to
construct a completely new std::string instance. Making the lookups via
GetSegIdFromString() completely non-allocating.

Notably, this also allows it to properly function with
non-null-terminated string_view instances.
2019-10-26 21:17:49 -04:00

52 lines
1.3 KiB
C++

#pragma once
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "Runtime/CFactoryMgr.hpp"
#include "Runtime/IOStreams.hpp"
#include "Runtime/Character/CSegId.hpp"
#include "Runtime/Character/CSegIdList.hpp"
#include "Runtime/Character/TSegIdMap.hpp"
#include <zeus/CVector3f.hpp>
namespace urde {
class CCharLayoutNode {
public:
struct Bone {
CSegId x0_parentId;
zeus::CVector3f x4_origin;
std::vector<CSegId> x10_children;
void read(CInputStream& in);
};
private:
TSegIdMap<Bone> x0_boneMap;
public:
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, std::less<>> x18_segIdMap;
public:
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;
zeus::CVector3f GetFromRootUnrotated(const CSegId& id) const;
CSegId GetSegIdFromString(std::string_view name) const;
};
CFactoryFnReturn FCharLayoutInfo(const SObjectTag&, CInputStream&, const CVParamTransfer&, CObjectReference* selfRef);
} // namespace urde