Parcourir la source

Split off postprocessing progress

Gargaj il y a 11 ans
Parent
commit
dfe1f03e5b
2 fichiers modifiés avec 15 ajouts et 1 suppressions
  1. 2 1
      code/Importer.cpp
  2. 13 0
      include/assimp/ProgressHandler.hpp

+ 2 - 1
code/Importer.cpp

@@ -768,6 +768,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
 	for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++)	{
 	for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++)	{
 
 
 		BaseProcess* process = pimpl->mPostProcessingSteps[a];
 		BaseProcess* process = pimpl->mPostProcessingSteps[a];
+		pimpl->mProgressHandler->UpdatePostProcess( a, pimpl->mPostProcessingSteps.size() );
 		if( process->IsActive( pFlags))	{
 		if( process->IsActive( pFlags))	{
 
 
 			if (profiler) {
 			if (profiler) {
@@ -775,7 +776,6 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
 			}
 			}
 
 
 			process->ExecuteOnScene	( this );
 			process->ExecuteOnScene	( this );
-			pimpl->mProgressHandler->Update();
 
 
 			if (profiler) {
 			if (profiler) {
 				profiler->EndRegion("postprocess");
 				profiler->EndRegion("postprocess");
@@ -803,6 +803,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
 		}
 		}
 #endif // ! DEBUG
 #endif // ! DEBUG
 	}
 	}
+	pimpl->mProgressHandler->UpdatePostProcess( pimpl->mPostProcessingSteps.size(), pimpl->mPostProcessingSteps.size() );
 
 
 	// update private scene flags
 	// update private scene flags
   if( pimpl->mScene )
   if( pimpl->mScene )

+ 13 - 0
include/assimp/ProgressHandler.hpp

@@ -88,6 +88,19 @@ public:
 	virtual bool Update(float percentage = -1.f) = 0;
 	virtual bool Update(float percentage = -1.f) = 0;
 
 
 
 
+	// -------------------------------------------------------------------
+	/** @brief Progress callback for post-processing steps
+	 *  @param numberOfSteps The number of total post-processing
+	 *   steps
+	 *  @param currentStep The index of the current post-processing
+	 *   step that will run, or equal to numberOfSteps if all of
+	 *   them has finished. This number is always strictly monotone
+	 *   increasing, although not necessarily linearly.
+	 *   */
+	virtual void UpdatePostProcess(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) {
+		float f = currentStep / (float)numberOfSteps;
+		Update( f * 0.5f + 0.5f );
+	};
 
 
 }; // !class ProgressHandler 
 }; // !class ProgressHandler 
 // ------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------