- Redesign the C interface to allow per-import settings.

- Make C-API threadsafe even without boost (no longer a global importer <-> scene map).
- Cleanup headers.
- Change the way how Importer::pimpl is accessed - all users are no longer friends of Importer to avoid spoiling the public interface. Rather, pimpl is exposed via a public member function and anyone having the definition of ImporterPimpl can access it.

THIS IS A BREAKING API CHANGE for anyone using properties with the C API. It is, however, a huge step forward and finally makes our C API functionally equivalent to the C++ interface.

I hope we can adapt all ports as soon as possible. I'd be grateful if the respective maintainers could do this.

Documentation is not yet up to date.

All this is in anticipation to the upcoming 3.0 release, which I'm actively working on.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1111 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/5/head
aramis_acg 2012-01-13 14:07:58 +00:00
parent 20495de804
commit 3f369342d6
8 changed files with 208 additions and 170 deletions

View File

@ -59,9 +59,8 @@ using namespace Assimp;
namespace Assimp
{
/** Stores the importer objects for all active import processes */
typedef std::map<const aiScene*, Assimp::Importer*> ImporterMap;
// underlying structure for aiPropertyStore
typedef BatchLoader::PropertyMap PropertyMap;
/** Stores the LogStream objects for all active C log streams */
struct mpred {
@ -74,9 +73,6 @@ namespace Assimp
/** Stores the LogStream objects allocated by #aiGetPredefinedLogStream */
typedef std::list<Assimp::LogStream*> PredefLogStreamMap;
/** Local storage of all active import processes */
static ImporterMap gActiveImports;
/** Local storage of all active log streams */
static LogStreamMap gActiveLogStreams;
@ -90,22 +86,13 @@ namespace Assimp
static aiBool gVerboseLogging = false;
}
/** Configuration properties */
static ImporterPimpl::IntPropertyMap gIntProperties;
static ImporterPimpl::FloatPropertyMap gFloatProperties;
static ImporterPimpl::StringPropertyMap gStringProperties;
#ifdef AI_C_THREADSAFE
/** Global mutex to manage the access to the importer map */
static boost::mutex gMutex;
/** Global mutex to manage the access to the logstream map */
static boost::mutex gLogStreamMutex;
#endif
// ------------------------------------------------------------------------------------------------
// Custom LogStream implementation for the C-API
class LogToCallbackRedirector : public LogStream
@ -147,7 +134,7 @@ private:
void ReportSceneNotFoundError()
{
DefaultLogger::get()->error("Unable to find the Assimp::Importer for this aiScene. "
"Are you playing fools with us? Don't mix cpp and c API. Thanks.");
"The C-API does not accept scenes produced by the C++ API and vice versa");
assert(false);
}
@ -160,8 +147,15 @@ const aiScene* aiImportFile( const char* pFile, unsigned int pFlags)
}
// ------------------------------------------------------------------------------------------------
const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags,
aiFileIO* pFS)
const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags, aiFileIO* pFS)
{
return aiImportFileExWithProperties(pFile, pFlags, pFS, NULL);
}
// ------------------------------------------------------------------------------------------------
const aiScene* aiImportFileExWithProperties( const char* pFile, unsigned int pFlags,
aiFileIO* pFS,
const aiPropertyStore* props)
{
ai_assert(NULL != pFile);
@ -171,18 +165,14 @@ const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags,
// create an Importer for this file
Assimp::Importer* imp = new Assimp::Importer();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
// copy the global property lists to the Importer instance
imp->pimpl->mIntProperties = gIntProperties;
imp->pimpl->mFloatProperties = gFloatProperties;
imp->pimpl->mStringProperties = gStringProperties;
#ifdef AI_C_THREADSAFE
lock.unlock();
#endif
// copy properties
if(props) {
const PropertyMap* pp = reinterpret_cast<const PropertyMap*>(props);
ImporterPimpl* pimpl = imp->Pimpl();
pimpl->mIntProperties = pp->ints;
pimpl->mFloatProperties = pp->floats;
pimpl->mStringProperties = pp->strings;
}
// setup a custom IO system if necessary
if (pFS) {
imp->SetIOHandler( new CIOSystemWrapper (pFS) );
@ -191,12 +181,10 @@ const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags,
// and have it read the file
scene = imp->ReadFile( pFile, pFlags);
// if succeeded, place it in the collection of active processes
// if succeeded, store the importer in the scene and keep it alive
if( scene) {
#ifdef AI_C_THREADSAFE
lock.lock();
#endif
gActiveImports[scene] = imp;
ScenePrivateData* priv = const_cast<ScenePrivateData*>( ScenePriv(scene) );
priv->mOrigImporter = imp;
}
else {
// if failed, extract error code and destroy the import
@ -215,6 +203,17 @@ const aiScene* aiImportFileFromMemory(
unsigned int pLength,
unsigned int pFlags,
const char* pHint)
{
return aiImportFileFromMemoryWithProperties(pBuffer, pLength, pFlags, pHint, NULL);
}
// ------------------------------------------------------------------------------------------------
const aiScene* aiImportFileFromMemoryWithProperties(
const char* pBuffer,
unsigned int pLength,
unsigned int pFlags,
const char* pHint,
const aiPropertyStore* props)
{
ai_assert(NULL != pBuffer && 0 != pLength);
@ -224,27 +223,22 @@ const aiScene* aiImportFileFromMemory(
// create an Importer for this file
Assimp::Importer* imp = new Assimp::Importer();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
// copy the global property lists to the Importer instance
imp->pimpl->mIntProperties = gIntProperties;
imp->pimpl->mFloatProperties = gFloatProperties;
imp->pimpl->mStringProperties = gStringProperties;
#ifdef AI_C_THREADSAFE
lock.unlock();
#endif
// copy properties
if(props) {
const PropertyMap* pp = reinterpret_cast<const PropertyMap*>(props);
ImporterPimpl* pimpl = imp->Pimpl();
pimpl->mIntProperties = pp->ints;
pimpl->mFloatProperties = pp->floats;
pimpl->mStringProperties = pp->strings;
}
// and have it read the file from the memory buffer
scene = imp->ReadFileFromMemory( pBuffer, pLength, pFlags,pHint);
// if succeeded, place it in the collection of active processes
// if succeeded, store the importer in the scene and keep it alive
if( scene) {
#ifdef AI_C_THREADSAFE
lock.lock();
#endif
gActiveImports[scene] = imp;
ScenePrivateData* priv = const_cast<ScenePrivateData*>( ScenePriv(scene) );
priv->mOrigImporter = imp;
}
else {
// if failed, extract error code and destroy the import
@ -266,21 +260,16 @@ void aiReleaseImport( const aiScene* pScene)
ASSIMP_BEGIN_EXCEPTION_REGION();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
// find the importer associated with this data
ImporterMap::iterator it = gActiveImports.find( pScene);
// it should be there... else the user is playing fools with us
if( it == gActiveImports.end()) {
ReportSceneNotFoundError();
return;
const ScenePrivateData* priv = ScenePriv(pScene);
if( !priv || !priv->mOrigImporter) {
delete pScene;
}
else {
// deleting the Importer also deletes the scene
delete priv->mOrigImporter;
}
// kill the importer, the data dies with it
delete it->second;
gActiveImports.erase( it);
ASSIMP_END_EXCEPTION_REGION(void);
}
@ -293,27 +282,17 @@ ASSIMP_API const aiScene* aiApplyPostProcessing(const aiScene* pScene,
ASSIMP_BEGIN_EXCEPTION_REGION();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
// find the importer associated with this data
ImporterMap::iterator it = gActiveImports.find( pScene);
// it should be there... else the user is playing fools with us
if( it == gActiveImports.end()) {
const ScenePrivateData* priv = ScenePriv(pScene);
if( !priv || !priv->mOrigImporter) {
ReportSceneNotFoundError();
return NULL;
}
#ifdef AI_C_THREADSAFE
lock.unlock();
#endif
sc = it->second->ApplyPostProcessing(pFlags);
#ifdef AI_C_THREADSAFE
lock.lock();
#endif
sc = priv->mOrigImporter->ApplyPostProcessing(pFlags);
if (!sc) {
// kill the importer, the data dies with it
delete it->second;
gActiveImports.erase( it);
aiReleaseImport(pScene);
return NULL;
}
@ -435,15 +414,7 @@ aiBool aiIsExtensionSupported(const char* szExtension)
aiBool candoit=AI_FALSE;
ASSIMP_BEGIN_EXCEPTION_REGION();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
if (!gActiveImports.empty()) {
return ((*(gActiveImports.begin())).second->IsExtensionSupported( szExtension )) ? AI_TRUE : AI_FALSE;
}
// fixme: no need to create a temporary Importer instance just for that ..
// FIXME: no need to create a temporary Importer instance just for that ..
Assimp::Importer tmp;
candoit = tmp.IsExtensionSupported(std::string(szExtension)) ? AI_TRUE : AI_FALSE;
@ -458,15 +429,7 @@ void aiGetExtensionList(aiString* szOut)
ai_assert(NULL != szOut);
ASSIMP_BEGIN_EXCEPTION_REGION();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
if (!gActiveImports.empty()) {
(*(gActiveImports.begin())).second->GetExtensionList(*szOut);
return;
}
// fixme: no need to create a temporary Importer instance just for that ..
// FIXME: no need to create a temporary Importer instance just for that ..
Assimp::Importer tmp;
tmp.GetExtensionList(*szOut);
@ -479,63 +442,62 @@ void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn,
C_STRUCT aiMemoryInfo* in)
{
ASSIMP_BEGIN_EXCEPTION_REGION();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
// find the importer associated with this data
ImporterMap::iterator it = gActiveImports.find( pIn);
// it should be there... else the user is playing fools with us
if( it == gActiveImports.end()) {
const ScenePrivateData* priv = ScenePriv(pIn);
if( !priv || !priv->mOrigImporter) {
ReportSceneNotFoundError();
return;
}
// get memory statistics
#ifdef AI_C_THREADSAFE
lock.unlock();
#endif
it->second->GetMemoryRequirements(*in);
return priv->mOrigImporter->GetMemoryRequirements(*in);
ASSIMP_END_EXCEPTION_REGION(void);
}
// ------------------------------------------------------------------------------------------------
ASSIMP_API aiPropertyStore* aiCreatePropertyStore(void)
{
return reinterpret_cast<aiPropertyStore*>( new PropertyMap() );
}
// ------------------------------------------------------------------------------------------------
ASSIMP_API void aiReleasePropertyStore(aiPropertyStore* p)
{
delete reinterpret_cast<PropertyMap*>(p);
}
// ------------------------------------------------------------------------------------------------
// Importer::SetPropertyInteger
ASSIMP_API void aiSetImportPropertyInteger(const char* szName, int value)
ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szName, int value)
{
ASSIMP_BEGIN_EXCEPTION_REGION();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
SetGenericProperty<int>(gIntProperties,szName,value,NULL);
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
SetGenericProperty<int>(pp->ints,szName,value,NULL);
ASSIMP_END_EXCEPTION_REGION(void);
}
// ------------------------------------------------------------------------------------------------
// Importer::SetPropertyFloat
ASSIMP_API void aiSetImportPropertyFloat(const char* szName, float value)
ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName, float value)
{
ASSIMP_BEGIN_EXCEPTION_REGION();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
SetGenericProperty<float>(gFloatProperties,szName,value,NULL);
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
SetGenericProperty<float>(pp->floats,szName,value,NULL);
ASSIMP_END_EXCEPTION_REGION(void);
}
// ------------------------------------------------------------------------------------------------
// Importer::SetPropertyString
ASSIMP_API void aiSetImportPropertyString(const char* szName,
ASSIMP_API void aiSetImportPropertyString(aiPropertyStore* p, const char* szName,
const C_STRUCT aiString* st)
{
if (!st) {
return;
}
ASSIMP_BEGIN_EXCEPTION_REGION();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
SetGenericProperty<std::string>(gStringProperties,szName,
std::string( st->data ),NULL);
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
SetGenericProperty<std::string>(pp->strings,szName,std::string(st->C_Str()),NULL);
ASSIMP_END_EXCEPTION_REGION(void);
}
@ -574,16 +536,16 @@ ASSIMP_API void aiTransposeMatrix4(aiMatrix4x4* mat)
// ------------------------------------------------------------------------------------------------
// Vector transformation
ASSIMP_API void aiTransformVecByMatrix3(C_STRUCT aiVector3D* vec,
const C_STRUCT aiMatrix3x3* mat)
ASSIMP_API void aiTransformVecByMatrix3(aiVector3D* vec,
const aiMatrix3x3* mat)
{
ai_assert(NULL != mat && NULL != vec);
*vec *= (*mat);
}
// ------------------------------------------------------------------------------------------------
ASSIMP_API void aiTransformVecByMatrix4(C_STRUCT aiVector3D* vec,
const C_STRUCT aiMatrix4x4* mat)
ASSIMP_API void aiTransformVecByMatrix4(aiVector3D* vec,
const aiMatrix4x4* mat)
{
ai_assert(NULL != mat && NULL != vec);
*vec *= (*mat);
@ -592,8 +554,8 @@ ASSIMP_API void aiTransformVecByMatrix4(C_STRUCT aiVector3D* vec,
// ------------------------------------------------------------------------------------------------
// Matrix multiplication
ASSIMP_API void aiMultiplyMatrix4(
C_STRUCT aiMatrix4x4* dst,
const C_STRUCT aiMatrix4x4* src)
aiMatrix4x4* dst,
const aiMatrix4x4* src)
{
ai_assert(NULL != dst && NULL != src);
*dst = (*dst) * (*src);
@ -601,8 +563,8 @@ ASSIMP_API void aiMultiplyMatrix4(
// ------------------------------------------------------------------------------------------------
ASSIMP_API void aiMultiplyMatrix3(
C_STRUCT aiMatrix3x3* dst,
const C_STRUCT aiMatrix3x3* src)
aiMatrix3x3* dst,
const aiMatrix3x3* src)
{
ai_assert(NULL != dst && NULL != src);
*dst = (*dst) * (*src);
@ -611,7 +573,7 @@ ASSIMP_API void aiMultiplyMatrix3(
// ------------------------------------------------------------------------------------------------
// Matrix identity
ASSIMP_API void aiIdentityMatrix3(
C_STRUCT aiMatrix3x3* mat)
aiMatrix3x3* mat)
{
ai_assert(NULL != mat);
*mat = aiMatrix3x3();
@ -619,7 +581,7 @@ ASSIMP_API void aiIdentityMatrix3(
// ------------------------------------------------------------------------------------------------
ASSIMP_API void aiIdentityMatrix4(
C_STRUCT aiMatrix4x4* mat)
aiMatrix4x4* mat)
{
ai_assert(NULL != mat);
*mat = aiMatrix4x4();

View File

@ -507,9 +507,10 @@ void BatchLoader::LoadAll()
pp |= aiProcess_ValidateDataStructure;
#endif
// setup config properties if necessary
data->pImporter->pimpl->mFloatProperties = (*it).map.floats;
data->pImporter->pimpl->mIntProperties = (*it).map.ints;
data->pImporter->pimpl->mStringProperties = (*it).map.strings;
ImporterPimpl* pimpl = data->pImporter->Pimpl();
pimpl->mFloatProperties = (*it).map.floats;
pimpl->mIntProperties = (*it).map.ints;
pimpl->mStringProperties = (*it).map.strings;
if (!DefaultLogger::isNullLogger())
{

View File

@ -67,7 +67,7 @@ BaseProcess::~BaseProcess()
// ------------------------------------------------------------------------------------------------
void BaseProcess::ExecuteOnScene( Importer* pImp)
{
ai_assert(NULL != pImp && NULL != pImp->pimpl->mScene);
ai_assert(NULL != pImp && NULL != pImp->Pimpl()->mScene);
progress = pImp->GetProgressHandler();
ai_assert(progress);
@ -77,17 +77,17 @@ void BaseProcess::ExecuteOnScene( Importer* pImp)
// catch exceptions thrown inside the PostProcess-Step
try
{
Execute(pImp->pimpl->mScene);
Execute(pImp->Pimpl()->mScene);
} catch( const std::exception& err ) {
// extract error description
pImp->pimpl->mErrorString = err.what();
DefaultLogger::get()->error(pImp->pimpl->mErrorString);
pImp->Pimpl()->mErrorString = err.what();
DefaultLogger::get()->error(pImp->Pimpl()->mErrorString);
// and kill the partially imported data
delete pImp->pimpl->mScene;
pImp->pimpl->mScene = NULL;
delete pImp->Pimpl()->mScene;
pImp->Pimpl()->mScene = NULL;
}
}

View File

@ -46,12 +46,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
class Importer;
struct ScenePrivateData {
ScenePrivateData()
: mPPStepsApplied()
: mOrigImporter()
, mPPStepsApplied()
{}
// Importer that originally loaded the scene though the C-API
// If set, this object is owned by this private data instance.
Assimp::Importer* mOrigImporter;
// List of postprocessing steps already applied to the scene.
unsigned int mPPStepsApplied;
};

View File

@ -70,6 +70,19 @@ struct aiLogStream
char* user;
};
// --------------------------------------------------------------------------------
/** C-API: Represents an opaque set of settings to be used during importing.
* @see aiCreatePropertyStore
* @see aiReleasePropertyStore
* @see aiImportFileExWithProperties
* @see aiSetPropertyInteger
* @see aiSetPropertyFloat
* @see aiSetPropertyString
*/
// --------------------------------------------------------------------------------
struct aiPropertyStore {};
/** Our own C boolean type */
typedef int aiBool;
@ -112,7 +125,8 @@ ASSIMP_API const C_STRUCT aiScene* aiImportFile(
* a successful import. Provide a bitwise combination of the
* #aiPostProcessSteps flags.
* @param pFS aiFileIO structure. Will be used to open the model file itself
* and any other files the loader needs to open.
* and any other files the loader needs to open. Pass NULL to use the default
* implementation.
* @return Pointer to the imported data or NULL if the import failed.
* @note Include <aiFileIO.h> for the definition of #aiFileIO.
*/
@ -121,6 +135,18 @@ ASSIMP_API const C_STRUCT aiScene* aiImportFileEx(
unsigned int pFlags,
C_STRUCT aiFileIO* pFS);
// --------------------------------------------------------------------------------
/** Same as #aiImportFileEx, but adds an extra parameter containing importer settings.
*
* @param pProps #aiPropertyStore instance containing import settings.
* @see aiImportFileEx
*/
ASSIMP_API const C_STRUCT aiScene* aiImportFileExWithProperties(
const char* pFile,
unsigned int pFlags,
C_STRUCT aiFileIO* pFS,
const C_STRUCT aiPropertyStore* pProps);
// --------------------------------------------------------------------------------
/** Reads the given file from a given memory buffer,
*
@ -156,6 +182,19 @@ ASSIMP_API const C_STRUCT aiScene* aiImportFileFromMemory(
unsigned int pFlags,
const char* pHint);
// --------------------------------------------------------------------------------
/** Same as #aiImportFileFromMemory, but adds an extra parameter containing importer settings.
*
* @param pProps #aiPropertyStore instance containing import settings.
* @see aiImportFileFromMemory
*/
ASSIMP_API const C_STRUCT aiScene* aiImportFileFromMemoryWithProperties(
const char* pBuffer,
unsigned int pLength,
unsigned int pFlags,
const char* pHint,
const C_STRUCT aiPropertyStore* pProps);
// --------------------------------------------------------------------------------
/** Apply post-processing to an already-imported scene.
*
@ -283,7 +322,7 @@ ASSIMP_API void aiGetExtensionList(
C_STRUCT aiString* szOut);
// --------------------------------------------------------------------------------
/** Get the storage required by an imported asset
/** Get the approximated storage required by an imported asset
* @param pIn Input asset.
* @param in Data structure to be filled.
*/
@ -291,6 +330,22 @@ ASSIMP_API void aiGetMemoryRequirements(
const C_STRUCT aiScene* pIn,
C_STRUCT aiMemoryInfo* in);
// --------------------------------------------------------------------------------
/** Create an empty property store. Property stores are used to collect import
* settings.
* @return New property store. Property stores need to be manually destroyed using
* the #aiReleasePropertyStore API function.
*/
ASSIMP_API C_STRUCT aiPropertyStore* aiCreatePropertyStore(void);
// --------------------------------------------------------------------------------
/** Delete a property store.
* @param p Property store to be deleted.
*/
ASSIMP_API void aiReleasePropertyStore(aiPropertyStore* p);
// --------------------------------------------------------------------------------
/** Set an integer property.
*
@ -303,6 +358,7 @@ ASSIMP_API void aiGetMemoryRequirements(
* @param value New value for the property
*/
ASSIMP_API void aiSetImportPropertyInteger(
aiPropertyStore* store,
const char* szName,
int value);
@ -318,6 +374,7 @@ ASSIMP_API void aiSetImportPropertyInteger(
* @param value New value for the property
*/
ASSIMP_API void aiSetImportPropertyFloat(
aiPropertyStore* store,
const char* szName,
float value);
@ -328,11 +385,13 @@ ASSIMP_API void aiSetImportPropertyFloat(
* interface, properties are always shared by all imports. It is not possible to
* specify them per import.
*
* @param property store to modify. Use #aiCreatePropertyStore to obtain a store.
* @param szName Name of the configuration property to be set. All supported
* public properties are defined in the aiConfig.h header file (#AI_CONFIG_XXX).
* @param value New value for the property
*/
ASSIMP_API void aiSetImportPropertyString(
aiPropertyStore* store,
const char* szName,
const C_STRUCT aiString* st);

View File

@ -83,10 +83,6 @@ namespace Assimp {
#define AI_PROPERTY_WAS_NOT_EXISTING 0xffffffff
struct aiScene;
struct aiFileIO;
extern "C" ASSIMP_API const aiScene* aiImportFileEx( const char*, unsigned int, aiFileIO*);
extern "C" ASSIMP_API const aiScene* aiImportFileFromMemory( const char*,
unsigned int,unsigned int,const char*);
/** @namespace Assimp Assimp's CPP-API and all internal APIs */
namespace Assimp {
@ -117,13 +113,6 @@ namespace Assimp {
*/
class ASSIMP_API Importer {
// for internal use
friend class BaseProcess;
friend class BatchLoader;
friend const aiScene* ::aiImportFileEx( const char*, unsigned int, aiFileIO*);
friend const aiScene* ::aiImportFileFromMemory( const char*,
unsigned int,unsigned int,const char*);
public:
// -------------------------------------------------------------------
@ -579,6 +568,12 @@ public:
* intended for use in production environments. */
void SetExtraVerbose(bool bDo);
// -------------------------------------------------------------------
/** Private, do not use. */
ImporterPimpl* Pimpl() { return pimpl; };
const ImporterPimpl* Pimpl() const { return pimpl; };
protected:
// Just because we don't want you to know how we're hacking around.

View File

@ -54,7 +54,7 @@ extern "C" {
#endif
struct aiScene; // aiScene.h
struct aiFileIO; // aiFileIO.h
// --------------------------------------------------------------------------------
/** Describes an file format which Assimp can export to. Use #aiGetExportFormatCount() to
@ -102,7 +102,8 @@ ASSIMP_API const C_STRUCT aiExportFormatDesc* aiGetExportFormatDescription( size
* @param pIn Valid scene to be copied
* @param pOut User-allocated scene to be filled.
*/
ASSIMP_API void aiCopyScene(const C_STRUCT aiScene* pIn, C_STRUCT aiScene** pOut);
ASSIMP_API void aiCopyScene(const C_STRUCT aiScene* pIn,
C_STRUCT aiScene** pOut);
// --------------------------------------------------------------------------------
/** Exports the given scene to a chosen file format and writes the result file(s) to disk.
@ -138,7 +139,10 @@ ASSIMP_API void aiCopyScene(const C_STRUCT aiScene* pIn, C_STRUCT aiScene** pOut
* triangulate data so they would run the step anyway.
* @return a status code indicating the result of the export
*/
ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene, const char* pFormatId, const char* pFileName, unsigned int pPreprocessing);
ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene,
const char* pFormatId,
const char* pFileName,
unsigned int pPreprocessing);
// --------------------------------------------------------------------------------
@ -149,11 +153,16 @@ ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene, const char* p
* @param pFileName Output file to write
* @param pIO custom IO implementation to be used. Use this if you use your own storage methods.
* If none is supplied, a default implementation using standard file IO is used. Note that
* #aiExportSceneToBlob is provided as convienience function to export to memory buffers.
* #aiExportSceneToBlob is provided as convenience function to export to memory buffers.
* @param pPreprocessing Please see the documentation for #aiExportScene
* @return a status code indicating the result of the export
* @note Include <aiFileIO.h> for the definition of #aiFileIO.
*/
ASSIMP_API aiReturn aiExportSceneEx( const C_STRUCT aiScene* pScene, const char* pFormatId, const char* pFileName, C_STRUCT aiFileIO* pIO, unsigned int pPreprocessing );
ASSIMP_API aiReturn aiExportSceneEx( const C_STRUCT aiScene* pScene,
const char* pFormatId,
const char* pFileName,
C_STRUCT aiFileIO* pIO,
unsigned int pPreprocessing );
// --------------------------------------------------------------------------------

View File

@ -148,15 +148,16 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
// get current time
double fCur = (double)timeGetTime();
aiSetImportPropertyInteger(AI_CONFIG_IMPORT_TER_MAKE_UVS,1);
aiSetImportPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,g_smoothAngle);
aiSetImportPropertyInteger(AI_CONFIG_PP_SBP_REMOVE,nopointslines ? aiPrimitiveType_LINE | aiPrimitiveType_POINT : 0 );
aiPropertyStore* props = aiCreatePropertyStore();
aiSetImportPropertyInteger(props,AI_CONFIG_IMPORT_TER_MAKE_UVS,1);
aiSetImportPropertyFloat(props,AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,g_smoothAngle);
aiSetImportPropertyInteger(props,AI_CONFIG_PP_SBP_REMOVE,nopointslines ? aiPrimitiveType_LINE | aiPrimitiveType_POINT : 0 );
aiSetImportPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME,1);
//aiSetImportPropertyInteger(AI_CONFIG_PP_PTV_KEEP_HIERARCHY,1);
aiSetImportPropertyInteger(props,AI_CONFIG_GLOB_MEASURE_TIME,1);
//aiSetImportPropertyInteger(props,AI_CONFIG_PP_PTV_KEEP_HIERARCHY,1);
// Call ASSIMPs C-API to load the file
g_pcAsset->pcScene = (aiScene*)aiImportFile(g_szFileName,
g_pcAsset->pcScene = (aiScene*)aiImportFileExWithProperties(g_szFileName,
ppsteps | /* configurable pp steps */
aiProcess_GenSmoothNormals | // generate smooth normal vectors if not existing
@ -164,7 +165,11 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
aiProcess_Triangulate | // triangulate polygons with more than 3 edges
aiProcess_ConvertToLeftHanded | // convert everything to D3D left handed space
aiProcess_SortByPType | // make 'clean' meshes which consist of a single typ of primitives
0);
0,
NULL,
props);
aiReleasePropertyStore(props);
// get the end time of zje operation, calculate delta t
double fEnd = (double)timeGetTime();