A crash in the aiMesh descructor
parent
893a0177ff
commit
873a358ce4
|
@ -253,7 +253,7 @@ ELSEIF(MSVC)
|
||||||
IF(MSVC12)
|
IF(MSVC12)
|
||||||
ADD_COMPILE_OPTIONS(/wd4351)
|
ADD_COMPILE_OPTIONS(/wd4351)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Ob2")
|
SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Ob2 /DEBUG:FULL /Zi")
|
||||||
ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
|
ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
|
||||||
IF(NOT HUNTER_ENABLED)
|
IF(NOT HUNTER_ENABLED)
|
||||||
SET(CMAKE_CXX_FLAGS "-fPIC -std=c++11 ${CMAKE_CXX_FLAGS}")
|
SET(CMAKE_CXX_FLAGS "-fPIC -std=c++11 ${CMAKE_CXX_FLAGS}")
|
||||||
|
|
|
@ -1091,6 +1091,35 @@ void SceneCombiner::Copy( aiMesh** _dest, const aiMesh* src ) {
|
||||||
aiFace& f = dest->mFaces[i];
|
aiFace& f = dest->mFaces[i];
|
||||||
GetArrayCopy(f.mIndices,f.mNumIndices);
|
GetArrayCopy(f.mIndices,f.mNumIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make a deep copy of all blend shapes
|
||||||
|
CopyPtrArray(dest->mAnimMeshes, dest->mAnimMeshes, dest->mNumAnimMeshes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void SceneCombiner::Copy(aiAnimMesh** _dest, const aiAnimMesh* src) {
|
||||||
|
if (nullptr == _dest || nullptr == src) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
aiAnimMesh* dest = *_dest = new aiAnimMesh();
|
||||||
|
|
||||||
|
// get a flat copy
|
||||||
|
::memcpy(dest, src, sizeof(aiAnimMesh));
|
||||||
|
|
||||||
|
// and reallocate all arrays
|
||||||
|
GetArrayCopy(dest->mVertices, dest->mNumVertices);
|
||||||
|
GetArrayCopy(dest->mNormals, dest->mNumVertices);
|
||||||
|
GetArrayCopy(dest->mTangents, dest->mNumVertices);
|
||||||
|
GetArrayCopy(dest->mBitangents, dest->mNumVertices);
|
||||||
|
|
||||||
|
unsigned int n = 0;
|
||||||
|
while (dest->HasTextureCoords(n))
|
||||||
|
GetArrayCopy(dest->mTextureCoords[n++], dest->mNumVertices);
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
while (dest->HasVertexColors(n))
|
||||||
|
GetArrayCopy(dest->mColors[n++], dest->mNumVertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -65,6 +65,7 @@ struct aiLight;
|
||||||
struct aiMetadata;
|
struct aiMetadata;
|
||||||
struct aiBone;
|
struct aiBone;
|
||||||
struct aiMesh;
|
struct aiMesh;
|
||||||
|
struct aiAnimMesh;
|
||||||
struct aiAnimation;
|
struct aiAnimation;
|
||||||
struct aiNodeAnim;
|
struct aiNodeAnim;
|
||||||
|
|
||||||
|
@ -363,6 +364,7 @@ public:
|
||||||
static void Copy (aiMesh** dest, const aiMesh* src);
|
static void Copy (aiMesh** dest, const aiMesh* src);
|
||||||
|
|
||||||
// similar to Copy():
|
// similar to Copy():
|
||||||
|
static void Copy (aiAnimMesh** dest, const aiAnimMesh* src);
|
||||||
static void Copy (aiMaterial** dest, const aiMaterial* src);
|
static void Copy (aiMaterial** dest, const aiMaterial* src);
|
||||||
static void Copy (aiTexture** dest, const aiTexture* src);
|
static void Copy (aiTexture** dest, const aiTexture* src);
|
||||||
static void Copy (aiAnimation** dest, const aiAnimation* src);
|
static void Copy (aiAnimation** dest, const aiAnimation* src);
|
||||||
|
|
|
@ -380,4 +380,13 @@ TEST_F( utglTF2ImportExport, exportglTF2FromFileTest ) {
|
||||||
EXPECT_TRUE( exporterTest() );
|
EXPECT_TRUE( exporterTest() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F( utglTF2ImportExport, crash_in_anim_mesh_destructor ) {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Sample-Models/AnimatedMorphCube-glTF/AnimatedMorphCube.gltf",
|
||||||
|
aiProcess_ValidateDataStructure);
|
||||||
|
ASSERT_NE( nullptr, scene );
|
||||||
|
Assimp::Exporter exporter;
|
||||||
|
ASSERT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2", ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Sample-Models/AnimatedMorphCube-glTF/AnimatedMorphCube_out.glTF"));
|
||||||
|
}
|
||||||
|
|
||||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
Loading…
Reference in New Issue