2
0
Эх сурвалжийг харах

Add aiFreeScene() API for symmetry with aiCopyScene.

Alexander Gessler 12 жил өмнө
parent
commit
0edb78d940

+ 11 - 0
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 )
 {

+ 9 - 3
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.