Updated assimp to latest

This commit is contained in:
Areloch 2019-03-05 14:39:38 -06:00
parent 25ce4477ce
commit 161bf7f83b
461 changed files with 34662 additions and 30165 deletions

View file

@ -3,7 +3,8 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
Copyright (c) 2006-2019, assimp team
All rights reserved.
@ -49,13 +50,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sstream>
#include <stdarg.h>
#include "ColladaParser.h"
#include "fast_atof.h"
#include "ParsingUtils.h"
#include "StringUtils.h"
#include <assimp/fast_atof.h>
#include <assimp/ParsingUtils.h>
#include <assimp/StringUtils.h>
#include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.hpp>
#include <assimp/light.h>
#include "TinyFormatter.h"
#include <assimp/TinyFormatter.h>
#include <memory>
@ -67,7 +68,7 @@ using namespace Assimp::Formatter;
// Constructor to be privately used by Importer
ColladaParser::ColladaParser( IOSystem* pIOHandler, const std::string& pFile)
: mFileName( pFile )
, mReader( NULL )
, mReader( nullptr )
, mDataLibrary()
, mAccessorLibrary()
, mMeshLibrary()
@ -78,20 +79,20 @@ ColladaParser::ColladaParser( IOSystem* pIOHandler, const std::string& pFile)
, mLightLibrary()
, mCameraLibrary()
, mControllerLibrary()
, mRootNode( NULL )
, mRootNode( nullptr )
, mAnims()
, mUnitSize( 1.0f )
, mUpDirection( UP_Y )
, mFormat(FV_1_5_n ) // We assume the newest file format by default
{
// validate io-handler instance
if ( NULL == pIOHandler ) {
if (nullptr == pIOHandler ) {
throw DeadlyImportError("IOSystem is NULL." );
}
// open the file
std::unique_ptr<IOStream> file( pIOHandler->Open(pFile ) );
if (file.get() == NULL) {
if (file.get() == nullptr) {
throw DeadlyImportError( "Failed to open file " + pFile + "." );
}
@ -151,22 +152,22 @@ void ColladaParser::ReadContents()
if (!::strncmp(version,"1.5",3)) {
mFormat = FV_1_5_n;
DefaultLogger::get()->debug("Collada schema version is 1.5.n");
ASSIMP_LOG_DEBUG("Collada schema version is 1.5.n");
}
else if (!::strncmp(version,"1.4",3)) {
mFormat = FV_1_4_n;
DefaultLogger::get()->debug("Collada schema version is 1.4.n");
ASSIMP_LOG_DEBUG("Collada schema version is 1.4.n");
}
else if (!::strncmp(version,"1.3",3)) {
mFormat = FV_1_3_n;
DefaultLogger::get()->debug("Collada schema version is 1.3.n");
ASSIMP_LOG_DEBUG("Collada schema version is 1.3.n");
}
}
ReadStructure();
} else
{
DefaultLogger::get()->debug( format() << "Ignoring global element <" << mReader->getNodeName() << ">." );
ASSIMP_LOG_DEBUG_F( "Ignoring global element <", mReader->getNodeName(), ">." );
SkipElement();
}
} else
@ -221,6 +222,7 @@ void ColladaParser::ReadStructure()
}
PostProcessRootAnimations();
PostProcessControllers();
}
// ------------------------------------------------------------------------------------------------
@ -359,6 +361,21 @@ void ColladaParser::ReadAnimationClipLibrary()
}
}
void ColladaParser::PostProcessControllers()
{
std::string meshId;
for (ControllerLibrary::iterator it = mControllerLibrary.begin(); it != mControllerLibrary.end(); ++it) {
meshId = it->second.mMeshId;
ControllerLibrary::iterator findItr = mControllerLibrary.find(meshId);
while(findItr != mControllerLibrary.end()) {
meshId = findItr->second.mMeshId;
findItr = mControllerLibrary.find(meshId);
}
it->second.mMeshId = meshId;
}
}
// ------------------------------------------------------------------------------------------------
// Re-build animations from animation clip library, if present, otherwise combine single-channel animations
void ColladaParser::PostProcessRootAnimations()
@ -967,13 +984,13 @@ void ColladaParser::ReadImage( Collada::Image& pImage)
// they're not skipped.
int attrib = TestAttribute("array_index");
if (attrib != -1 && mReader->getAttributeValueAsInt(attrib) > 0) {
DefaultLogger::get()->warn("Collada: Ignoring texture array index");
ASSIMP_LOG_WARN("Collada: Ignoring texture array index");
continue;
}
attrib = TestAttribute("mip_index");
if (attrib != -1 && mReader->getAttributeValueAsInt(attrib) > 0) {
DefaultLogger::get()->warn("Collada: Ignoring MIP map layer");
ASSIMP_LOG_WARN("Collada: Ignoring MIP map layer");
continue;
}
@ -994,7 +1011,7 @@ void ColladaParser::ReadImage( Collada::Image& pImage)
// embedded image. get format
const int attrib = TestAttribute("format");
if (-1 == attrib)
DefaultLogger::get()->warn("Collada: Unknown image file format");
ASSIMP_LOG_WARN("Collada: Unknown image file format");
else pImage.mEmbeddedFormat = mReader->getAttributeValue(attrib);
const char* data = GetTextContent();
@ -1573,7 +1590,7 @@ void ColladaParser::ReadSamplerProperties( Sampler& out )
out.mOp = aiTextureOp_Multiply;
else {
DefaultLogger::get()->warn("Collada: Unsupported MAYA texture blend mode");
ASSIMP_LOG_WARN("Collada: Unsupported MAYA texture blend mode");
}
TestClosing( "blend_mode");
}
@ -2345,7 +2362,7 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
if( expectedPointCount > 0 && indices.size() != expectedPointCount * numOffsets) {
if (pPrimType == Prim_Lines) {
// HACK: We just fix this number since SketchUp 15.3.331 writes the wrong 'count' for 'lines'
ReportWarning( "Expected different index count in <p> element, %d instead of %d.", indices.size(), expectedPointCount * numOffsets);
ReportWarning( "Expected different index count in <p> element, %zu instead of %zu.", indices.size(), expectedPointCount * numOffsets);
pNumPrimitives = (indices.size() / numOffsets) / 2;
} else
ThrowException( "Expected different index count in <p> element.");
@ -2524,7 +2541,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
if( pInput.mIndex == 0)
pMesh->mPositions.push_back( aiVector3D( obj[0], obj[1], obj[2]));
else
DefaultLogger::get()->error("Collada: just one vertex position stream supported");
ASSIMP_LOG_ERROR("Collada: just one vertex position stream supported");
break;
case IT_Normal:
// pad to current vertex count if necessary
@ -2535,7 +2552,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
if( pInput.mIndex == 0)
pMesh->mNormals.push_back( aiVector3D( obj[0], obj[1], obj[2]));
else
DefaultLogger::get()->error("Collada: just one vertex normal stream supported");
ASSIMP_LOG_ERROR("Collada: just one vertex normal stream supported");
break;
case IT_Tangent:
// pad to current vertex count if necessary
@ -2546,7 +2563,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
if( pInput.mIndex == 0)
pMesh->mTangents.push_back( aiVector3D( obj[0], obj[1], obj[2]));
else
DefaultLogger::get()->error("Collada: just one vertex tangent stream supported");
ASSIMP_LOG_ERROR("Collada: just one vertex tangent stream supported");
break;
case IT_Bitangent:
// pad to current vertex count if necessary
@ -2557,7 +2574,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
if( pInput.mIndex == 0)
pMesh->mBitangents.push_back( aiVector3D( obj[0], obj[1], obj[2]));
else
DefaultLogger::get()->error("Collada: just one vertex bitangent stream supported");
ASSIMP_LOG_ERROR("Collada: just one vertex bitangent stream supported");
break;
case IT_Texcoord:
// up to 4 texture coord sets are fine, ignore the others
@ -2573,7 +2590,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
pMesh->mNumUVComponents[pInput.mIndex]=3;
} else
{
DefaultLogger::get()->error("Collada: too many texture coordinate sets. Skipping.");
ASSIMP_LOG_ERROR("Collada: too many texture coordinate sets. Skipping.");
}
break;
case IT_Color:
@ -2593,7 +2610,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
pMesh->mColors[pInput.mIndex].push_back(result);
} else
{
DefaultLogger::get()->error("Collada: too many vertex color sets. Skipping.");
ASSIMP_LOG_ERROR("Collada: too many vertex color sets. Skipping.");
}
break;
@ -2722,7 +2739,7 @@ void ColladaParser::ReadSceneNode( Node* pNode)
{
const char* s = mReader->getAttributeValue(attrId);
if (s[0] != '#')
DefaultLogger::get()->error("Collada: Unresolved reference format of camera");
ASSIMP_LOG_ERROR("Collada: Unresolved reference format of camera");
else
pNode->mPrimaryCamera = s+1;
}
@ -2735,7 +2752,7 @@ void ColladaParser::ReadSceneNode( Node* pNode)
{
const char* s = mReader->getAttributeValue(attrID);
if (s[0] != '#')
DefaultLogger::get()->error("Collada: Unresolved reference format of node");
ASSIMP_LOG_ERROR("Collada: Unresolved reference format of node");
else
{
pNode->mNodeInstances.push_back(NodeInstance());
@ -2753,7 +2770,7 @@ void ColladaParser::ReadSceneNode( Node* pNode)
// Reference to a light, name given in 'url' attribute
int attrID = TestAttribute("url");
if (-1 == attrID)
DefaultLogger::get()->warn("Collada: Expected url attribute in <instance_light> element");
ASSIMP_LOG_WARN("Collada: Expected url attribute in <instance_light> element");
else
{
const char* url = mReader->getAttributeValue( attrID);
@ -2769,7 +2786,7 @@ void ColladaParser::ReadSceneNode( Node* pNode)
// Reference to a camera, name given in 'url' attribute
int attrID = TestAttribute("url");
if (-1 == attrID)
DefaultLogger::get()->warn("Collada: Expected url attribute in <instance_camera> element");
ASSIMP_LOG_WARN("Collada: Expected url attribute in <instance_camera> element");
else
{
const char* url = mReader->getAttributeValue( attrID);
@ -2856,7 +2873,7 @@ void ColladaParser::ReadMaterialVertexInputBinding( Collada::SemanticMappingTabl
tbl.mMap[s] = vn;
}
else if( IsElement( "bind")) {
DefaultLogger::get()->warn("Collada: Found unsupported <bind> element");
ASSIMP_LOG_WARN("Collada: Found unsupported <bind> element");
}
}
else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) {
@ -2975,10 +2992,9 @@ void ColladaParser::ReportWarning(const char* msg,...)
ai_assert(iLen > 0);
va_end(args);
DefaultLogger::get()->warn("Validation warning: " + std::string(szBuffer,iLen));
ASSIMP_LOG_WARN_F("Validation warning: ", std::string(szBuffer,iLen));
}
// ------------------------------------------------------------------------------------------------
// Skips all data until the end node of the current element
void ColladaParser::SkipElement()
@ -3089,7 +3105,7 @@ const char* ColladaParser::TestTextContent()
// read contents of the element
if( !mReader->read() )
return NULL;
if( mReader->getNodeType() != irr::io::EXN_TEXT)
if( mReader->getNodeType() != irr::io::EXN_TEXT && mReader->getNodeType() != irr::io::EXN_CDATA)
return NULL;
// skip leading whitespace
@ -3173,7 +3189,7 @@ aiMatrix4x4 ColladaParser::CalculateResultTransform( const std::vector<Transform
Collada::InputType ColladaParser::GetTypeForSemantic( const std::string& semantic)
{
if ( semantic.empty() ) {
DefaultLogger::get()->warn( format() << "Vertex input type is empty." );
ASSIMP_LOG_WARN("Vertex input type is empty." );
return IT_Invalid;
}
@ -3192,7 +3208,7 @@ Collada::InputType ColladaParser::GetTypeForSemantic( const std::string& semanti
else if( semantic == "TANGENT" || semantic == "TEXTANGENT")
return IT_Tangent;
DefaultLogger::get()->warn( format() << "Unknown vertex input type \"" << semantic << "\". Ignoring." );
ASSIMP_LOG_WARN_F( "Unknown vertex input type \"", semantic, "\". Ignoring." );
return IT_Invalid;
}