Merge branch 'master' into isue_1621
commit
096f7e272a
|
@ -147,10 +147,7 @@ void AllocateFromAssimpHeap::operator delete[] ( void* data) {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Importer constructor.
|
// Importer constructor.
|
||||||
Importer::Importer()
|
Importer::Importer()
|
||||||
: pimpl( NULL ) {
|
: pimpl( new ImporterPimpl ) {
|
||||||
// allocate the pimpl first
|
|
||||||
pimpl = new ImporterPimpl();
|
|
||||||
|
|
||||||
pimpl->mScene = NULL;
|
pimpl->mScene = NULL;
|
||||||
pimpl->mErrorString = "";
|
pimpl->mErrorString = "";
|
||||||
|
|
||||||
|
|
|
@ -68,10 +68,8 @@ namespace Assimp {
|
||||||
* std::vector and std::map in the public headers. Furthermore we are dropping
|
* std::vector and std::map in the public headers. Furthermore we are dropping
|
||||||
* any STL interface problems caused by mismatching STL settings. All
|
* any STL interface problems caused by mismatching STL settings. All
|
||||||
* size calculation are now done by us, not the app heap. */
|
* size calculation are now done by us, not the app heap. */
|
||||||
class ImporterPimpl
|
class ImporterPimpl {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Data type to store the key hash
|
// Data type to store the key hash
|
||||||
typedef unsigned int KeyType;
|
typedef unsigned int KeyType;
|
||||||
|
|
||||||
|
@ -82,8 +80,6 @@ public:
|
||||||
typedef std::map<KeyType, std::string> StringPropertyMap;
|
typedef std::map<KeyType, std::string> StringPropertyMap;
|
||||||
typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
|
typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/** IO handler to use for all file accesses. */
|
/** IO handler to use for all file accesses. */
|
||||||
IOSystem* mIOHandler;
|
IOSystem* mIOHandler;
|
||||||
bool mIsDefaultHandler;
|
bool mIsDefaultHandler;
|
||||||
|
@ -117,12 +113,34 @@ public:
|
||||||
MatrixPropertyMap mMatrixProperties;
|
MatrixPropertyMap mMatrixProperties;
|
||||||
|
|
||||||
/** Used for testing - extra verbose mode causes the ValidateDataStructure-Step
|
/** Used for testing - extra verbose mode causes the ValidateDataStructure-Step
|
||||||
* to be executed before and after every single postprocess step */
|
* to be executed before and after every single post-process step */
|
||||||
bool bExtraVerbose;
|
bool bExtraVerbose;
|
||||||
|
|
||||||
/** Used by post-process steps to share data */
|
/** Used by post-process steps to share data */
|
||||||
SharedPostProcessInfo* mPPShared;
|
SharedPostProcessInfo* mPPShared;
|
||||||
|
|
||||||
|
/// The default class constructor.
|
||||||
|
ImporterPimpl();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline
|
||||||
|
ImporterPimpl::ImporterPimpl()
|
||||||
|
: mIOHandler( nullptr )
|
||||||
|
, mIsDefaultHandler( false )
|
||||||
|
, mProgressHandler( nullptr )
|
||||||
|
, mIsDefaultProgressHandler( false )
|
||||||
|
, mImporter()
|
||||||
|
, mPostProcessingSteps()
|
||||||
|
, mScene( nullptr )
|
||||||
|
, mErrorString()
|
||||||
|
, mIntProperties()
|
||||||
|
, mFloatProperties()
|
||||||
|
, mStringProperties()
|
||||||
|
, mMatrixProperties()
|
||||||
|
, bExtraVerbose( false )
|
||||||
|
, mPPShared( nullptr ) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
//! @endcond
|
//! @endcond
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -439,8 +439,14 @@ void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4
|
||||||
void ObjExporter::AddNode(const aiNode* nd, const aiMatrix4x4& mParent) {
|
void ObjExporter::AddNode(const aiNode* nd, const aiMatrix4x4& mParent) {
|
||||||
const aiMatrix4x4& mAbs = mParent * nd->mTransformation;
|
const aiMatrix4x4& mAbs = mParent * nd->mTransformation;
|
||||||
|
|
||||||
|
aiMesh *cm( nullptr );
|
||||||
for(unsigned int i = 0; i < nd->mNumMeshes; ++i) {
|
for(unsigned int i = 0; i < nd->mNumMeshes; ++i) {
|
||||||
AddMesh(nd->mName, pScene->mMeshes[nd->mMeshes[i]], mAbs);
|
cm = pScene->mMeshes[nd->mMeshes[i]];
|
||||||
|
if (nullptr != cm) {
|
||||||
|
AddMesh(cm->mName, pScene->mMeshes[nd->mMeshes[i]], mAbs);
|
||||||
|
} else {
|
||||||
|
AddMesh(nd->mName, pScene->mMeshes[nd->mMeshes[i]], mAbs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(unsigned int i = 0; i < nd->mNumChildren; ++i) {
|
for(unsigned int i = 0; i < nd->mNumChildren; ++i) {
|
||||||
|
|
|
@ -73,28 +73,28 @@ using namespace Assimp;
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
OptimizeGraphProcess::OptimizeGraphProcess()
|
OptimizeGraphProcess::OptimizeGraphProcess()
|
||||||
: mScene()
|
: mScene()
|
||||||
, nodes_in()
|
, nodes_in()
|
||||||
, nodes_out()
|
, nodes_out()
|
||||||
, count_merged()
|
, count_merged() {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor, private as well
|
// Destructor, private as well
|
||||||
OptimizeGraphProcess::~OptimizeGraphProcess()
|
OptimizeGraphProcess::~OptimizeGraphProcess() {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the processing step is present in the given flag field.
|
// Returns whether the processing step is present in the given flag field.
|
||||||
bool OptimizeGraphProcess::IsActive( unsigned int pFlags) const
|
bool OptimizeGraphProcess::IsActive( unsigned int pFlags) const {
|
||||||
{
|
|
||||||
return (0 != (pFlags & aiProcess_OptimizeGraph));
|
return (0 != (pFlags & aiProcess_OptimizeGraph));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Setup properties for the postprocessing step
|
// Setup properties for the post-processing step
|
||||||
void OptimizeGraphProcess::SetupProperties(const Importer* pImp)
|
void OptimizeGraphProcess::SetupProperties(const Importer* pImp) {
|
||||||
{
|
|
||||||
// Get value of AI_CONFIG_PP_OG_EXCLUDE_LIST
|
// Get value of AI_CONFIG_PP_OG_EXCLUDE_LIST
|
||||||
std::string tmp = pImp->GetPropertyString(AI_CONFIG_PP_OG_EXCLUDE_LIST,"");
|
std::string tmp = pImp->GetPropertyString(AI_CONFIG_PP_OG_EXCLUDE_LIST,"");
|
||||||
AddLockedNodeList(tmp);
|
AddLockedNodeList(tmp);
|
||||||
|
@ -102,16 +102,14 @@ void OptimizeGraphProcess::SetupProperties(const Importer* pImp)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Collect new children
|
// Collect new children
|
||||||
void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& nodes)
|
void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& nodes) {
|
||||||
{
|
|
||||||
nodes_in += nd->mNumChildren;
|
nodes_in += nd->mNumChildren;
|
||||||
|
|
||||||
// Process children
|
// Process children
|
||||||
std::list<aiNode*> child_nodes;
|
std::list<aiNode*> child_nodes;
|
||||||
for (unsigned int i = 0; i < nd->mNumChildren; ++i) {
|
for (unsigned int i = 0; i < nd->mNumChildren; ++i) {
|
||||||
|
|
||||||
CollectNewChildren(nd->mChildren[i],child_nodes);
|
CollectNewChildren(nd->mChildren[i],child_nodes);
|
||||||
nd->mChildren[i] = NULL;
|
nd->mChildren[i] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether we need this node; if not we can replace it by our own children (warn, danger of incest).
|
// Check whether we need this node; if not we can replace it by our own children (warn, danger of incest).
|
||||||
|
@ -130,13 +128,11 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& no
|
||||||
|
|
||||||
if (nd->mNumMeshes || !child_nodes.empty()) {
|
if (nd->mNumMeshes || !child_nodes.empty()) {
|
||||||
nodes.push_back(nd);
|
nodes.push_back(nd);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
delete nd; /* bye, node */
|
delete nd; /* bye, node */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
// Retain our current position in the hierarchy
|
// Retain our current position in the hierarchy
|
||||||
nodes.push_back(nd);
|
nodes.push_back(nd);
|
||||||
|
@ -160,14 +156,11 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& no
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (n == child->mNumMeshes) {
|
if (n == child->mNumMeshes) {
|
||||||
|
|
||||||
if (!join_master) {
|
if (!join_master) {
|
||||||
join_master = child;
|
join_master = child;
|
||||||
inv = join_master->mTransformation;
|
inv = join_master->mTransformation;
|
||||||
inv.Inverse();
|
inv.Inverse();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
child->mTransformation = inv * child->mTransformation ;
|
child->mTransformation = inv * child->mTransformation ;
|
||||||
|
|
||||||
join.push_back(child);
|
join.push_back(child);
|
||||||
|
@ -227,9 +220,10 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& no
|
||||||
|
|
||||||
delete[] nd->mChildren;
|
delete[] nd->mChildren;
|
||||||
|
|
||||||
if (!child_nodes.empty())
|
if (!child_nodes.empty()) {
|
||||||
nd->mChildren = new aiNode*[child_nodes.size()];
|
nd->mChildren = new aiNode*[child_nodes.size()];
|
||||||
else nd->mChildren = NULL;
|
}
|
||||||
|
else nd->mChildren = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nd->mNumChildren = static_cast<unsigned int>(child_nodes.size());
|
nd->mNumChildren = static_cast<unsigned int>(child_nodes.size());
|
||||||
|
@ -246,9 +240,8 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& no
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Execute the postprocessing step on the given scene
|
// Execute the post-processing step on the given scene
|
||||||
void OptimizeGraphProcess::Execute( aiScene* pScene)
|
void OptimizeGraphProcess::Execute( aiScene* pScene) {
|
||||||
{
|
|
||||||
DefaultLogger::get()->debug("OptimizeGraphProcess begin");
|
DefaultLogger::get()->debug("OptimizeGraphProcess begin");
|
||||||
nodes_in = nodes_out = count_merged = 0;
|
nodes_in = nodes_out = count_merged = 0;
|
||||||
mScene = pScene;
|
mScene = pScene;
|
||||||
|
@ -268,7 +261,6 @@ void OptimizeGraphProcess::Execute( aiScene* pScene)
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pScene->mNumAnimations; ++i) {
|
for (unsigned int i = 0; i < pScene->mNumAnimations; ++i) {
|
||||||
for (unsigned int a = 0; a < pScene->mAnimations[i]->mNumChannels; ++a) {
|
for (unsigned int a = 0; a < pScene->mAnimations[i]->mNumChannels; ++a) {
|
||||||
|
|
||||||
aiNodeAnim* anim = pScene->mAnimations[i]->mChannels[a];
|
aiNodeAnim* anim = pScene->mAnimations[i]->mChannels[a];
|
||||||
locked.insert(AI_OG_GETKEY(anim->mNodeName));
|
locked.insert(AI_OG_GETKEY(anim->mNodeName));
|
||||||
}
|
}
|
||||||
|
@ -349,7 +341,7 @@ void OptimizeGraphProcess::Execute( aiScene* pScene)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Buidl a LUT of all instanced meshes
|
// Build a LUT of all instanced meshes
|
||||||
void OptimizeGraphProcess::FindInstancedMeshes (aiNode* pNode)
|
void OptimizeGraphProcess::FindInstancedMeshes (aiNode* pNode)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < pNode->mNumMeshes;++i) {
|
for (unsigned int i = 0; i < pNode->mNumMeshes;++i) {
|
||||||
|
|
|
@ -412,7 +412,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)
|
||||||
aim->mBitangents[i] = (aim->mNormals[i] ^ tangents[i].xyz) * tangents[i].w;
|
aim->mBitangents[i] = (aim->mNormals[i] ^ tangents[i].xyz) * tangents[i].w;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete tangents;
|
delete [] tangents;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue