mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-16 09:48:00 -05:00
chore: make XModelCommon use offset instead of pointer
This commit is contained in:
@ -18,12 +18,16 @@ protected:
|
||||
auto vertexOffset = 0u;
|
||||
for (const auto& vertex : xmodel.m_vertices)
|
||||
{
|
||||
XModelVertexBoneWeights weights{nullptr, 0};
|
||||
XModelVertexBoneWeights weights{0, 0};
|
||||
|
||||
if (vertexOffset < xmodel.m_vertex_bone_weights.size())
|
||||
weights = xmodel.m_vertex_bone_weights[vertexOffset];
|
||||
|
||||
m_vertex_merger.Add(VertexMergerPos{vertex.coordinates[0], vertex.coordinates[1], vertex.coordinates[2], weights.weights, weights.weightCount});
|
||||
m_vertex_merger.Add(VertexMergerPos{vertex.coordinates[0],
|
||||
vertex.coordinates[1],
|
||||
vertex.coordinates[2],
|
||||
&xmodel.m_bone_weight_data.weights[weights.weightOffset],
|
||||
weights.weightCount});
|
||||
|
||||
vertexOffset++;
|
||||
}
|
||||
|
@ -496,14 +496,15 @@ namespace
|
||||
auto* weights = reinterpret_cast<float*>(&bufferData[currentBufferOffset + sizeof(uint8_t) * 4u * xmodel.m_vertex_bone_weights.size()]);
|
||||
for (const auto& commonVertexWeights : xmodel.m_vertex_bone_weights)
|
||||
{
|
||||
assert(commonVertexWeights.weights != nullptr);
|
||||
assert(commonVertexWeights.weightOffset < xmodel.m_bone_weight_data.weights.size());
|
||||
assert(commonVertexWeights.weightCount <= 4u);
|
||||
|
||||
const auto commonVertexWeightCount = std::min(commonVertexWeights.weightCount, 4u);
|
||||
const auto* commonVertexWeightData = &xmodel.m_bone_weight_data.weights[commonVertexWeights.weightOffset];
|
||||
for (auto i = 0u; i < commonVertexWeightCount; i++)
|
||||
{
|
||||
joints[i] = static_cast<unsigned char>(commonVertexWeights.weights[i].boneIndex);
|
||||
weights[i] = commonVertexWeights.weights[i].weight;
|
||||
joints[i] = static_cast<unsigned char>(commonVertexWeightData[i].boneIndex);
|
||||
weights[i] = commonVertexWeightData[i].weight;
|
||||
}
|
||||
|
||||
for (auto i = commonVertexWeightCount; i < 4u; i++)
|
||||
|
Reference in New Issue
Block a user