mirror of https://github.com/AxioDL/metaforce.git
Normalize skinning weights from Blender
This commit is contained in:
parent
d5e0536d63
commit
3438cb34a3
|
@ -653,6 +653,7 @@ BlenderConnection::DataStream::Mesh::Mesh
|
||||||
for (uint32_t j=0 ; j<bindCount ; ++j)
|
for (uint32_t j=0 ; j<bindCount ; ++j)
|
||||||
binds.emplace_back(conn);
|
binds.emplace_back(conn);
|
||||||
}
|
}
|
||||||
|
normalizeSkinBinds();
|
||||||
|
|
||||||
/* Assume 16 islands per material for reserve */
|
/* Assume 16 islands per material for reserve */
|
||||||
if (materialSets.size())
|
if (materialSets.size())
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <float.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -430,6 +431,19 @@ public:
|
||||||
std::vector<std::vector<SkinBind>> skins;
|
std::vector<std::vector<SkinBind>> skins;
|
||||||
std::vector<size_t> contiguousSkinVertCounts;
|
std::vector<size_t> contiguousSkinVertCounts;
|
||||||
|
|
||||||
|
void normalizeSkinBinds()
|
||||||
|
{
|
||||||
|
for (std::vector<SkinBind>& 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 */
|
/** Islands of the same material/skinBank are represented here */
|
||||||
struct Surface
|
struct Surface
|
||||||
{
|
{
|
||||||
|
|
|
@ -135,6 +135,7 @@ HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers(bool absoluteCoo
|
||||||
{
|
{
|
||||||
const SkinBanks::Bank& bank = skinBanks.banks[s.skinBankIdx];
|
const SkinBanks::Bank& bank = skinBanks.banks[s.skinBankIdx];
|
||||||
const std::vector<SkinBind>& binds = skins[v.iSkin];
|
const std::vector<SkinBind>& binds = skins[v.iSkin];
|
||||||
|
|
||||||
auto it = bank.m_boneIdxs.cbegin();
|
auto it = bank.m_boneIdxs.cbegin();
|
||||||
for (size_t i=0 ; i<weightVecCount ; ++i)
|
for (size_t i=0 ; i<weightVecCount ; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit a96b5879657efb449326a56826bb944b8892b7d6
|
Subproject commit c33f8d5d3cd1675d851fbf96a1b30ac4fae90dfc
|
Loading…
Reference in New Issue