PostProcessing: first prototype of customized post processing.
parent
11d0085f4d
commit
8bbd55a790
|
@ -102,7 +102,7 @@ namespace Assimp
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_SINGLETHREADED
|
#ifndef ASSIMP_BUILD_SINGLETHREADED
|
||||||
/** Global mutex to manage the access to the logstream map */
|
/** Global mutex to manage the access to the log-stream map */
|
||||||
static boost::mutex gLogStreamMutex;
|
static boost::mutex gLogStreamMutex;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -230,7 +230,8 @@ const aiScene* aiImportFileFromMemoryWithProperties(
|
||||||
const char* pHint,
|
const char* pHint,
|
||||||
const aiPropertyStore* props)
|
const aiPropertyStore* props)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != pBuffer && 0 != pLength);
|
ai_assert( NULL != pBuffer );
|
||||||
|
ai_assert( 0 != pLength );
|
||||||
|
|
||||||
const aiScene* scene = NULL;
|
const aiScene* scene = NULL;
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
|
@ -319,10 +320,38 @@ ASSIMP_API const aiScene* aiApplyPostProcessing(const aiScene* pScene,
|
||||||
return sc;
|
return sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
ASSIMP_API const aiScene *aiApplyCustomizedPostProcessing( const aiScene *scene,
|
||||||
|
BaseProcess* process,
|
||||||
|
bool requestValidation ) {
|
||||||
|
const aiScene* sc( NULL );
|
||||||
|
|
||||||
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
|
|
||||||
|
// find the importer associated with this data
|
||||||
|
const ScenePrivateData* priv = ScenePriv( scene );
|
||||||
|
if ( NULL == priv || NULL == priv->mOrigImporter ) {
|
||||||
|
ReportSceneNotFoundError();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sc = priv->mOrigImporter->ApplyCustomizedPostProcessing( process, requestValidation );
|
||||||
|
|
||||||
|
if ( !sc ) {
|
||||||
|
aiReleaseImport( scene );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSIMP_END_EXCEPTION_REGION( const aiScene* );
|
||||||
|
|
||||||
|
return sc;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CallbackToLogRedirector (const char* msg, char* dt)
|
void CallbackToLogRedirector (const char* msg, char* dt)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != msg && NULL != dt);
|
ai_assert( NULL != msg );
|
||||||
|
ai_assert( NULL != dt );
|
||||||
LogStream* s = (LogStream*)dt;
|
LogStream* s = (LogStream*)dt;
|
||||||
|
|
||||||
s->write(msg);
|
s->write(msg);
|
||||||
|
@ -375,7 +404,7 @@ ASSIMP_API aiReturn aiDetachLogStream( const aiLogStream* stream)
|
||||||
#ifndef ASSIMP_BUILD_SINGLETHREADED
|
#ifndef ASSIMP_BUILD_SINGLETHREADED
|
||||||
boost::mutex::scoped_lock lock(gLogStreamMutex);
|
boost::mutex::scoped_lock lock(gLogStreamMutex);
|
||||||
#endif
|
#endif
|
||||||
// find the logstream associated with this data
|
// find the log-stream associated with this data
|
||||||
LogStreamMap::iterator it = gActiveLogStreams.find( *stream);
|
LogStreamMap::iterator it = gActiveLogStreams.find( *stream);
|
||||||
// it should be there... else the user is playing fools with us
|
// it should be there... else the user is playing fools with us
|
||||||
if( it == gActiveLogStreams.end()) {
|
if( it == gActiveLogStreams.end()) {
|
||||||
|
@ -439,7 +468,6 @@ size_t aiGetImportFormatCount(void)
|
||||||
return Importer().GetImporterCount();
|
return Importer().GetImporterCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns the error text of the last failed import process.
|
// Returns the error text of the last failed import process.
|
||||||
aiBool aiIsExtensionSupported(const char* szExtension)
|
aiBool aiIsExtensionSupported(const char* szExtension)
|
||||||
|
@ -494,7 +522,6 @@ ASSIMP_API aiPropertyStore* aiCreatePropertyStore(void)
|
||||||
return reinterpret_cast<aiPropertyStore*>( new PropertyMap() );
|
return reinterpret_cast<aiPropertyStore*>( new PropertyMap() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
ASSIMP_API void aiReleasePropertyStore(aiPropertyStore* p)
|
ASSIMP_API void aiReleasePropertyStore(aiPropertyStore* p)
|
||||||
{
|
{
|
||||||
|
@ -553,7 +580,8 @@ ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore* p, const char* szName
|
||||||
// Rotation matrix to quaternion
|
// Rotation matrix to quaternion
|
||||||
ASSIMP_API void aiCreateQuaternionFromMatrix(aiQuaternion* quat,const aiMatrix3x3* mat)
|
ASSIMP_API void aiCreateQuaternionFromMatrix(aiQuaternion* quat,const aiMatrix3x3* mat)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != quat && NULL != mat);
|
ai_assert( NULL != quat );
|
||||||
|
ai_assert( NULL != mat );
|
||||||
*quat = aiQuaternion(*mat);
|
*quat = aiQuaternion(*mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,7 +591,10 @@ ASSIMP_API void aiDecomposeMatrix(const aiMatrix4x4* mat,aiVector3D* scaling,
|
||||||
aiQuaternion* rotation,
|
aiQuaternion* rotation,
|
||||||
aiVector3D* position)
|
aiVector3D* position)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != rotation && NULL != position && NULL != scaling && NULL != mat);
|
ai_assert( NULL != rotation );
|
||||||
|
ai_assert( NULL != position );
|
||||||
|
ai_assert( NULL != scaling );
|
||||||
|
ai_assert( NULL != mat );
|
||||||
mat->Decompose(*scaling,*rotation,*position);
|
mat->Decompose(*scaling,*rotation,*position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,7 +618,8 @@ ASSIMP_API void aiTransposeMatrix4(aiMatrix4x4* mat)
|
||||||
ASSIMP_API void aiTransformVecByMatrix3(aiVector3D* vec,
|
ASSIMP_API void aiTransformVecByMatrix3(aiVector3D* vec,
|
||||||
const aiMatrix3x3* mat)
|
const aiMatrix3x3* mat)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != mat && NULL != vec);
|
ai_assert( NULL != mat );
|
||||||
|
ai_assert( NULL != vec);
|
||||||
*vec *= (*mat);
|
*vec *= (*mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,7 +627,9 @@ ASSIMP_API void aiTransformVecByMatrix3(aiVector3D* vec,
|
||||||
ASSIMP_API void aiTransformVecByMatrix4(aiVector3D* vec,
|
ASSIMP_API void aiTransformVecByMatrix4(aiVector3D* vec,
|
||||||
const aiMatrix4x4* mat)
|
const aiMatrix4x4* mat)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != mat && NULL != vec);
|
ai_assert( NULL != mat );
|
||||||
|
ai_assert( NULL != vec );
|
||||||
|
|
||||||
*vec *= (*mat);
|
*vec *= (*mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,7 +639,8 @@ ASSIMP_API void aiMultiplyMatrix4(
|
||||||
aiMatrix4x4* dst,
|
aiMatrix4x4* dst,
|
||||||
const aiMatrix4x4* src)
|
const aiMatrix4x4* src)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != dst && NULL != src);
|
ai_assert( NULL != dst );
|
||||||
|
ai_assert( NULL != src );
|
||||||
*dst = (*dst) * (*src);
|
*dst = (*dst) * (*src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,7 +649,8 @@ ASSIMP_API void aiMultiplyMatrix3(
|
||||||
aiMatrix3x3* dst,
|
aiMatrix3x3* dst,
|
||||||
const aiMatrix3x3* src)
|
const aiMatrix3x3* src)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != dst && NULL != src);
|
ai_assert( NULL != dst );
|
||||||
|
ai_assert( NULL != src );
|
||||||
*dst = (*dst) * (*src);
|
*dst = (*dst) * (*src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -833,6 +833,80 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
|
||||||
return pimpl->mScene;
|
return pimpl->mScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess, bool requestValidation ) {
|
||||||
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
|
|
||||||
|
// Return immediately if no scene is active
|
||||||
|
if ( NULL == pimpl->mScene ) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no flags are given, return the current scene with no further action
|
||||||
|
if ( NULL == rootProcess ) {
|
||||||
|
return pimpl->mScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In debug builds: run basic flag validation
|
||||||
|
DefaultLogger::get()->info( "Entering customized post processing pipeline" );
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
|
||||||
|
// The ValidateDS process plays an exceptional role. It isn't contained in the global
|
||||||
|
// list of post-processing steps, so we need to call it manually.
|
||||||
|
if ( requestValidation )
|
||||||
|
{
|
||||||
|
ValidateDSProcess ds;
|
||||||
|
ds.ExecuteOnScene( this );
|
||||||
|
if ( !pimpl->mScene ) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // no validation
|
||||||
|
#ifdef ASSIMP_BUILD_DEBUG
|
||||||
|
if ( pimpl->bExtraVerbose )
|
||||||
|
{
|
||||||
|
#ifdef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
|
||||||
|
DefaultLogger::get()->error( "Verbose Import is not available due to build settings" );
|
||||||
|
#endif // no validation
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if ( pimpl->bExtraVerbose ) {
|
||||||
|
DefaultLogger::get()->warn( "Not a debug build, ignoring extra verbose setting" );
|
||||||
|
}
|
||||||
|
#endif // ! DEBUG
|
||||||
|
|
||||||
|
boost::scoped_ptr<Profiler> profiler( GetPropertyInteger( AI_CONFIG_GLOB_MEASURE_TIME, 0 ) ? new Profiler() : NULL );
|
||||||
|
|
||||||
|
if ( profiler ) {
|
||||||
|
profiler->BeginRegion( "postprocess" );
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProcess->ExecuteOnScene( this );
|
||||||
|
|
||||||
|
if ( profiler ) {
|
||||||
|
profiler->EndRegion( "postprocess" );
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step
|
||||||
|
if ( pimpl->bExtraVerbose || requestValidation ) {
|
||||||
|
DefaultLogger::get()->debug( "Verbose Import: revalidating data structures" );
|
||||||
|
|
||||||
|
ValidateDSProcess ds;
|
||||||
|
ds.ExecuteOnScene( this );
|
||||||
|
if ( !pimpl->mScene ) {
|
||||||
|
DefaultLogger::get()->error( "Verbose Import: failed to revalidate data structures" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear any data allocated by post-process steps
|
||||||
|
pimpl->mPPShared->Clean();
|
||||||
|
DefaultLogger::get()->info( "Leaving customized post processing pipeline" );
|
||||||
|
|
||||||
|
ASSIMP_END_EXCEPTION_REGION( const aiScene* );
|
||||||
|
|
||||||
|
return pimpl->mScene;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Helper function to check whether an extension is supported by ASSIMP
|
// Helper function to check whether an extension is supported by ASSIMP
|
||||||
bool Importer::IsExtensionSupported(const char* szExtension) const
|
bool Importer::IsExtensionSupported(const char* szExtension) const
|
||||||
|
|
|
@ -458,6 +458,8 @@ public:
|
||||||
* to the #Importer instance. */
|
* to the #Importer instance. */
|
||||||
const aiScene* ApplyPostProcessing(unsigned int pFlags);
|
const aiScene* ApplyPostProcessing(unsigned int pFlags);
|
||||||
|
|
||||||
|
const aiScene* ApplyCustomizedPostProcessing( BaseProcess *rootProcess, bool requestValidation );
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Reads the given file and returns its contents if successful.
|
/** @brief Reads the given file and returns its contents if successful.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue