Compare commits
2 Commits
master
...
kimkulling
Author | SHA1 | Date |
---|---|---|
Kim Kulling | d1e41aef21 | |
Kim Kulling | 2e6c92a797 |
|
@ -312,8 +312,6 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
|
||||||
|
|
||||||
child->mParent = last_parent;
|
child->mParent = last_parent;
|
||||||
last_parent = child.mNode;
|
last_parent = child.mNode;
|
||||||
|
|
||||||
new_abs_transform *= child->mTransformation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// attach geometry
|
// attach geometry
|
||||||
|
@ -336,8 +334,6 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
|
||||||
|
|
||||||
postnode->mParent = last_parent;
|
postnode->mParent = last_parent;
|
||||||
last_parent = postnode.mNode;
|
last_parent = postnode.mNode;
|
||||||
|
|
||||||
new_abs_transform *= postnode->mTransformation;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// free the nodes we allocated as we don't need them
|
// free the nodes we allocated as we don't need them
|
||||||
|
|
|
@ -78,15 +78,7 @@ static constexpr aiImporterDesc desc = {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Recursive parsing of LWS files
|
// Recursive parsing of LWS files
|
||||||
namespace {
|
void LWS::Element::Parse(const char *&buffer, const char *end) {
|
||||||
constexpr int MAX_DEPTH = 1000; // Define the maximum depth allowed
|
|
||||||
}
|
|
||||||
|
|
||||||
void LWS::Element::Parse(const char *&buffer, const char *end, int depth) {
|
|
||||||
if (depth > MAX_DEPTH) {
|
|
||||||
throw std::runtime_error("Maximum recursion depth exceeded in LWS::Element::Parse");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (; SkipSpacesAndLineEnd(&buffer, end); SkipLine(&buffer, end)) {
|
for (; SkipSpacesAndLineEnd(&buffer, end); SkipLine(&buffer, end)) {
|
||||||
|
|
||||||
// begin of a new element with children
|
// begin of a new element with children
|
||||||
|
@ -129,7 +121,7 @@ void LWS::Element::Parse(const char *&buffer, const char *end, int depth) {
|
||||||
|
|
||||||
// parse more elements recursively
|
// parse more elements recursively
|
||||||
if (sub) {
|
if (sub) {
|
||||||
children.back().Parse(buffer, end, depth + 1);
|
children.back().Parse(buffer, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
std::list<Element> children;
|
std::list<Element> children;
|
||||||
|
|
||||||
//! Recursive parsing function
|
//! Recursive parsing function
|
||||||
void Parse(const char *&buffer, const char *end, int depth = 0);
|
void Parse(const char *&buffer, const char *end);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define AI_LWS_MASK (0xffffffff >> 4u)
|
#define AI_LWS_MASK (0xffffffff >> 4u)
|
||||||
|
|
|
@ -724,7 +724,6 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
std::vector<unsigned char> mBuffer2(fileSize);
|
std::vector<unsigned char> mBuffer2(fileSize);
|
||||||
file->Read(&mBuffer2[0], 1, fileSize);
|
file->Read(&mBuffer2[0], 1, fileSize);
|
||||||
mBuffer = &mBuffer2[0];
|
mBuffer = &mBuffer2[0];
|
||||||
const unsigned char* bufferEnd = mBuffer + fileSize;
|
|
||||||
|
|
||||||
pcHeader = (BE_NCONST MD3::Header *)mBuffer;
|
pcHeader = (BE_NCONST MD3::Header *)mBuffer;
|
||||||
|
|
||||||
|
@ -750,15 +749,9 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
|
|
||||||
// Navigate to the list of surfaces
|
// Navigate to the list of surfaces
|
||||||
BE_NCONST MD3::Surface *pcSurfaces = (BE_NCONST MD3::Surface *)(mBuffer + pcHeader->OFS_SURFACES);
|
BE_NCONST MD3::Surface *pcSurfaces = (BE_NCONST MD3::Surface *)(mBuffer + pcHeader->OFS_SURFACES);
|
||||||
if ((const unsigned char*)pcSurfaces + sizeof(MD3::Surface) * pcHeader->NUM_SURFACES > bufferEnd) {
|
|
||||||
throw DeadlyImportError("MD3 surface headers are outside the file");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Navigate to the list of tags
|
// Navigate to the list of tags
|
||||||
BE_NCONST MD3::Tag *pcTags = (BE_NCONST MD3::Tag *)(mBuffer + pcHeader->OFS_TAGS);
|
BE_NCONST MD3::Tag *pcTags = (BE_NCONST MD3::Tag *)(mBuffer + pcHeader->OFS_TAGS);
|
||||||
if ((const unsigned char*)pcTags + sizeof(MD3::Tag) * pcHeader->NUM_TAGS > bufferEnd) {
|
|
||||||
throw DeadlyImportError("MD3 tags are outside the file");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allocate output storage
|
// Allocate output storage
|
||||||
pScene->mNumMeshes = pcHeader->NUM_SURFACES;
|
pScene->mNumMeshes = pcHeader->NUM_SURFACES;
|
||||||
|
@ -1033,10 +1026,6 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pcHeader->NUM_TAGS; ++i, ++pcTags) {
|
for (unsigned int i = 0; i < pcHeader->NUM_TAGS; ++i, ++pcTags) {
|
||||||
aiNode *nd = pScene->mRootNode->mChildren[i] = new aiNode();
|
aiNode *nd = pScene->mRootNode->mChildren[i] = new aiNode();
|
||||||
if ((const unsigned char*)pcTags + sizeof(MD3::Tag) > bufferEnd) {
|
|
||||||
throw DeadlyImportError("MD3 tag is outside the file");
|
|
||||||
}
|
|
||||||
|
|
||||||
nd->mName.Set((const char *)pcTags->NAME);
|
nd->mName.Set((const char *)pcTags->NAME);
|
||||||
nd->mParent = pScene->mRootNode;
|
nd->mParent = pScene->mRootNode;
|
||||||
|
|
||||||
|
|
|
@ -848,7 +848,11 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef ASSIMP_BUILD_DEBUG
|
#ifdef ASSIMP_BUILD_DEBUG
|
||||||
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
|
|
||||||
|
#ifdef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
|
||||||
|
continue;
|
||||||
|
#endif // no validation
|
||||||
|
|
||||||
// If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step
|
// If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step
|
||||||
if (pimpl->bExtraVerbose) {
|
if (pimpl->bExtraVerbose) {
|
||||||
ASSIMP_LOG_DEBUG("Verbose Import: re-validating data structures");
|
ASSIMP_LOG_DEBUG("Verbose Import: re-validating data structures");
|
||||||
|
@ -860,7 +864,6 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // no validation
|
|
||||||
#endif // ! DEBUG
|
#endif // ! DEBUG
|
||||||
}
|
}
|
||||||
pimpl->mProgressHandler->UpdatePostProcess( static_cast<int>(pimpl->mPostProcessingSteps.size()),
|
pimpl->mProgressHandler->UpdatePostProcess( static_cast<int>(pimpl->mPostProcessingSteps.size()),
|
||||||
|
@ -936,7 +939,6 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess
|
||||||
profiler->EndRegion( "postprocess" );
|
profiler->EndRegion( "postprocess" );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
|
|
||||||
// If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step
|
// If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step
|
||||||
if ( pimpl->bExtraVerbose || requestValidation ) {
|
if ( pimpl->bExtraVerbose || requestValidation ) {
|
||||||
ASSIMP_LOG_DEBUG( "Verbose Import: revalidating data structures" );
|
ASSIMP_LOG_DEBUG( "Verbose Import: revalidating data structures" );
|
||||||
|
@ -947,7 +949,6 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess
|
||||||
ASSIMP_LOG_ERROR( "Verbose Import: failed to revalidate data structures" );
|
ASSIMP_LOG_ERROR( "Verbose Import: failed to revalidate data structures" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // no validation
|
|
||||||
|
|
||||||
// clear any data allocated by post-process steps
|
// clear any data allocated by post-process steps
|
||||||
pimpl->mPPShared->Clean();
|
pimpl->mPPShared->Clean();
|
||||||
|
|
|
@ -65,47 +65,37 @@ void SortByPTypeProcess::SetupProperties(const Importer *pImp) {
|
||||||
mConfigRemoveMeshes = pImp->GetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, 0);
|
mConfigRemoveMeshes = pImp->GetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
static void clearMeshesInNode(aiNode *node) {
|
|
||||||
delete[] node->mMeshes;
|
|
||||||
node->mNumMeshes = 0;
|
|
||||||
node->mMeshes = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Update changed meshes in all nodes
|
// Update changed meshes in all nodes
|
||||||
void UpdateNodes(const std::vector<unsigned int> &replaceMeshIndex, aiNode *node) {
|
void UpdateNodes(const std::vector<unsigned int> &replaceMeshIndex, aiNode *node) {
|
||||||
ai_assert(node != nullptr);
|
|
||||||
|
|
||||||
if (node->mNumMeshes) {
|
if (node->mNumMeshes) {
|
||||||
unsigned int newSize = 0;
|
unsigned int newSize = 0;
|
||||||
for (unsigned int m = 0; m < node->mNumMeshes; ++m) {
|
for (unsigned int m = 0; m < node->mNumMeshes; ++m) {
|
||||||
unsigned int add = node->mMeshes[m] << 2;
|
unsigned int add = node->mMeshes[m] << 2;
|
||||||
for (unsigned int i = 0; i < 4; ++i) {
|
for (unsigned int i = 0; i < 4; ++i) {
|
||||||
if (UINT_MAX != replaceMeshIndex[add + i]) {
|
if (UINT_MAX != replaceMeshIndex[add + i]) ++newSize;
|
||||||
++newSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newSize == 0) {
|
if (!newSize) {
|
||||||
clearMeshesInNode(node);
|
delete[] node->mMeshes;
|
||||||
return;
|
node->mNumMeshes = 0;
|
||||||
}
|
node->mMeshes = nullptr;
|
||||||
|
} else {
|
||||||
// Try to reuse the old array if possible
|
// Try to reuse the old array if possible
|
||||||
unsigned int *newMeshes = (newSize > node->mNumMeshes ? new unsigned int[newSize] : node->mMeshes);
|
unsigned int *newMeshes = (newSize > node->mNumMeshes ? new unsigned int[newSize] : node->mMeshes);
|
||||||
for (unsigned int m = 0; m < node->mNumMeshes; ++m) {
|
|
||||||
unsigned int add = node->mMeshes[m] << 2;
|
for (unsigned int m = 0; m < node->mNumMeshes; ++m) {
|
||||||
for (unsigned int i = 0; i < 4; ++i) {
|
unsigned int add = node->mMeshes[m] << 2;
|
||||||
if (UINT_MAX != replaceMeshIndex[add + i]) {
|
for (unsigned int i = 0; i < 4; ++i) {
|
||||||
*newMeshes++ = replaceMeshIndex[add + i];
|
if (UINT_MAX != replaceMeshIndex[add + i])
|
||||||
|
*newMeshes++ = replaceMeshIndex[add + i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (newSize > node->mNumMeshes)
|
||||||
|
delete[] node->mMeshes;
|
||||||
|
|
||||||
|
node->mMeshes = newMeshes - (node->mNumMeshes = newSize);
|
||||||
}
|
}
|
||||||
if (newSize > node->mNumMeshes) {
|
|
||||||
clearMeshesInNode(node);
|
|
||||||
}
|
|
||||||
node->mMeshes = newMeshes - (node->mNumMeshes = newSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// call all subnodes recursively
|
// call all subnodes recursively
|
||||||
|
@ -177,10 +167,6 @@ void SortByPTypeProcess::Execute(aiScene *pScene) {
|
||||||
// with the largest number of primitives
|
// with the largest number of primitives
|
||||||
unsigned int aiNumPerPType[4] = { 0, 0, 0, 0 };
|
unsigned int aiNumPerPType[4] = { 0, 0, 0, 0 };
|
||||||
aiFace *pFirstFace = mesh->mFaces;
|
aiFace *pFirstFace = mesh->mFaces;
|
||||||
if (pFirstFace == nullptr) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
aiFace *const pLastFace = pFirstFace + mesh->mNumFaces;
|
aiFace *const pLastFace = pFirstFace + mesh->mNumFaces;
|
||||||
|
|
||||||
unsigned int numPolyVerts = 0;
|
unsigned int numPolyVerts = 0;
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_WIN32)
|
||||||
# pragma warning( disable: 4273)
|
# pragma warning( disable: 4273)
|
||||||
# define P2T_COMPILER_DLLEXPORT __declspec(dllexport)
|
# define P2T_COMPILER_DLLEXPORT __declspec(dllexport)
|
||||||
# define P2T_COMPILER_DLLIMPORT __declspec(dllimport)
|
# define P2T_COMPILER_DLLIMPORT __declspec(dllimport)
|
||||||
|
|
|
@ -701,7 +701,7 @@ struct aiMaterialProperty {
|
||||||
* Material data is stored using a key-value structure. A single key-value
|
* Material data is stored using a key-value structure. A single key-value
|
||||||
* pair is called a 'material property'. C++ users should use the provided
|
* pair is called a 'material property'. C++ users should use the provided
|
||||||
* member functions of aiMaterial to process material properties, C users
|
* member functions of aiMaterial to process material properties, C users
|
||||||
* have to stick with the aiGetMaterialXXX family of unbound functions.
|
* have to stick with the aiMaterialGetXXX family of unbound functions.
|
||||||
* The library defines a set of standard keys (AI_MATKEY_XXX).
|
* The library defines a set of standard keys (AI_MATKEY_XXX).
|
||||||
*/
|
*/
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Reference in New Issue