diff --git a/.gitattributes b/.gitattributes
index 7f9357f62..f3df90d38 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -13,3 +13,10 @@ CHANGES text eol=lf
CREDITS text eol=lf
LICENSE text eol=lf
Readme.md text eol=lf
+# make sure that repo-specific settings (.gitignore, CI-setup,...)
+# are excluded from the source-package generated via 'git archive'
+.git* export-ignore
+/.travis* export-ignore
+/.coveralls* export-ignore
+appveyor.yml export-ignore
+
diff --git a/.travis.yml b/.travis.yml
index ffebab3cb..38849dae4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,14 +28,16 @@ env:
- secure: "lZ7pHQvl5dpZWzBQAaIMf0wqrvtcZ4wiZKeIZjf83TEsflW8+z0uTpIuN30ZV6Glth/Sq1OhLnTP5+N57fZU/1ebA5twHdvP4bS5CIUUg71/CXQZNl36xeaqvxsG/xRrdpKOsPdjAOsQ9KPTQulsX43XDLS7CasMiLvYOpqKcPc="
- PV=r8e PLATF=linux-x86_64 NDK_HOME=${TRAVIS_BUILD_DIR}/android-ndk-${PV} PATH=${PATH}:${NDK_HOME}
matrix:
- - LINUX=1 TRAVIS_NO_EXPORT=YES ENABLE_COVERALLS=ON
- - LINUX=1 TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF
- - LINUX=1 SHARED_BUILD=ON ENABLE_COVERALLS=OFF
- - LINUX=1 SHARED_BUILD=OFF ENABLE_COVERALLS=OFF
-
-compiler:
- - gcc
- - clang
+ - os: linux LINUX=1 TRAVIS_NO_EXPORT=YES ENABLE_COVERALLS=ON
+ compiler: gcc
+ - os: linux LINUX=1 TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF
+ compiler: clang
+ - os: linux LINUX=1 SHARED_BUILD=ON TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF
+ compiler: gcc
+ - os: linux LINUX=1 SHARED_BUILD=ON TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF
+ compiler: clang
+ - os: osx
+ osx_image: xcode8.2
install:
- if [ $ANDROID ]; then wget -c http://dl.google.com/android/ndk/android-ndk-${PV}-${PLATF}.tar.bz2 && tar xf android-ndk-${PV}-${PLATF}.tar.bz2 ; fi
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 676a48385..690351e8b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -148,6 +148,12 @@ find_package(OpenMP)
if (OPENMP_FOUND)
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+
+ IF(MSVC)
+ IF(MSVC_VERSION GREATER 1910)
+ SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:twoPhase-")
+ ENDIF()
+ ENDIF()
endif()
CONFIGURE_FILE(
diff --git a/Readme.md b/Readme.md
index d09208203..a5c31881a 100644
--- a/Readme.md
+++ b/Readme.md
@@ -8,7 +8,6 @@ A library to import and export various 3d-model-formats including scene-post-pro
-
[![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master)
[![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -19,6 +18,11 @@ Additionally, assimp features various __mesh post processing tools__: normals an
This is the development repo containing the latest features and bugfixes. For productive use though, we recommend one of the stable releases available from [Github Assimp Releases](https://github.com/assimp/assimp/releases).
+Monthly donations via Patreon:
+
[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/assimp)
+
+
+
One-off donations via PayPal:
[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4)
@@ -114,6 +118,8 @@ Take a look into the `INSTALL` file. Our build system is CMake, if you used CMak
* [.NET](port/AssimpNET/Readme.md)
* [Pascal](port/AssimpPascal/Readme.md)
* [Javascript (Alpha)](https://github.com/makc/assimp2json)
+* [Unity 3d Plugin] (https://www.assetstore.unity3d.com/en/#!/content/91777)
+* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (currently supported obj, ply, stl, ~collada)
### Other tools ###
[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.
diff --git a/code/3DSConverter.cpp b/code/3DSConverter.cpp
index da8c918a7..820c28f90 100644
--- a/code/3DSConverter.cpp
+++ b/code/3DSConverter.cpp
@@ -56,18 +56,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
+static const unsigned int NotSet = 0xcdcdcdcd;
+
// ------------------------------------------------------------------------------------------------
// Setup final material indices, generae a default material if necessary
void Discreet3DSImporter::ReplaceDefaultMaterial()
{
-
// Try to find an existing material that matches the
// typical default material setting:
// - no textures
// - diffuse color (in grey!)
// NOTE: This is here to workaround the fact that some
// exporters are writing a default material, too.
- unsigned int idx = 0xcdcdcdcd;
+ unsigned int idx( NotSet );
for (unsigned int i = 0; i < mScene->mMaterials.size();++i)
{
std::string s = mScene->mMaterials[i].mName;
@@ -93,7 +94,9 @@ void Discreet3DSImporter::ReplaceDefaultMaterial()
}
idx = i;
}
- if (0xcdcdcdcd == idx)idx = (unsigned int)mScene->mMaterials.size();
+ if ( NotSet == idx ) {
+ idx = ( unsigned int )mScene->mMaterials.size();
+ }
// now iterate through all meshes and through all faces and
// find all faces that are using the default material
diff --git a/code/AssbinExporter.cpp b/code/AssbinExporter.cpp
index e97f27a8a..4ea261718 100644
--- a/code/AssbinExporter.cpp
+++ b/code/AssbinExporter.cpp
@@ -325,7 +325,7 @@ inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size)
{
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODE );
- size_t nb_metadata = (node->mMetaData != NULL ? node->mMetaData->mNumProperties : 0);
+ unsigned int nb_metadata = (node->mMetaData != NULL ? node->mMetaData->mNumProperties : 0);
Write(&chunk,node->mName);
Write(&chunk,node->mTransformation);
diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp
index 745975e5d..06604bc8e 100644
--- a/code/ColladaExporter.cpp
+++ b/code/ColladaExporter.cpp
@@ -866,8 +866,8 @@ void ColladaExporter::WriteController( size_t pIndex)
std::vector bind_poses;
bind_poses.reserve(mesh->mNumBones * 16);
- for( size_t i = 0; i < mesh->mNumBones; ++i)
- for( size_t j = 0; j < 4; ++j)
+ for(unsigned int i = 0; i < mesh->mNumBones; ++i)
+ for( unsigned int j = 0; j < 4; ++j)
bind_poses.insert(bind_poses.end(), mesh->mBones[i]->mOffsetMatrix[j], mesh->mBones[i]->mOffsetMatrix[j] + 4);
WriteFloatArray( idstr + "-skin-bind_poses", FloatType_Mat4x4, (const ai_real*) bind_poses.data(), bind_poses.size() / 16);
@@ -924,11 +924,11 @@ void ColladaExporter::WriteController( size_t pIndex)
ai_uint weight_index = 0;
std::vector joint_weight_indices(2 * joint_weight_indices_length, (ai_int)-1);
- for( size_t i = 0; i < mesh->mNumBones; ++i)
- for( size_t j = 0; j < mesh->mBones[i]->mNumWeights; ++j)
+ for( unsigned int i = 0; i < mesh->mNumBones; ++i)
+ for( unsigned j = 0; j < mesh->mBones[i]->mNumWeights; ++j)
{
unsigned int vId = mesh->mBones[i]->mWeights[j].mVertexId;
- for( size_t k = 0; k < num_influences[vId]; ++k)
+ for( ai_uint k = 0; k < num_influences[vId]; ++k)
{
if (joint_weight_indices[2 * (accum_influences[vId] + k)] == -1)
{
diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp
index c68eb27c9..f7ef903f4 100644
--- a/code/ColladaLoader.cpp
+++ b/code/ColladaLoader.cpp
@@ -728,7 +728,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
? aiMorphingMethod_MORPH_RELATIVE
: aiMorphingMethod_MORPH_NORMALIZED;
dstMesh->mAnimMeshes = new aiAnimMesh*[animMeshes.size()];
- dstMesh->mNumAnimMeshes = animMeshes.size();
+ dstMesh->mNumAnimMeshes = static_cast(animMeshes.size());
for (unsigned int i = 0; i < animMeshes.size(); i++)
dstMesh->mAnimMeshes[i] = animMeshes.at(i);
}
@@ -1377,9 +1377,9 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
{
aiNodeAnim* dstAnim = new aiNodeAnim;
dstAnim->mNodeName = nodeName;
- dstAnim->mNumPositionKeys = resultTrafos.size();
- dstAnim->mNumRotationKeys= resultTrafos.size();
- dstAnim->mNumScalingKeys = resultTrafos.size();
+ dstAnim->mNumPositionKeys = static_cast(resultTrafos.size());
+ dstAnim->mNumRotationKeys = static_cast(resultTrafos.size());
+ dstAnim->mNumScalingKeys = static_cast(resultTrafos.size());
dstAnim->mPositionKeys = new aiVectorKey[resultTrafos.size()];
dstAnim->mRotationKeys = new aiQuatKey[resultTrafos.size()];
dstAnim->mScalingKeys = new aiVectorKey[resultTrafos.size()];
@@ -1445,11 +1445,11 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
++morphAnimChannelIndex;
}
- morphAnim->mNumKeys = morphTimeValues.size();
+ morphAnim->mNumKeys = static_cast(morphTimeValues.size());
morphAnim->mKeys = new aiMeshMorphKey[morphAnim->mNumKeys];
for (unsigned int key = 0; key < morphAnim->mNumKeys; key++)
{
- morphAnim->mKeys[key].mNumValuesAndWeights = morphChannels.size();
+ morphAnim->mKeys[key].mNumValuesAndWeights = static_cast(morphChannels.size());
morphAnim->mKeys[key].mValues = new unsigned int [morphChannels.size()];
morphAnim->mKeys[key].mWeights = new double [morphChannels.size()];
@@ -1470,13 +1470,13 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
{
aiAnimation* anim = new aiAnimation;
anim->mName.Set( pName);
- anim->mNumChannels = anims.size();
+ anim->mNumChannels = static_cast(anims.size());
if (anim->mNumChannels > 0)
{
anim->mChannels = new aiNodeAnim*[anims.size()];
std::copy( anims.begin(), anims.end(), anim->mChannels);
}
- anim->mNumMorphMeshChannels = morphAnims.size();
+ anim->mNumMorphMeshChannels = static_cast(morphAnims.size());
if (anim->mNumMorphMeshChannels > 0)
{
anim->mMorphMeshChannels = new aiMeshMorphAnim*[anim->mNumMorphMeshChannels];
diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp
index dbbbdcb18..7b6592351 100644
--- a/code/ColladaParser.cpp
+++ b/code/ColladaParser.cpp
@@ -2231,7 +2231,7 @@ void ColladaParser::ReadIndexData( Mesh* pMesh)
}
#ifdef ASSIMP_BUILD_DEBUG
- if (primType != Prim_TriFans && primType != Prim_TriStrips &&
+ if (primType != Prim_TriFans && primType != Prim_TriStrips && primType != Prim_LineStrip &&
primType != Prim_Lines) { // this is ONLY to workaround a bug in SketchUp 15.3.331 where it writes the wrong 'count' when it writes out the 'lines'.
ai_assert(actualPrimitives == numPrimitives);
}
@@ -2400,6 +2400,10 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector& pP
size_t numberOfVertices = indices.size() / numOffsets;
numPrimitives = numberOfVertices - 2;
}
+ if (pPrimType == Prim_LineStrip) {
+ size_t numberOfVertices = indices.size() / numOffsets;
+ numPrimitives = numberOfVertices - 1;
+ }
pMesh->mFaceSize.reserve( numPrimitives);
pMesh->mFacePosIndices.reserve( indices.size() / numOffsets);
@@ -2416,6 +2420,11 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector& pP
for (size_t currentVertex = 0; currentVertex < numPoints; currentVertex++)
CopyVertex(currentVertex, numOffsets, numPoints, perVertexOffset, pMesh, pPerIndexChannels, currentPrimitive, indices);
break;
+ case Prim_LineStrip:
+ numPoints = 2;
+ for (size_t currentVertex = 0; currentVertex < numPoints; currentVertex++)
+ CopyVertex(currentVertex, numOffsets, 1, perVertexOffset, pMesh, pPerIndexChannels, currentPrimitive, indices);
+ break;
case Prim_Triangles:
numPoints = 3;
for (size_t currentVertex = 0; currentVertex < numPoints; currentVertex++)
diff --git a/code/D3MFImporter.cpp b/code/D3MFImporter.cpp
index 0f06d4a1e..e97e22859 100644
--- a/code/D3MFImporter.cpp
+++ b/code/D3MFImporter.cpp
@@ -95,14 +95,10 @@ public:
XmlSerializer(XmlReader* xmlReader)
: xmlReader(xmlReader)
{
-
+ // empty
}
- void ImportXml(aiScene* scene)
- {
-
- scene->mFlags |= AI_SCENE_FLAGS_NON_VERBOSE_FORMAT;
-
+ void ImportXml(aiScene* scene) {
scene->mRootNode = new aiNode();
std::vector children;
diff --git a/code/FBXBinaryTokenizer.cpp b/code/FBXBinaryTokenizer.cpp
index a02458fa5..46e85d888 100644
--- a/code/FBXBinaryTokenizer.cpp
+++ b/code/FBXBinaryTokenizer.cpp
@@ -56,47 +56,46 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
namespace FBX {
-enum Flag
-{
- e_unknown_0 = 1 << 0,
- e_unknown_1 = 1 << 1,
- e_unknown_2 = 1 << 2,
- e_unknown_3 = 1 << 3,
- e_unknown_4 = 1 << 4,
- e_unknown_5 = 1 << 5,
- e_unknown_6 = 1 << 6,
- e_unknown_7 = 1 << 7,
- e_unknown_8 = 1 << 8,
- e_unknown_9 = 1 << 9,
- e_unknown_10 = 1 << 10,
- e_unknown_11 = 1 << 11,
- e_unknown_12 = 1 << 12,
- e_unknown_13 = 1 << 13,
- e_unknown_14 = 1 << 14,
- e_unknown_15 = 1 << 15,
- e_unknown_16 = 1 << 16,
- e_unknown_17 = 1 << 17,
- e_unknown_18 = 1 << 18,
- e_unknown_19 = 1 << 19,
- e_unknown_20 = 1 << 20,
- e_unknown_21 = 1 << 21,
- e_unknown_22 = 1 << 22,
- e_unknown_23 = 1 << 23,
- e_flag_field_size_64_bit = 1 << 24, // Not sure what is
- e_unknown_25 = 1 << 25,
- e_unknown_26 = 1 << 26,
- e_unknown_27 = 1 << 27,
- e_unknown_28 = 1 << 28,
- e_unknown_29 = 1 << 29,
- e_unknown_30 = 1 << 30,
- e_unknown_31 = 1 << 31
-};
-
-bool check_flag(uint32_t flags, Flag to_check)
-{
- return (flags & to_check) != 0;
-}
-
+//enum Flag
+//{
+// e_unknown_0 = 1 << 0,
+// e_unknown_1 = 1 << 1,
+// e_unknown_2 = 1 << 2,
+// e_unknown_3 = 1 << 3,
+// e_unknown_4 = 1 << 4,
+// e_unknown_5 = 1 << 5,
+// e_unknown_6 = 1 << 6,
+// e_unknown_7 = 1 << 7,
+// e_unknown_8 = 1 << 8,
+// e_unknown_9 = 1 << 9,
+// e_unknown_10 = 1 << 10,
+// e_unknown_11 = 1 << 11,
+// e_unknown_12 = 1 << 12,
+// e_unknown_13 = 1 << 13,
+// e_unknown_14 = 1 << 14,
+// e_unknown_15 = 1 << 15,
+// e_unknown_16 = 1 << 16,
+// e_unknown_17 = 1 << 17,
+// e_unknown_18 = 1 << 18,
+// e_unknown_19 = 1 << 19,
+// e_unknown_20 = 1 << 20,
+// e_unknown_21 = 1 << 21,
+// e_unknown_22 = 1 << 22,
+// e_unknown_23 = 1 << 23,
+// e_flag_field_size_64_bit = 1 << 24, // Not sure what is
+// e_unknown_25 = 1 << 25,
+// e_unknown_26 = 1 << 26,
+// e_unknown_27 = 1 << 27,
+// e_unknown_28 = 1 << 28,
+// e_unknown_29 = 1 << 29,
+// e_unknown_30 = 1 << 30,
+// e_unknown_31 = 1 << 31
+//};
+//
+//bool check_flag(uint32_t flags, Flag to_check)
+//{
+// return (flags & to_check) != 0;
+//}
// ------------------------------------------------------------------------------------------------
Token::Token(const char* sbegin, const char* send, TokenType type, unsigned int offset)
:
@@ -341,10 +340,10 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
// ------------------------------------------------------------------------------------------------
-bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor, const char* end, uint32_t const flags)
+bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor, const char* end, bool const is64bits)
{
// the first word contains the offset at which this block ends
- const uint64_t end_offset = /*check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) : */ReadWord(input, cursor, end);
+ const uint64_t end_offset = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end);
// we may get 0 if reading reached the end of the file -
// fbx files have a mysterious extra footer which I don't know
@@ -362,10 +361,10 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
}
// the second data word contains the number of properties in the scope
- const uint64_t prop_count = /*check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) : */ReadWord(input, cursor, end);
+ const uint64_t prop_count = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end);
// the third data word contains the length of the property list
- const uint64_t prop_length = /*check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) :*/ ReadWord(input, cursor, end);
+ const uint64_t prop_length = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end);
// now comes the name of the scope/key
const char* sbeg, *send;
@@ -392,7 +391,7 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
// at the end of each nested block, there is a NUL record to indicate
// that the sub-scope exists (i.e. to distinguish between P: and P : {})
// this NUL record is 13 bytes long on 32 bit version and 25 bytes long on 64 bit.
- const size_t sentinel_block_length = /*check_flag(flags, e_flag_field_size_64_bit) ? (sizeof(uint64_t) * 3 + 1) : */(sizeof(uint32_t) * 3 + 1);
+ const size_t sentinel_block_length = is64bits ? (sizeof(uint64_t)* 3 + 1) : (sizeof(uint32_t)* 3 + 1);
if (Offset(input, cursor) < end_offset) {
if (end_offset - Offset(input, cursor) < sentinel_block_length) {
@@ -403,7 +402,7 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
// XXX this is vulnerable to stack overflowing ..
while(Offset(input, cursor) < end_offset - sentinel_block_length) {
- ReadScope(output_tokens, input, cursor, input + end_offset - sentinel_block_length, flags);
+ ReadScope(output_tokens, input, cursor, input + end_offset - sentinel_block_length, is64bits);
}
output_tokens.push_back(new_Token(cursor, cursor + 1, TokenType_CLOSE_BRACKET, Offset(input, cursor) ));
@@ -426,6 +425,7 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
}
// ------------------------------------------------------------------------------------------------
+// TODO: Test FBX Binary files newer than the 7500 version to check if the 64 bits address behaviour is consistent
void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int length)
{
ai_assert(input);
@@ -438,19 +438,17 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int le
TokenizeError("magic bytes not found",0);
}
-
- //uint32_t offset = 0x15;
- const char* cursor = input + 0x15;
-
- const uint32_t flags = ReadWord(input, cursor, input + length);
-
- const uint8_t padding_0 = ReadByte(input, cursor, input + length); // unused
- (void) padding_0;
- const uint8_t padding_1 = ReadByte(input, cursor, input + length); // unused
- (void) padding_1;
+ const char* cursor = input + 18;
+ const uint8_t unknown_1 = ReadByte(input, cursor, input + length);
+ const uint8_t unknown_2 = ReadByte(input, cursor, input + length);
+ const uint8_t unknown_3 = ReadByte(input, cursor, input + length);
+ const uint8_t unknown_4 = ReadByte(input, cursor, input + length);
+ const uint8_t unknown_5 = ReadByte(input, cursor, input + length);
+ const uint32_t version = ReadWord(input, cursor, input + length);
+ const bool is64bits = version >= 7500;
while (cursor < input + length)
{
- if(!ReadScope(output_tokens, input, cursor, input + length, flags)) {
+ if (!ReadScope(output_tokens, input, cursor, input + length, is64bits)) {
break;
}
}
diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp
index ff355100f..7f79aeb04 100644
--- a/code/FBXConverter.cpp
+++ b/code/FBXConverter.cpp
@@ -2367,8 +2367,13 @@ void Converter::ConvertAnimationStack( const AnimationStack& st )
int64_t start_time = st.LocalStart();
int64_t stop_time = st.LocalStop();
- double start_timeF = CONVERT_FBX_TIME( start_time );
- double stop_timeF = CONVERT_FBX_TIME( stop_time );
+ bool has_local_startstop = start_time != 0 || stop_time != 0;
+ if ( !has_local_startstop ) {
+ // no time range given, so accept every keyframe and use the actual min/max time
+ // the numbers are INT64_MIN/MAX, the 20000 is for safety because GenerateNodeAnimations uses an epsilon of 10000
+ start_time = -9223372036854775807ll + 20000;
+ stop_time = 9223372036854775807ll - 20000;
+ }
try {
for( const NodeMap::value_type& kv : node_map ) {
@@ -2400,27 +2405,23 @@ void Converter::ConvertAnimationStack( const AnimationStack& st )
return;
}
- //adjust relative timing for animation
- {
- double start_fps = start_timeF * anim_fps;
+ double start_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(start_time) * anim_fps) : min_time;
+ double stop_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(stop_time) * anim_fps) : max_time;
- for ( unsigned int c = 0; c < anim->mNumChannels; c++ )
- {
- aiNodeAnim* channel = anim->mChannels[ c ];
- for ( uint32_t i = 0; i < channel->mNumPositionKeys; i++ )
- channel->mPositionKeys[ i ].mTime -= start_fps;
- for ( uint32_t i = 0; i < channel->mNumRotationKeys; i++ )
- channel->mRotationKeys[ i ].mTime -= start_fps;
- for ( uint32_t i = 0; i < channel->mNumScalingKeys; i++ )
- channel->mScalingKeys[ i ].mTime -= start_fps;
- }
-
- max_time -= min_time;
+ // adjust relative timing for animation
+ for ( unsigned int c = 0; c < anim->mNumChannels; c++ ) {
+ aiNodeAnim* channel = anim->mChannels[ c ];
+ for ( uint32_t i = 0; i < channel->mNumPositionKeys; i++ )
+ channel->mPositionKeys[ i ].mTime -= start_time_fps;
+ for ( uint32_t i = 0; i < channel->mNumRotationKeys; i++ )
+ channel->mRotationKeys[ i ].mTime -= start_time_fps;
+ for ( uint32_t i = 0; i < channel->mNumScalingKeys; i++ )
+ channel->mScalingKeys[ i ].mTime -= start_time_fps;
}
// for some mysterious reason, mDuration is simply the maximum key -- the
// validator always assumes animations to start at zero.
- anim->mDuration = ( stop_timeF - start_timeF ) * anim_fps;
+ anim->mDuration = stop_time_fps - start_time_fps;
anim->mTicksPerSecond = anim_fps;
}
diff --git a/code/IFCProfile.cpp b/code/IFCProfile.cpp
index e94d98a04..595159a6b 100644
--- a/code/IFCProfile.cpp
+++ b/code/IFCProfile.cpp
@@ -128,7 +128,7 @@ void ProcessParametrizedProfile(const IfcParameterizedProfileDef& def, TempMesh&
meshout.verts.push_back( IfcVector3( std::cos(angle)*radius, std::sin(angle)*radius, 0.f ));
}
- meshout.vertcnt.push_back(segments);
+ meshout.vertcnt.push_back(static_cast(segments));
}
else if( const IfcIShapeProfileDef* const ishape = def.ToPtr()) {
// construct simplified IBeam shape
diff --git a/code/MDLFileData.h b/code/MDLFileData.h
index a691851be..2afea8a95 100644
--- a/code/MDLFileData.h
+++ b/code/MDLFileData.h
@@ -164,7 +164,7 @@ struct Header {
//! Could be the total size of the file (and not a float)
float size;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@@ -223,7 +223,7 @@ struct Header_MDL7 {
//! Size of the Frame_MDL7 data structure used in the file
uint16_t frame_stc_size;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@@ -242,7 +242,7 @@ struct Bone_MDL7 {
//! Optional name of the bone
char name[1 /* DUMMY SIZE */];
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
#if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS)
# define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS (16 + 20)
@@ -290,7 +290,7 @@ struct Group_MDL7 {
//! Number of frames
int32_t numframes;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
#define AI_MDL7_SKINTYPE_MIPFLAG 0x08
#define AI_MDL7_SKINTYPE_MATERIAL 0x10
@@ -312,7 +312,7 @@ struct Deformer_MDL7 {
int32_t group_index;
int32_t elements;
int32_t deformerdata_size;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@@ -324,7 +324,7 @@ struct DeformerElement_MDL7 {
int32_t element_index;
char element_name[AI_MDL7_MAX_BONENAMESIZE];
int32_t weights;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct DeformerWeight_MDL7
@@ -334,7 +334,7 @@ struct DeformerWeight_MDL7 {
//! for deformer_typ==0 (==bones) index == vertex index
int32_t index;
float weight;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// don't know why this was in the original headers ...
typedef int32_t MD7_MATERIAL_ASCDEFSIZE;
@@ -345,7 +345,7 @@ typedef int32_t MD7_MATERIAL_ASCDEFSIZE;
*/
struct ColorValue_MDL7 {
float r,g,b,a;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Material_MDL7
@@ -366,7 +366,7 @@ struct Material_MDL7 {
//! Phong power
float Power;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Skin
@@ -388,7 +388,7 @@ struct Skin {
//! Texture data
uint8_t *data;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@@ -399,7 +399,7 @@ struct Skin {
struct Skin_MDL5 {
int32_t size, width, height;
uint8_t *data;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// maximum length of texture file name
#if (!defined AI_MDL7_MAX_TEXNAMESIZE)
@@ -416,7 +416,7 @@ struct Skin_MDL7 {
int32_t width;
int32_t height;
char texture_name[AI_MDL7_MAX_TEXNAMESIZE];
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct RGB565
@@ -426,7 +426,7 @@ struct RGB565 {
uint16_t r : 5;
uint16_t g : 6;
uint16_t b : 5;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct ARGB4
@@ -455,7 +455,7 @@ struct GroupSkin {
//! Data of each image
uint8_t **data;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct TexCoord
@@ -470,7 +470,7 @@ struct TexCoord {
//! Texture coordinate in the ty direction
int32_t t;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct TexCoord_MDL3
@@ -482,7 +482,7 @@ struct TexCoord_MDL3 {
//! position, vertically in range 0..skinheight-1
int16_t v;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct TexCoord_MDL7
@@ -494,7 +494,7 @@ struct TexCoord_MDL7 {
//! position, vertically in range 0..1
float v;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct SkinSet_MDL7
@@ -510,7 +510,7 @@ struct SkinSet_MDL7
//! Material index
int32_t material; // size 4
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Triangle
@@ -523,7 +523,7 @@ struct Triangle
//! Vertex indices
int32_t vertex[3];
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Triangle_MDL3
@@ -536,7 +536,7 @@ struct Triangle_MDL3
//! Index of 3 skin vertices in range 0..numskinverts
uint16_t index_uv[3];
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Triangle_MDL7
@@ -549,7 +549,7 @@ struct Triangle_MDL7
//! Two skinsets. The second will be used for multi-texturing
SkinSet_MDL7 skinsets[2];
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
#if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV)
# define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV (6+sizeof(SkinSet_MDL7)-sizeof(uint32_t))
@@ -577,7 +577,7 @@ struct Vertex
{
uint8_t v[3];
uint8_t normalIndex;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@@ -603,7 +603,7 @@ struct Vertex_MDL7
uint8_t norm162index;
float norm[3];
};
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct BoneTransform_MDL7
@@ -620,7 +620,7 @@ struct BoneTransform_MDL7
//! I HATE 3DGS AND THE SILLY DEVELOPER WHO DESIGNED
//! THIS STUPID FILE FORMAT!
int8_t _unused_[2];
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
#define AI_MDL7_MAX_FRAMENAMESIZE 16
@@ -654,7 +654,7 @@ struct SimpleFrame
//! Vertex list of the frame
Vertex *verts;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Frame
@@ -667,7 +667,7 @@ struct Frame
//! Frame data
SimpleFrame frame;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@@ -684,7 +684,7 @@ struct SimpleFrame_MDLn_SP
//! Vertex list of the frame
Vertex_MDL4 *verts;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct GroupFrame
@@ -706,7 +706,7 @@ struct GroupFrame
//! List of single frames
SimpleFrame *frames;
-} /* PACK_STRUCT */;
+} PACK_STRUCT;
#include "./../include/assimp/Compiler/poppack1.h"
diff --git a/code/MMDImporter.cpp b/code/MMDImporter.cpp
index 149761c34..84797cba2 100644
--- a/code/MMDImporter.cpp
+++ b/code/MMDImporter.cpp
@@ -278,7 +278,7 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
bone_vertex_map[vsBDEF2_ptr->bone_index1].push_back(
aiVertexWeight(index, vsBDEF2_ptr->bone_weight));
bone_vertex_map[vsBDEF2_ptr->bone_index2].push_back(
- aiVertexWeight(index, 1.0 - vsBDEF2_ptr->bone_weight));
+ aiVertexWeight(index, 1.0f - vsBDEF2_ptr->bone_weight));
break;
case pmx::PmxVertexSkinningType::BDEF4:
bone_vertex_map[vsBDEF4_ptr->bone_index1].push_back(
@@ -295,7 +295,7 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
bone_vertex_map[vsSDEF_ptr->bone_index1].push_back(
aiVertexWeight(index, vsSDEF_ptr->bone_weight));
bone_vertex_map[vsSDEF_ptr->bone_index2].push_back(
- aiVertexWeight(index, 1.0 - vsSDEF_ptr->bone_weight));
+ aiVertexWeight(index, 1.0f - vsSDEF_ptr->bone_weight));
break;
case pmx::PmxVertexSkinningType::QDEF:
const auto vsQDEF_ptr =
@@ -325,7 +325,7 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
aiMatrix4x4::Translation(-pos, pBone->mOffsetMatrix);
auto it = bone_vertex_map.find(ii);
if (it != bone_vertex_map.end()) {
- pBone->mNumWeights = it->second.size();
+ pBone->mNumWeights = static_cast(it->second.size());
pBone->mWeights = it->second.data();
it->second.swap(*(new vector));
}
diff --git a/code/ObjFileMtlImporter.cpp b/code/ObjFileMtlImporter.cpp
index 69f35a67d..36bb6c2cb 100644
--- a/code/ObjFileMtlImporter.cpp
+++ b/code/ObjFileMtlImporter.cpp
@@ -304,7 +304,7 @@ void ObjFileMtlImporter::createMaterial()
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
if (m_pModel->m_pCurrentMesh) {
- m_pModel->m_pCurrentMesh->m_uiMaterialIndex = m_pModel->m_MaterialLib.size() - 1;
+ m_pModel->m_pCurrentMesh->m_uiMaterialIndex = static_cast(m_pModel->m_MaterialLib.size() - 1);
}
m_pModel->m_MaterialLib.push_back( name );
m_pModel->m_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;
diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp
index dfa77dba2..41677fce5 100644
--- a/code/ObjFileParser.cpp
+++ b/code/ObjFileParser.cpp
@@ -555,10 +555,15 @@ void ObjFileParser::getMaterialDesc() {
// Search for material
std::map::iterator it = m_pModel->m_MaterialMap.find(strName);
if (it == m_pModel->m_MaterialMap.end()) {
- // Not found, use default material
- m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
- DefaultLogger::get()->error("OBJ: failed to locate material " + strName + ", skipping");
- strName = m_pModel->m_pDefaultMaterial->MaterialName.C_Str();
+ // Not found, so we don't know anything about the material except for its name.
+ // This may be the case if the material library is missing. We don't want to lose all
+ // materials if that happens, so create a new named material instead of discarding it
+ // completely.
+ DefaultLogger::get()->error("OBJ: failed to locate material " + strName + ", creating new material");
+ m_pModel->m_pCurrentMaterial = new ObjFile::Material();
+ m_pModel->m_pCurrentMaterial->MaterialName.Set(strName);
+ m_pModel->m_MaterialLib.push_back(strName);
+ m_pModel->m_MaterialMap[strName] = m_pModel->m_pCurrentMaterial;
} else {
// Found, using detected material
m_pModel->m_pCurrentMaterial = (*it).second;
diff --git a/code/PlyLoader.cpp b/code/PlyLoader.cpp
index 090473893..d348fe113 100644
--- a/code/PlyLoader.cpp
+++ b/code/PlyLoader.cpp
@@ -538,7 +538,7 @@ void PLYImporter::LoadFace(const PLY::Element* pcElement, const PLY::ElementInst
ai_assert(NULL != instElement);
if (mGeneratedMesh == NULL)
- throw DeadlyImportError("Invalid .ply file: Vertices shoud be declared before faces");
+ throw DeadlyImportError("Invalid .ply file: Vertices should be declared before faces");
bool bOne = false;
diff --git a/code/PlyParser.cpp b/code/PlyParser.cpp
index d978b513b..f4b68a83f 100644
--- a/code/PlyParser.cpp
+++ b/code/PlyParser.cpp
@@ -618,7 +618,7 @@ bool PLY::DOM::ParseInstanceBinary(IOStreamBuffer &streamBuffer, DOM* p_pc
}
streamBuffer.getNextBlock(buffer);
- unsigned int bufferSize = buffer.size();
+ unsigned int bufferSize = static_cast(buffer.size());
const char* pCur = (char*)&buffer[0];
if (!p_pcOut->ParseElementInstanceListsBinary(streamBuffer, buffer, pCur, bufferSize, loader, p_bBE))
{
@@ -1025,7 +1025,7 @@ bool PLY::PropertyInstance::ParseValueBinary(IOStreamBuffer &streamBuffer,
buffer = std::vector(buffer.end() - bufferSize, buffer.end());
buffer.insert(buffer.end(), nbuffer.begin(), nbuffer.end());
nbuffer.clear();
- bufferSize = buffer.size();
+ bufferSize = static_cast(buffer.size());
pCur = (char*)&buffer[0];
}
else
diff --git a/code/PretransformVertices.cpp b/code/PretransformVertices.cpp
index 1339053f7..7bfed4292 100644
--- a/code/PretransformVertices.cpp
+++ b/code/PretransformVertices.cpp
@@ -160,6 +160,11 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
unsigned int& num_ref = num_refs[pcNode->mMeshes[i]];
ai_assert(0 != num_ref);
--num_ref;
+ // Save the name of the last mesh
+ if (num_ref==0)
+ {
+ pcMeshOut->mName = pcMesh->mName;
+ }
if (identity) {
// copy positions without modifying them
@@ -626,9 +631,10 @@ void PretransformVertices::Execute( aiScene* pScene)
// now delete all nodes in the scene and build a new
// flat node graph with a root node and some level 1 children
+ aiNode* newRoot = new aiNode();
+ newRoot->mName = pScene->mRootNode->mName;
delete pScene->mRootNode;
pScene->mRootNode = new aiNode();
- pScene->mRootNode->mName.Set("");
if (1 == pScene->mNumMeshes && !pScene->mNumLights && !pScene->mNumCameras)
{
@@ -646,7 +652,7 @@ void PretransformVertices::Execute( aiScene* pScene)
{
aiNode* pcNode = *nodes = new aiNode();
pcNode->mParent = pScene->mRootNode;
- pcNode->mName.length = ::ai_snprintf(pcNode->mName.data,MAXLEN,"mesh_%u",i);
+ pcNode->mName = pScene->mMeshes[i]->mName;
// setup mesh indices
pcNode->mNumMeshes = 1;
diff --git a/code/Q3BSPZipArchive.cpp b/code/Q3BSPZipArchive.cpp
index 86f399659..7428c04c3 100644
--- a/code/Q3BSPZipArchive.cpp
+++ b/code/Q3BSPZipArchive.cpp
@@ -39,14 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-
-
#ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
#include "Q3BSPZipArchive.h"
-#include
#include
-#include
#include
namespace Assimp {
@@ -137,7 +133,6 @@ zlib_filefunc_def IOSystem2Unzip::get(IOSystem* pIOHandler) {
return mapping;
}
-// ------------------------------------------------------------------------------------------------
ZipFile::ZipFile(size_t size) : m_Size(size) {
ai_assert(m_Size != 0);
diff --git a/code/Q3BSPZipArchive.h b/code/Q3BSPZipArchive.h
index 280c44fc0..5430bac6f 100644
--- a/code/Q3BSPZipArchive.h
+++ b/code/Q3BSPZipArchive.h
@@ -44,7 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
#include
#include
-#include
#include
#include