small refactorings.

pull/3058/head
kimkulling 2020-03-09 10:55:32 +01:00
parent bb3db0ebaf
commit f3b6b78d4d
8 changed files with 83 additions and 134 deletions

View File

@ -589,7 +589,7 @@ IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
ADD_SUBDIRECTORY( tools/assimp_view/ ) ADD_SUBDIRECTORY( tools/assimp_view/ )
ENDIF () ENDIF ()
ENDIF () ENDIF ()
# Te command line tool # The command line tool
ADD_SUBDIRECTORY( tools/assimp_cmd/ ) ADD_SUBDIRECTORY( tools/assimp_cmd/ )
ENDIF () ENDIF ()

View File

@ -185,8 +185,6 @@ SET( Common_SRCS
Common/ScenePreprocessor.cpp Common/ScenePreprocessor.cpp
Common/ScenePreprocessor.h Common/ScenePreprocessor.h
Common/SkeletonMeshBuilder.cpp Common/SkeletonMeshBuilder.cpp
Common/SplitByBoneCountProcess.cpp
Common/SplitByBoneCountProcess.h
Common/StandardShapes.cpp Common/StandardShapes.cpp
Common/TargetAnimation.cpp Common/TargetAnimation.cpp
Common/TargetAnimation.h Common/TargetAnimation.h
@ -737,6 +735,8 @@ SET( PostProcessing_SRCS
PostProcessing/ArmaturePopulate.h PostProcessing/ArmaturePopulate.h
PostProcessing/GenBoundingBoxesProcess.cpp PostProcessing/GenBoundingBoxesProcess.cpp
PostProcessing/GenBoundingBoxesProcess.h PostProcessing/GenBoundingBoxesProcess.h
PostProcessing/SplitByBoneCountProcess.cpp
PostProcessing/SplitByBoneCountProcess.h
) )
SOURCE_GROUP( PostProcessing FILES ${PostProcessing_SRCS}) SOURCE_GROUP( PostProcessing FILES ${PostProcessing_SRCS})

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -43,42 +41,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/** @file Implementation of BaseProcess */ /** @file Implementation of BaseProcess */
#include <assimp/BaseImporter.h>
#include "BaseProcess.h" #include "BaseProcess.h"
#include <assimp/DefaultLogger.hpp>
#include <assimp/scene.h>
#include "Importer.h" #include "Importer.h"
#include <assimp/BaseImporter.h>
#include <assimp/scene.h>
#include <assimp/DefaultLogger.hpp>
using namespace Assimp; using namespace Assimp;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
BaseProcess::BaseProcess() AI_NO_EXCEPT BaseProcess::BaseProcess() AI_NO_EXCEPT
: shared() : shared(),
, progress() progress() {
{ // empty
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Destructor, private as well // Destructor, private as well
BaseProcess::~BaseProcess() BaseProcess::~BaseProcess() {
{
// nothing to do here // nothing to do here
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void BaseProcess::ExecuteOnScene( Importer* pImp) void BaseProcess::ExecuteOnScene(Importer *pImp) {
{ ai_assert( nullptr != pImp );
ai_assert(NULL != pImp && NULL != pImp->Pimpl()->mScene); ai_assert( nullptr != pImp->Pimpl()->mScene);
progress = pImp->GetProgressHandler(); progress = pImp->GetProgressHandler();
ai_assert(progress); ai_assert(nullptr != progress);
SetupProperties(pImp); SetupProperties(pImp);
// catch exceptions thrown inside the PostProcess-Step // catch exceptions thrown inside the PostProcess-Step
try try {
{
Execute(pImp->Pimpl()->mScene); Execute(pImp->Pimpl()->mScene);
} catch (const std::exception &err) { } catch (const std::exception &err) {
@ -94,14 +90,11 @@ void BaseProcess::ExecuteOnScene( Importer* pImp)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void BaseProcess::SetupProperties(const Importer* /*pImp*/) void BaseProcess::SetupProperties(const Importer * /*pImp*/) {
{
// the default implementation does nothing // the default implementation does nothing
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool BaseProcess::RequireVerboseFormat() const bool BaseProcess::RequireVerboseFormat() const {
{
return true; return true;
} }

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -44,9 +43,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef INCLUDED_AI_BASEPROCESS_H #ifndef INCLUDED_AI_BASEPROCESS_H
#define INCLUDED_AI_BASEPROCESS_H #define INCLUDED_AI_BASEPROCESS_H
#include <map>
#include <assimp/GenericProperty.h> #include <assimp/GenericProperty.h>
#include <map>
struct aiScene; struct aiScene;
namespace Assimp { namespace Assimp {
@ -60,26 +60,19 @@ class Importer;
* to provide additional information to other steps. This is primarily * to provide additional information to other steps. This is primarily
* intended for cross-step optimizations. * intended for cross-step optimizations.
*/ */
class SharedPostProcessInfo class SharedPostProcessInfo {
{
public: public:
struct Base {
struct Base virtual ~Base() {}
{
virtual ~Base()
{}
}; };
//! Represents data that is allocated on the heap, thus needs to be deleted //! Represents data that is allocated on the heap, thus needs to be deleted
template <typename T> template <typename T>
struct THeapData : public Base struct THeapData : public Base {
{ explicit THeapData(T *in) :
explicit THeapData(T* in) data(in) {}
: data (in)
{}
~THeapData() ~THeapData() {
{
delete data; delete data;
} }
T *data; T *data;
@ -87,14 +80,11 @@ public:
//! Represents static, by-value data not allocated on the heap //! Represents static, by-value data not allocated on the heap
template <typename T> template <typename T>
struct TStaticData : public Base struct TStaticData : public Base {
{ explicit TStaticData(T in) :
explicit TStaticData(T in) data(in) {}
: data (in)
{}
~TStaticData() ~TStaticData() {}
{}
T data; T data;
}; };
@ -104,20 +94,16 @@ public:
typedef std::map<KeyType, Base *> PropertyMap; typedef std::map<KeyType, Base *> PropertyMap;
public: public:
//! Destructor //! Destructor
~SharedPostProcessInfo() ~SharedPostProcessInfo() {
{
Clean(); Clean();
} }
//! Remove all stored properties from the table //! Remove all stored properties from the table
void Clean() void Clean() {
{
// invoke the virtual destructor for all stored properties // invoke the virtual destructor for all stored properties
for (PropertyMap::iterator it = pmap.begin(), end = pmap.end(); for (PropertyMap::iterator it = pmap.begin(), end = pmap.end();
it != end; ++it) it != end; ++it) {
{
delete (*it).second; delete (*it).second;
} }
pmap.clear(); pmap.clear();
@ -135,14 +121,11 @@ public:
AddProperty(name, (Base *)new TStaticData<T>(in)); AddProperty(name, (Base *)new TStaticData<T>(in));
} }
//! Get a heap property //! Get a heap property
template <typename T> template <typename T>
bool GetProperty( const char* name, T*& out ) const bool GetProperty(const char *name, T *&out) const {
{
THeapData<T> *t = (THeapData<T> *)GetPropertyInternal(name); THeapData<T> *t = (THeapData<T> *)GetPropertyInternal(name);
if(!t) if (!t) {
{
out = NULL; out = NULL;
return false; return false;
} }
@ -152,53 +135,34 @@ public:
//! Get a static, by-value property //! Get a static, by-value property
template <typename T> template <typename T>
bool GetProperty( const char* name, T& out ) const bool GetProperty(const char *name, T &out) const {
{
TStaticData<T> *t = (TStaticData<T> *)GetPropertyInternal(name); TStaticData<T> *t = (TStaticData<T> *)GetPropertyInternal(name);
if(!t)return false; if ( nullptr == t) {
return false;
}
out = t->data; out = t->data;
return true; return true;
} }
//! Remove a property of a specific type //! Remove a property of a specific type
void RemoveProperty(const char *name) { void RemoveProperty(const char *name) {
SetGenericPropertyPtr<Base>(pmap,name,NULL); SetGenericPropertyPtr<Base>(pmap, name, nullptr );
} }
private: private:
void AddProperty(const char *name, Base *data) { void AddProperty(const char *name, Base *data) {
SetGenericPropertyPtr<Base>(pmap, name, data); SetGenericPropertyPtr<Base>(pmap, name, data);
} }
Base *GetPropertyInternal(const char *name) const { Base *GetPropertyInternal(const char *name) const {
return GetGenericProperty<Base*>(pmap,name,NULL); return GetGenericProperty<Base *>(pmap, name, nullptr );
} }
private: private:
//! Map of all stored properties //! Map of all stored properties
PropertyMap pmap; PropertyMap pmap;
}; };
#if 0
// ---------------------------------------------------------------------------
/** @brief Represents a dependency table for a postprocessing steps.
*
* For future use.
*/
struct PPDependencyTable
{
unsigned int execute_me_before_these;
unsigned int execute_me_after_these;
unsigned int only_if_these_are_not_specified;
unsigned int mutually_exclusive_with;
};
#endif
#define AI_SPP_SPATIAL_SORT "$Spat" #define AI_SPP_SPATIAL_SORT "$Spat"
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -258,7 +222,6 @@ public:
*/ */
virtual void Execute(aiScene *pScene) = 0; virtual void Execute(aiScene *pScene) = 0;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Assign a new SharedPostProcessInfo to the step. This object /** Assign a new SharedPostProcessInfo to the step. This object
* allows multiple postprocess steps to share data. * allows multiple postprocess steps to share data.
@ -276,7 +239,6 @@ public:
} }
protected: protected:
/** See the doc of #SharedPostProcessInfo for more details */ /** See the doc of #SharedPostProcessInfo for more details */
SharedPostProcessInfo *shared; SharedPostProcessInfo *shared;
@ -284,7 +246,6 @@ protected:
ProgressHandler *progress; ProgressHandler *progress;
}; };
} // end of namespace Assimp } // end of namespace Assimp
#endif // AI_BASEPROCESS_H_INC #endif // AI_BASEPROCESS_H_INC

View File

@ -123,7 +123,7 @@ corresponding preprocessor flag to selectively disable steps.
# include "PostProcessing/OptimizeGraph.h" # include "PostProcessing/OptimizeGraph.h"
#endif #endif
#ifndef ASSIMP_BUILD_NO_SPLITBYBONECOUNT_PROCESS #ifndef ASSIMP_BUILD_NO_SPLITBYBONECOUNT_PROCESS
# include "Common/SplitByBoneCountProcess.h" # include "PostProcessing/SplitByBoneCountProcess.h"
#endif #endif
#ifndef ASSIMP_BUILD_NO_DEBONE_PROCESS #ifndef ASSIMP_BUILD_NO_DEBONE_PROCESS
# include "PostProcessing/DeboneProcess.h" # include "PostProcessing/DeboneProcess.h"

View File

@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_SPLITBYBONECOUNTPROCESS_H_INC #define AI_SPLITBYBONECOUNTPROCESS_H_INC
#include <vector> #include <vector>
#include "BaseProcess.h" #include "Common/BaseProcess.h"
#include <assimp/mesh.h> #include <assimp/mesh.h>
#include <assimp/scene.h> #include <assimp/scene.h>

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -48,16 +47,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# pragma GCC system_header # pragma GCC system_header
#endif #endif
#include <assimp/Importer.hpp>
#include <assimp/ai_assert.h>
#include <assimp/Hash.h> #include <assimp/Hash.h>
#include <assimp/ai_assert.h>
#include <assimp/Importer.hpp>
#include <map> #include <map>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <class T> template <class T>
inline inline bool SetGenericProperty(std::map<unsigned int, T> &list,
bool SetGenericProperty(std::map< unsigned int, T >& list,
const char *szName, const T &value) { const char *szName, const T &value) {
ai_assert(nullptr != szName); ai_assert(nullptr != szName);
const uint32_t hash = SuperFastHash(szName); const uint32_t hash = SuperFastHash(szName);
@ -74,8 +72,7 @@ bool SetGenericProperty(std::map< unsigned int, T >& list,
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <class T> template <class T>
inline inline const T &GetGenericProperty(const std::map<unsigned int, T> &list,
const T& GetGenericProperty(const std::map< unsigned int, T >& list,
const char *szName, const T &errorReturn) { const char *szName, const T &errorReturn) {
ai_assert(nullptr != szName); ai_assert(nullptr != szName);
const uint32_t hash = SuperFastHash(szName); const uint32_t hash = SuperFastHash(szName);
@ -92,8 +89,7 @@ const T& GetGenericProperty(const std::map< unsigned int, T >& list,
// Special version for pointer types - they will be deleted when replaced with another value // Special version for pointer types - they will be deleted when replaced with another value
// passing NULL removes the whole property // passing NULL removes the whole property
template <class T> template <class T>
inline inline void SetGenericPropertyPtr(std::map<unsigned int, T *> &list,
void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
const char *szName, T *value, bool *bWasExisting = nullptr) { const char *szName, T *value, bool *bWasExisting = nullptr) {
ai_assert(nullptr != szName); ai_assert(nullptr != szName);
const uint32_t hash = SuperFastHash(szName); const uint32_t hash = SuperFastHash(szName);
@ -121,8 +117,7 @@ void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <class T> template <class T>
inline inline bool HasGenericProperty(const std::map<unsigned int, T> &list,
bool HasGenericProperty(const std::map< unsigned int, T >& list,
const char *szName) { const char *szName) {
ai_assert(nullptr != szName); ai_assert(nullptr != szName);
const uint32_t hash = SuperFastHash(szName); const uint32_t hash = SuperFastHash(szName);