diff --git a/code/AssimpCExport.cpp b/code/AssimpCExport.cpp index 469842482..9483eb2d3 100644 --- a/code/AssimpCExport.cpp +++ b/code/AssimpCExport.cpp @@ -64,6 +64,7 @@ ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex return Exporter().GetExportFormatDescription(pIndex); } + // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut) { @@ -74,6 +75,16 @@ ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut) SceneCombiner::CopyScene(pOut,pIn,true); } + +// ------------------------------------------------------------------------------------------------ +ASSIMP_API void aiFreeScene(const C_STRUCT aiScene* pIn) +{ + // note: aiReleaseImport() is also able to delete scene copies, but in addition + // it also handles scenes with import metadata. + delete pIn; +} + + // ------------------------------------------------------------------------------------------------ ASSIMP_API aiReturn aiExportScene( const aiScene* pScene, const char* pFormatId, const char* pFileName, unsigned int pPreprocessing ) { diff --git a/include/assimp/cexport.h b/include/assimp/cexport.h index b044dfd25..14b9be189 100644 --- a/include/assimp/cexport.h +++ b/include/assimp/cexport.h @@ -95,16 +95,22 @@ ASSIMP_API const C_STRUCT aiExportFormatDesc* aiGetExportFormatDescription( size // -------------------------------------------------------------------------------- -/** Create a modifyable copy of a scene. +/** Create a modifiable copy of a scene. * This is useful to import files via Assimp, change their topology and * export them again. Since the scene returned by the various importer functions - * is const, a modifyable copy is needed. + * is const, a modifiable copy is needed. * @param pIn Valid scene to be copied - * @param pOut Receives a modifyable copy of the scene. + * @param pOut Receives a modifyable copy of the scene. Use aiFreeScene() to + * delete it again. */ ASSIMP_API void aiCopyScene(const C_STRUCT aiScene* pIn, C_STRUCT aiScene** pOut); + +// -------------------------------------------------------------------------------- +/** Frees a scene copy created using aiCopyScene() */ +ASSIMP_API void aiFreeScene(const C_STRUCT aiScene* pIn); + // -------------------------------------------------------------------------------- /** Exports the given scene to a chosen file format and writes the result file(s) to disk. * @param pScene The scene to export. Stays in possession of the caller, is not changed by the function.