Changed bone weight data format in mesh

This commit is contained in:
Xiao Qi 2023-03-02 15:17:52 +08:00
parent 2188aa4998
commit 5839a2b80d
3 changed files with 14 additions and 25 deletions

View File

@ -99,20 +99,8 @@ namespace SH_COMP
try try
{ {
std::vector<SHVec4>weights; FetchData(primitive.attributes.at(ATT_WEIGHTS.data()), meshIn.weights);
std::vector<SHVec4i>joints; FetchData(primitive.attributes.at(ATT_JOINT.data()), meshIn.joints);
FetchData(primitive.attributes.at(ATT_WEIGHTS.data()), weights);
FetchData(primitive.attributes.at(ATT_JOINT.data()), joints);
meshIn.weights.resize(weights.size());
std::ranges::transform(
weights,
joints,
meshIn.weights.begin(),
[](SHVec4 const& weights, SHVec4i const& joints) ->VertexWeights
{
return { weights, joints };
}
);
std::cout << "hi\n"; std::cout << "hi\n";
} }

View File

@ -58,10 +58,16 @@ namespace SH_COMP
); );
if (header.hasWeights) if (header.hasWeights)
{
file.write( file.write(
reinterpret_cast<char const*>(asset.weights.data()), reinterpret_cast<char const*>(asset.weights.data()),
sizeof(VertexWeights) * header.vertexCount sizeof(SHVec4) * header.vertexCount
); );
file.write(
reinterpret_cast<char const*>(asset.joints.data()),
sizeof(SHVec4i) * header.vertexCount
);
}
} }
} }

View File

@ -15,12 +15,6 @@ namespace SH_COMP
bool hasWeights; bool hasWeights;
}; };
struct VertexWeights
{
SHVec4 weights;
SHVec4i joints;
};
struct MeshData struct MeshData
{ {
std::string name; std::string name;
@ -32,6 +26,7 @@ namespace SH_COMP
std::vector<IndexType> indices; std::vector<IndexType> indices;
//Variable data //Variable data
std::vector<VertexWeights> weights; std::vector<SHVec4> weights;
std::vector<SHVec4i> joints;
}; };
} }