mirror of https://github.com/AxioDL/metaforce.git
Fix skin binding unordered_map use
This commit is contained in:
parent
5c59acddf2
commit
92e2c03a01
|
@ -315,7 +315,8 @@ struct Mesh {
|
|||
float weight = 0.f;
|
||||
SkinBind() = default;
|
||||
explicit SkinBind(Connection& conn);
|
||||
operator bool() const { return vg_idx != UINT32_MAX; }
|
||||
bool valid() const { return vg_idx != UINT32_MAX; }
|
||||
bool operator==(const SkinBind& other) const { return vg_idx == other.vg_idx && weight == other.weight; }
|
||||
};
|
||||
std::vector<std::array<SkinBind, MaxSkinEntries>> skins;
|
||||
std::vector<size_t> contiguousSkinVertCounts;
|
||||
|
@ -323,7 +324,7 @@ struct Mesh {
|
|||
static size_t countSkinBinds(const std::array<SkinBind, MaxSkinEntries>& arr) {
|
||||
size_t ret = 0;
|
||||
for (const auto& b : arr)
|
||||
if (b)
|
||||
if (b.valid())
|
||||
++ret;
|
||||
else
|
||||
break;
|
||||
|
@ -823,7 +824,7 @@ struct hash<array<hecl::blender::Mesh::SkinBind, 16>> {
|
|||
size_t operator()(const array<hecl::blender::Mesh::SkinBind, 16>& val) const noexcept {
|
||||
size_t h = 0;
|
||||
for (const auto& bind : val) {
|
||||
if (!bind)
|
||||
if (!bind.valid())
|
||||
break;
|
||||
hecl::hash_combine_impl(h, std::hash<float>()(bind.vg_idx));
|
||||
hecl::hash_combine_impl(h, std::hash<float>()(bind.weight));
|
||||
|
|
|
@ -825,11 +825,11 @@ void Mesh::normalizeSkinBinds() {
|
|||
for (auto& skin : skins) {
|
||||
float accum = 0.f;
|
||||
for (const SkinBind& bind : skin)
|
||||
if (bind)
|
||||
if (bind.valid())
|
||||
accum += bind.weight;
|
||||
if (accum > FLT_EPSILON) {
|
||||
for (SkinBind& bind : skin)
|
||||
if (bind)
|
||||
if (bind.valid())
|
||||
bind.weight /= accum;
|
||||
}
|
||||
}
|
||||
|
@ -1030,7 +1030,7 @@ void Mesh::SkinBanks::Bank::addSkins(const Mesh& parent, const std::vector<uint3
|
|||
for (uint32_t sidx : skinIdxs) {
|
||||
m_skinIdxs.push_back(sidx);
|
||||
for (const SkinBind& bind : parent.skins[sidx]) {
|
||||
if (!bind)
|
||||
if (!bind.valid())
|
||||
break;
|
||||
bool found = false;
|
||||
for (uint32_t bidx : m_boneIdxs) {
|
||||
|
|
|
@ -147,7 +147,7 @@ HMDLBuffers Mesh::getHMDLBuffers(bool absoluteCoords, PoolSkinIndex& poolSkinInd
|
|||
if (it == bank.m_boneIdxs.cend())
|
||||
break;
|
||||
for (const SkinBind& bind : binds) {
|
||||
if (!bind)
|
||||
if (!bind.valid())
|
||||
break;
|
||||
if (bind.vg_idx == *it) {
|
||||
vec.simd[j] = bind.weight;
|
||||
|
|
|
@ -10,7 +10,7 @@ template <typename T>
|
|||
static void insert_unique_attr(std::unordered_map<T, uint32_t>& set, const T& attr) {
|
||||
if (set.find(attr) == set.cend()) {
|
||||
size_t sz = set.size();
|
||||
set[attr] = sz;
|
||||
set.insert(std::make_pair(attr, sz));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ MeshOptimizer::MeshOptimizer(Connection& conn, const std::vector<Material>& mate
|
|||
for (uint32_t i = 0; i < vert_count.val; ++i) {
|
||||
verts.emplace_back(conn);
|
||||
insert_unique_attr(b_pos, verts.back().co);
|
||||
if (verts.back().skin_ents[0])
|
||||
if (verts.back().skin_ents[0].valid())
|
||||
insert_unique_attr(b_skin, verts.back().skin_ents);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue