Fix memory leak.
parent
f6cbb26d9c
commit
8912bb333c
|
@ -658,7 +658,8 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref<Mesh>& meshRef, Ref<Buf
|
||||||
delete[] arrys;
|
delete[] arrys;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Accessor> vertexWeightAccessor = ExportData(mAsset, skinRef->id, bufferRef, aimesh->mNumVertices, vertexWeightData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
|
Ref<Accessor> vertexWeightAccessor = ExportData(mAsset, skinRef->id, bufferRef, aimesh->mNumVertices,
|
||||||
|
vertexWeightData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
|
||||||
if ( vertexWeightAccessor ) {
|
if ( vertexWeightAccessor ) {
|
||||||
p.attributes.weight.push_back( vertexWeightAccessor );
|
p.attributes.weight.push_back( vertexWeightAccessor );
|
||||||
}
|
}
|
||||||
|
@ -747,8 +748,7 @@ void glTF2Exporter::ExportMeshes()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************** Vertex colors ****************/
|
/*************** Vertex colors ****************/
|
||||||
for (unsigned int indexColorChannel = 0; indexColorChannel < aim->GetNumColorChannels(); ++indexColorChannel)
|
for (unsigned int indexColorChannel = 0; indexColorChannel < aim->GetNumColorChannels(); ++indexColorChannel) {
|
||||||
{
|
|
||||||
Ref<Accessor> c = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mColors[indexColorChannel], AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT, false);
|
Ref<Accessor> c = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mColors[indexColorChannel], AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT, false);
|
||||||
if (c)
|
if (c)
|
||||||
p.attributes.color.push_back(c);
|
p.attributes.color.push_back(c);
|
||||||
|
@ -794,8 +794,12 @@ void glTF2Exporter::ExportMeshes()
|
||||||
CopyValue(inverseBindMatricesData[idx_joint], invBindMatrixData[idx_joint]);
|
CopyValue(inverseBindMatricesData[idx_joint], invBindMatrixData[idx_joint]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Accessor> invBindMatrixAccessor = ExportData(*mAsset, skinName, b, static_cast<unsigned int>(inverseBindMatricesData.size()), invBindMatrixData, AttribType::MAT4, AttribType::MAT4, ComponentType_FLOAT);
|
Ref<Accessor> invBindMatrixAccessor = ExportData(*mAsset, skinName, b,
|
||||||
if (invBindMatrixAccessor) skinRef->inverseBindMatrices = invBindMatrixAccessor;
|
static_cast<unsigned int>(inverseBindMatricesData.size()),
|
||||||
|
invBindMatrixData, AttribType::MAT4, AttribType::MAT4, ComponentType_FLOAT);
|
||||||
|
if (invBindMatrixAccessor) {
|
||||||
|
skinRef->inverseBindMatrices = invBindMatrixAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
// Identity Matrix =====> skinRef->bindShapeMatrix
|
// Identity Matrix =====> skinRef->bindShapeMatrix
|
||||||
// Temporary. Hard-coded identity matrix here
|
// Temporary. Hard-coded identity matrix here
|
||||||
|
@ -823,10 +827,11 @@ void glTF2Exporter::ExportMeshes()
|
||||||
meshNode->skeletons.push_back(rootJoint);
|
meshNode->skeletons.push_back(rootJoint);
|
||||||
meshNode->skin = skinRef;
|
meshNode->skin = skinRef;
|
||||||
}
|
}
|
||||||
|
delete[] invBindMatrixData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//merges a node's multiple meshes (with one primitive each) into one mesh with multiple primitives
|
// Merges a node's multiple meshes (with one primitive each) into one mesh with multiple primitives
|
||||||
void glTF2Exporter::MergeMeshes()
|
void glTF2Exporter::MergeMeshes()
|
||||||
{
|
{
|
||||||
for (unsigned int n = 0; n < mAsset->nodes.Size(); ++n) {
|
for (unsigned int n = 0; n < mAsset->nodes.Size(); ++n) {
|
||||||
|
|
Loading…
Reference in New Issue