diff --git a/hecl/blender/BlenderConnection.cpp b/hecl/blender/BlenderConnection.cpp index 83dd148a6..eca86aa3a 100644 --- a/hecl/blender/BlenderConnection.cpp +++ b/hecl/blender/BlenderConnection.cpp @@ -653,6 +653,7 @@ BlenderConnection::DataStream::Mesh::Mesh for (uint32_t j=0 ; j #include +#include #include #include #include @@ -430,6 +431,19 @@ public: std::vector> skins; std::vector contiguousSkinVertCounts; + void normalizeSkinBinds() + { + for (std::vector& skin : skins) + { + float accum = 0.f; + for (const SkinBind& bind : skin) + accum += bind.weight; + if (accum > FLT_EPSILON) + for (SkinBind& bind : skin) + bind.weight /= accum; + } + } + /** Islands of the same material/skinBank are represented here */ struct Surface { diff --git a/hecl/blender/HMDL.cpp b/hecl/blender/HMDL.cpp index 894b822bb..3d2576341 100644 --- a/hecl/blender/HMDL.cpp +++ b/hecl/blender/HMDL.cpp @@ -135,6 +135,7 @@ HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers(bool absoluteCoo { const SkinBanks::Bank& bank = skinBanks.banks[s.skinBankIdx]; const std::vector& binds = skins[v.iSkin]; + auto it = bank.m_boneIdxs.cbegin(); for (size_t i=0 ; i