summaryrefslogtreecommitdiff
path: root/thirdparty/assimp/code
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-11-06 12:55:45 +0100
committerGitHub <noreply@github.com>2019-11-06 12:55:45 +0100
commitb30e6496bdc640422b5d708f27acb860a927425f (patch)
treed1eba0971b63f8f8e39e6f2752fc8d9944960318 /thirdparty/assimp/code
parent245c99175c242bdc60a212cc84986b1a9ad5aa08 (diff)
parent5fb160c7c692c469488f11aca90a36ac3248dfee (diff)
Merge pull request #33347 from RevoluPowered/demo/assimp-importer-fbx
FBX Skinning and batch of fixes
Diffstat (limited to 'thirdparty/assimp/code')
-rw-r--r--thirdparty/assimp/code/Common/BaseImporter.cpp17
-rw-r--r--thirdparty/assimp/code/Common/DefaultIOSystem.cpp161
-rw-r--r--thirdparty/assimp/code/Common/Exporter.cpp42
-rw-r--r--thirdparty/assimp/code/Common/ImporterRegistry.cpp6
-rw-r--r--thirdparty/assimp/code/Common/PostStepRegistry.cpp7
-rw-r--r--thirdparty/assimp/code/Common/SceneCombiner.cpp50
-rw-r--r--thirdparty/assimp/code/Common/Version.cpp14
-rw-r--r--thirdparty/assimp/code/Common/scene.cpp18
-rw-r--r--thirdparty/assimp/code/FBX/FBXCompileConfig.h8
-rw-r--r--thirdparty/assimp/code/FBX/FBXConverter.cpp345
-rw-r--r--thirdparty/assimp/code/FBX/FBXConverter.h94
-rw-r--r--thirdparty/assimp/code/FBX/FBXDocument.h39
-rw-r--r--thirdparty/assimp/code/FBX/FBXExportProperty.cpp6
-rw-r--r--thirdparty/assimp/code/FBX/FBXExporter.cpp122
-rw-r--r--thirdparty/assimp/code/FBX/FBXExporter.h2
-rw-r--r--thirdparty/assimp/code/FBX/FBXImporter.cpp217
-rw-r--r--thirdparty/assimp/code/FBX/FBXMeshGeometry.cpp20
-rw-r--r--thirdparty/assimp/code/MMD/MMDCpp14.h83
-rw-r--r--thirdparty/assimp/code/MMD/MMDImporter.cpp372
-rw-r--r--thirdparty/assimp/code/MMD/MMDImporter.h96
-rw-r--r--thirdparty/assimp/code/MMD/MMDPmdParser.h597
-rw-r--r--thirdparty/assimp/code/MMD/MMDPmxParser.cpp608
-rw-r--r--thirdparty/assimp/code/MMD/MMDPmxParser.h782
-rw-r--r--thirdparty/assimp/code/MMD/MMDVmdParser.h376
-rw-r--r--thirdparty/assimp/code/Material/MaterialSystem.cpp19
-rw-r--r--thirdparty/assimp/code/PostProcessing/ArmaturePopulate.cpp268
-rw-r--r--thirdparty/assimp/code/PostProcessing/ArmaturePopulate.h112
-rw-r--r--thirdparty/assimp/code/PostProcessing/ComputeUVMappingProcess.cpp6
-rw-r--r--thirdparty/assimp/code/PostProcessing/FindInvalidDataProcess.cpp1
-rw-r--r--thirdparty/assimp/code/PostProcessing/JoinVerticesProcess.cpp25
-rw-r--r--thirdparty/assimp/code/PostProcessing/MakeVerboseFormat.cpp29
-rw-r--r--thirdparty/assimp/code/PostProcessing/MakeVerboseFormat.h7
-rw-r--r--thirdparty/assimp/code/PostProcessing/ValidateDataStructure.cpp63
-rw-r--r--thirdparty/assimp/code/PostProcessing/ValidateDataStructure.h8
-rw-r--r--thirdparty/assimp/code/revision.h23
35 files changed, 1199 insertions, 3444 deletions
diff --git a/thirdparty/assimp/code/Common/BaseImporter.cpp b/thirdparty/assimp/code/Common/BaseImporter.cpp
index de5018a250..5c1e605549 100644
--- a/thirdparty/assimp/code/Common/BaseImporter.cpp
+++ b/thirdparty/assimp/code/Common/BaseImporter.cpp
@@ -67,7 +67,20 @@ using namespace Assimp;
// Constructor to be privately used by Importer
BaseImporter::BaseImporter() AI_NO_EXCEPT
: m_progress() {
- // nothing to do here
+ /**
+ * Assimp Importer
+ * unit conversions available
+ * if you need another measurment unit add it below.
+ * it's currently defined in assimp that we prefer meters.
+ *
+ * NOTE: Initialised here rather than in the header file
+ * to workaround a VS2013 bug with brace initialisers
+ * */
+ importerUnits[ImporterUnits::M] = 1.0;
+ importerUnits[ImporterUnits::CM] = 0.01;
+ importerUnits[ImporterUnits::MM] = 0.001;
+ importerUnits[ImporterUnits::INCHES] = 0.0254;
+ importerUnits[ImporterUnits::FEET] = 0.3048;
}
// ------------------------------------------------------------------------------------------------
@@ -85,7 +98,7 @@ void BaseImporter::UpdateImporterScale( Importer* pImp )
double activeScale = importerScale * fileScale;
// Set active scaling
- pImp->SetPropertyFloat( AI_CONFIG_APP_SCALE_KEY, activeScale);
+ pImp->SetPropertyFloat( AI_CONFIG_APP_SCALE_KEY, static_cast<float>( activeScale) );
ASSIMP_LOG_DEBUG_F("UpdateImporterScale scale set: %f", activeScale );
}
diff --git a/thirdparty/assimp/code/Common/DefaultIOSystem.cpp b/thirdparty/assimp/code/Common/DefaultIOSystem.cpp
index d40b67de32..6fdc24dd80 100644
--- a/thirdparty/assimp/code/Common/DefaultIOSystem.cpp
+++ b/thirdparty/assimp/code/Common/DefaultIOSystem.cpp
@@ -61,83 +61,66 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
-// maximum path length
-// XXX http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
-#ifdef PATH_MAX
-# define PATHLIMIT PATH_MAX
-#else
-# define PATHLIMIT 4096
+#ifdef _WIN32
+static std::wstring Utf8ToWide(const char* in)
+{
+ int size = MultiByteToWideChar(CP_UTF8, 0, in, -1, nullptr, 0);
+ // size includes terminating null; std::wstring adds null automatically
+ std::wstring out(static_cast<size_t>(size) - 1, L'\0');
+ MultiByteToWideChar(CP_UTF8, 0, in, -1, &out[0], size);
+ return out;
+}
+
+static std::string WideToUtf8(const wchar_t* in)
+{
+ int size = WideCharToMultiByte(CP_UTF8, 0, in, -1, nullptr, 0, nullptr, nullptr);
+ // size includes terminating null; std::string adds null automatically
+ std::string out(static_cast<size_t>(size) - 1, '\0');
+ WideCharToMultiByte(CP_UTF8, 0, in, -1, &out[0], size, nullptr, nullptr);
+ return out;
+}
#endif
// ------------------------------------------------------------------------------------------------
// Tests for the existence of a file at the given path.
-bool DefaultIOSystem::Exists( const char* pFile) const
+bool DefaultIOSystem::Exists(const char* pFile) const
{
#ifdef _WIN32
- wchar_t fileName16[PATHLIMIT];
-
-#ifndef WindowsStore
- bool isUnicode = IsTextUnicode(pFile, static_cast<int>(strlen(pFile)), NULL) != 0;
- if (isUnicode) {
-
- MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, pFile, -1, fileName16, PATHLIMIT);
- struct __stat64 filestat;
- if (0 != _wstat64(fileName16, &filestat)) {
- return false;
- }
- } else {
-#endif
- FILE* file = ::fopen(pFile, "rb");
- if (!file)
- return false;
-
- ::fclose(file);
-#ifndef WindowsStore
+ struct __stat64 filestat;
+ if (_wstat64(Utf8ToWide(pFile).c_str(), &filestat) != 0) {
+ return false;
}
-#endif
#else
- FILE* file = ::fopen( pFile, "rb");
- if( !file)
+ FILE* file = ::fopen(pFile, "rb");
+ if (!file)
return false;
- ::fclose( file);
+ ::fclose(file);
#endif
return true;
}
// ------------------------------------------------------------------------------------------------
// Open a new file with a given path.
-IOStream* DefaultIOSystem::Open( const char* strFile, const char* strMode)
+IOStream* DefaultIOSystem::Open(const char* strFile, const char* strMode)
{
- ai_assert(NULL != strFile);
- ai_assert(NULL != strMode);
+ ai_assert(strFile != nullptr);
+ ai_assert(strMode != nullptr);
FILE* file;
#ifdef _WIN32
- wchar_t fileName16[PATHLIMIT];
-#ifndef WindowsStore
- bool isUnicode = IsTextUnicode(strFile, static_cast<int>(strlen(strFile)), NULL) != 0;
- if (isUnicode) {
- MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, strFile, -1, fileName16, PATHLIMIT);
- std::string mode8(strMode);
- file = ::_wfopen(fileName16, std::wstring(mode8.begin(), mode8.end()).c_str());
- } else {
-#endif
- file = ::fopen(strFile, strMode);
-#ifndef WindowsStore
- }
-#endif
+ file = ::_wfopen(Utf8ToWide(strFile).c_str(), Utf8ToWide(strMode).c_str());
#else
file = ::fopen(strFile, strMode);
#endif
- if (nullptr == file)
+ if (!file)
return nullptr;
- return new DefaultIOStream(file, (std::string) strFile);
+ return new DefaultIOStream(file, strFile);
}
// ------------------------------------------------------------------------------------------------
// Closes the given file and releases all resources associated with it.
-void DefaultIOSystem::Close( IOStream* pFile)
+void DefaultIOSystem::Close(IOStream* pFile)
{
delete pFile;
}
@@ -155,78 +138,56 @@ char DefaultIOSystem::getOsSeparator() const
// ------------------------------------------------------------------------------------------------
// IOSystem default implementation (ComparePaths isn't a pure virtual function)
-bool IOSystem::ComparePaths (const char* one, const char* second) const
+bool IOSystem::ComparePaths(const char* one, const char* second) const
{
- return !ASSIMP_stricmp(one,second);
+ return !ASSIMP_stricmp(one, second);
}
// ------------------------------------------------------------------------------------------------
// Convert a relative path into an absolute path
-inline static void MakeAbsolutePath (const char* in, char* _out)
+inline static std::string MakeAbsolutePath(const char* in)
{
- ai_assert(in && _out);
-#if defined( _MSC_VER ) || defined( __MINGW32__ )
-#ifndef WindowsStore
- bool isUnicode = IsTextUnicode(in, static_cast<int>(strlen(in)), NULL) != 0;
- if (isUnicode) {
- wchar_t out16[PATHLIMIT];
- wchar_t in16[PATHLIMIT];
- MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, in, -1, out16, PATHLIMIT);
- wchar_t* ret = ::_wfullpath(out16, in16, PATHLIMIT);
- if (ret) {
- WideCharToMultiByte(CP_UTF8, MB_PRECOMPOSED, out16, -1, _out, PATHLIMIT, nullptr, nullptr);
- }
- if (!ret) {
- // preserve the input path, maybe someone else is able to fix
- // the path before it is accessed (e.g. our file system filter)
- ASSIMP_LOG_WARN_F("Invalid path: ", std::string(in));
- strcpy(_out, in);
- }
-
- } else {
-#endif
- char* ret = :: _fullpath(_out, in, PATHLIMIT);
- if (!ret) {
- // preserve the input path, maybe someone else is able to fix
- // the path before it is accessed (e.g. our file system filter)
- ASSIMP_LOG_WARN_F("Invalid path: ", std::string(in));
- strcpy(_out, in);
- }
-#ifndef WindowsStore
+ ai_assert(in);
+ std::string out;
+#ifdef _WIN32
+ wchar_t* ret = ::_wfullpath(nullptr, Utf8ToWide(in).c_str(), 0);
+ if (ret) {
+ out = WideToUtf8(ret);
+ free(ret);
}
-#endif
#else
- // use realpath
- char* ret = realpath(in, _out);
- if(!ret) {
+ char* ret = realpath(in, nullptr);
+ if (ret) {
+ out = ret;
+ free(ret);
+ }
+#endif
+ if (!ret) {
// preserve the input path, maybe someone else is able to fix
// the path before it is accessed (e.g. our file system filter)
ASSIMP_LOG_WARN_F("Invalid path: ", std::string(in));
- strcpy(_out,in);
+ out = in;
}
-#endif
+ return out;
}
// ------------------------------------------------------------------------------------------------
// DefaultIOSystem's more specialized implementation
-bool DefaultIOSystem::ComparePaths (const char* one, const char* second) const
+bool DefaultIOSystem::ComparePaths(const char* one, const char* second) const
{
// chances are quite good both paths are formatted identically,
// so we can hopefully return here already
- if( !ASSIMP_stricmp(one,second) )
+ if (!ASSIMP_stricmp(one, second))
return true;
- char temp1[PATHLIMIT];
- char temp2[PATHLIMIT];
-
- MakeAbsolutePath (one, temp1);
- MakeAbsolutePath (second, temp2);
+ std::string temp1 = MakeAbsolutePath(one);
+ std::string temp2 = MakeAbsolutePath(second);
- return !ASSIMP_stricmp(temp1,temp2);
+ return !ASSIMP_stricmp(temp1, temp2);
}
// ------------------------------------------------------------------------------------------------
-std::string DefaultIOSystem::fileName( const std::string &path )
+std::string DefaultIOSystem::fileName(const std::string& path)
{
std::string ret = path;
std::size_t last = ret.find_last_of("\\/");
@@ -235,16 +196,16 @@ std::string DefaultIOSystem::fileName( const std::string &path )
}
// ------------------------------------------------------------------------------------------------
-std::string DefaultIOSystem::completeBaseName( const std::string &path )
+std::string DefaultIOSystem::completeBaseName(const std::string& path)
{
std::string ret = fileName(path);
std::size_t pos = ret.find_last_of('.');
- if(pos != ret.npos) ret = ret.substr(0, pos);
+ if (pos != std::string::npos) ret = ret.substr(0, pos);
return ret;
}
// ------------------------------------------------------------------------------------------------
-std::string DefaultIOSystem::absolutePath( const std::string &path )
+std::string DefaultIOSystem::absolutePath(const std::string& path)
{
std::string ret = path;
std::size_t last = ret.find_last_of("\\/");
@@ -253,5 +214,3 @@ std::string DefaultIOSystem::absolutePath( const std::string &path )
}
// ------------------------------------------------------------------------------------------------
-
-#undef PATHLIMIT
diff --git a/thirdparty/assimp/code/Common/Exporter.cpp b/thirdparty/assimp/code/Common/Exporter.cpp
index 090b561ae0..4ce1a2bd80 100644
--- a/thirdparty/assimp/code/Common/Exporter.cpp
+++ b/thirdparty/assimp/code/Common/Exporter.cpp
@@ -102,6 +102,8 @@ void ExportSceneX3D(const char*, IOSystem*, const aiScene*, const ExportProperti
void ExportSceneFBX(const char*, IOSystem*, const aiScene*, const ExportProperties*);
void ExportSceneFBXA(const char*, IOSystem*, const aiScene*, const ExportProperties*);
void ExportScene3MF( const char*, IOSystem*, const aiScene*, const ExportProperties* );
+void ExportSceneM3D(const char*, IOSystem*, const aiScene*, const ExportProperties*);
+void ExportSceneA3D(const char*, IOSystem*, const aiScene*, const ExportProperties*);
void ExportAssimp2Json(const char* , IOSystem*, const aiScene* , const Assimp::ExportProperties*);
// ------------------------------------------------------------------------------------------------
@@ -179,6 +181,11 @@ Exporter::ExportFormatEntry gExporters[] =
Exporter::ExportFormatEntry( "fbxa", "Autodesk FBX (ascii)", "fbx", &ExportSceneFBXA, 0 ),
#endif
+#ifndef ASSIMP_BUILD_NO_M3D_EXPORTER
+ Exporter::ExportFormatEntry( "m3d", "Model 3D (binary)", "m3d", &ExportSceneM3D, 0 ),
+ Exporter::ExportFormatEntry( "a3d", "Model 3D (ascii)", "m3d", &ExportSceneA3D, 0 ),
+#endif
+
#ifndef ASSIMP_BUILD_NO_3MF_EXPORTER
Exporter::ExportFormatEntry( "3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0 ),
#endif
@@ -316,34 +323,6 @@ const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const cha
}
// ------------------------------------------------------------------------------------------------
-bool IsVerboseFormat(const aiMesh* mesh) {
- // avoid slow vector<bool> specialization
- std::vector<unsigned int> seen(mesh->mNumVertices,0);
- for(unsigned int i = 0; i < mesh->mNumFaces; ++i) {
- const aiFace& f = mesh->mFaces[i];
- for(unsigned int j = 0; j < f.mNumIndices; ++j) {
- if(++seen[f.mIndices[j]] == 2) {
- // found a duplicate index
- return false;
- }
- }
- }
-
- return true;
-}
-
-// ------------------------------------------------------------------------------------------------
-bool IsVerboseFormat(const aiScene* pScene) {
- for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
- if(!IsVerboseFormat(pScene->mMeshes[i])) {
- return false;
- }
- }
-
- return true;
-}
-
-// ------------------------------------------------------------------------------------------------
aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const char* pPath,
unsigned int pPreprocessing, const ExportProperties* pProperties) {
ASSIMP_BEGIN_EXCEPTION_REGION();
@@ -352,7 +331,7 @@ aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const c
// format. They will likely not be aware that there is a flag in the scene to indicate
// this, however. To avoid surprises and bug reports, we check for duplicates in
// meshes upfront.
- const bool is_verbose_format = !(pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) || IsVerboseFormat(pScene);
+ const bool is_verbose_format = !(pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) || MakeVerboseFormatProcess::IsVerboseFormat(pScene);
pimpl->mProgressHandler->UpdateFileWrite(0, 4);
@@ -472,7 +451,10 @@ aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const c
}
ExportProperties emptyProperties; // Never pass NULL ExportProperties so Exporters don't have to worry.
- exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get(), pProperties ? pProperties : &emptyProperties);
+ ExportProperties* pProp = pProperties ? (ExportProperties*)pProperties : &emptyProperties;
+ pProp->SetPropertyBool("bJoinIdenticalVertices", must_join_again);
+ exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get(), pProp);
+ exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get(), pProp);
pimpl->mProgressHandler->UpdateFileWrite(4, 4);
} catch (DeadlyExportError& err) {
diff --git a/thirdparty/assimp/code/Common/ImporterRegistry.cpp b/thirdparty/assimp/code/Common/ImporterRegistry.cpp
index 32ac3b4168..b9f28f0356 100644
--- a/thirdparty/assimp/code/Common/ImporterRegistry.cpp
+++ b/thirdparty/assimp/code/Common/ImporterRegistry.cpp
@@ -197,6 +197,9 @@ corresponding preprocessor flag to selectively disable formats.
#ifndef ASSIMP_BUILD_NO_MMD_IMPORTER
# include "MMD/MMDImporter.h"
#endif
+#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
+# include "M3D/M3DImporter.h"
+#endif
#ifndef ASSIMP_BUILD_NO_STEP_IMPORTER
# include "Importer/StepFile/StepFileImporter.h"
#endif
@@ -223,6 +226,9 @@ void GetImporterInstanceList(std::vector< BaseImporter* >& out)
#if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
out.push_back( new Discreet3DSImporter());
#endif
+#if (!defined ASSIMP_BUILD_NO_M3D_IMPORTER)
+ out.push_back( new M3DImporter());
+#endif
#if (!defined ASSIMP_BUILD_NO_MD3_IMPORTER)
out.push_back( new MD3Importer());
#endif
diff --git a/thirdparty/assimp/code/Common/PostStepRegistry.cpp b/thirdparty/assimp/code/Common/PostStepRegistry.cpp
index ef58f8ddfd..8ff4af0400 100644
--- a/thirdparty/assimp/code/Common/PostStepRegistry.cpp
+++ b/thirdparty/assimp/code/Common/PostStepRegistry.cpp
@@ -131,11 +131,15 @@ corresponding preprocessor flag to selectively disable steps.
#if (!defined ASSIMP_BUILD_NO_GLOBALSCALE_PROCESS)
# include "PostProcessing/ScaleProcess.h"
#endif
+#if (!defined ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS)
+# include "PostProcessing/ArmaturePopulate.h"
+#endif
#if (!defined ASSIMP_BUILD_NO_GENBOUNDINGBOXES_PROCESS)
# include "PostProcessing/GenBoundingBoxesProcess.h"
#endif
+
namespace Assimp {
// ------------------------------------------------------------------------------------------------
@@ -180,6 +184,9 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out)
#if (!defined ASSIMP_BUILD_NO_GLOBALSCALE_PROCESS)
out.push_back( new ScaleProcess());
#endif
+#if (!defined ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS)
+ out.push_back( new ArmaturePopulate());
+#endif
#if (!defined ASSIMP_BUILD_NO_PRETRANSFORMVERTICES_PROCESS)
out.push_back( new PretransformVertices());
#endif
diff --git a/thirdparty/assimp/code/Common/SceneCombiner.cpp b/thirdparty/assimp/code/Common/SceneCombiner.cpp
index e445bd7434..f7b13cc951 100644
--- a/thirdparty/assimp/code/Common/SceneCombiner.cpp
+++ b/thirdparty/assimp/code/Common/SceneCombiner.cpp
@@ -1091,6 +1091,35 @@ void SceneCombiner::Copy( aiMesh** _dest, const aiMesh* src ) {
aiFace& f = dest->mFaces[i];
GetArrayCopy(f.mIndices,f.mNumIndices);
}
+
+ // make a deep copy of all blend shapes
+ CopyPtrArray(dest->mAnimMeshes, dest->mAnimMeshes, dest->mNumAnimMeshes);
+}
+
+// ------------------------------------------------------------------------------------------------
+void SceneCombiner::Copy(aiAnimMesh** _dest, const aiAnimMesh* src) {
+ if (nullptr == _dest || nullptr == src) {
+ return;
+ }
+
+ aiAnimMesh* dest = *_dest = new aiAnimMesh();
+
+ // get a flat copy
+ ::memcpy(dest, src, sizeof(aiAnimMesh));
+
+ // and reallocate all arrays
+ GetArrayCopy(dest->mVertices, dest->mNumVertices);
+ GetArrayCopy(dest->mNormals, dest->mNumVertices);
+ GetArrayCopy(dest->mTangents, dest->mNumVertices);
+ GetArrayCopy(dest->mBitangents, dest->mNumVertices);
+
+ unsigned int n = 0;
+ while (dest->HasTextureCoords(n))
+ GetArrayCopy(dest->mTextureCoords[n++], dest->mNumVertices);
+
+ n = 0;
+ while (dest->HasVertexColors(n))
+ GetArrayCopy(dest->mColors[n++], dest->mNumVertices);
}
// ------------------------------------------------------------------------------------------------
@@ -1167,6 +1196,7 @@ void SceneCombiner::Copy( aiAnimation** _dest, const aiAnimation* src ) {
// and reallocate all arrays
CopyPtrArray( dest->mChannels, src->mChannels, dest->mNumChannels );
+ CopyPtrArray( dest->mMorphMeshChannels, src->mMorphMeshChannels, dest->mNumMorphMeshChannels );
}
// ------------------------------------------------------------------------------------------------
@@ -1186,6 +1216,26 @@ void SceneCombiner::Copy(aiNodeAnim** _dest, const aiNodeAnim* src) {
GetArrayCopy( dest->mRotationKeys, dest->mNumRotationKeys );
}
+void SceneCombiner::Copy(aiMeshMorphAnim** _dest, const aiMeshMorphAnim* src) {
+ if ( nullptr == _dest || nullptr == src ) {
+ return;
+ }
+
+ aiMeshMorphAnim* dest = *_dest = new aiMeshMorphAnim();
+
+ // get a flat copy
+ ::memcpy(dest,src,sizeof(aiMeshMorphAnim));
+
+ // and reallocate all arrays
+ GetArrayCopy( dest->mKeys, dest->mNumKeys );
+ for (ai_uint i = 0; i < dest->mNumKeys;++i) {
+ dest->mKeys[i].mValues = new unsigned int[dest->mKeys[i].mNumValuesAndWeights];
+ dest->mKeys[i].mWeights = new double[dest->mKeys[i].mNumValuesAndWeights];
+ ::memcpy(dest->mKeys[i].mValues, src->mKeys[i].mValues, dest->mKeys[i].mNumValuesAndWeights * sizeof(unsigned int));
+ ::memcpy(dest->mKeys[i].mWeights, src->mKeys[i].mWeights, dest->mKeys[i].mNumValuesAndWeights * sizeof(double));
+ }
+}
+
// ------------------------------------------------------------------------------------------------
void SceneCombiner::Copy( aiCamera** _dest,const aiCamera* src) {
if ( nullptr == _dest || nullptr == src ) {
diff --git a/thirdparty/assimp/code/Common/Version.cpp b/thirdparty/assimp/code/Common/Version.cpp
index cc94340ac8..cf1da7d5ba 100644
--- a/thirdparty/assimp/code/Common/Version.cpp
+++ b/thirdparty/assimp/code/Common/Version.cpp
@@ -46,8 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h>
#include "ScenePrivate.h"
-static const unsigned int MajorVersion = 4;
-static const unsigned int MinorVersion = 1;
+#include "revision.h"
// --------------------------------------------------------------------------------
// Legal information string - don't remove this.
@@ -56,9 +55,9 @@ static const char* LEGAL_INFORMATION =
"Open Asset Import Library (Assimp).\n"
"A free C/C++ library to import various 3D file formats into applications\n\n"
-"(c) 2008-2017, assimp team\n"
+"(c) 2006-2019, assimp team\n"
"License under the terms and conditions of the 3-clause BSD license\n"
-"http://assimp.sourceforge.net\n"
+"http://assimp.org\n"
;
// ------------------------------------------------------------------------------------------------
@@ -70,13 +69,13 @@ ASSIMP_API const char* aiGetLegalString () {
// ------------------------------------------------------------------------------------------------
// Get Assimp minor version
ASSIMP_API unsigned int aiGetVersionMinor () {
- return MinorVersion;
+ return VER_MINOR;
}
// ------------------------------------------------------------------------------------------------
// Get Assimp major version
ASSIMP_API unsigned int aiGetVersionMajor () {
- return MajorVersion;
+ return VER_MAJOR;
}
// ------------------------------------------------------------------------------------------------
@@ -104,9 +103,6 @@ ASSIMP_API unsigned int aiGetCompileFlags () {
return flags;
}
-// include current build revision, which is even updated from time to time -- :-)
-#include "revision.h"
-
// ------------------------------------------------------------------------------------------------
ASSIMP_API unsigned int aiGetVersionRevision() {
return GitVersion;
diff --git a/thirdparty/assimp/code/Common/scene.cpp b/thirdparty/assimp/code/Common/scene.cpp
index 2acb348d81..d15619acff 100644
--- a/thirdparty/assimp/code/Common/scene.cpp
+++ b/thirdparty/assimp/code/Common/scene.cpp
@@ -44,23 +44,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
aiNode::aiNode()
: mName("")
-, mParent(NULL)
+, mParent(nullptr)
, mNumChildren(0)
-, mChildren(NULL)
+, mChildren(nullptr)
, mNumMeshes(0)
-, mMeshes(NULL)
-, mMetaData(NULL) {
+, mMeshes(nullptr)
+, mMetaData(nullptr) {
// empty
}
aiNode::aiNode(const std::string& name)
: mName(name)
-, mParent(NULL)
+, mParent(nullptr)
, mNumChildren(0)
-, mChildren(NULL)
+, mChildren(nullptr)
, mNumMeshes(0)
-, mMeshes(NULL)
-, mMetaData(NULL) {
+, mMeshes(nullptr)
+, mMetaData(nullptr) {
// empty
}
@@ -68,7 +68,7 @@ aiNode::aiNode(const std::string& name)
aiNode::~aiNode() {
// delete all children recursively
// to make sure we won't crash if the data is invalid ...
- if (mChildren && mNumChildren)
+ if (mNumChildren && mChildren)
{
for (unsigned int a = 0; a < mNumChildren; a++)
delete mChildren[a];
diff --git a/thirdparty/assimp/code/FBX/FBXCompileConfig.h b/thirdparty/assimp/code/FBX/FBXCompileConfig.h
index 3a3841fa5b..03536a1823 100644
--- a/thirdparty/assimp/code/FBX/FBXCompileConfig.h
+++ b/thirdparty/assimp/code/FBX/FBXCompileConfig.h
@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define INCLUDED_AI_FBX_COMPILECONFIG_H
#include <map>
+#include <set>
//
#if _MSC_VER > 1500 || (defined __GNUC___)
@@ -54,16 +55,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# else
# define fbx_unordered_map map
# define fbx_unordered_multimap multimap
+# define fbx_unordered_set set
+# define fbx_unordered_multiset multiset
#endif
#ifdef ASSIMP_FBX_USE_UNORDERED_MULTIMAP
# include <unordered_map>
+# include <unordered_set>
# if _MSC_VER > 1600
# define fbx_unordered_map unordered_map
# define fbx_unordered_multimap unordered_multimap
+# define fbx_unordered_set unordered_set
+# define fbx_unordered_multiset unordered_multiset
# else
# define fbx_unordered_map tr1::unordered_map
# define fbx_unordered_multimap tr1::unordered_multimap
+# define fbx_unordered_set tr1::unordered_set
+# define fbx_unordered_multiset tr1::unordered_multiset
# endif
#endif
diff --git a/thirdparty/assimp/code/FBX/FBXConverter.cpp b/thirdparty/assimp/code/FBX/FBXConverter.cpp
index 3f64016ea4..d8a22d9f74 100644
--- a/thirdparty/assimp/code/FBX/FBXConverter.cpp
+++ b/thirdparty/assimp/code/FBX/FBXConverter.cpp
@@ -55,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXImporter.h"
#include <assimp/StringComparison.h>
+#include <assimp/MathFunctions.h>
#include <assimp/scene.h>
@@ -67,7 +68,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sstream>
#include <iomanip>
#include <cstdint>
-
+#include <iostream>
+#include <stdlib.h>
namespace Assimp {
namespace FBX {
@@ -76,7 +78,7 @@ namespace Assimp {
#define MAGIC_NODE_TAG "_$AssimpFbx$"
-#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000L
+#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000LL
FBXConverter::FBXConverter(aiScene* out, const Document& doc, bool removeEmptyBones )
: defaultMaterialIndex()
@@ -95,6 +97,14 @@ namespace Assimp {
// populate the node_anim_chain_bits map, which is needed
// to determine which nodes need to be generated.
ConvertAnimations();
+ // Embedded textures in FBX could be connected to nothing but to itself,
+ // for instance Texture -> Video connection only but not to the main graph,
+ // The idea here is to traverse all objects to find these Textures and convert them,
+ // so later during material conversion it will find converted texture in the textures_converted array.
+ if (doc.Settings().readTextures)
+ {
+ ConvertOrphantEmbeddedTextures();
+ }
ConvertRootNode();
if (doc.Settings().readAllMaterials) {
@@ -144,7 +154,7 @@ namespace Assimp {
out->mRootNode->mName.Set(unique_name);
// root has ID 0
- ConvertNodes(0L, *out->mRootNode);
+ ConvertNodes(0L, out->mRootNode, out->mRootNode);
}
static std::string getAncestorBaseName(const aiNode* node)
@@ -178,8 +188,11 @@ namespace Assimp {
GetUniqueName(original_name, unique_name);
return unique_name;
}
-
- void FBXConverter::ConvertNodes(uint64_t id, aiNode& parent, const aiMatrix4x4& parent_transform) {
+ /// todo: pre-build node hierarchy
+ /// todo: get bone from stack
+ /// todo: make map of aiBone* to aiNode*
+ /// then update convert clusters to the new format
+ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node) {
const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(id, "Model");
std::vector<aiNode*> nodes;
@@ -190,62 +203,69 @@ namespace Assimp {
try {
for (const Connection* con : conns) {
-
// ignore object-property links
if (con->PropertyName().length()) {
- continue;
+ // really important we document why this is ignored.
+ FBXImporter::LogInfo("ignoring property link - no docs on why this is ignored");
+ continue; //?
}
+ // convert connection source object into Object base class
const Object* const object = con->SourceObject();
if (nullptr == object) {
- FBXImporter::LogWarn("failed to convert source object for Model link");
+ FBXImporter::LogError("failed to convert source object for Model link");
continue;
}
+ // FBX Model::Cube, Model::Bone001, etc elements
+ // This detects if we can cast the object into this model structure.
const Model* const model = dynamic_cast<const Model*>(object);
if (nullptr != model) {
nodes_chain.clear();
post_nodes_chain.clear();
- aiMatrix4x4 new_abs_transform = parent_transform;
-
- std::string unique_name = MakeUniqueNodeName(model, parent);
-
+ aiMatrix4x4 new_abs_transform = parent->mTransformation;
+ std::string node_name = FixNodeName(model->Name());
// even though there is only a single input node, the design of
// assimp (or rather: the complicated transformation chain that
// is employed by fbx) means that we may need multiple aiNode's
// to represent a fbx node's transformation.
- const bool need_additional_node = GenerateTransformationNodeChain(*model, unique_name, nodes_chain, post_nodes_chain);
+
+ // generate node transforms - this includes pivot data
+ // if need_additional_node is true then you t
+ const bool need_additional_node = GenerateTransformationNodeChain(*model, node_name, nodes_chain, post_nodes_chain);
+
+ // assert that for the current node we must have at least a single transform
ai_assert(nodes_chain.size());
if (need_additional_node) {
- nodes_chain.push_back(new aiNode(unique_name));
+ nodes_chain.push_back(new aiNode(node_name));
}
//setup metadata on newest node
SetupNodeMetadata(*model, *nodes_chain.back());
// link all nodes in a row
- aiNode* last_parent = &parent;
- for (aiNode* prenode : nodes_chain) {
- ai_assert(prenode);
+ aiNode* last_parent = parent;
+ for (aiNode* child : nodes_chain) {
+ ai_assert(child);
- if (last_parent != &parent) {
+ if (last_parent != parent) {
last_parent->mNumChildren = 1;
last_parent->mChildren = new aiNode*[1];
- last_parent->mChildren[0] = prenode;
+ last_parent->mChildren[0] = child;
}
- prenode->mParent = last_parent;
- last_parent = prenode;
+ child->mParent = last_parent;
+ last_parent = child;
- new_abs_transform *= prenode->mTransformation;
+ new_abs_transform *= child->mTransformation;
}
// attach geometry
- ConvertModel(*model, *nodes_chain.back(), new_abs_transform);
+ ConvertModel(*model, nodes_chain.back(), root_node, new_abs_transform);
// check if there will be any child nodes
const std::vector<const Connection*>& child_conns
@@ -257,7 +277,7 @@ namespace Assimp {
for (aiNode* postnode : post_nodes_chain) {
ai_assert(postnode);
- if (last_parent != &parent) {
+ if (last_parent != parent) {
last_parent->mNumChildren = 1;
last_parent->mChildren = new aiNode*[1];
last_parent->mChildren[0] = postnode;
@@ -279,15 +299,15 @@ namespace Assimp {
);
}
- // attach sub-nodes (if any)
- ConvertNodes(model->ID(), *last_parent, new_abs_transform);
+ // recursion call - child nodes
+ ConvertNodes(model->ID(), last_parent, root_node);
if (doc.Settings().readLights) {
- ConvertLights(*model, unique_name);
+ ConvertLights(*model, node_name);
}
if (doc.Settings().readCameras) {
- ConvertCameras(*model, unique_name);
+ ConvertCameras(*model, node_name);
}
nodes.push_back(nodes_chain.front());
@@ -296,11 +316,17 @@ namespace Assimp {
}
if (nodes.size()) {
- parent.mChildren = new aiNode*[nodes.size()]();
- parent.mNumChildren = static_cast<unsigned int>(nodes.size());
+ parent->mChildren = new aiNode*[nodes.size()]();
+ parent->mNumChildren = static_cast<unsigned int>(nodes.size());
- std::swap_ranges(nodes.begin(), nodes.end(), parent.mChildren);
+ std::swap_ranges(nodes.begin(), nodes.end(), parent->mChildren);
}
+ else
+ {
+ parent->mNumChildren = 0;
+ parent->mChildren = nullptr;
+ }
+
}
catch (std::exception&) {
Util::delete_fun<aiNode> deleter;
@@ -553,7 +579,7 @@ namespace Assimp {
return;
}
- const float angle_epsilon = 1e-6f;
+ const float angle_epsilon = Math::getEpsilon<float>();
out = aiMatrix4x4();
@@ -694,7 +720,7 @@ namespace Assimp {
std::fill_n(chain, static_cast<unsigned int>(TransformationComp_MAXIMUM), aiMatrix4x4());
// generate transformation matrices for all the different transformation components
- const float zero_epsilon = 1e-6f;
+ const float zero_epsilon = Math::getEpsilon<float>();
const aiVector3D all_ones(1.0f, 1.0f, 1.0f);
const aiVector3D& PreRotation = PropertyGet<aiVector3D>(props, "PreRotation", ok);
@@ -802,7 +828,7 @@ namespace Assimp {
// is_complex needs to be consistent with NeedsComplexTransformationChain()
// or the interplay between this code and the animation converter would
// not be guaranteed.
- ai_assert(NeedsComplexTransformationChain(model) == ((chainBits & chainMaskComplex) != 0));
+ //ai_assert(NeedsComplexTransformationChain(model) == ((chainBits & chainMaskComplex) != 0));
// now, if we have more than just Translation, Scaling and Rotation,
// we need to generate a full node chain to accommodate for assimp's
@@ -904,7 +930,8 @@ namespace Assimp {
}
}
- void FBXConverter::ConvertModel(const Model& model, aiNode& nd, const aiMatrix4x4& node_global_transform)
+ void FBXConverter::ConvertModel(const Model &model, aiNode *parent, aiNode *root_node,
+ const aiMatrix4x4 &absolute_transform)
{
const std::vector<const Geometry*>& geos = model.GetGeometry();
@@ -916,11 +943,12 @@ namespace Assimp {
const MeshGeometry* const mesh = dynamic_cast<const MeshGeometry*>(geo);
const LineGeometry* const line = dynamic_cast<const LineGeometry*>(geo);
if (mesh) {
- const std::vector<unsigned int>& indices = ConvertMesh(*mesh, model, node_global_transform, nd);
+ const std::vector<unsigned int>& indices = ConvertMesh(*mesh, model, parent, root_node,
+ absolute_transform);
std::copy(indices.begin(), indices.end(), std::back_inserter(meshes));
}
else if (line) {
- const std::vector<unsigned int>& indices = ConvertLine(*line, model, node_global_transform, nd);
+ const std::vector<unsigned int>& indices = ConvertLine(*line, model, parent, root_node);
std::copy(indices.begin(), indices.end(), std::back_inserter(meshes));
}
else {
@@ -929,15 +957,16 @@ namespace Assimp {
}
if (meshes.size()) {
- nd.mMeshes = new unsigned int[meshes.size()]();
- nd.mNumMeshes = static_cast<unsigned int>(meshes.size());
+ parent->mMeshes = new unsigned int[meshes.size()]();
+ parent->mNumMeshes = static_cast<unsigned int>(meshes.size());
- std::swap_ranges(meshes.begin(), meshes.end(), nd.mMeshes);
+ std::swap_ranges(meshes.begin(), meshes.end(), parent->mMeshes);
}
}
- std::vector<unsigned int> FBXConverter::ConvertMesh(const MeshGeometry& mesh, const Model& model,
- const aiMatrix4x4& node_global_transform, aiNode& nd)
+ std::vector<unsigned int>
+ FBXConverter::ConvertMesh(const MeshGeometry &mesh, const Model &model, aiNode *parent, aiNode *root_node,
+ const aiMatrix4x4 &absolute_transform)
{
std::vector<unsigned int> temp;
@@ -961,18 +990,18 @@ namespace Assimp {
const MatIndexArray::value_type base = mindices[0];
for (MatIndexArray::value_type index : mindices) {
if (index != base) {
- return ConvertMeshMultiMaterial(mesh, model, node_global_transform, nd);
+ return ConvertMeshMultiMaterial(mesh, model, parent, root_node, absolute_transform);
}
}
}
// faster code-path, just copy the data
- temp.push_back(ConvertMeshSingleMaterial(mesh, model, node_global_transform, nd));
+ temp.push_back(ConvertMeshSingleMaterial(mesh, model, absolute_transform, parent, root_node));
return temp;
}
std::vector<unsigned int> FBXConverter::ConvertLine(const LineGeometry& line, const Model& model,
- const aiMatrix4x4& node_global_transform, aiNode& nd)
+ aiNode *parent, aiNode *root_node)
{
std::vector<unsigned int> temp;
@@ -983,7 +1012,7 @@ namespace Assimp {
return temp;
}
- aiMesh* const out_mesh = SetupEmptyMesh(line, nd);
+ aiMesh* const out_mesh = SetupEmptyMesh(line, root_node);
out_mesh->mPrimitiveTypes |= aiPrimitiveType_LINE;
// copy vertices
@@ -1018,7 +1047,7 @@ namespace Assimp {
return temp;
}
- aiMesh* FBXConverter::SetupEmptyMesh(const Geometry& mesh, aiNode& nd)
+ aiMesh* FBXConverter::SetupEmptyMesh(const Geometry& mesh, aiNode *parent)
{
aiMesh* const out_mesh = new aiMesh();
meshes.push_back(out_mesh);
@@ -1035,17 +1064,18 @@ namespace Assimp {
}
else
{
- out_mesh->mName = nd.mName;
+ out_mesh->mName = parent->mName;
}
return out_mesh;
}
- unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry& mesh, const Model& model,
- const aiMatrix4x4& node_global_transform, aiNode& nd)
+ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, const Model &model,
+ const aiMatrix4x4 &absolute_transform, aiNode *parent,
+ aiNode *root_node)
{
const MatIndexArray& mindices = mesh.GetMaterialIndices();
- aiMesh* const out_mesh = SetupEmptyMesh(mesh, nd);
+ aiMesh* const out_mesh = SetupEmptyMesh(mesh, parent);
const std::vector<aiVector3D>& vertices = mesh.GetVertices();
const std::vector<unsigned int>& faces = mesh.GetFaceIndexCounts();
@@ -1112,7 +1142,7 @@ namespace Assimp {
binormals = &tempBinormals;
}
else {
- binormals = NULL;
+ binormals = nullptr;
}
}
@@ -1162,8 +1192,9 @@ namespace Assimp {
ConvertMaterialForMesh(out_mesh, model, mesh, mindices[0]);
}
- if (doc.Settings().readWeights && mesh.DeformerSkin() != NULL) {
- ConvertWeights(out_mesh, model, mesh, node_global_transform, NO_MATERIAL_SEPARATION);
+ if (doc.Settings().readWeights && mesh.DeformerSkin() != nullptr) {
+ ConvertWeights(out_mesh, model, mesh, absolute_transform, parent, root_node, NO_MATERIAL_SEPARATION,
+ nullptr);
}
std::vector<aiAnimMesh*> animMeshes;
@@ -1208,8 +1239,10 @@ namespace Assimp {
return static_cast<unsigned int>(meshes.size() - 1);
}
- std::vector<unsigned int> FBXConverter::ConvertMeshMultiMaterial(const MeshGeometry& mesh, const Model& model,
- const aiMatrix4x4& node_global_transform, aiNode& nd)
+ std::vector<unsigned int>
+ FBXConverter::ConvertMeshMultiMaterial(const MeshGeometry &mesh, const Model &model, aiNode *parent,
+ aiNode *root_node,
+ const aiMatrix4x4 &absolute_transform)
{
const MatIndexArray& mindices = mesh.GetMaterialIndices();
ai_assert(mindices.size());
@@ -1220,7 +1253,7 @@ namespace Assimp {
for (MatIndexArray::value_type index : mindices) {
if (had.find(index) == had.end()) {
- indices.push_back(ConvertMeshMultiMaterial(mesh, model, index, node_global_transform, nd));
+ indices.push_back(ConvertMeshMultiMaterial(mesh, model, index, parent, root_node, absolute_transform));
had.insert(index);
}
}
@@ -1228,18 +1261,18 @@ namespace Assimp {
return indices;
}
- unsigned int FBXConverter::ConvertMeshMultiMaterial(const MeshGeometry& mesh, const Model& model,
- MatIndexArray::value_type index,
- const aiMatrix4x4& node_global_transform,
- aiNode& nd)
+ unsigned int FBXConverter::ConvertMeshMultiMaterial(const MeshGeometry &mesh, const Model &model,
+ MatIndexArray::value_type index,
+ aiNode *parent, aiNode *root_node,
+ const aiMatrix4x4 &absolute_transform)
{
- aiMesh* const out_mesh = SetupEmptyMesh(mesh, nd);
+ aiMesh* const out_mesh = SetupEmptyMesh(mesh, parent);
const MatIndexArray& mindices = mesh.GetMaterialIndices();
const std::vector<aiVector3D>& vertices = mesh.GetVertices();
const std::vector<unsigned int>& faces = mesh.GetFaceIndexCounts();
- const bool process_weights = doc.Settings().readWeights && mesh.DeformerSkin() != NULL;
+ const bool process_weights = doc.Settings().readWeights && mesh.DeformerSkin() != nullptr;
unsigned int count_faces = 0;
unsigned int count_vertices = 0;
@@ -1299,7 +1332,7 @@ namespace Assimp {
binormals = &tempBinormals;
}
else {
- binormals = NULL;
+ binormals = nullptr;
}
}
@@ -1398,7 +1431,7 @@ namespace Assimp {
ConvertMaterialForMesh(out_mesh, model, mesh, index);
if (process_weights) {
- ConvertWeights(out_mesh, model, mesh, node_global_transform, index, &reverseMapping);
+ ConvertWeights(out_mesh, model, mesh, absolute_transform, parent, root_node, index, &reverseMapping);
}
std::vector<aiAnimMesh*> animMeshes;
@@ -1448,10 +1481,10 @@ namespace Assimp {
return static_cast<unsigned int>(meshes.size() - 1);
}
- void FBXConverter::ConvertWeights(aiMesh* out, const Model& model, const MeshGeometry& geo,
- const aiMatrix4x4& node_global_transform,
- unsigned int materialIndex,
- std::vector<unsigned int>* outputVertStartIndices)
+ void FBXConverter::ConvertWeights(aiMesh *out, const Model &model, const MeshGeometry &geo,
+ const aiMatrix4x4 &absolute_transform,
+ aiNode *parent, aiNode *root_node, unsigned int materialIndex,
+ std::vector<unsigned int> *outputVertStartIndices)
{
ai_assert(geo.DeformerSkin());
@@ -1462,13 +1495,12 @@ namespace Assimp {
const Skin& sk = *geo.DeformerSkin();
std::vector<aiBone*> bones;
- bones.reserve(sk.Clusters().size());
const bool no_mat_check = materialIndex == NO_MATERIAL_SEPARATION;
ai_assert(no_mat_check || outputVertStartIndices);
try {
-
+ // iterate over the sub deformers
for (const Cluster* cluster : sk.Clusters()) {
ai_assert(cluster);
@@ -1482,15 +1514,16 @@ namespace Assimp {
index_out_indices.clear();
out_indices.clear();
+
// now check if *any* of these weights is contained in the output mesh,
// taking notes so we don't need to do it twice.
for (WeightIndexArray::value_type index : indices) {
unsigned int count = 0;
const unsigned int* const out_idx = geo.ToOutputVertexIndex(index, count);
- // ToOutputVertexIndex only returns NULL if index is out of bounds
+ // ToOutputVertexIndex only returns nullptr if index is out of bounds
// which should never happen
- ai_assert(out_idx != NULL);
+ ai_assert(out_idx != nullptr);
index_out_indices.push_back(no_index_sentinel);
count_out_indices.push_back(0);
@@ -1519,68 +1552,107 @@ namespace Assimp {
}
}
}
-
+
// if we found at least one, generate the output bones
// XXX this could be heavily simplified by collecting the bone
// data in a single step.
- ConvertCluster(bones, model, *cluster, out_indices, index_out_indices,
- count_out_indices, node_global_transform);
+ ConvertCluster(bones, cluster, out_indices, index_out_indices,
+ count_out_indices, absolute_transform, parent, root_node);
}
+
+ bone_map.clear();
}
- catch (std::exception&) {
+ catch (std::exception&e) {
std::for_each(bones.begin(), bones.end(), Util::delete_fun<aiBone>());
throw;
}
if (bones.empty()) {
+ out->mBones = nullptr;
+ out->mNumBones = 0;
return;
- }
-
- out->mBones = new aiBone*[bones.size()]();
- out->mNumBones = static_cast<unsigned int>(bones.size());
+ } else {
+ out->mBones = new aiBone *[bones.size()]();
+ out->mNumBones = static_cast<unsigned int>(bones.size());
- std::swap_ranges(bones.begin(), bones.end(), out->mBones);
+ std::swap_ranges(bones.begin(), bones.end(), out->mBones);
+ }
}
- void FBXConverter::ConvertCluster(std::vector<aiBone*>& bones, const Model& /*model*/, const Cluster& cl,
- std::vector<size_t>& out_indices,
- std::vector<size_t>& index_out_indices,
- std::vector<size_t>& count_out_indices,
- const aiMatrix4x4& node_global_transform)
+ const aiNode* FBXConverter::GetNodeByName( const aiString& name, aiNode *current_node )
{
+ aiNode * iter = current_node;
+ //printf("Child count: %d", iter->mNumChildren);
+ return iter;
+ }
- aiBone* const bone = new aiBone();
- bones.push_back(bone);
+ void FBXConverter::ConvertCluster(std::vector<aiBone *> &local_mesh_bones, const Cluster *cl,
+ std::vector<size_t> &out_indices, std::vector<size_t> &index_out_indices,
+ std::vector<size_t> &count_out_indices, const aiMatrix4x4 &absolute_transform,
+ aiNode *parent, aiNode *root_node) {
+ ai_assert(cl); // make sure cluster valid
+ std::string deformer_name = cl->TargetNode()->Name();
+ aiString bone_name = aiString(FixNodeName(deformer_name));
- bone->mName = FixNodeName(cl.TargetNode()->Name());
+ aiBone *bone = nullptr;
- bone->mOffsetMatrix = cl.TransformLink();
- bone->mOffsetMatrix.Inverse();
+ if (bone_map.count(deformer_name)) {
+ std::cout << "retrieved bone from lookup " << bone_name.C_Str() << ". Deformer: " << deformer_name
+ << std::endl;
+ bone = bone_map[deformer_name];
+ } else {
+ std::cout << "created new bone " << bone_name.C_Str() << ". Deformer: " << deformer_name << std::endl;
+ bone = new aiBone();
+ bone->mName = bone_name;
- bone->mOffsetMatrix = bone->mOffsetMatrix * node_global_transform;
+ // store local transform link for post processing
+ bone->mOffsetMatrix = cl->TransformLink();
+ bone->mOffsetMatrix.Inverse();
- bone->mNumWeights = static_cast<unsigned int>(out_indices.size());
- aiVertexWeight* cursor = bone->mWeights = new aiVertexWeight[out_indices.size()];
+ aiMatrix4x4 matrix = (aiMatrix4x4)absolute_transform;
- const size_t no_index_sentinel = std::numeric_limits<size_t>::max();
- const WeightArray& weights = cl.GetWeights();
+ bone->mOffsetMatrix = bone->mOffsetMatrix * matrix; // * mesh_offset
- const size_t c = index_out_indices.size();
- for (size_t i = 0; i < c; ++i) {
- const size_t index_index = index_out_indices[i];
- if (index_index == no_index_sentinel) {
- continue;
- }
+ //
+ // Now calculate the aiVertexWeights
+ //
+
+ aiVertexWeight *cursor = nullptr;
+
+ bone->mNumWeights = static_cast<unsigned int>(out_indices.size());
+ cursor = bone->mWeights = new aiVertexWeight[out_indices.size()];
- const size_t cc = count_out_indices[i];
- for (size_t j = 0; j < cc; ++j) {
- aiVertexWeight& out_weight = *cursor++;
+ const size_t no_index_sentinel = std::numeric_limits<size_t>::max();
+ const WeightArray& weights = cl->GetWeights();
- out_weight.mVertexId = static_cast<unsigned int>(out_indices[index_index + j]);
- out_weight.mWeight = weights[i];
+ const size_t c = index_out_indices.size();
+ for (size_t i = 0; i < c; ++i) {
+ const size_t index_index = index_out_indices[i];
+
+ if (index_index == no_index_sentinel) {
+ continue;
+ }
+
+ const size_t cc = count_out_indices[i];
+ for (size_t j = 0; j < cc; ++j) {
+ // cursor runs from first element relative to the start
+ // or relative to the start of the next indexes.
+ aiVertexWeight& out_weight = *cursor++;
+
+ out_weight.mVertexId = static_cast<unsigned int>(out_indices[index_index + j]);
+ out_weight.mWeight = weights[i];
+ }
}
+
+ bone_map.insert(std::pair<const std::string, aiBone *>(deformer_name, bone));
}
+
+ std::cout << "bone research: Indicies size: " << out_indices.size() << std::endl;
+
+ // lookup must be populated in case something goes wrong
+ // this also allocates bones to mesh instance outside
+ local_mesh_bones.push_back(bone);
}
void FBXConverter::ConvertMaterialForMesh(aiMesh* out, const Model& model, const MeshGeometry& geo,
@@ -1710,7 +1782,7 @@ namespace Assimp {
bool textureReady = false; //tells if our texture is ready (if it was loaded or if it was found)
unsigned int index;
- VideoMap::const_iterator it = textures_converted.find(media);
+ VideoMap::const_iterator it = textures_converted.find(*media);
if (it != textures_converted.end()) {
index = (*it).second;
textureReady = true;
@@ -1718,7 +1790,7 @@ namespace Assimp {
else {
if (media->ContentLength() > 0) {
index = ConvertVideo(*media);
- textures_converted[media] = index;
+ textures_converted[*media] = index;
textureReady = true;
}
}
@@ -2242,13 +2314,13 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTa
if (media != nullptr && media->ContentLength() > 0) {
unsigned int index;
- VideoMap::const_iterator it = textures_converted.find(media);
+ VideoMap::const_iterator it = textures_converted.find(*media);
if (it != textures_converted.end()) {
index = (*it).second;
}
else {
index = ConvertVideo(*media);
- textures_converted[media] = index;
+ textures_converted[*media] = index;
}
// setup texture reference string (copied from ColladaLoader::FindFilenameForEffectTexture)
@@ -2676,7 +2748,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTa
// sanity check whether the input is ok
static void validateAnimCurveNodes(const std::vector<const AnimationCurveNode*>& curves,
bool strictMode) {
- const Object* target(NULL);
+ const Object* target(nullptr);
for (const AnimationCurveNode* node : curves) {
if (!target) {
target = node->Target();
@@ -2707,7 +2779,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTa
#ifdef ASSIMP_BUILD_DEBUG
validateAnimCurveNodes(curves, doc.Settings().strictMode);
#endif
- const AnimationCurveNode* curve_node = NULL;
+ const AnimationCurveNode* curve_node = nullptr;
for (const AnimationCurveNode* node : curves) {
ai_assert(node);
@@ -2967,7 +3039,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTa
TransformationCompDefaultValue(comp)
);
- const float epsilon = 1e-6f;
+ const float epsilon = Math::getEpsilon<float>();
return (dyn_val - static_val).SquareLength() < epsilon;
}
@@ -3555,7 +3627,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTa
ai_assert(!out->mMeshes);
ai_assert(!out->mNumMeshes);
- // note: the trailing () ensures initialization with NULL - not
+ // note: the trailing () ensures initialization with nullptr - not
// many C++ users seem to know this, so pointing it out to avoid
// confusion why this code works.
@@ -3602,6 +3674,47 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTa
}
}
+ void FBXConverter::ConvertOrphantEmbeddedTextures()
+ {
+ // in C++14 it could be:
+ // for (auto&& [id, object] : objects)
+ for (auto&& id_and_object : doc.Objects())
+ {
+ auto&& id = std::get<0>(id_and_object);
+ auto&& object = std::get<1>(id_and_object);
+ // If an object doesn't have parent
+ if (doc.ConnectionsBySource().count(id) == 0)
+ {
+ const Texture* realTexture = nullptr;
+ try
+ {
+ const auto& element = object->GetElement();
+ const Token& key = element.KeyToken();
+ const char* obtype = key.begin();
+ const size_t length = static_cast<size_t>(key.end() - key.begin());
+ if (strncmp(obtype, "Texture", length) == 0)
+ {
+ const Texture* texture = static_cast<const Texture*>(object->Get());
+ if (texture->Media() && texture->Media()->ContentLength() > 0)
+ {
+ realTexture = texture;
+ }
+ }
+ }
+ catch (...)
+ {
+ // do nothing
+ }
+ if (realTexture)
+ {
+ const Video* media = realTexture->Media();
+ unsigned int index = ConvertVideo(*media);
+ textures_converted[*media] = index;
+ }
+ }
+ }
+ }
+
// ------------------------------------------------------------------------------------------------
void ConvertToAssimpScene(aiScene* out, const Document& doc, bool removeEmptyBones)
{
diff --git a/thirdparty/assimp/code/FBX/FBXConverter.h b/thirdparty/assimp/code/FBX/FBXConverter.h
index ab610058a4..46693bdca6 100644
--- a/thirdparty/assimp/code/FBX/FBXConverter.h
+++ b/thirdparty/assimp/code/FBX/FBXConverter.h
@@ -76,16 +76,6 @@ namespace Assimp {
namespace FBX {
class Document;
-
-enum class FbxUnit {
- cm = 0,
- m,
- km,
- NumUnits,
-
- Undefined
-};
-
/**
* Convert a FBX #Document to #aiScene
* @param out Empty scene to be populated
@@ -133,7 +123,7 @@ private:
// ------------------------------------------------------------------------------------------------
// collect and assign child nodes
- void ConvertNodes(uint64_t id, aiNode& parent, const aiMatrix4x4& parent_transform = aiMatrix4x4());
+ void ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node);
// ------------------------------------------------------------------------------------------------
void ConvertLights(const Model& model, const std::string &orig_name );
@@ -189,32 +179,35 @@ private:
void SetupNodeMetadata(const Model& model, aiNode& nd);
// ------------------------------------------------------------------------------------------------
- void ConvertModel(const Model& model, aiNode& nd, const aiMatrix4x4& node_global_transform);
+ void ConvertModel(const Model &model, aiNode *parent, aiNode *root_node,
+ const aiMatrix4x4 &absolute_transform);
// ------------------------------------------------------------------------------------------------
// MeshGeometry -> aiMesh, return mesh index + 1 or 0 if the conversion failed
- std::vector<unsigned int> ConvertMesh(const MeshGeometry& mesh, const Model& model,
- const aiMatrix4x4& node_global_transform, aiNode& nd);
+ std::vector<unsigned int>
+ ConvertMesh(const MeshGeometry &mesh, const Model &model, aiNode *parent, aiNode *root_node,
+ const aiMatrix4x4 &absolute_transform);
// ------------------------------------------------------------------------------------------------
std::vector<unsigned int> ConvertLine(const LineGeometry& line, const Model& model,
- const aiMatrix4x4& node_global_transform, aiNode& nd);
+ aiNode *parent, aiNode *root_node);
// ------------------------------------------------------------------------------------------------
- aiMesh* SetupEmptyMesh(const Geometry& mesh, aiNode& nd);
+ aiMesh* SetupEmptyMesh(const Geometry& mesh, aiNode *parent);
// ------------------------------------------------------------------------------------------------
- unsigned int ConvertMeshSingleMaterial(const MeshGeometry& mesh, const Model& model,
- const aiMatrix4x4& node_global_transform, aiNode& nd);
+ unsigned int ConvertMeshSingleMaterial(const MeshGeometry &mesh, const Model &model,
+ const aiMatrix4x4 &absolute_transform, aiNode *parent,
+ aiNode *root_node);
// ------------------------------------------------------------------------------------------------
- std::vector<unsigned int> ConvertMeshMultiMaterial(const MeshGeometry& mesh, const Model& model,
- const aiMatrix4x4& node_global_transform, aiNode& nd);
+ std::vector<unsigned int>
+ ConvertMeshMultiMaterial(const MeshGeometry &mesh, const Model &model, aiNode *parent, aiNode *root_node,
+ const aiMatrix4x4 &absolute_transform);
// ------------------------------------------------------------------------------------------------
- unsigned int ConvertMeshMultiMaterial(const MeshGeometry& mesh, const Model& model,
- MatIndexArray::value_type index,
- const aiMatrix4x4& node_global_transform, aiNode& nd);
+ unsigned int ConvertMeshMultiMaterial(const MeshGeometry &mesh, const Model &model, MatIndexArray::value_type index,
+ aiNode *parent, aiNode *root_node, const aiMatrix4x4 &absolute_transform);
// ------------------------------------------------------------------------------------------------
static const unsigned int NO_MATERIAL_SEPARATION = /* std::numeric_limits<unsigned int>::max() */
@@ -227,17 +220,17 @@ private:
* - outputVertStartIndices is only used when a material index is specified, it gives for
* each output vertex the DOM index it maps to.
*/
- void ConvertWeights(aiMesh* out, const Model& model, const MeshGeometry& geo,
- const aiMatrix4x4& node_global_transform = aiMatrix4x4(),
- unsigned int materialIndex = NO_MATERIAL_SEPARATION,
- std::vector<unsigned int>* outputVertStartIndices = NULL);
-
+ void ConvertWeights(aiMesh *out, const Model &model, const MeshGeometry &geo, const aiMatrix4x4 &absolute_transform,
+ aiNode *parent = NULL, aiNode *root_node = NULL,
+ unsigned int materialIndex = NO_MATERIAL_SEPARATION,
+ std::vector<unsigned int> *outputVertStartIndices = NULL);
+ // lookup
+ static const aiNode* GetNodeByName( const aiString& name, aiNode *current_node );
// ------------------------------------------------------------------------------------------------
- void ConvertCluster(std::vector<aiBone*>& bones, const Model& /*model*/, const Cluster& cl,
- std::vector<size_t>& out_indices,
- std::vector<size_t>& index_out_indices,
- std::vector<size_t>& count_out_indices,
- const aiMatrix4x4& node_global_transform);
+ void ConvertCluster(std::vector<aiBone *> &local_mesh_bones, const Cluster *cl,
+ std::vector<size_t> &out_indices, std::vector<size_t> &index_out_indices,
+ std::vector<size_t> &count_out_indices, const aiMatrix4x4 &absolute_transform,
+ aiNode *parent, aiNode *root_node);
// ------------------------------------------------------------------------------------------------
void ConvertMaterialForMesh(aiMesh* out, const Model& model, const MeshGeometry& geo,
@@ -434,6 +427,10 @@ private:
// copy generated meshes, animations, lights, cameras and textures to the output scene
void TransferDataToScene();
+ // ------------------------------------------------------------------------------------------------
+ // FBX file could have embedded textures not connected to anything
+ void ConvertOrphantEmbeddedTextures();
+
private:
// 0: not assigned yet, others: index is value - 1
unsigned int defaultMaterialIndex;
@@ -445,28 +442,47 @@ private:
std::vector<aiCamera*> cameras;
std::vector<aiTexture*> textures;
- using MaterialMap = std::map<const Material*, unsigned int>;
+ using MaterialMap = std::fbx_unordered_map<const Material*, unsigned int>;
MaterialMap materials_converted;
- using VideoMap = std::map<const Video*, unsigned int>;
+ using VideoMap = std::fbx_unordered_map<const Video, unsigned int>;
VideoMap textures_converted;
- using MeshMap = std::map<const Geometry*, std::vector<unsigned int> >;
+ using MeshMap = std::fbx_unordered_map<const Geometry*, std::vector<unsigned int> >;
MeshMap meshes_converted;
// fixed node name -> which trafo chain components have animations?
- using NodeAnimBitMap = std::map<std::string, unsigned int> ;
+ using NodeAnimBitMap = std::fbx_unordered_map<std::string, unsigned int> ;
NodeAnimBitMap node_anim_chain_bits;
// number of nodes with the same name
- using NodeNameCache = std::unordered_map<std::string, unsigned int>;
+ using NodeNameCache = std::fbx_unordered_map<std::string, unsigned int>;
NodeNameCache mNodeNames;
+ // Deformer name is not the same as a bone name - it does contain the bone name though :)
+ // Deformer names in FBX are always unique in an FBX file.
+ std::map<const std::string, aiBone *> bone_map;
+
double anim_fps;
aiScene* const out;
const FBX::Document& doc;
- FbxUnit mCurrentUnit;
+
+ static void BuildBoneList(aiNode *current_node, const aiNode *root_node, const aiScene *scene,
+ std::vector<aiBone*>& bones);
+
+ void BuildBoneStack(aiNode *current_node, const aiNode *root_node, const aiScene *scene,
+ const std::vector<aiBone *> &bones,
+ std::map<aiBone *, aiNode *> &bone_stack,
+ std::vector<aiNode*> &node_stack );
+
+ static void BuildNodeList(aiNode *current_node, std::vector<aiNode *> &nodes);
+
+ static aiNode *GetNodeFromStack(const aiString &node_name, std::vector<aiNode *> &nodes);
+
+ static aiNode *GetArmatureRoot(aiNode *bone_node, std::vector<aiBone*> &bone_list);
+
+ static bool IsBoneNode(const aiString &bone_name, std::vector<aiBone *> &bones);
};
}
diff --git a/thirdparty/assimp/code/FBX/FBXDocument.h b/thirdparty/assimp/code/FBX/FBXDocument.h
index 18e5c38f13..a60d7d9efa 100644
--- a/thirdparty/assimp/code/FBX/FBXDocument.h
+++ b/thirdparty/assimp/code/FBX/FBXDocument.h
@@ -637,6 +637,20 @@ public:
return ptr;
}
+ bool operator==(const Video& other) const
+ {
+ return (
+ type == other.type
+ && relativeFileName == other.relativeFileName
+ && fileName == other.fileName
+ );
+ }
+
+ bool operator<(const Video& other) const
+ {
+ return std::tie(type, relativeFileName, fileName) < std::tie(other.type, other.relativeFileName, other.fileName);
+ }
+
private:
std::string type;
std::string relativeFileName;
@@ -1005,10 +1019,10 @@ public:
// during their entire lifetime (Document). FBX files have
// up to many thousands of objects (most of which we never use),
// so the memory overhead for them should be kept at a minimum.
-typedef std::map<uint64_t, LazyObject*> ObjectMap;
+typedef std::fbx_unordered_map<uint64_t, LazyObject*> ObjectMap;
typedef std::fbx_unordered_map<std::string, std::shared_ptr<const PropertyTable> > PropertyTemplateMap;
-typedef std::multimap<uint64_t, const Connection*> ConnectionMap;
+typedef std::fbx_unordered_multimap<uint64_t, const Connection*> ConnectionMap;
/** DOM class for global document settings, a single instance per document can
* be accessed via Document.Globals(). */
@@ -1177,4 +1191,25 @@ private:
} // Namespace FBX
} // Namespace Assimp
+namespace std
+{
+ template <>
+ struct hash<const Assimp::FBX::Video>
+ {
+ std::size_t operator()(const Assimp::FBX::Video& video) const
+ {
+ using std::size_t;
+ using std::hash;
+ using std::string;
+
+ size_t res = 17;
+ res = res * 31 + hash<string>()(video.Name());
+ res = res * 31 + hash<string>()(video.RelativeFilename());
+ res = res * 31 + hash<string>()(video.Type());
+
+ return res;
+ }
+ };
+}
+
#endif // INCLUDED_AI_FBX_DOCUMENT_H
diff --git a/thirdparty/assimp/code/FBX/FBXExportProperty.cpp b/thirdparty/assimp/code/FBX/FBXExportProperty.cpp
index f8593e6295..f2a63b72b9 100644
--- a/thirdparty/assimp/code/FBX/FBXExportProperty.cpp
+++ b/thirdparty/assimp/code/FBX/FBXExportProperty.cpp
@@ -59,11 +59,7 @@ namespace FBX {
FBXExportProperty::FBXExportProperty(bool v)
: type('C')
-, data(1) {
- data = {
- uint8_t(v)
- };
-}
+, data(1, uint8_t(v)) {}
FBXExportProperty::FBXExportProperty(int16_t v)
: type('Y')
diff --git a/thirdparty/assimp/code/FBX/FBXExporter.cpp b/thirdparty/assimp/code/FBX/FBXExporter.cpp
index 8ebc8555a2..9316dc4f02 100644
--- a/thirdparty/assimp/code/FBX/FBXExporter.cpp
+++ b/thirdparty/assimp/code/FBX/FBXExporter.cpp
@@ -67,6 +67,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vector>
#include <array>
#include <unordered_set>
+#include <numeric>
// RESOURCES:
// https://code.blender.org/2013/08/fbx-binary-file-format-specification/
@@ -1005,6 +1006,9 @@ void FBXExporter::WriteObjects ()
object_node.EndProperties(outstream, binary, indent);
object_node.BeginChildren(outstream, binary, indent);
+ bool bJoinIdenticalVertices = mProperties->GetPropertyBool("bJoinIdenticalVertices", true);
+ std::vector<std::vector<int32_t>> vVertexIndice;//save vertex_indices as it is needed later
+
// geometry (aiMesh)
mesh_uids.clear();
indent = 1;
@@ -1031,21 +1035,35 @@ void FBXExporter::WriteObjects ()
std::vector<int32_t> vertex_indices;
// map of vertex value to its index in the data vector
std::map<aiVector3D,size_t> index_by_vertex_value;
- int32_t index = 0;
- for (size_t vi = 0; vi < m->mNumVertices; ++vi) {
- aiVector3D vtx = m->mVertices[vi];
- auto elem = index_by_vertex_value.find(vtx);
- if (elem == index_by_vertex_value.end()) {
- vertex_indices.push_back(index);
- index_by_vertex_value[vtx] = index;
- flattened_vertices.push_back(vtx[0]);
- flattened_vertices.push_back(vtx[1]);
- flattened_vertices.push_back(vtx[2]);
- ++index;
- } else {
- vertex_indices.push_back(int32_t(elem->second));
+ if(bJoinIdenticalVertices){
+ int32_t index = 0;
+ for (size_t vi = 0; vi < m->mNumVertices; ++vi) {
+ aiVector3D vtx = m->mVertices[vi];
+ auto elem = index_by_vertex_value.find(vtx);
+ if (elem == index_by_vertex_value.end()) {
+ vertex_indices.push_back(index);
+ index_by_vertex_value[vtx] = index;
+ flattened_vertices.push_back(vtx[0]);
+ flattened_vertices.push_back(vtx[1]);
+ flattened_vertices.push_back(vtx[2]);
+ ++index;
+ } else {
+ vertex_indices.push_back(int32_t(elem->second));
+ }
+ }
+ }
+ else { // do not join vertex, respect the export flag
+ vertex_indices.resize(m->mNumVertices);
+ std::iota(vertex_indices.begin(), vertex_indices.end(), 0);
+ for(unsigned int v = 0; v < m->mNumVertices; ++ v) {
+ aiVector3D vtx = m->mVertices[v];
+ flattened_vertices.push_back(vtx.x);
+ flattened_vertices.push_back(vtx.y);
+ flattened_vertices.push_back(vtx.z);
}
}
+ vVertexIndice.push_back(vertex_indices);
+
FBX::Node::WritePropertyNode(
"Vertices", flattened_vertices, outstream, binary, indent
);
@@ -1116,6 +1134,51 @@ void FBXExporter::WriteObjects ()
normals.End(outstream, binary, indent, true);
}
+ // colors, if any
+ // TODO only one color channel currently
+ const int32_t colorChannelIndex = 0;
+ if (m->HasVertexColors(colorChannelIndex)) {
+ FBX::Node vertexcolors("LayerElementColor", int32_t(colorChannelIndex));
+ vertexcolors.Begin(outstream, binary, indent);
+ vertexcolors.DumpProperties(outstream, binary, indent);
+ vertexcolors.EndProperties(outstream, binary, indent);
+ vertexcolors.BeginChildren(outstream, binary, indent);
+ indent = 3;
+ FBX::Node::WritePropertyNode(
+ "Version", int32_t(101), outstream, binary, indent
+ );
+ char layerName[8];
+ sprintf(layerName, "COLOR_%d", colorChannelIndex);
+ FBX::Node::WritePropertyNode(
+ "Name", (const char*)layerName, outstream, binary, indent
+ );
+ FBX::Node::WritePropertyNode(
+ "MappingInformationType", "ByPolygonVertex",
+ outstream, binary, indent
+ );
+ FBX::Node::WritePropertyNode(
+ "ReferenceInformationType", "Direct",
+ outstream, binary, indent
+ );
+ std::vector<double> color_data;
+ color_data.reserve(4 * polygon_data.size());
+ for (size_t fi = 0; fi < m->mNumFaces; ++fi) {
+ const aiFace &f = m->mFaces[fi];
+ for (size_t pvi = 0; pvi < f.mNumIndices; ++pvi) {
+ const aiColor4D &c = m->mColors[colorChannelIndex][f.mIndices[pvi]];
+ color_data.push_back(c.r);
+ color_data.push_back(c.g);
+ color_data.push_back(c.b);
+ color_data.push_back(c.a);
+ }
+ }
+ FBX::Node::WritePropertyNode(
+ "Colors", color_data, outstream, binary, indent
+ );
+ indent = 2;
+ vertexcolors.End(outstream, binary, indent, true);
+ }
+
// uvs, if any
for (size_t uvi = 0; uvi < m->GetNumUVChannels(); ++uvi) {
if (m->mNumUVComponents[uvi] > 2) {
@@ -1209,6 +1272,11 @@ void FBXExporter::WriteObjects ()
le.AddChild("Type", "LayerElementNormal");
le.AddChild("TypedIndex", int32_t(0));
layer.AddChild(le);
+ // TODO only 1 color channel currently
+ le = FBX::Node("LayerElement");
+ le.AddChild("Type", "LayerElementColor");
+ le.AddChild("TypedIndex", int32_t(0));
+ layer.AddChild(le);
le = FBX::Node("LayerElement");
le.AddChild("Type", "LayerElementMaterial");
le.AddChild("TypedIndex", int32_t(0));
@@ -1221,7 +1289,7 @@ void FBXExporter::WriteObjects ()
for(unsigned int lr = 1; lr < m->GetNumUVChannels(); ++ lr)
{
- FBX::Node layerExtra("Layer", int32_t(1));
+ FBX::Node layerExtra("Layer", int32_t(lr));
layerExtra.AddChild("Version", int32_t(100));
FBX::Node leExtra("LayerElement");
leExtra.AddChild("Type", "LayerElementUV");
@@ -1748,28 +1816,8 @@ void FBXExporter::WriteObjects ()
// connect it
connections.emplace_back("C", "OO", deformer_uid, mesh_uids[mi]);
- // we will be indexing by vertex...
- // but there might be a different number of "vertices"
- // between assimp and our output FBX.
- // this code is cut-and-pasted from the geometry section above...
- // ideally this should not be so.
- // ---
- // index of original vertex in vertex data vector
- std::vector<int32_t> vertex_indices;
- // map of vertex value to its index in the data vector
- std::map<aiVector3D,size_t> index_by_vertex_value;
- int32_t index = 0;
- for (size_t vi = 0; vi < m->mNumVertices; ++vi) {
- aiVector3D vtx = m->mVertices[vi];
- auto elem = index_by_vertex_value.find(vtx);
- if (elem == index_by_vertex_value.end()) {
- vertex_indices.push_back(index);
- index_by_vertex_value[vtx] = index;
- ++index;
- } else {
- vertex_indices.push_back(int32_t(elem->second));
- }
- }
+ //computed before
+ std::vector<int32_t>& vertex_indices = vVertexIndice[mi];
// TODO, FIXME: this won't work if anything is not in the bind pose.
// for now if such a situation is detected, we throw an exception.
@@ -2435,7 +2483,7 @@ void FBXExporter::WriteModelNodes(
void FBXExporter::WriteAnimationCurveNode(
StreamWriterLE& outstream,
int64_t uid,
- std::string name, // "T", "R", or "S"
+ const std::string& name, // "T", "R", or "S"
aiVector3D default_value,
std::string property_name, // "Lcl Translation" etc
int64_t layer_uid,
diff --git a/thirdparty/assimp/code/FBX/FBXExporter.h b/thirdparty/assimp/code/FBX/FBXExporter.h
index 71fb55c57f..1ae727eda9 100644
--- a/thirdparty/assimp/code/FBX/FBXExporter.h
+++ b/thirdparty/assimp/code/FBX/FBXExporter.h
@@ -156,7 +156,7 @@ namespace Assimp
void WriteAnimationCurveNode(
StreamWriterLE& outstream,
int64_t uid,
- std::string name, // "T", "R", or "S"
+ const std::string& name, // "T", "R", or "S"
aiVector3D default_value,
std::string property_name, // "Lcl Translation" etc
int64_t animation_layer_uid,
diff --git a/thirdparty/assimp/code/FBX/FBXImporter.cpp b/thirdparty/assimp/code/FBX/FBXImporter.cpp
index 271935a568..afcc1ddc78 100644
--- a/thirdparty/assimp/code/FBX/FBXImporter.cpp
+++ b/thirdparty/assimp/code/FBX/FBXImporter.cpp
@@ -48,26 +48,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXImporter.h"
-#include "FBXTokenizer.h"
+#include "FBXConverter.h"
+#include "FBXDocument.h"
#include "FBXParser.h"
+#include "FBXTokenizer.h"
#include "FBXUtil.h"
-#include "FBXDocument.h"
-#include "FBXConverter.h"
-#include <assimp/StreamReader.h>
#include <assimp/MemoryIOWrapper.h>
-#include <assimp/Importer.hpp>
+#include <assimp/StreamReader.h>
#include <assimp/importerdesc.h>
+#include <assimp/Importer.hpp>
namespace Assimp {
-template<>
-const char* LogFunctions<FBXImporter>::Prefix() {
- static auto prefix = "FBX: ";
- return prefix;
+template <>
+const char *LogFunctions<FBXImporter>::Prefix() {
+ static auto prefix = "FBX: ";
+ return prefix;
}
-}
+} // namespace Assimp
using namespace Assimp;
using namespace Assimp::Formatter;
@@ -76,136 +76,123 @@ using namespace Assimp::FBX;
namespace {
static const aiImporterDesc desc = {
- "Autodesk FBX Importer",
- "",
- "",
- "",
- aiImporterFlags_SupportTextFlavour,
- 0,
- 0,
- 0,
- 0,
- "fbx"
+ "Autodesk FBX Importer",
+ "",
+ "",
+ "",
+ aiImporterFlags_SupportTextFlavour,
+ 0,
+ 0,
+ 0,
+ 0,
+ "fbx"
};
}
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by #Importer
-FBXImporter::FBXImporter()
-{
+FBXImporter::FBXImporter() {
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
-FBXImporter::~FBXImporter()
-{
+FBXImporter::~FBXImporter() {
}
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
-bool FBXImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
-{
- const std::string& extension = GetExtension(pFile);
- if (extension == std::string( desc.mFileExtensions ) ) {
- return true;
- }
-
- else if ((!extension.length() || checkSig) && pIOHandler) {
- // at least ASCII-FBX files usually have a 'FBX' somewhere in their head
- const char* tokens[] = {"fbx"};
- return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1);
- }
- return false;
+bool FBXImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const {
+ const std::string &extension = GetExtension(pFile);
+ if (extension == std::string(desc.mFileExtensions)) {
+ return true;
+ }
+
+ else if ((!extension.length() || checkSig) && pIOHandler) {
+ // at least ASCII-FBX files usually have a 'FBX' somewhere in their head
+ const char *tokens[] = { "fbx" };
+ return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
+ }
+ return false;
}
// ------------------------------------------------------------------------------------------------
// List all extensions handled by this loader
-const aiImporterDesc* FBXImporter::GetInfo () const
-{
- return &desc;
+const aiImporterDesc *FBXImporter::GetInfo() const {
+ return &desc;
}
// ------------------------------------------------------------------------------------------------
// Setup configuration properties for the loader
-void FBXImporter::SetupProperties(const Importer* pImp)
-{
- settings.readAllLayers = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_ALL_GEOMETRY_LAYERS, true);
- settings.readAllMaterials = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_ALL_MATERIALS, false);
- settings.readMaterials = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_MATERIALS, true);
- settings.readTextures = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_TEXTURES, true);
- settings.readCameras = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_CAMERAS, true);
- settings.readLights = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_LIGHTS, true);
- settings.readAnimations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_ANIMATIONS, true);
- settings.strictMode = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_STRICT_MODE, false);
- settings.preservePivots = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, true);
- settings.optimizeEmptyAnimationCurves = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES, true);
- settings.useLegacyEmbeddedTextureNaming = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING, false);
- settings.removeEmptyBones = pImp->GetPropertyBool(AI_CONFIG_IMPORT_REMOVE_EMPTY_BONES, true);
- settings.convertToMeters = pImp->GetPropertyBool(AI_CONFIG_FBX_CONVERT_TO_M, false);
+void FBXImporter::SetupProperties(const Importer *pImp) {
+ settings.readAllLayers = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_ALL_GEOMETRY_LAYERS, true);
+ settings.readAllMaterials = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_ALL_MATERIALS, false);
+ settings.readMaterials = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_MATERIALS, true);
+ settings.readTextures = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_TEXTURES, true);
+ settings.readCameras = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_CAMERAS, true);
+ settings.readLights = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_LIGHTS, true);
+ settings.readAnimations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_READ_ANIMATIONS, true);
+ settings.strictMode = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_STRICT_MODE, false);
+ settings.preservePivots = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, true);
+ settings.optimizeEmptyAnimationCurves = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES, true);
+ settings.useLegacyEmbeddedTextureNaming = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING, false);
+ settings.removeEmptyBones = pImp->GetPropertyBool(AI_CONFIG_IMPORT_REMOVE_EMPTY_BONES, true);
+ settings.convertToMeters = pImp->GetPropertyBool(AI_CONFIG_FBX_CONVERT_TO_M, false);
}
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
-void FBXImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
-{
- std::unique_ptr<IOStream> stream(pIOHandler->Open(pFile,"rb"));
- if (!stream) {
- ThrowException("Could not open file for reading");
- }
-
- // read entire file into memory - no streaming for this, fbx
- // files can grow large, but the assimp output data structure
- // then becomes very large, too. Assimp doesn't support
- // streaming for its output data structures so the net win with
- // streaming input data would be very low.
- std::vector<char> contents;
- contents.resize(stream->FileSize()+1);
- stream->Read( &*contents.begin(), 1, contents.size()-1 );
- contents[ contents.size() - 1 ] = 0;
- const char* const begin = &*contents.begin();
-
- // broadphase tokenizing pass in which we identify the core
- // syntax elements of FBX (brackets, commas, key:value mappings)
- TokenList tokens;
- try {
-
- bool is_binary = false;
- if (!strncmp(begin,"Kaydara FBX Binary",18)) {
- is_binary = true;
- TokenizeBinary(tokens,begin,contents.size());
- }
- else {
- Tokenize(tokens,begin);
- }
-
- // use this information to construct a very rudimentary
- // parse-tree representing the FBX scope structure
- Parser parser(tokens, is_binary);
-
- // take the raw parse-tree and convert it to a FBX DOM
- Document doc(parser,settings);
-
- FbxUnit unit(FbxUnit::cm);
- if (settings.convertToMeters) {
- unit = FbxUnit::m;
- }
-
- // convert the FBX DOM to aiScene
- ConvertToAssimpScene(pScene, doc, settings.removeEmptyBones);
-
- // size relative to cm
- float size_relative_to_cm = doc.GlobalSettings().UnitScaleFactor();
-
- // Set FBX file scale is relative to CM must be converted to M for
- // assimp universal format (M)
- SetFileScale( size_relative_to_cm * 0.01f);
-
- std::for_each(tokens.begin(),tokens.end(),Util::delete_fun<Token>());
- }
- catch(std::exception&) {
- std::for_each(tokens.begin(),tokens.end(),Util::delete_fun<Token>());
- throw;
- }
+void FBXImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
+ std::unique_ptr<IOStream> stream(pIOHandler->Open(pFile, "rb"));
+ if (!stream) {
+ ThrowException("Could not open file for reading");
+ }
+
+ // read entire file into memory - no streaming for this, fbx
+ // files can grow large, but the assimp output data structure
+ // then becomes very large, too. Assimp doesn't support
+ // streaming for its output data structures so the net win with
+ // streaming input data would be very low.
+ std::vector<char> contents;
+ contents.resize(stream->FileSize() + 1);
+ stream->Read(&*contents.begin(), 1, contents.size() - 1);
+ contents[contents.size() - 1] = 0;
+ const char *const begin = &*contents.begin();
+
+ // broadphase tokenizing pass in which we identify the core
+ // syntax elements of FBX (brackets, commas, key:value mappings)
+ TokenList tokens;
+ try {
+
+ bool is_binary = false;
+ if (!strncmp(begin, "Kaydara FBX Binary", 18)) {
+ is_binary = true;
+ TokenizeBinary(tokens, begin, contents.size());
+ } else {
+ Tokenize(tokens, begin);
+ }
+
+ // use this information to construct a very rudimentary
+ // parse-tree representing the FBX scope structure
+ Parser parser(tokens, is_binary);
+
+ // take the raw parse-tree and convert it to a FBX DOM
+ Document doc(parser, settings);
+
+ // convert the FBX DOM to aiScene
+ ConvertToAssimpScene(pScene, doc, settings.removeEmptyBones);
+
+ // size relative to cm
+ float size_relative_to_cm = doc.GlobalSettings().UnitScaleFactor();
+
+ // Set FBX file scale is relative to CM must be converted to M for
+ // assimp universal format (M)
+ SetFileScale(size_relative_to_cm * 0.01f);
+
+ std::for_each(tokens.begin(), tokens.end(), Util::delete_fun<Token>());
+ } catch (std::exception &) {
+ std::for_each(tokens.begin(), tokens.end(), Util::delete_fun<Token>());
+ throw;
+ }
}
#endif // !ASSIMP_BUILD_NO_FBX_IMPORTER
diff --git a/thirdparty/assimp/code/FBX/FBXMeshGeometry.cpp b/thirdparty/assimp/code/FBX/FBXMeshGeometry.cpp
index 5c9a0e309d..1386e2383c 100644
--- a/thirdparty/assimp/code/FBX/FBXMeshGeometry.cpp
+++ b/thirdparty/assimp/code/FBX/FBXMeshGeometry.cpp
@@ -610,11 +610,11 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
const std::string& ReferenceInformationType)
{
const size_t face_count = m_faces.size();
- if(face_count <= 0)
+ if( 0 == face_count )
{
return;
}
-
+
// materials are handled separately. First of all, they are assigned per-face
// and not per polyvert. Secondly, ReferenceInformationType=IndexToDirect
// has a slightly different meaning for materials.
@@ -625,16 +625,14 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
if (materials_out.empty()) {
FBXImporter::LogError(Formatter::format("expected material index, ignoring"));
return;
- }
- else if (materials_out.size() > 1) {
+ } else if (materials_out.size() > 1) {
FBXImporter::LogWarn(Formatter::format("expected only a single material index, ignoring all except the first one"));
materials_out.clear();
}
materials_out.resize(m_vertices.size());
std::fill(materials_out.begin(), materials_out.end(), materials_out.at(0));
- }
- else if (MappingInformationType == "ByPolygon" && ReferenceInformationType == "IndexToDirect") {
+ } else if (MappingInformationType == "ByPolygon" && ReferenceInformationType == "IndexToDirect") {
materials_out.resize(face_count);
if(materials_out.size() != face_count) {
@@ -643,18 +641,16 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
);
return;
}
- }
- else {
+ } else {
FBXImporter::LogError(Formatter::format("ignoring material assignments, access type not implemented: ")
<< MappingInformationType << "," << ReferenceInformationType);
}
}
// ------------------------------------------------------------------------------------------------
ShapeGeometry::ShapeGeometry(uint64_t id, const Element& element, const std::string& name, const Document& doc)
- : Geometry(id, element, name, doc)
-{
- const Scope* sc = element.Compound();
- if (!sc) {
+: Geometry(id, element, name, doc) {
+ const Scope *sc = element.Compound();
+ if (nullptr == sc) {
DOMError("failed to read Geometry object (class: Shape), no data scope found");
}
const Element& Indexes = GetRequiredElement(*sc, "Indexes", &element);
diff --git a/thirdparty/assimp/code/MMD/MMDCpp14.h b/thirdparty/assimp/code/MMD/MMDCpp14.h
deleted file mode 100644
index 638b0bfd2f..0000000000
--- a/thirdparty/assimp/code/MMD/MMDCpp14.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-Open Asset Import Library (assimp)
-----------------------------------------------------------------------
-
-Copyright (c) 2006-2019, assimp team
-
-
-All rights reserved.
-
-Redistribution and use of this software in source and binary forms,
-with or without modification, are permitted provided that the
-following conditions are met:
-
-* Redistributions of source code must retain the above
-copyright notice, this list of conditions and the
-following disclaimer.
-
-* Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the
-following disclaimer in the documentation and/or other
-materials provided with the distribution.
-
-* Neither the name of the assimp team, nor the names of its
-contributors may be used to endorse or promote products
-derived from this software without specific prior
-written permission of the assimp team.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------------------------
-*/
-#pragma once
-
-#ifndef MMD_CPP14_H
-#define MMD_CPP14_H
-
-#include <cstddef>
-#include <memory>
-#include <type_traits>
-#include <utility>
-
-namespace mmd {
- template<class T> struct _Unique_if {
- typedef std::unique_ptr<T> _Single_object;
- };
-
- template<class T> struct _Unique_if<T[]> {
- typedef std::unique_ptr<T[]> _Unknown_bound;
- };
-
- template<class T, size_t N> struct _Unique_if<T[N]> {
- typedef void _Known_bound;
- };
-
- template<class T, class... Args>
- typename _Unique_if<T>::_Single_object
- make_unique(Args&&... args) {
- return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
- }
-
- template<class T>
- typename _Unique_if<T>::_Unknown_bound
- make_unique(size_t n) {
- typedef typename std::remove_extent<T>::type U;
- return std::unique_ptr<T>(new U[n]());
- }
-
- template<class T, class... Args>
- typename _Unique_if<T>::_Known_bound
- make_unique(Args&&...) = delete;
-}
-
-#endif
diff --git a/thirdparty/assimp/code/MMD/MMDImporter.cpp b/thirdparty/assimp/code/MMD/MMDImporter.cpp
deleted file mode 100644
index e7744e4cd0..0000000000
--- a/thirdparty/assimp/code/MMD/MMDImporter.cpp
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
----------------------------------------------------------------------------
-Open Asset Import Library (assimp)
----------------------------------------------------------------------------
-
-Copyright (c) 2006-2016, assimp team
-
-All rights reserved.
-
-Redistribution and use of this software in source and binary forms,
-with or without modification, are permitted provided that the following
-conditions are met:
-
-* Redistributions of source code must retain the above
- copyright notice, this list of conditions and the
- following disclaimer.
-
-* Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the
- following disclaimer in the documentation and/or other
- materials provided with the distribution.
-
-* Neither the name of the assimp team, nor the names of its
- contributors may be used to endorse or promote products
- derived from this software without specific prior
- written permission of the assimp team.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------------
-*/
-
-#ifndef ASSIMP_BUILD_NO_MMD_IMPORTER
-
-#include "MMD/MMDImporter.h"
-#include "MMD/MMDPmdParser.h"
-#include "MMD/MMDPmxParser.h"
-#include "MMD/MMDVmdParser.h"
-#include "PostProcessing/ConvertToLHProcess.h"
-
-#include <assimp/DefaultIOSystem.h>
-#include <assimp/Importer.hpp>
-#include <assimp/ai_assert.h>
-#include <assimp/scene.h>
-
-#include <fstream>
-#include <iomanip>
-#include <memory>
-
-static const aiImporterDesc desc = {"MMD Importer",
- "",
- "",
- "surfaces supported?",
- aiImporterFlags_SupportTextFlavour,
- 0,
- 0,
- 0,
- 0,
- "pmx"};
-
-namespace Assimp {
-
-using namespace std;
-
-// ------------------------------------------------------------------------------------------------
-// Default constructor
-MMDImporter::MMDImporter()
-: m_Buffer()
-, m_strAbsPath("") {
- DefaultIOSystem io;
- m_strAbsPath = io.getOsSeparator();
-}
-
-// ------------------------------------------------------------------------------------------------
-// Destructor.
-MMDImporter::~MMDImporter() {
- // empty
-}
-
-// ------------------------------------------------------------------------------------------------
-// Returns true, if file is an pmx file.
-bool MMDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler,
- bool checkSig) const {
- if (!checkSig) // Check File Extension
- {
- return SimpleExtensionCheck(pFile, "pmx");
- } else // Check file Header
- {
- static const char *pTokens[] = {"PMX "};
- return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 1);
- }
-}
-
-// ------------------------------------------------------------------------------------------------
-const aiImporterDesc *MMDImporter::GetInfo() const { return &desc; }
-
-// ------------------------------------------------------------------------------------------------
-// MMD import implementation
-void MMDImporter::InternReadFile(const std::string &file, aiScene *pScene,
- IOSystem * /*pIOHandler*/) {
- // Read file by istream
- std::filebuf fb;
- if (!fb.open(file, std::ios::in | std::ios::binary)) {
- throw DeadlyImportError("Failed to open file " + file + ".");
- }
-
- std::istream fileStream(&fb);
-
- // Get the file-size and validate it, throwing an exception when fails
- fileStream.seekg(0, fileStream.end);
- size_t fileSize = static_cast<size_t>(fileStream.tellg());
- fileStream.seekg(0, fileStream.beg);
-
- if (fileSize < sizeof(pmx::PmxModel)) {
- throw DeadlyImportError(file + " is too small.");
- }
-
- pmx::PmxModel model;
- model.Read(&fileStream);
-
- CreateDataFromImport(&model, pScene);
-}
-
-// ------------------------------------------------------------------------------------------------
-void MMDImporter::CreateDataFromImport(const pmx::PmxModel *pModel,
- aiScene *pScene) {
- if (pModel == NULL) {
- return;
- }
-
- aiNode *pNode = new aiNode;
- if (!pModel->model_name.empty()) {
- pNode->mName.Set(pModel->model_name);
- }
-
- pScene->mRootNode = pNode;
-
- pNode = new aiNode;
- pScene->mRootNode->addChildren(1, &pNode);
- pNode->mName.Set(string(pModel->model_name) + string("_mesh"));
-
- // split mesh by materials
- pNode->mNumMeshes = pModel->material_count;
- pNode->mMeshes = new unsigned int[pNode->mNumMeshes];
- for (unsigned int index = 0; index < pNode->mNumMeshes; index++) {
- pNode->mMeshes[index] = index;
- }
-
- pScene->mNumMeshes = pModel->material_count;
- pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
- for (unsigned int i = 0, indexStart = 0; i < pScene->mNumMeshes; i++) {
- const int indexCount = pModel->materials[i].index_count;
-
- pScene->mMeshes[i] = CreateMesh(pModel, indexStart, indexCount);
- pScene->mMeshes[i]->mName = pModel->materials[i].material_name;
- pScene->mMeshes[i]->mMaterialIndex = i;
- indexStart += indexCount;
- }
-
- // create node hierarchy for bone position
- std::unique_ptr<aiNode *[]> ppNode(new aiNode *[pModel->bone_count]);
- for (auto i = 0; i < pModel->bone_count; i++) {
- ppNode[i] = new aiNode(pModel->bones[i].bone_name);
- }
-
- for (auto i = 0; i < pModel->bone_count; i++) {
- const pmx::PmxBone &bone = pModel->bones[i];
-
- if (bone.parent_index < 0) {
- pScene->mRootNode->addChildren(1, ppNode.get() + i);
- } else {
- ppNode[bone.parent_index]->addChildren(1, ppNode.get() + i);
-
- aiVector3D v3 = aiVector3D(
- bone.position[0] - pModel->bones[bone.parent_index].position[0],
- bone.position[1] - pModel->bones[bone.parent_index].position[1],
- bone.position[2] - pModel->bones[bone.parent_index].position[2]);
- aiMatrix4x4::Translation(v3, ppNode[i]->mTransformation);
- }
- }
-
- // create materials
- pScene->mNumMaterials = pModel->material_count;
- pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials];
- for (unsigned int i = 0; i < pScene->mNumMaterials; i++) {
- pScene->mMaterials[i] = CreateMaterial(&pModel->materials[i], pModel);
- }
-
- // Convert everything to OpenGL space
- MakeLeftHandedProcess convertProcess;
- convertProcess.Execute(pScene);
-
- FlipUVsProcess uvFlipper;
- uvFlipper.Execute(pScene);
-
- FlipWindingOrderProcess windingFlipper;
- windingFlipper.Execute(pScene);
-}
-
-// ------------------------------------------------------------------------------------------------
-aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
- const int indexStart, const int indexCount) {
- aiMesh *pMesh = new aiMesh;
-
- pMesh->mNumVertices = indexCount;
-
- pMesh->mNumFaces = indexCount / 3;
- pMesh->mFaces = new aiFace[pMesh->mNumFaces];
-
- const int numIndices = 3; // triangular face
- for (unsigned int index = 0; index < pMesh->mNumFaces; index++) {
- pMesh->mFaces[index].mNumIndices = numIndices;
- unsigned int *indices = new unsigned int[numIndices];
- indices[0] = numIndices * index;
- indices[1] = numIndices * index + 1;
- indices[2] = numIndices * index + 2;
- pMesh->mFaces[index].mIndices = indices;
- }
-
- pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
- pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
- pMesh->mTextureCoords[0] = new aiVector3D[pMesh->mNumVertices];
- pMesh->mNumUVComponents[0] = 2;
-
- // additional UVs
- for (int i = 1; i <= pModel->setting.uv; i++) {
- pMesh->mTextureCoords[i] = new aiVector3D[pMesh->mNumVertices];
- pMesh->mNumUVComponents[i] = 4;
- }
-
- map<int, vector<aiVertexWeight>> bone_vertex_map;
-
- // fill in contents and create bones
- for (int index = 0; index < indexCount; index++) {
- const pmx::PmxVertex *v =
- &pModel->vertices[pModel->indices[indexStart + index]];
- const float *position = v->position;
- pMesh->mVertices[index].Set(position[0], position[1], position[2]);
- const float *normal = v->normal;
-
- pMesh->mNormals[index].Set(normal[0], normal[1], normal[2]);
- pMesh->mTextureCoords[0][index].x = v->uv[0];
- pMesh->mTextureCoords[0][index].y = v->uv[1];
-
- for (int i = 1; i <= pModel->setting.uv; i++) {
- // TODO: wrong here? use quaternion transform?
- pMesh->mTextureCoords[i][index].x = v->uva[i][0];
- pMesh->mTextureCoords[i][index].y = v->uva[i][1];
- }
-
- // handle bone map
- const auto vsBDEF1_ptr =
- dynamic_cast<pmx::PmxVertexSkinningBDEF1 *>(v->skinning.get());
- const auto vsBDEF2_ptr =
- dynamic_cast<pmx::PmxVertexSkinningBDEF2 *>(v->skinning.get());
- const auto vsBDEF4_ptr =
- dynamic_cast<pmx::PmxVertexSkinningBDEF4 *>(v->skinning.get());
- const auto vsSDEF_ptr =
- dynamic_cast<pmx::PmxVertexSkinningSDEF *>(v->skinning.get());
- switch (v->skinning_type) {
- case pmx::PmxVertexSkinningType::BDEF1:
- bone_vertex_map[vsBDEF1_ptr->bone_index].push_back(
- aiVertexWeight(index, 1.0));
- break;
- case pmx::PmxVertexSkinningType::BDEF2:
- 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.0f - vsBDEF2_ptr->bone_weight));
- break;
- case pmx::PmxVertexSkinningType::BDEF4:
- bone_vertex_map[vsBDEF4_ptr->bone_index1].push_back(
- aiVertexWeight(index, vsBDEF4_ptr->bone_weight1));
- bone_vertex_map[vsBDEF4_ptr->bone_index2].push_back(
- aiVertexWeight(index, vsBDEF4_ptr->bone_weight2));
- bone_vertex_map[vsBDEF4_ptr->bone_index3].push_back(
- aiVertexWeight(index, vsBDEF4_ptr->bone_weight3));
- bone_vertex_map[vsBDEF4_ptr->bone_index4].push_back(
- aiVertexWeight(index, vsBDEF4_ptr->bone_weight4));
- break;
- case pmx::PmxVertexSkinningType::SDEF: // TODO: how to use sdef_c, sdef_r0,
- // sdef_r1?
- 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.0f - vsSDEF_ptr->bone_weight));
- break;
- case pmx::PmxVertexSkinningType::QDEF:
- const auto vsQDEF_ptr =
- dynamic_cast<pmx::PmxVertexSkinningQDEF *>(v->skinning.get());
- bone_vertex_map[vsQDEF_ptr->bone_index1].push_back(
- aiVertexWeight(index, vsQDEF_ptr->bone_weight1));
- bone_vertex_map[vsQDEF_ptr->bone_index2].push_back(
- aiVertexWeight(index, vsQDEF_ptr->bone_weight2));
- bone_vertex_map[vsQDEF_ptr->bone_index3].push_back(
- aiVertexWeight(index, vsQDEF_ptr->bone_weight3));
- bone_vertex_map[vsQDEF_ptr->bone_index4].push_back(
- aiVertexWeight(index, vsQDEF_ptr->bone_weight4));
- break;
- }
- }
-
- // make all bones for each mesh
- // assign bone weights to skinned bones (otherwise just initialize)
- auto bone_ptr_ptr = new aiBone *[pModel->bone_count];
- pMesh->mNumBones = pModel->bone_count;
- pMesh->mBones = bone_ptr_ptr;
- for (auto ii = 0; ii < pModel->bone_count; ++ii) {
- auto pBone = new aiBone;
- const auto &pmxBone = pModel->bones[ii];
- pBone->mName = pmxBone.bone_name;
- aiVector3D pos(pmxBone.position[0], pmxBone.position[1], pmxBone.position[2]);
- aiMatrix4x4::Translation(-pos, pBone->mOffsetMatrix);
- auto it = bone_vertex_map.find(ii);
- if (it != bone_vertex_map.end()) {
- pBone->mNumWeights = static_cast<unsigned int>(it->second.size());
- pBone->mWeights = new aiVertexWeight[pBone->mNumWeights];
- for (unsigned int j = 0; j < pBone->mNumWeights; j++) {
- pBone->mWeights[j] = it->second[j];
- }
- }
- bone_ptr_ptr[ii] = pBone;
- }
-
- return pMesh;
-}
-
-// ------------------------------------------------------------------------------------------------
-aiMaterial *MMDImporter::CreateMaterial(const pmx::PmxMaterial *pMat,
- const pmx::PmxModel *pModel) {
- aiMaterial *mat = new aiMaterial();
- aiString name(pMat->material_english_name);
- mat->AddProperty(&name, AI_MATKEY_NAME);
-
- aiColor3D diffuse(pMat->diffuse[0], pMat->diffuse[1], pMat->diffuse[2]);
- mat->AddProperty(&diffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
- aiColor3D specular(pMat->specular[0], pMat->specular[1], pMat->specular[2]);
- mat->AddProperty(&specular, 1, AI_MATKEY_COLOR_SPECULAR);
- aiColor3D ambient(pMat->ambient[0], pMat->ambient[1], pMat->ambient[2]);
- mat->AddProperty(&ambient, 1, AI_MATKEY_COLOR_AMBIENT);
-
- float opacity = pMat->diffuse[3];
- mat->AddProperty(&opacity, 1, AI_MATKEY_OPACITY);
- float shininess = pMat->specularlity;
- mat->AddProperty(&shininess, 1, AI_MATKEY_SHININESS_STRENGTH);
-
- if(pMat->diffuse_texture_index >= 0) {
- aiString texture_path(pModel->textures[pMat->diffuse_texture_index]);
- mat->AddProperty(&texture_path, AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0));
- }
-
- int mapping_uvwsrc = 0;
- mat->AddProperty(&mapping_uvwsrc, 1,
- AI_MATKEY_UVWSRC(aiTextureType_DIFFUSE, 0));
-
- return mat;
-}
-
-// ------------------------------------------------------------------------------------------------
-
-} // Namespace Assimp
-
-#endif // !! ASSIMP_BUILD_NO_MMD_IMPORTER
diff --git a/thirdparty/assimp/code/MMD/MMDImporter.h b/thirdparty/assimp/code/MMD/MMDImporter.h
deleted file mode 100644
index 4ee94eeb00..0000000000
--- a/thirdparty/assimp/code/MMD/MMDImporter.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
-Open Asset Import Library (assimp)
-----------------------------------------------------------------------
-
-Copyright (c) 2006-2016, assimp team
-All rights reserved.
-
-Redistribution and use of this software in source and binary forms,
-with or without modification, are permitted provided that the
-following conditions are met:
-
-* Redistributions of source code must retain the above
- copyright notice, this list of conditions and the
- following disclaimer.
-
-* Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the
- following disclaimer in the documentation and/or other
- materials provided with the distribution.
-
-* Neither the name of the assimp team, nor the names of its
- contributors may be used to endorse or promote products
- derived from this software without specific prior
- written permission of the assimp team.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------------------------
-*/
-#ifndef MMD_FILE_IMPORTER_H_INC
-#define MMD_FILE_IMPORTER_H_INC
-
-#include <assimp/BaseImporter.h>
-#include "MMDPmxParser.h"
-#include <assimp/material.h>
-#include <vector>
-
-struct aiMesh;
-
-namespace Assimp {
-
-// ------------------------------------------------------------------------------------------------
-/// \class MMDImporter
-/// \brief Imports MMD a pmx/pmd/vmd file
-// ------------------------------------------------------------------------------------------------
-class MMDImporter : public BaseImporter {
-public:
- /// \brief Default constructor
- MMDImporter();
-
- /// \brief Destructor
- ~MMDImporter();
-
-public:
- /// \brief Returns whether the class can handle the format of the given file.
- /// \remark See BaseImporter::CanRead() for details.
- bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const;
-
-private:
- //! \brief Appends the supported extension.
- const aiImporterDesc* GetInfo () const;
-
- //! \brief File import implementation.
- void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
-
- //! \brief Create the data from imported content.
- void CreateDataFromImport(const pmx::PmxModel* pModel, aiScene* pScene);
-
- //! \brief Create the mesh
- aiMesh* CreateMesh(const pmx::PmxModel* pModel, const int indexStart, const int indexCount);
-
- //! \brief Create the material
- aiMaterial* CreateMaterial(const pmx::PmxMaterial* pMat, const pmx::PmxModel* pModel);
-
-private:
- //! Data buffer
- std::vector<char> m_Buffer;
- //! Absolute pathname of model in file system
- std::string m_strAbsPath;
-};
-
-// ------------------------------------------------------------------------------------------------
-
-} // Namespace Assimp
-
-#endif \ No newline at end of file
diff --git a/thirdparty/assimp/code/MMD/MMDPmdParser.h b/thirdparty/assimp/code/MMD/MMDPmdParser.h
deleted file mode 100644
index d2f2224aa1..0000000000
--- a/thirdparty/assimp/code/MMD/MMDPmdParser.h
+++ /dev/null
@@ -1,597 +0,0 @@
-/*
-Open Asset Import Library (assimp)
-----------------------------------------------------------------------
-
-Copyright (c) 2006-2019, assimp team
-
-
-All rights reserved.
-
-Redistribution and use of this software in source and binary forms,
-with or without modification, are permitted provided that the
-following conditions are met:
-
-* Redistributions of source code must retain the above
-copyright notice, this list of conditions and the
-following disclaimer.
-
-* Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the
-following disclaimer in the documentation and/or other
-materials provided with the distribution.
-
-* Neither the name of the assimp team, nor the names of its
-contributors may be used to endorse or promote products
-derived from this software without specific prior
-written permission of the assimp team.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------------------------
-*/
-#pragma once
-
-#include <vector>
-#include <string>
-#include <memory>
-#include <iostream>
-#include <fstream>
-#include "MMDCpp14.h"
-
-namespace pmd
-{
- class PmdHeader
- {
- public:
- std::string name;
- std::string name_english;
- std::string comment;
- std::string comment_english;
-
- bool Read(std::ifstream* stream)
- {
- char buffer[256];
- stream->read(buffer, 20);
- name = std::string(buffer);
- stream->read(buffer, 256);
- comment = std::string(buffer);
- return true;
- }
-
- bool ReadExtension(std::ifstream* stream)
- {
- char buffer[256];
- stream->read(buffer, 20);
- name_english = std::string(buffer);
- stream->read(buffer, 256);
- comment_english = std::string(buffer);
- return true;
- }
- };
-
- class PmdVertex
- {
- public:
- float position[3];
-
- float normal[3];
-
- float uv[2];
-
- uint16_t bone_index[2];
-
- uint8_t bone_weight;
-
- bool edge_invisible;
-
- bool Read(std::ifstream* stream)
- {
- stream->read((char*) position, sizeof(float) * 3);
- stream->read((char*) normal, sizeof(float) * 3);
- stream->read((char*) uv, sizeof(float) * 2);
- stream->read((char*) bone_index, sizeof(uint16_t) * 2);
- stream->read((char*) &bone_weight, sizeof(uint8_t));
- stream->read((char*) &edge_invisible, sizeof(uint8_t));
- return true;
- }
- };
-
- class PmdMaterial
- {
- public:
- float diffuse[4];
- float power;
- float specular[3];
- float ambient[3];
- uint8_t toon_index;
- uint8_t edge_flag;
- uint32_t index_count;
- std::string texture_filename;
- std::string sphere_filename;
-
- bool Read(std::ifstream* stream)
- {
- char buffer[20];
- stream->read((char*) &diffuse, sizeof(float) * 4);
- stream->read((char*) &power, sizeof(float));
- stream->read((char*) &specular, sizeof(float) * 3);
- stream->read((char*) &ambient, sizeof(float) * 3);
- stream->read((char*) &toon_index, sizeof(uint8_t));
- stream->read((char*) &edge_flag, sizeof(uint8_t));
- stream->read((char*) &index_count, sizeof(uint32_t));
- stream->read((char*) &buffer, sizeof(char) * 20);
- char* pstar = strchr(buffer, '*');
- if (NULL == pstar)
- {
- texture_filename = std::string(buffer);
- sphere_filename.clear();
- }
- else {
- *pstar = 0;
- texture_filename = std::string(buffer);
- sphere_filename = std::string(pstar+1);
- }
- return true;
- }
- };
-
- enum class BoneType : uint8_t
- {
- Rotation,
- RotationAndMove,
- IkEffector,
- Unknown,
- IkEffectable,
- RotationEffectable,
- IkTarget,
- Invisible,
- Twist,
- RotationMovement
- };
-
- class PmdBone
- {
- public:
- std::string name;
- std::string name_english;
- uint16_t parent_bone_index;
- uint16_t tail_pos_bone_index;
- BoneType bone_type;
- uint16_t ik_parent_bone_index;
- float bone_head_pos[3];
-
- void Read(std::istream *stream)
- {
- char buffer[20];
- stream->read(buffer, 20);
- name = std::string(buffer);
- stream->read((char*) &parent_bone_index, sizeof(uint16_t));
- stream->read((char*) &tail_pos_bone_index, sizeof(uint16_t));
- stream->read((char*) &bone_type, sizeof(uint8_t));
- stream->read((char*) &ik_parent_bone_index, sizeof(uint16_t));
- stream->read((char*) &bone_head_pos, sizeof(float) * 3);
- }
-
- void ReadExpantion(std::istream *stream)
- {
- char buffer[20];
- stream->read(buffer, 20);
- name_english = std::string(buffer);
- }
- };
-
- class PmdIk
- {
- public:
- uint16_t ik_bone_index;
- uint16_t target_bone_index;
- uint16_t interations;
- float angle_limit;
- std::vector<uint16_t> ik_child_bone_index;
-
- void Read(std::istream *stream)
- {
- stream->read((char *) &ik_bone_index, sizeof(uint16_t));
- stream->read((char *) &target_bone_index, sizeof(uint16_t));
- uint8_t ik_chain_length;
- stream->read((char*) &ik_chain_length, sizeof(uint8_t));
- stream->read((char *) &interations, sizeof(uint16_t));
- stream->read((char *) &angle_limit, sizeof(float));
- ik_child_bone_index.resize(ik_chain_length);
- for (int i = 0; i < ik_chain_length; i++)
- {
- stream->read((char *) &ik_child_bone_index[i], sizeof(uint16_t));
- }
- }
- };
-
- class PmdFaceVertex
- {
- public:
- int vertex_index;
- float position[3];
-
- void Read(std::istream *stream)
- {
- stream->read((char *) &vertex_index, sizeof(int));
- stream->read((char *) position, sizeof(float) * 3);
- }
- };
-
- enum class FaceCategory : uint8_t
- {
- Base,
- Eyebrow,
- Eye,
- Mouth,
- Other
- };
-
- class PmdFace
- {
- public:
- std::string name;
- FaceCategory type;
- std::vector<PmdFaceVertex> vertices;
- std::string name_english;
-
- void Read(std::istream *stream)
- {
- char buffer[20];
- stream->read(buffer, 20);
- name = std::string(buffer);
- int vertex_count;
- stream->read((char*) &vertex_count, sizeof(int));
- stream->read((char*) &type, sizeof(uint8_t));
- vertices.resize(vertex_count);
- for (int i = 0; i < vertex_count; i++)
- {
- vertices[i].Read(stream);
- }
- }
-
- void ReadExpantion(std::istream *stream)
- {
- char buffer[20];
- stream->read(buffer, 20);
- name_english = std::string(buffer);
- }
- };
-
- class PmdBoneDispName
- {
- public:
- std::string bone_disp_name;
- std::string bone_disp_name_english;
-
- void Read(std::istream *stream)
- {
- char buffer[50];
- stream->read(buffer, 50);
- bone_disp_name = std::string(buffer);
- bone_disp_name_english.clear();
- }
- void ReadExpantion(std::istream *stream)
- {
- char buffer[50];
- stream->read(buffer, 50);
- bone_disp_name_english = std::string(buffer);
- }
- };
-
- class PmdBoneDisp
- {
- public:
- uint16_t bone_index;
- uint8_t bone_disp_index;
-
- void Read(std::istream *stream)
- {
- stream->read((char*) &bone_index, sizeof(uint16_t));
- stream->read((char*) &bone_disp_index, sizeof(uint8_t));
- }
- };
-
- enum class RigidBodyShape : uint8_t
- {
- Sphere = 0,
- Box = 1,
- Cpusel = 2
- };
-
- enum class RigidBodyType : uint8_t
- {
- BoneConnected = 0,
- Physics = 1,
- ConnectedPhysics = 2
- };
-
- class PmdRigidBody
- {
- public:
- std::string name;
- uint16_t related_bone_index;
- uint8_t group_index;
- uint16_t mask;
- RigidBodyShape shape;
- float size[3];
- float position[3];
- float orientation[3];
- float weight;
- float linear_damping;
- float anglar_damping;
- float restitution;
- float friction;
- RigidBodyType rigid_type;
-
- void Read(std::istream *stream)
- {
- char buffer[20];
- stream->read(buffer, sizeof(char) * 20);
- name = (std::string(buffer));
- stream->read((char*) &related_bone_index, sizeof(uint16_t));
- stream->read((char*) &group_index, sizeof(uint8_t));
- stream->read((char*) &mask, sizeof(uint16_t));
- stream->read((char*) &shape, sizeof(uint8_t));
- stream->read((char*) size, sizeof(float) * 3);
- stream->read((char*) position, sizeof(float) * 3);
- stream->read((char*) orientation, sizeof(float) * 3);
- stream->read((char*) &weight, sizeof(float));
- stream->read((char*) &linear_damping, sizeof(float));
- stream->read((char*) &anglar_damping, sizeof(float));
- stream->read((char*) &restitution, sizeof(float));
- stream->read((char*) &friction, sizeof(float));
- stream->read((char*) &rigid_type, sizeof(char));
- }
- };
-
- class PmdConstraint
- {
- public:
- std::string name;
- uint32_t rigid_body_index_a;
- uint32_t rigid_body_index_b;
- float position[3];
- float orientation[3];
- float linear_lower_limit[3];
- float linear_upper_limit[3];
- float angular_lower_limit[3];
- float angular_upper_limit[3];
- float linear_stiffness[3];
- float angular_stiffness[3];
-
- void Read(std::istream *stream)
- {
- char buffer[20];
- stream->read(buffer, 20);
- name = std::string(buffer);
- stream->read((char *) &rigid_body_index_a, sizeof(uint32_t));
- stream->read((char *) &rigid_body_index_b, sizeof(uint32_t));
- stream->read((char *) position, sizeof(float) * 3);
- stream->read((char *) orientation, sizeof(float) * 3);
- stream->read((char *) linear_lower_limit, sizeof(float) * 3);
- stream->read((char *) linear_upper_limit, sizeof(float) * 3);
- stream->read((char *) angular_lower_limit, sizeof(float) * 3);
- stream->read((char *) angular_upper_limit, sizeof(float) * 3);
- stream->read((char *) linear_stiffness, sizeof(float) * 3);
- stream->read((char *) angular_stiffness, sizeof(float) * 3);
- }
- };
-
- class PmdModel
- {
- public:
- float version;
- PmdHeader header;
- std::vector<PmdVertex> vertices;
- std::vector<uint16_t> indices;
- std::vector<PmdMaterial> materials;
- std::vector<PmdBone> bones;
- std::vector<PmdIk> iks;
- std::vector<PmdFace> faces;
- std::vector<uint16_t> faces_indices;
- std::vector<PmdBoneDispName> bone_disp_name;
- std::vector<PmdBoneDisp> bone_disp;
- std::vector<std::string> toon_filenames;
- std::vector<PmdRigidBody> rigid_bodies;
- std::vector<PmdConstraint> constraints;
-
- static std::unique_ptr<PmdModel> LoadFromFile(const char *filename)
- {
- std::ifstream stream(filename, std::ios::binary);
- if (stream.fail())
- {
- std::cerr << "could not open \"" << filename << "\"" << std::endl;
- return nullptr;
- }
- auto result = LoadFromStream(&stream);
- stream.close();
- return result;
- }
-
- static std::unique_ptr<PmdModel> LoadFromStream(std::ifstream *stream)
- {
- auto result = mmd::make_unique<PmdModel>();
- char buffer[100];
-
- // magic
- char magic[3];
- stream->read(magic, 3);
- if (magic[0] != 'P' || magic[1] != 'm' || magic[2] != 'd')
- {
- std::cerr << "invalid file" << std::endl;
- return nullptr;
- }
-
- // version
- stream->read((char*) &(result->version), sizeof(float));
- if (result ->version != 1.0f)
- {
- std::cerr << "invalid version" << std::endl;
- return nullptr;
- }
-
- // header
- result->header.Read(stream);
-
- // vertices
- uint32_t vertex_num;
- stream->read((char*) &vertex_num, sizeof(uint32_t));
- result->vertices.resize(vertex_num);
- for (uint32_t i = 0; i < vertex_num; i++)
- {
- result->vertices[i].Read(stream);
- }
-
- // indices
- uint32_t index_num;
- stream->read((char*) &index_num, sizeof(uint32_t));
- result->indices.resize(index_num);
- for (uint32_t i = 0; i < index_num; i++)
- {
- stream->read((char*) &result->indices[i], sizeof(uint16_t));
- }
-
- // materials
- uint32_t material_num;
- stream->read((char*) &material_num, sizeof(uint32_t));
- result->materials.resize(material_num);
- for (uint32_t i = 0; i < material_num; i++)
- {
- result->materials[i].Read(stream);
- }
-
- // bones
- uint16_t bone_num;
- stream->read((char*) &bone_num, sizeof(uint16_t));
- result->bones.resize(bone_num);
- for (uint32_t i = 0; i < bone_num; i++)
- {
- result->bones[i].Read(stream);
- }
-
- // iks
- uint16_t ik_num;
- stream->read((char*) &ik_num, sizeof(uint16_t));
- result->iks.resize(ik_num);
- for (uint32_t i = 0; i < ik_num; i++)
- {
- result->iks[i].Read(stream);
- }
-
- // faces
- uint16_t face_num;
- stream->read((char*) &face_num, sizeof(uint16_t));
- result->faces.resize(face_num);
- for (uint32_t i = 0; i < face_num; i++)
- {
- result->faces[i].Read(stream);
- }
-
- // face frames
- uint8_t face_frame_num;
- stream->read((char*) &face_frame_num, sizeof(uint8_t));
- result->faces_indices.resize(face_frame_num);
- for (uint32_t i = 0; i < face_frame_num; i++)
- {
- stream->read((char*) &result->faces_indices[i], sizeof(uint16_t));
- }
-
- // bone names
- uint8_t bone_disp_num;
- stream->read((char*) &bone_disp_num, sizeof(uint8_t));
- result->bone_disp_name.resize(bone_disp_num);
- for (uint32_t i = 0; i < bone_disp_num; i++)
- {
- result->bone_disp_name[i].Read(stream);
- }
-
- // bone frame
- uint32_t bone_frame_num;
- stream->read((char*) &bone_frame_num, sizeof(uint32_t));
- result->bone_disp.resize(bone_frame_num);
- for (uint32_t i = 0; i < bone_frame_num; i++)
- {
- result->bone_disp[i].Read(stream);
- }
-
- // english name
- bool english;
- stream->read((char*) &english, sizeof(char));
- if (english)
- {
- result->header.ReadExtension(stream);
- for (uint32_t i = 0; i < bone_num; i++)
- {
- result->bones[i].ReadExpantion(stream);
- }
- for (uint32_t i = 0; i < face_num; i++)
- {
- if (result->faces[i].type == pmd::FaceCategory::Base)
- {
- continue;
- }
- result->faces[i].ReadExpantion(stream);
- }
- for (uint32_t i = 0; i < result->bone_disp_name.size(); i++)
- {
- result->bone_disp_name[i].ReadExpantion(stream);
- }
- }
-
- // toon textures
- if (stream->peek() == std::ios::traits_type::eof())
- {
- result->toon_filenames.clear();
- }
- else {
- result->toon_filenames.resize(10);
- for (uint32_t i = 0; i < 10; i++)
- {
- stream->read(buffer, 100);
- result->toon_filenames[i] = std::string(buffer);
- }
- }
-
- // physics
- if (stream->peek() == std::ios::traits_type::eof())
- {
- result->rigid_bodies.clear();
- result->constraints.clear();
- }
- else {
- uint32_t rigid_body_num;
- stream->read((char*) &rigid_body_num, sizeof(uint32_t));
- result->rigid_bodies.resize(rigid_body_num);
- for (uint32_t i = 0; i < rigid_body_num; i++)
- {
- result->rigid_bodies[i].Read(stream);
- }
- uint32_t constraint_num;
- stream->read((char*) &constraint_num, sizeof(uint32_t));
- result->constraints.resize(constraint_num);
- for (uint32_t i = 0; i < constraint_num; i++)
- {
- result->constraints[i].Read(stream);
- }
- }
-
- if (stream->peek() != std::ios::traits_type::eof())
- {
- std::cerr << "there is unknown data" << std::endl;
- }
-
- return result;
- }
- };
-}
diff --git a/thirdparty/assimp/code/MMD/MMDPmxParser.cpp b/thirdparty/assimp/code/MMD/MMDPmxParser.cpp
deleted file mode 100644
index 80f0986dd7..0000000000
--- a/thirdparty/assimp/code/MMD/MMDPmxParser.cpp
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
-Open Asset Import Library (assimp)
-----------------------------------------------------------------------
-
-Copyright (c) 2006-2019, assimp team
-
-
-All rights reserved.
-
-Redistribution and use of this software in source and binary forms,
-with or without modification, are permitted provided that the
-following conditions are met:
-
-* Redistributions of source code must retain the above
-copyright notice, this list of conditions and the
-following disclaimer.
-
-* Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the
-following disclaimer in the documentation and/or other
-materials provided with the distribution.
-
-* Neither the name of the assimp team, nor the names of its
-contributors may be used to endorse or promote products
-derived from this software without specific prior
-written permission of the assimp team.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------------------------
-*/
-#include <utility>
-#include "MMDPmxParser.h"
-#include <assimp/StringUtils.h>
-#ifdef ASSIMP_USE_HUNTER
-# include <utf8/utf8.h>
-#else
-# include "../contrib/utf8cpp/source/utf8.h"
-#endif
-#include <assimp/Exceptional.h>
-
-namespace pmx
-{
- int ReadIndex(std::istream *stream, int size)
- {
- switch (size)
- {
- case 1:
- uint8_t tmp8;
- stream->read((char*) &tmp8, sizeof(uint8_t));
- if (255 == tmp8)
- {
- return -1;
- }
- else {
- return (int) tmp8;
- }
- case 2:
- uint16_t tmp16;
- stream->read((char*) &tmp16, sizeof(uint16_t));
- if (65535 == tmp16)
- {
- return -1;
- }
- else {
- return (int) tmp16;
- }
- case 4:
- int tmp32;
- stream->read((char*) &tmp32, sizeof(int));
- return tmp32;
- default:
- return -1;
- }
- }
-
- std::string ReadString(std::istream *stream, uint8_t encoding)
- {
- int size;
- stream->read((char*) &size, sizeof(int));
- std::vector<char> buffer;
- if (size == 0)
- {
- return std::string("");
- }
- buffer.reserve(size);
- stream->read((char*) buffer.data(), size);
- if (encoding == 0)
- {
- // UTF16 to UTF8
- const uint16_t* sourceStart = (uint16_t*)buffer.data();
- const unsigned int targetSize = size * 3; // enough to encode
- char *targetStart = new char[targetSize];
- std::memset(targetStart, 0, targetSize * sizeof(char));
-
- utf8::utf16to8( sourceStart, sourceStart + size/2, targetStart );
-
- std::string result(targetStart);
- delete [] targetStart;
- return result;
- }
- else
- {
- // the name is already UTF8
- return std::string((const char*)buffer.data(), size);
- }
- }
-
- void PmxSetting::Read(std::istream *stream)
- {
- uint8_t count;
- stream->read((char*) &count, sizeof(uint8_t));
- if (count < 8)
- {
- throw DeadlyImportError("MMD: invalid size");
- }
- stream->read((char*) &encoding, sizeof(uint8_t));
- stream->read((char*) &uv, sizeof(uint8_t));
- stream->read((char*) &vertex_index_size, sizeof(uint8_t));
- stream->read((char*) &texture_index_size, sizeof(uint8_t));
- stream->read((char*) &material_index_size, sizeof(uint8_t));
- stream->read((char*) &bone_index_size, sizeof(uint8_t));
- stream->read((char*) &morph_index_size, sizeof(uint8_t));
- stream->read((char*) &rigidbody_index_size, sizeof(uint8_t));
- uint8_t temp;
- for (int i = 8; i < count; i++)
- {
- stream->read((char*)&temp, sizeof(uint8_t));
- }
- }
-
- void PmxVertexSkinningBDEF1::Read(std::istream *stream, PmxSetting *setting)
- {
- this->bone_index = ReadIndex(stream, setting->bone_index_size);
- }
-
- void PmxVertexSkinningBDEF2::Read(std::istream *stream, PmxSetting *setting)
- {
- this->bone_index1 = ReadIndex(stream, setting->bone_index_size);
- this->bone_index2 = ReadIndex(stream, setting->bone_index_size);
- stream->read((char*) &this->bone_weight, sizeof(float));
- }
-
- void PmxVertexSkinningBDEF4::Read(std::istream *stream, PmxSetting *setting)
- {
- this->bone_index1 = ReadIndex(stream, setting->bone_index_size);
- this->bone_index2 = ReadIndex(stream, setting->bone_index_size);
- this->bone_index3 = ReadIndex(stream, setting->bone_index_size);
- this->bone_index4 = ReadIndex(stream, setting->bone_index_size);
- stream->read((char*) &this->bone_weight1, sizeof(float));
- stream->read((char*) &this->bone_weight2, sizeof(float));
- stream->read((char*) &this->bone_weight3, sizeof(float));
- stream->read((char*) &this->bone_weight4, sizeof(float));
- }
-
- void PmxVertexSkinningSDEF::Read(std::istream *stream, PmxSetting *setting)
- {
- this->bone_index1 = ReadIndex(stream, setting->bone_index_size);
- this->bone_index2 = ReadIndex(stream, setting->bone_index_size);
- stream->read((char*) &this->bone_weight, sizeof(float));
- stream->read((char*) this->sdef_c, sizeof(float) * 3);
- stream->read((char*) this->sdef_r0, sizeof(float) * 3);
- stream->read((char*) this->sdef_r1, sizeof(float) * 3);
- }
-
- void PmxVertexSkinningQDEF::Read(std::istream *stream, PmxSetting *setting)
- {
- this->bone_index1 = ReadIndex(stream, setting->bone_index_size);
- this->bone_index2 = ReadIndex(stream, setting->bone_index_size);
- this->bone_index3 = ReadIndex(stream, setting->bone_index_size);
- this->bone_index4 = ReadIndex(stream, setting->bone_index_size);
- stream->read((char*) &this->bone_weight1, sizeof(float));
- stream->read((char*) &this->bone_weight2, sizeof(float));
- stream->read((char*) &this->bone_weight3, sizeof(float));
- stream->read((char*) &this->bone_weight4, sizeof(float));
- }
-
- void PmxVertex::Read(std::istream *stream, PmxSetting *setting)
- {
- stream->read((char*) this->position, sizeof(float) * 3);
- stream->read((char*) this->normal, sizeof(float) * 3);
- stream->read((char*) this->uv, sizeof(float) * 2);
- for (int i = 0; i < setting->uv; ++i)
- {
- stream->read((char*) this->uva[i], sizeof(float) * 4);
- }
- stream->read((char*) &this->skinning_type, sizeof(PmxVertexSkinningType));
- switch (this->skinning_type)
- {
- case PmxVertexSkinningType::BDEF1:
- this->skinning = mmd::make_unique<PmxVertexSkinningBDEF1>();
- break;
- case PmxVertexSkinningType::BDEF2:
- this->skinning = mmd::make_unique<PmxVertexSkinningBDEF2>();
- break;
- case PmxVertexSkinningType::BDEF4:
- this->skinning = mmd::make_unique<PmxVertexSkinningBDEF4>();
- break;
- case PmxVertexSkinningType::SDEF:
- this->skinning = mmd::make_unique<PmxVertexSkinningSDEF>();
- break;
- case PmxVertexSkinningType::QDEF:
- this->skinning = mmd::make_unique<PmxVertexSkinningQDEF>();
- break;
- default:
- throw "invalid skinning type";
- }
- this->skinning->Read(stream, setting);
- stream->read((char*) &this->edge, sizeof(float));
- }
-
- void PmxMaterial::Read(std::istream *stream, PmxSetting *setting)
- {
- this->material_name = ReadString(stream, setting->encoding);
- this->material_english_name = ReadString(stream, setting->encoding);
- stream->read((char*) this->diffuse, sizeof(float) * 4);
- stream->read((char*) this->specular, sizeof(float) * 3);
- stream->read((char*) &this->specularlity, sizeof(float));
- stream->read((char*) this->ambient, sizeof(float) * 3);
- stream->read((char*) &this->flag, sizeof(uint8_t));
- stream->read((char*) this->edge_color, sizeof(float) * 4);
- stream->read((char*) &this->edge_size, sizeof(float));
- this->diffuse_texture_index = ReadIndex(stream, setting->texture_index_size);
- this->sphere_texture_index = ReadIndex(stream, setting->texture_index_size);
- stream->read((char*) &this->sphere_op_mode, sizeof(uint8_t));
- stream->read((char*) &this->common_toon_flag, sizeof(uint8_t));
- if (this->common_toon_flag)
- {
- stream->read((char*) &this->toon_texture_index, sizeof(uint8_t));
- }
- else {
- this->toon_texture_index = ReadIndex(stream, setting->texture_index_size);
- }
- this->memo = ReadString(stream, setting->encoding);
- stream->read((char*) &this->index_count, sizeof(int));
- }
-
- void PmxIkLink::Read(std::istream *stream, PmxSetting *setting)
- {
- this->link_target = ReadIndex(stream, setting->bone_index_size);
- stream->read((char*) &this->angle_lock, sizeof(uint8_t));
- if (angle_lock == 1)
- {
- stream->read((char*) this->max_radian, sizeof(float) * 3);
- stream->read((char*) this->min_radian, sizeof(float) * 3);
- }
- }
-
- void PmxBone::Read(std::istream *stream, PmxSetting *setting)
- {
- this->bone_name = ReadString(stream, setting->encoding);
- this->bone_english_name = ReadString(stream, setting->encoding);
- stream->read((char*) this->position, sizeof(float) * 3);
- this->parent_index = ReadIndex(stream, setting->bone_index_size);
- stream->read((char*) &this->level, sizeof(int));
- stream->read((char*) &this->bone_flag, sizeof(uint16_t));
- if (this->bone_flag & 0x0001) {
- this->target_index = ReadIndex(stream, setting->bone_index_size);
- }
- else {
- stream->read((char*)this->offset, sizeof(float) * 3);
- }
- if (this->bone_flag & (0x0100 | 0x0200)) {
- this->grant_parent_index = ReadIndex(stream, setting->bone_index_size);
- stream->read((char*) &this->grant_weight, sizeof(float));
- }
- if (this->bone_flag & 0x0400) {
- stream->read((char*)this->lock_axis_orientation, sizeof(float) * 3);
- }
- if (this->bone_flag & 0x0800) {
- stream->read((char*)this->local_axis_x_orientation, sizeof(float) * 3);
- stream->read((char*)this->local_axis_y_orientation, sizeof(float) * 3);
- }
- if (this->bone_flag & 0x2000) {
- stream->read((char*) &this->key, sizeof(int));
- }
- if (this->bone_flag & 0x0020) {
- this->ik_target_bone_index = ReadIndex(stream, setting->bone_index_size);
- stream->read((char*) &ik_loop, sizeof(int));
- stream->read((char*) &ik_loop_angle_limit, sizeof(float));
- stream->read((char*) &ik_link_count, sizeof(int));
- this->ik_links = mmd::make_unique<PmxIkLink []>(ik_link_count);
- for (int i = 0; i < ik_link_count; i++) {
- ik_links[i].Read(stream, setting);
- }
- }
- }
-
- void PmxMorphVertexOffset::Read(std::istream *stream, PmxSetting *setting)
- {
- this->vertex_index = ReadIndex(stream, setting->vertex_index_size);
- stream->read((char*)this->position_offset, sizeof(float) * 3);
- }
-
- void PmxMorphUVOffset::Read(std::istream *stream, PmxSetting *setting)
- {
- this->vertex_index = ReadIndex(stream, setting->vertex_index_size);
- stream->read((char*)this->uv_offset, sizeof(float) * 4);
- }
-
- void PmxMorphBoneOffset::Read(std::istream *stream, PmxSetting *setting)
- {
- this->bone_index = ReadIndex(stream, setting->bone_index_size);
- stream->read((char*)this->translation, sizeof(float) * 3);
- stream->read((char*)this->rotation, sizeof(float) * 4);
- }
-
- void PmxMorphMaterialOffset::Read(std::istream *stream, PmxSetting *setting)
- {
- this->material_index = ReadIndex(stream, setting->material_index_size);
- stream->read((char*) &this->offset_operation, sizeof(uint8_t));
- stream->read((char*)this->diffuse, sizeof(float) * 4);
- stream->read((char*)this->specular, sizeof(float) * 3);
- stream->read((char*) &this->specularity, sizeof(float));
- stream->read((char*)this->ambient, sizeof(float) * 3);
- stream->read((char*)this->edge_color, sizeof(float) * 4);
- stream->read((char*) &this->edge_size, sizeof(float));
- stream->read((char*)this->texture_argb, sizeof(float) * 4);
- stream->read((char*)this->sphere_texture_argb, sizeof(float) * 4);
- stream->read((char*)this->toon_texture_argb, sizeof(float) * 4);
- }
-
- void PmxMorphGroupOffset::Read(std::istream *stream, PmxSetting *setting)
- {
- this->morph_index = ReadIndex(stream, setting->morph_index_size);
- stream->read((char*) &this->morph_weight, sizeof(float));
- }
-
- void PmxMorphFlipOffset::Read(std::istream *stream, PmxSetting *setting)
- {
- this->morph_index = ReadIndex(stream, setting->morph_index_size);
- stream->read((char*) &this->morph_value, sizeof(float));
- }
-
- void PmxMorphImplusOffset::Read(std::istream *stream, PmxSetting *setting)
- {
- this->rigid_body_index = ReadIndex(stream, setting->rigidbody_index_size);
- stream->read((char*) &this->is_local, sizeof(uint8_t));
- stream->read((char*)this->velocity, sizeof(float) * 3);
- stream->read((char*)this->angular_torque, sizeof(float) * 3);
- }
-
- void PmxMorph::Read(std::istream *stream, PmxSetting *setting)
- {
- this->morph_name = ReadString(stream, setting->encoding);
- this->morph_english_name = ReadString(stream, setting->encoding);
- stream->read((char*) &category, sizeof(MorphCategory));
- stream->read((char*) &morph_type, sizeof(MorphType));
- stream->read((char*) &this->offset_count, sizeof(int));
- switch (this->morph_type)
- {
- case MorphType::Group:
- group_offsets = mmd::make_unique<PmxMorphGroupOffset []>(this->offset_count);
- for (int i = 0; i < offset_count; i++)
- {
- group_offsets[i].Read(stream, setting);
- }
- break;
- case MorphType::Vertex:
- vertex_offsets = mmd::make_unique<PmxMorphVertexOffset []>(this->offset_count);
- for (int i = 0; i < offset_count; i++)
- {
- vertex_offsets[i].Read(stream, setting);
- }
- break;
- case MorphType::Bone:
- bone_offsets = mmd::make_unique<PmxMorphBoneOffset []>(this->offset_count);
- for (int i = 0; i < offset_count; i++)
- {
- bone_offsets[i].Read(stream, setting);
- }
- break;
- case MorphType::Matrial:
- material_offsets = mmd::make_unique<PmxMorphMaterialOffset []>(this->offset_count);
- for (int i = 0; i < offset_count; i++)
- {
- material_offsets[i].Read(stream, setting);
- }
- break;
- case MorphType::UV:
- case MorphType::AdditionalUV1:
- case MorphType::AdditionalUV2:
- case MorphType::AdditionalUV3:
- case MorphType::AdditionalUV4:
- uv_offsets = mmd::make_unique<PmxMorphUVOffset []>(this->offset_count);
- for (int i = 0; i < offset_count; i++)
- {
- uv_offsets[i].Read(stream, setting);
- }
- break;
- default:
- throw DeadlyImportError("MMD: unknown morth type");
- }
- }
-
- void PmxFrameElement::Read(std::istream *stream, PmxSetting *setting)
- {
- stream->read((char*) &this->element_target, sizeof(uint8_t));
- if (this->element_target == 0x00)
- {
- this->index = ReadIndex(stream, setting->bone_index_size);
- }
- else {
- this->index = ReadIndex(stream, setting->morph_index_size);
- }
- }
-
- void PmxFrame::Read(std::istream *stream, PmxSetting *setting)
- {
- this->frame_name = ReadString(stream, setting->encoding);
- this->frame_english_name = ReadString(stream, setting->encoding);
- stream->read((char*) &this->frame_flag, sizeof(uint8_t));
- stream->read((char*) &this->element_count, sizeof(int));
- this->elements = mmd::make_unique<PmxFrameElement []>(this->element_count);
- for (int i = 0; i < this->element_count; i++)
- {
- this->elements[i].Read(stream, setting);
- }
- }
-
- void PmxRigidBody::Read(std::istream *stream, PmxSetting *setting)
- {
- this->girid_body_name = ReadString(stream, setting->encoding);
- this->girid_body_english_name = ReadString(stream, setting->encoding);
- this->target_bone = ReadIndex(stream, setting->bone_index_size);
- stream->read((char*) &this->group, sizeof(uint8_t));
- stream->read((char*) &this->mask, sizeof(uint16_t));
- stream->read((char*) &this->shape, sizeof(uint8_t));
- stream->read((char*) this->size, sizeof(float) * 3);
- stream->read((char*) this->position, sizeof(float) * 3);
- stream->read((char*) this->orientation, sizeof(float) * 3);
- stream->read((char*) &this->mass, sizeof(float));
- stream->read((char*) &this->move_attenuation, sizeof(float));
- stream->read((char*) &this->rotation_attenuation, sizeof(float));
- stream->read((char*) &this->repulsion, sizeof(float));
- stream->read((char*) &this->friction, sizeof(float));
- stream->read((char*) &this->physics_calc_type, sizeof(uint8_t));
- }
-
- void PmxJointParam::Read(std::istream *stream, PmxSetting *setting)
- {
- this->rigid_body1 = ReadIndex(stream, setting->rigidbody_index_size);
- this->rigid_body2 = ReadIndex(stream, setting->rigidbody_index_size);
- stream->read((char*) this->position, sizeof(float) * 3);
- stream->read((char*) this->orientaiton, sizeof(float) * 3);
- stream->read((char*) this->move_limitation_min, sizeof(float) * 3);
- stream->read((char*) this->move_limitation_max, sizeof(float) * 3);
- stream->read((char*) this->rotation_limitation_min, sizeof(float) * 3);
- stream->read((char*) this->rotation_limitation_max, sizeof(float) * 3);
- stream->read((char*) this->spring_move_coefficient, sizeof(float) * 3);
- stream->read((char*) this->spring_rotation_coefficient, sizeof(float) * 3);
- }
-
- void PmxJoint::Read(std::istream *stream, PmxSetting *setting)
- {
- this->joint_name = ReadString(stream, setting->encoding);
- this->joint_english_name = ReadString(stream, setting->encoding);
- stream->read((char*) &this->joint_type, sizeof(uint8_t));
- this->param.Read(stream, setting);
- }
-
- void PmxAncherRigidBody::Read(std::istream *stream, PmxSetting *setting)
- {
- this->related_rigid_body = ReadIndex(stream, setting->rigidbody_index_size);
- this->related_vertex = ReadIndex(stream, setting->vertex_index_size);
- stream->read((char*) &this->is_near, sizeof(uint8_t));
- }
-
- void PmxSoftBody::Read(std::istream * /*stream*/, PmxSetting * /*setting*/)
- {
- std::cerr << "Not Implemented Exception" << std::endl;
- throw DeadlyImportError("MMD: Not Implemented Exception");
- }
-
- void PmxModel::Init()
- {
- this->version = 0.0f;
- this->model_name.clear();
- this->model_english_name.clear();
- this->model_comment.clear();
- this->model_english_comment.clear();
- this->vertex_count = 0;
- this->vertices = nullptr;
- this->index_count = 0;
- this->indices = nullptr;
- this->texture_count = 0;
- this->textures = nullptr;
- this->material_count = 0;
- this->materials = nullptr;
- this->bone_count = 0;
- this->bones = nullptr;
- this->morph_count = 0;
- this->morphs = nullptr;
- this->frame_count = 0;
- this->frames = nullptr;
- this->rigid_body_count = 0;
- this->rigid_bodies = nullptr;
- this->joint_count = 0;
- this->joints = nullptr;
- this->soft_body_count = 0;
- this->soft_bodies = nullptr;
- }
-
- void PmxModel::Read(std::istream *stream)
- {
- char magic[4];
- stream->read((char*) magic, sizeof(char) * 4);
- if (magic[0] != 0x50 || magic[1] != 0x4d || magic[2] != 0x58 || magic[3] != 0x20)
- {
- std::cerr << "invalid magic number." << std::endl;
- throw DeadlyImportError("MMD: invalid magic number.");
- }
- stream->read((char*) &version, sizeof(float));
- if (version != 2.0f && version != 2.1f)
- {
- std::cerr << "this is not ver2.0 or ver2.1 but " << version << "." << std::endl;
- throw DeadlyImportError("MMD: this is not ver2.0 or ver2.1 but " + to_string(version));
- }
- this->setting.Read(stream);
-
- this->model_name = ReadString(stream, setting.encoding);
- this->model_english_name = ReadString(stream, setting.encoding);
- this->model_comment = ReadString(stream, setting.encoding);
- this->model_english_comment = ReadString(stream, setting.encoding);
-
- // read vertices
- stream->read((char*) &vertex_count, sizeof(int));
- this->vertices = mmd::make_unique<PmxVertex []>(vertex_count);
- for (int i = 0; i < vertex_count; i++)
- {
- vertices[i].Read(stream, &setting);
- }
-
- // read indices
- stream->read((char*) &index_count, sizeof(int));
- this->indices = mmd::make_unique<int []>(index_count);
- for (int i = 0; i < index_count; i++)
- {
- this->indices[i] = ReadIndex(stream, setting.vertex_index_size);
- }
-
- // read texture names
- stream->read((char*) &texture_count, sizeof(int));
- this->textures = mmd::make_unique<std::string []>(texture_count);
- for (int i = 0; i < texture_count; i++)
- {
- this->textures[i] = ReadString(stream, setting.encoding);
- }
-
- // read materials
- stream->read((char*) &material_count, sizeof(int));
- this->materials = mmd::make_unique<PmxMaterial []>(material_count);
- for (int i = 0; i < material_count; i++)
- {
- this->materials[i].Read(stream, &setting);
- }
-
- // read bones
- stream->read((char*) &this->bone_count, sizeof(int));
- this->bones = mmd::make_unique<PmxBone []>(this->bone_count);
- for (int i = 0; i < this->bone_count; i++)
- {
- this->bones[i].Read(stream, &setting);
- }
-
- // read morphs
- stream->read((char*) &this->morph_count, sizeof(int));
- this->morphs = mmd::make_unique<PmxMorph []>(this->morph_count);
- for (int i = 0; i < this->morph_count; i++)
- {
- this->morphs[i].Read(stream, &setting);
- }
-
- // read display frames
- stream->read((char*) &this->frame_count, sizeof(int));
- this->frames = mmd::make_unique<PmxFrame []>(this->frame_count);
- for (int i = 0; i < this->frame_count; i++)
- {
- this->frames[i].Read(stream, &setting);
- }
-
- // read rigid bodies
- stream->read((char*) &this->rigid_body_count, sizeof(int));
- this->rigid_bodies = mmd::make_unique<PmxRigidBody []>(this->rigid_body_count);
- for (int i = 0; i < this->rigid_body_count; i++)
- {
- this->rigid_bodies[i].Read(stream, &setting);
- }
-
- // read joints
- stream->read((char*) &this->joint_count, sizeof(int));
- this->joints = mmd::make_unique<PmxJoint []>(this->joint_count);
- for (int i = 0; i < this->joint_count; i++)
- {
- this->joints[i].Read(stream, &setting);
- }
- }
-}
diff --git a/thirdparty/assimp/code/MMD/MMDPmxParser.h b/thirdparty/assimp/code/MMD/MMDPmxParser.h
deleted file mode 100644
index cf523a1298..0000000000
--- a/thirdparty/assimp/code/MMD/MMDPmxParser.h
+++ /dev/null
@@ -1,782 +0,0 @@
-/*
-Open Asset Import Library (assimp)
-----------------------------------------------------------------------
-
-Copyright (c) 2006-2019, assimp team
-
-
-All rights reserved.
-
-Redistribution and use of this software in source and binary forms,
-with or without modification, are permitted provided that the
-following conditions are met:
-
-* Redistributions of source code must retain the above
-copyright notice, this list of conditions and the
-following disclaimer.
-
-* Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the
-following disclaimer in the documentation and/or other
-materials provided with the distribution.
-
-* Neither the name of the assimp team, nor the names of its
-contributors may be used to endorse or promote products
-derived from this software without specific prior
-written permission of the assimp team.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------------------------
-*/
-#pragma once
-
-#include <vector>
-#include <string>
-#include <iostream>
-#include <fstream>
-#include <memory>
-#include "MMDCpp14.h"
-
-namespace pmx
-{
- class PmxSetting
- {
- public:
- PmxSetting()
- : encoding(0)
- , uv(0)
- , vertex_index_size(0)
- , texture_index_size(0)
- , material_index_size(0)
- , bone_index_size(0)
- , morph_index_size(0)
- , rigidbody_index_size(0)
- {}
-
- uint8_t encoding;
- uint8_t uv;
- uint8_t vertex_index_size;
- uint8_t texture_index_size;
- uint8_t material_index_size;
- uint8_t bone_index_size;
- uint8_t morph_index_size;
- uint8_t rigidbody_index_size;
- void Read(std::istream *stream);
- };
-
- enum class PmxVertexSkinningType : uint8_t
- {
- BDEF1 = 0,
- BDEF2 = 1,
- BDEF4 = 2,
- SDEF = 3,
- QDEF = 4,
- };
-
- class PmxVertexSkinning
- {
- public:
- virtual void Read(std::istream *stream, PmxSetting *setting) = 0;
- virtual ~PmxVertexSkinning() {}
- };
-
- class PmxVertexSkinningBDEF1 : public PmxVertexSkinning
- {
- public:
- PmxVertexSkinningBDEF1()
- : bone_index(0)
- {}
-
- int bone_index;
- void Read(std::istream *stresam, PmxSetting *setting);
- };
-
- class PmxVertexSkinningBDEF2 : public PmxVertexSkinning
- {
- public:
- PmxVertexSkinningBDEF2()
- : bone_index1(0)
- , bone_index2(0)
- , bone_weight(0.0f)
- {}
-
- int bone_index1;
- int bone_index2;
- float bone_weight;
- void Read(std::istream *stresam, PmxSetting *setting);
- };
-
- class PmxVertexSkinningBDEF4 : public PmxVertexSkinning
- {
- public:
- PmxVertexSkinningBDEF4()
- : bone_index1(0)
- , bone_index2(0)
- , bone_index3(0)
- , bone_index4(0)
- , bone_weight1(0.0f)
- , bone_weight2(0.0f)
- , bone_weight3(0.0f)
- , bone_weight4(0.0f)
- {}
-
- int bone_index1;
- int bone_index2;
- int bone_index3;
- int bone_index4;
- float bone_weight1;
- float bone_weight2;
- float bone_weight3;
- float bone_weight4;
- void Read(std::istream *stresam, PmxSetting *setting);
- };
-
- class PmxVertexSkinningSDEF : public PmxVertexSkinning
- {
- public:
- PmxVertexSkinningSDEF()
- : bone_index1(0)
- , bone_index2(0)
- , bone_weight(0.0f)
- {
- for (int i = 0; i < 3; ++i) {
- sdef_c[i] = 0.0f;
- sdef_r0[i] = 0.0f;
- sdef_r1[i] = 0.0f;
- }
- }
-
- int bone_index1;
- int bone_index2;
- float bone_weight;
- float sdef_c[3];
- float sdef_r0[3];
- float sdef_r1[3];
- void Read(std::istream *stresam, PmxSetting *setting);
- };
-
- class PmxVertexSkinningQDEF : public PmxVertexSkinning
- {
- public:
- PmxVertexSkinningQDEF()
- : bone_index1(0)
- , bone_index2(0)
- , bone_index3(0)
- , bone_index4(0)
- , bone_weight1(0.0f)
- , bone_weight2(0.0f)
- , bone_weight3(0.0f)
- , bone_weight4(0.0f)
- {}
-
- int bone_index1;
- int bone_index2;
- int bone_index3;
- int bone_index4;
- float bone_weight1;
- float bone_weight2;
- float bone_weight3;
- float bone_weight4;
- void Read(std::istream *stresam, PmxSetting *setting);
- };
-
- class PmxVertex
- {
- public:
- PmxVertex()
- : edge(0.0f)
- {
- uv[0] = uv[1] = 0.0f;
- for (int i = 0; i < 3; ++i) {
- position[i] = 0.0f;
- normal[i] = 0.0f;
- }
- for (int i = 0; i < 4; ++i) {
- for (int k = 0; k < 4; ++k) {
- uva[i][k] = 0.0f;
- }
- }
- }
-
- float position[3];
- float normal[3];
- float uv[2];
- float uva[4][4];
- PmxVertexSkinningType skinning_type;
- std::unique_ptr<PmxVertexSkinning> skinning;
- float edge;
- void Read(std::istream *stream, PmxSetting *setting);
- };
-
- class PmxMaterial
- {
- public:
- PmxMaterial()
- : specularlity(0.0f)
- , flag(0)
- , edge_size(0.0f)
- , diffuse_texture_index(0)
- , sphere_texture_index(0)
- , sphere_op_mode(0)
- , common_toon_flag(0)
- , toon_texture_index(0)
- , index_count(0)
- {
- for (int i = 0; i < 3; ++i) {
- specular[i] = 0.0f;
- ambient[i] = 0.0f;
- edge_color[i] = 0.0f;
- }
- for (int i = 0; i < 4; ++i) {
- diffuse[i] = 0.0f;
- }
- }
-
- std::string material_name;
- std::string material_english_name;
- float diffuse[4];
- float specular[3];
- float specularlity;
- float ambient[3];
- uint8_t flag;
- float edge_color[4];
- float edge_size;
- int diffuse_texture_index;
- int sphere_texture_index;
- uint8_t sphere_op_mode;
- uint8_t common_toon_flag;
- int toon_texture_index;
- std::string memo;
- int index_count;
- void Read(std::istream *stream, PmxSetting *setting);
- };
-
- class PmxIkLink
- {
- public:
- PmxIkLink()
- : link_target(0)
- , angle_lock(0)
- {
- for (int i = 0; i < 3; ++i) {
- max_radian[i] = 0.0f;
- min_radian[i] = 0.0f;
- }
- }
-
- int link_target;
- uint8_t angle_lock;
- float max_radian[3];
- float min_radian[3];
- void Read(std::istream *stream, PmxSetting *settingn);
- };
-
- class PmxBone
- {
- public:
- PmxBone()
- : parent_index(0)
- , level(0)
- , bone_flag(0)
- , target_index(0)
- , grant_parent_index(0)
- , grant_weight(0.0f)
- , key(0)
- , ik_target_bone_index(0)
- , ik_loop(0)
- , ik_loop_angle_limit(0.0f)
- , ik_link_count(0)
- {
- for (int i = 0; i < 3; ++i) {
- position[i] = 0.0f;
- offset[i] = 0.0f;
- lock_axis_orientation[i] = 0.0f;
- local_axis_x_orientation[i] = 0.0f;
- local_axis_y_orientation[i] = 0.0f;
- }
- }
-
- std::string bone_name;
- std::string bone_english_name;
- float position[3];
- int parent_index;
- int level;
- uint16_t bone_flag;
- float offset[3];
- int target_index;
- int grant_parent_index;
- float grant_weight;
- float lock_axis_orientation[3];
- float local_axis_x_orientation[3];
- float local_axis_y_orientation[3];
- int key;
- int ik_target_bone_index;
- int ik_loop;
- float ik_loop_angle_limit;
- int ik_link_count;
- std::unique_ptr<PmxIkLink []> ik_links;
- void Read(std::istream *stream, PmxSetting *setting);
- };
-
- enum class MorphType : uint8_t
- {
- Group = 0,
- Vertex = 1,
- Bone = 2,
- UV = 3,
- AdditionalUV1 = 4,
- AdditionalUV2 = 5,
- AdditionalUV3 = 6,
- AdditionalUV4 = 7,
- Matrial = 8,
- Flip = 9,
- Implus = 10,
- };
-
- enum class MorphCategory : uint8_t
- {
- ReservedCategory = 0,
- Eyebrow = 1,
- Eye = 2,
- Mouth = 3,
- Other = 4,
- };
-
- class PmxMorphOffset
- {
- public:
- void virtual Read(std::istream *stream, PmxSetting *setting) = 0;
- };
-
- class PmxMorphVertexOffset : public PmxMorphOffset
- {
- public:
- PmxMorphVertexOffset()
- : vertex_index(0)
- {
- for (int i = 0; i < 3; ++i) {
- position_offset[i] = 0.0f;
- }
- }
- int vertex_index;
- float position_offset[3];
- void Read(std::istream *stream, PmxSetting *setting); //override;
- };
-
- class PmxMorphUVOffset : public PmxMorphOffset
- {
- public:
- PmxMorphUVOffset()
- : vertex_index(0)
- {
- for (int i = 0; i < 4; ++i) {
- uv_offset[i] = 0.0f;
- }
- }
- int vertex_index;
- float uv_offset[4];
- void Read(std::istream *stream, PmxSetting *setting); //override;
- };
-
- class PmxMorphBoneOffset : public PmxMorphOffset
- {
- public:
- PmxMorphBoneOffset()
- : bone_index(0)
- {
- for (int i = 0; i < 3; ++i) {
- translation[i] = 0.0f;
- }
- for (int i = 0; i < 4; ++i) {
- rotation[i] = 0.0f;
- }
- }
- int bone_index;
- float translation[3];
- float rotation[4];
- void Read(std::istream *stream, PmxSetting *setting); //override;
- };
-
- class PmxMorphMaterialOffset : public PmxMorphOffset
- {
- public:
- PmxMorphMaterialOffset()
- : specularity(0.0f)
- , edge_size(0.0f)
- {
- for (int i = 0; i < 3; ++i) {
- specular[i] = 0.0f;
- ambient[i] = 0.0f;
- }
- for (int i = 0; i < 4; ++i) {
- diffuse[i] = 0.0f;
- edge_color[i] = 0.0f;
- texture_argb[i] = 0.0f;
- sphere_texture_argb[i] = 0.0f;
- toon_texture_argb[i] = 0.0f;
- }
- }
- int material_index;
- uint8_t offset_operation;
- float diffuse[4];
- float specular[3];
- float specularity;
- float ambient[3];
- float edge_color[4];
- float edge_size;
- float texture_argb[4];
- float sphere_texture_argb[4];
- float toon_texture_argb[4];
- void Read(std::istream *stream, PmxSetting *setting); //override;
- };
-
- class PmxMorphGroupOffset : public PmxMorphOffset
- {
- public:
- PmxMorphGroupOffset()
- : morph_index(0)
- , morph_weight(0.0f)
- {}
- int morph_index;
- float morph_weight;
- void Read(std::istream *stream, PmxSetting *setting); //override;
- };
-
- class PmxMorphFlipOffset : public PmxMorphOffset
- {
- public:
- PmxMorphFlipOffset()
- : morph_index(0)
- , morph_value(0.0f)
- {}
- int morph_index;
- float morph_value;
- void Read(std::istream *stream, PmxSetting *setting); //override;
- };
-
- class PmxMorphImplusOffset : public PmxMorphOffset
- {
- public:
- PmxMorphImplusOffset()
- : rigid_body_index(0)
- , is_local(0)
- {
- for (int i = 0; i < 3; ++i) {
- velocity[i] = 0.0f;
- angular_torque[i] = 0.0f;
- }
- }
- int rigid_body_index;
- uint8_t is_local;
- float velocity[3];
- float angular_torque[3];
- void Read(std::istream *stream, PmxSetting *setting); //override;
- };
-
- class PmxMorph
- {
- public:
- PmxMorph()
- : offset_count(0)
- {
- }
- std::string morph_name;
- std::string morph_english_name;
- MorphCategory category;
- MorphType morph_type;
- int offset_count;
- std::unique_ptr<PmxMorphVertexOffset []> vertex_offsets;
- std::unique_ptr<PmxMorphUVOffset []> uv_offsets;
- std::unique_ptr<PmxMorphBoneOffset []> bone_offsets;
- std::unique_ptr<PmxMorphMaterialOffset []> material_offsets;
- std::unique_ptr<PmxMorphGroupOffset []> group_offsets;
- std::unique_ptr<PmxMorphFlipOffset []> flip_offsets;
- std::unique_ptr<PmxMorphImplusOffset []> implus_offsets;
- void Read(std::istream *stream, PmxSetting *setting);
- };
-
- class PmxFrameElement
- {
- public:
- PmxFrameElement()
- : element_target(0)
- , index(0)
- {
- }
- uint8_t element_target;
- int index;
- void Read(std::istream *stream, PmxSetting *setting);
- };
-
- class PmxFrame
- {
- public:
- PmxFrame()
- : frame_flag(0)
- , element_count(0)
- {
- }
- std::string frame_name;
- std::string frame_english_name;
- uint8_t frame_flag;
- int element_count;
- std::unique_ptr<PmxFrameElement []> elements;
- void Read(std::istream *stream, PmxSetting *setting);
- };
-
- class PmxRigidBody
- {
- public:
- PmxRigidBody()
- : target_bone(0)
- , group(0)
- , mask(0)
- , shape(0)
- , mass(0.0f)
- , move_attenuation(0.0f)
- , rotation_attenuation(0.0f)
- , repulsion(0.0f)
- , friction(0.0f)
- , physics_calc_type(0)
- {
- for (int i = 0; i < 3; ++i) {
- size[i] = 0.0f;
- position[i] = 0.0f;
- orientation[i] = 0.0f;
- }
- }
- std::string girid_body_name;
- std::string girid_body_english_name;
- int target_bone;
- uint8_t group;
- uint16_t mask;
- uint8_t shape;
- float size[3];
- float position[3];
- float orientation[3];
- float mass;
- float move_attenuation;
- float rotation_attenuation;
- float repulsion;
- float friction;
- uint8_t physics_calc_type;
- void Read(std::istream *stream, PmxSetting *setting);
- };
-
- enum class PmxJointType : uint8_t
- {
- Generic6DofSpring = 0,
- Generic6Dof = 1,
- Point2Point = 2,
- ConeTwist = 3,
- Slider = 5,
- Hinge = 6
- };
-
- class PmxJointParam
- {
- public:
- PmxJointParam()
- : rigid_body1(0)
- , rigid_body2(0)
- {
- for (int i = 0; i < 3; ++i) {
- position[i] = 0.0f;
- orientaiton[i] = 0.0f;
- move_limitation_min[i] = 0.0f;
- move_limitation_max[i] = 0.0f;
- rotation_limitation_min[i] = 0.0f;
- rotation_limitation_max[i] = 0.0f;
- spring_move_coefficient[i] = 0.0f;
- spring_rotation_coefficient[i] = 0.0f;
- }
- }
- int rigid_body1;
- int rigid_body2;
- float position[3];
- float orientaiton[3];
- float move_limitation_min[3];
- float move_limitation_max[3];
- float rotation_limitation_min[3];
- float rotation_limitation_max[3];
- float spring_move_coefficient[3];
- float spring_rotation_coefficient[3];
- void Read(std::istream *stream, PmxSetting *setting);
- };
-
- class PmxJoint
- {
- public:
- std::string joint_name;
- std::string joint_english_name;
- PmxJointType joint_type;
- PmxJointParam param;
- void Read(std::istream *stream, PmxSetting *setting);
- };
-
- enum PmxSoftBodyFlag : uint8_t
- {
- BLink = 0x01,
- Cluster = 0x02,
- Link = 0x04
- };
-
- class PmxAncherRigidBody
- {
- public:
- PmxAncherRigidBody()
- : related_rigid_body(0)
- , related_vertex(0)
- , is_near(false)
- {}
- int related_rigid_body;
- int related_vertex;
- bool is_near;
- void Read(std::istream *stream, PmxSetting *setting);
- };
-
- class PmxSoftBody
- {
- public:
- PmxSoftBody()
- : shape(0)
- , target_material(0)
- , group(0)
- , mask(0)
- , blink_distance(0)
- , cluster_count(0)
- , mass(0.0)
- , collisioni_margin(0.0)
- , aero_model(0)
- , VCF(0.0f)
- , DP(0.0f)
- , DG(0.0f)
- , LF(0.0f)
- , PR(0.0f)
- , VC(0.0f)
- , DF(0.0f)
- , MT(0.0f)
- , CHR(0.0f)
- , KHR(0.0f)
- , SHR(0.0f)
- , AHR(0.0f)
- , SRHR_CL(0.0f)
- , SKHR_CL(0.0f)
- , SSHR_CL(0.0f)
- , SR_SPLT_CL(0.0f)
- , SK_SPLT_CL(0.0f)
- , SS_SPLT_CL(0.0f)
- , V_IT(0)
- , P_IT(0)
- , D_IT(0)
- , C_IT(0)
- , LST(0.0f)
- , AST(0.0f)
- , VST(0.0f)
- , anchor_count(0)
- , pin_vertex_count(0)
- {}
- std::string soft_body_name;
- std::string soft_body_english_name;
- uint8_t shape;
- int target_material;
- uint8_t group;
- uint16_t mask;
- PmxSoftBodyFlag flag;
- int blink_distance;
- int cluster_count;
- float mass;
- float collisioni_margin;
- int aero_model;
- float VCF;
- float DP;
- float DG;
- float LF;
- float PR;
- float VC;
- float DF;
- float MT;
- float CHR;
- float KHR;
- float SHR;
- float AHR;
- float SRHR_CL;
- float SKHR_CL;
- float SSHR_CL;
- float SR_SPLT_CL;
- float SK_SPLT_CL;
- float SS_SPLT_CL;
- int V_IT;
- int P_IT;
- int D_IT;
- int C_IT;
- float LST;
- float AST;
- float VST;
- int anchor_count;
- std::unique_ptr<PmxAncherRigidBody []> anchers;
- int pin_vertex_count;
- std::unique_ptr<int []> pin_vertices;
- void Read(std::istream *stream, PmxSetting *setting);
- };
-
- class PmxModel
- {
- public:
- PmxModel()
- : version(0.0f)
- , vertex_count(0)
- , index_count(0)
- , texture_count(0)
- , material_count(0)
- , bone_count(0)
- , morph_count(0)
- , frame_count(0)
- , rigid_body_count(0)
- , joint_count(0)
- , soft_body_count(0)
- {}
-
- float version;
- PmxSetting setting;
- std::string model_name;
- std::string model_english_name;
- std::string model_comment;
- std::string model_english_comment;
- int vertex_count;
- std::unique_ptr<PmxVertex []> vertices;
- int index_count;
- std::unique_ptr<int []> indices;
- int texture_count;
- std::unique_ptr< std::string []> textures;
- int material_count;
- std::unique_ptr<PmxMaterial []> materials;
- int bone_count;
- std::unique_ptr<PmxBone []> bones;
- int morph_count;
- std::unique_ptr<PmxMorph []> morphs;
- int frame_count;
- std::unique_ptr<PmxFrame [] > frames;
- int rigid_body_count;
- std::unique_ptr<PmxRigidBody []> rigid_bodies;
- int joint_count;
- std::unique_ptr<PmxJoint []> joints;
- int soft_body_count;
- std::unique_ptr<PmxSoftBody []> soft_bodies;
- void Init();
- void Read(std::istream *stream);
- //static std::unique_ptr<PmxModel> ReadFromFile(const char *filename);
- //static std::unique_ptr<PmxModel> ReadFromStream(std::istream *stream);
- };
-}
diff --git a/thirdparty/assimp/code/MMD/MMDVmdParser.h b/thirdparty/assimp/code/MMD/MMDVmdParser.h
deleted file mode 100644
index 947c3a2422..0000000000
--- a/thirdparty/assimp/code/MMD/MMDVmdParser.h
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
-Open Asset Import Library (assimp)
-----------------------------------------------------------------------
-
-Copyright (c) 2006-2019, assimp team
-
-
-All rights reserved.
-
-Redistribution and use of this software in source and binary forms,
-with or without modification, are permitted provided that the
-following conditions are met:
-
-* Redistributions of source code must retain the above
-copyright notice, this list of conditions and the
-following disclaimer.
-
-* Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the
-following disclaimer in the documentation and/or other
-materials provided with the distribution.
-
-* Neither the name of the assimp team, nor the names of its
-contributors may be used to endorse or promote products
-derived from this software without specific prior
-written permission of the assimp team.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------------------------
-*/
-#pragma once
-
-#include <vector>
-#include <string>
-#include <memory>
-#include <iostream>
-#include <fstream>
-#include <ostream>
-#include "MMDCpp14.h"
-
-namespace vmd
-{
- class VmdBoneFrame
- {
- public:
- std::string name;
- int frame;
- float position[3];
- float orientation[4];
- char interpolation[4][4][4];
-
- void Read(std::istream* stream)
- {
- char buffer[15];
- stream->read((char*) buffer, sizeof(char)*15);
- name = std::string(buffer);
- stream->read((char*) &frame, sizeof(int));
- stream->read((char*) position, sizeof(float)*3);
- stream->read((char*) orientation, sizeof(float)*4);
- stream->read((char*) interpolation, sizeof(char) * 4 * 4 * 4);
- }
-
- void Write(std::ostream* stream)
- {
- stream->write((char*)name.c_str(), sizeof(char) * 15);
- stream->write((char*)&frame, sizeof(int));
- stream->write((char*)position, sizeof(float) * 3);
- stream->write((char*)orientation, sizeof(float) * 4);
- stream->write((char*)interpolation, sizeof(char) * 4 * 4 * 4);
- }
- };
-
- class VmdFaceFrame
- {
- public:
- std::string face_name;
- float weight;
- uint32_t frame;
-
- void Read(std::istream* stream)
- {
- char buffer[15];
- stream->read((char*) &buffer, sizeof(char) * 15);
- face_name = std::string(buffer);
- stream->read((char*) &frame, sizeof(int));
- stream->read((char*) &weight, sizeof(float));
- }
-
- void Write(std::ostream* stream)
- {
- stream->write((char*)face_name.c_str(), sizeof(char) * 15);
- stream->write((char*)&frame, sizeof(int));
- stream->write((char*)&weight, sizeof(float));
- }
- };
-
- class VmdCameraFrame
- {
- public:
- int frame;
- float distance;
- float position[3];
- float orientation[3];
- char interpolation[6][4];
- float angle;
- char unknown[3];
-
- void Read(std::istream *stream)
- {
- stream->read((char*) &frame, sizeof(int));
- stream->read((char*) &distance, sizeof(float));
- stream->read((char*) position, sizeof(float) * 3);
- stream->read((char*) orientation, sizeof(float) * 3);
- stream->read((char*) interpolation, sizeof(char) * 24);
- stream->read((char*) &angle, sizeof(float));
- stream->read((char*) unknown, sizeof(char) * 3);
- }
-
- void Write(std::ostream *stream)
- {
- stream->write((char*)&frame, sizeof(int));
- stream->write((char*)&distance, sizeof(float));
- stream->write((char*)position, sizeof(float) * 3);
- stream->write((char*)orientation, sizeof(float) * 3);
- stream->write((char*)interpolation, sizeof(char) * 24);
- stream->write((char*)&angle, sizeof(float));
- stream->write((char*)unknown, sizeof(char) * 3);
- }
- };
-
- class VmdLightFrame
- {
- public:
- int frame;
- float color[3];
- float position[3];
-
- void Read(std::istream* stream)
- {
- stream->read((char*) &frame, sizeof(int));
- stream->read((char*) color, sizeof(float) * 3);
- stream->read((char*) position, sizeof(float) * 3);
- }
-
- void Write(std::ostream* stream)
- {
- stream->write((char*)&frame, sizeof(int));
- stream->write((char*)color, sizeof(float) * 3);
- stream->write((char*)position, sizeof(float) * 3);
- }
- };
-
- class VmdIkEnable
- {
- public:
- std::string ik_name;
- bool enable;
- };
-
- class VmdIkFrame
- {
- public:
- int frame;
- bool display;
- std::vector<VmdIkEnable> ik_enable;
-
- void Read(std::istream *stream)
- {
- char buffer[20];
- stream->read((char*) &frame, sizeof(int));
- stream->read((char*) &display, sizeof(uint8_t));
- int ik_count;
- stream->read((char*) &ik_count, sizeof(int));
- ik_enable.resize(ik_count);
- for (int i = 0; i < ik_count; i++)
- {
- stream->read(buffer, 20);
- ik_enable[i].ik_name = std::string(buffer);
- stream->read((char*) &ik_enable[i].enable, sizeof(uint8_t));
- }
- }
-
- void Write(std::ostream *stream)
- {
- stream->write((char*)&frame, sizeof(int));
- stream->write((char*)&display, sizeof(uint8_t));
- int ik_count = static_cast<int>(ik_enable.size());
- stream->write((char*)&ik_count, sizeof(int));
- for (int i = 0; i < ik_count; i++)
- {
- const VmdIkEnable& ik_enable = this->ik_enable.at(i);
- stream->write(ik_enable.ik_name.c_str(), 20);
- stream->write((char*)&ik_enable.enable, sizeof(uint8_t));
- }
- }
- };
-
- class VmdMotion
- {
- public:
- std::string model_name;
- int version;
- std::vector<VmdBoneFrame> bone_frames;
- std::vector<VmdFaceFrame> face_frames;
- std::vector<VmdCameraFrame> camera_frames;
- std::vector<VmdLightFrame> light_frames;
- std::vector<VmdIkFrame> ik_frames;
-
- static std::unique_ptr<VmdMotion> LoadFromFile(char const *filename)
- {
- std::ifstream stream(filename, std::ios::binary);
- auto result = LoadFromStream(&stream);
- stream.close();
- return result;
- }
-
- static std::unique_ptr<VmdMotion> LoadFromStream(std::ifstream *stream)
- {
-
- char buffer[30];
- auto result = mmd::make_unique<VmdMotion>();
-
- // magic and version
- stream->read((char*) buffer, 30);
- if (strncmp(buffer, "Vocaloid Motion Data", 20))
- {
- std::cerr << "invalid vmd file." << std::endl;
- return nullptr;
- }
- result->version = std::atoi(buffer + 20);
-
- // name
- stream->read(buffer, 20);
- result->model_name = std::string(buffer);
-
- // bone frames
- int bone_frame_num;
- stream->read((char*) &bone_frame_num, sizeof(int));
- result->bone_frames.resize(bone_frame_num);
- for (int i = 0; i < bone_frame_num; i++)
- {
- result->bone_frames[i].Read(stream);
- }
-
- // face frames
- int face_frame_num;
- stream->read((char*) &face_frame_num, sizeof(int));
- result->face_frames.resize(face_frame_num);
- for (int i = 0; i < face_frame_num; i++)
- {
- result->face_frames[i].Read(stream);
- }
-
- // camera frames
- int camera_frame_num;
- stream->read((char*) &camera_frame_num, sizeof(int));
- result->camera_frames.resize(camera_frame_num);
- for (int i = 0; i < camera_frame_num; i++)
- {
- result->camera_frames[i].Read(stream);
- }
-
- // light frames
- int light_frame_num;
- stream->read((char*) &light_frame_num, sizeof(int));
- result->light_frames.resize(light_frame_num);
- for (int i = 0; i < light_frame_num; i++)
- {
- result->light_frames[i].Read(stream);
- }
-
- // unknown2
- stream->read(buffer, 4);
-
- // ik frames
- if (stream->peek() != std::ios::traits_type::eof())
- {
- int ik_num;
- stream->read((char*) &ik_num, sizeof(int));
- result->ik_frames.resize(ik_num);
- for (int i = 0; i < ik_num; i++)
- {
- result->ik_frames[i].Read(stream);
- }
- }
-
- if (stream->peek() != std::ios::traits_type::eof())
- {
- std::cerr << "vmd stream has unknown data." << std::endl;
- }
-
- return result;
- }
-
- bool SaveToFile(const std::u16string& /*filename*/)
- {
- // TODO: How to adapt u16string to string?
- /*
- std::ofstream stream(filename.c_str(), std::ios::binary);
- auto result = SaveToStream(&stream);
- stream.close();
- return result;
- */
- return false;
- }
-
- bool SaveToStream(std::ofstream *stream)
- {
- std::string magic = "Vocaloid Motion Data 0002\0";
- magic.resize(30);
-
- // magic and version
- stream->write(magic.c_str(), 30);
-
- // name
- stream->write(model_name.c_str(), 20);
-
- // bone frames
- const int bone_frame_num = static_cast<int>(bone_frames.size());
- stream->write(reinterpret_cast<const char*>(&bone_frame_num), sizeof(int));
- for (int i = 0; i < bone_frame_num; i++)
- {
- bone_frames[i].Write(stream);
- }
-
- // face frames
- const int face_frame_num = static_cast<int>(face_frames.size());
- stream->write(reinterpret_cast<const char*>(&face_frame_num), sizeof(int));
- for (int i = 0; i < face_frame_num; i++)
- {
- face_frames[i].Write(stream);
- }
-
- // camera frames
- const int camera_frame_num = static_cast<int>(camera_frames.size());
- stream->write(reinterpret_cast<const char*>(&camera_frame_num), sizeof(int));
- for (int i = 0; i < camera_frame_num; i++)
- {
- camera_frames[i].Write(stream);
- }
-
- // light frames
- const int light_frame_num = static_cast<int>(light_frames.size());
- stream->write(reinterpret_cast<const char*>(&light_frame_num), sizeof(int));
- for (int i = 0; i < light_frame_num; i++)
- {
- light_frames[i].Write(stream);
- }
-
- // self shadow datas
- const int self_shadow_num = 0;
- stream->write(reinterpret_cast<const char*>(&self_shadow_num), sizeof(int));
-
- // ik frames
- const int ik_num = static_cast<int>(ik_frames.size());
- stream->write(reinterpret_cast<const char*>(&ik_num), sizeof(int));
- for (int i = 0; i < ik_num; i++)
- {
- ik_frames[i].Write(stream);
- }
-
- return true;
- }
- };
-}
diff --git a/thirdparty/assimp/code/Material/MaterialSystem.cpp b/thirdparty/assimp/code/Material/MaterialSystem.cpp
index d0b39093b6..0be6e9f7bb 100644
--- a/thirdparty/assimp/code/Material/MaterialSystem.cpp
+++ b/thirdparty/assimp/code/Material/MaterialSystem.cpp
@@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/types.h>
#include <assimp/material.h>
#include <assimp/DefaultLogger.hpp>
-#include <assimp/Macros.h>
using namespace Assimp;
@@ -545,23 +544,7 @@ aiReturn aiMaterial::AddProperty (const aiString* pInput,
unsigned int type,
unsigned int index)
{
- // We don't want to add the whole buffer .. write a 32 bit length
- // prefix followed by the zero-terminated UTF8 string.
- // (HACK) I don't want to break the ABI now, but we definitely
- // ought to change aiString::mLength to uint32_t one day.
- if (sizeof(size_t) == 8) {
- aiString copy = *pInput;
- uint32_t* s = reinterpret_cast<uint32_t*>(&copy.length);
- s[1] = static_cast<uint32_t>(pInput->length);
-
- return AddBinaryProperty(s+1,
- static_cast<unsigned int>(pInput->length+1+4),
- pKey,
- type,
- index,
- aiPTI_String);
- }
- ai_assert(sizeof(size_t)==4);
+ ai_assert(sizeof(ai_uint32)==4);
return AddBinaryProperty(pInput,
static_cast<unsigned int>(pInput->length+1+4),
pKey,
diff --git a/thirdparty/assimp/code/PostProcessing/ArmaturePopulate.cpp b/thirdparty/assimp/code/PostProcessing/ArmaturePopulate.cpp
new file mode 100644
index 0000000000..75daeb6b59
--- /dev/null
+++ b/thirdparty/assimp/code/PostProcessing/ArmaturePopulate.cpp
@@ -0,0 +1,268 @@
+/*
+Open Asset Import Library (assimp)
+----------------------------------------------------------------------
+
+Copyright (c) 2006-2019, assimp team
+
+
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the
+following conditions are met:
+
+* Redistributions of source code must retain the above
+copyright notice, this list of conditions and the
+following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the
+following disclaimer in the documentation and/or other
+materials provided with the distribution.
+
+* Neither the name of the assimp team, nor the names of its
+contributors may be used to endorse or promote products
+derived from this software without specific prior
+written permission of the assimp team.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+----------------------------------------------------------------------
+*/
+#include "ArmaturePopulate.h"
+
+#include <assimp/BaseImporter.h>
+#include <assimp/DefaultLogger.hpp>
+#include <assimp/postprocess.h>
+#include <assimp/scene.h>
+#include <iostream>
+
+namespace Assimp {
+
+/// The default class constructor.
+ArmaturePopulate::ArmaturePopulate() : BaseProcess()
+{}
+
+/// The class destructor.
+ArmaturePopulate::~ArmaturePopulate()
+{}
+
+bool ArmaturePopulate::IsActive(unsigned int pFlags) const {
+ return (pFlags & aiProcess_PopulateArmatureData) != 0;
+}
+
+void ArmaturePopulate::SetupProperties(const Importer *pImp) {
+ // do nothing
+}
+
+void ArmaturePopulate::Execute(aiScene *out) {
+
+ // Now convert all bone positions to the correct mOffsetMatrix
+ std::vector<aiBone *> bones;
+ std::vector<aiNode *> nodes;
+ std::map<aiBone *, aiNode *> bone_stack;
+ BuildBoneList(out->mRootNode, out->mRootNode, out, bones);
+ BuildNodeList(out->mRootNode, nodes);
+
+ BuildBoneStack(out->mRootNode, out->mRootNode, out, bones, bone_stack, nodes);
+
+ ASSIMP_LOG_DEBUG_F("Bone stack size: ", bone_stack.size());
+
+ for (std::pair<aiBone *, aiNode *> kvp : bone_stack) {
+ aiBone *bone = kvp.first;
+ aiNode *bone_node = kvp.second;
+ ASSIMP_LOG_DEBUG_F("active node lookup: ", bone->mName.C_Str());
+ // lcl transform grab - done in generate_nodes :)
+
+ // bone->mOffsetMatrix = bone_node->mTransformation;
+ aiNode *armature = GetArmatureRoot(bone_node, bones);
+
+ ai_assert(armature);
+
+ // set up bone armature id
+ bone->mArmature = armature;
+
+ // set this bone node to be referenced properly
+ ai_assert(bone_node);
+ bone->mNode = bone_node;
+ }
+}
+
+
+/* Reprocess all nodes to calculate bone transforms properly based on the REAL
+ * mOffsetMatrix not the local. */
+/* Before this would use mesh transforms which is wrong for bone transforms */
+/* Before this would work for simple character skeletons but not complex meshes
+ * with multiple origins */
+/* Source: sketch fab log cutter fbx */
+void ArmaturePopulate::BuildBoneList(aiNode *current_node,
+ const aiNode *root_node,
+ const aiScene *scene,
+ std::vector<aiBone *> &bones) {
+ ai_assert(scene);
+ for (unsigned int nodeId = 0; nodeId < current_node->mNumChildren; ++nodeId) {
+ aiNode *child = current_node->mChildren[nodeId];
+ ai_assert(child);
+
+ // check for bones
+ for (unsigned int meshId = 0; meshId < child->mNumMeshes; ++meshId) {
+ ai_assert(child->mMeshes);
+ unsigned int mesh_index = child->mMeshes[meshId];
+ aiMesh *mesh = scene->mMeshes[mesh_index];
+ ai_assert(mesh);
+
+ for (unsigned int boneId = 0; boneId < mesh->mNumBones; ++boneId) {
+ aiBone *bone = mesh->mBones[boneId];
+ ai_assert(bone);
+
+ // duplicate meshes exist with the same bones sometimes :)
+ // so this must be detected
+ if (std::find(bones.begin(), bones.end(), bone) == bones.end()) {
+ // add the element once
+ bones.push_back(bone);
+ }
+ }
+
+ // find mesh and get bones
+ // then do recursive lookup for bones in root node hierarchy
+ }
+
+ BuildBoneList(child, root_node, scene, bones);
+ }
+}
+
+/* Prepare flat node list which can be used for non recursive lookups later */
+void ArmaturePopulate::BuildNodeList(const aiNode *current_node,
+ std::vector<aiNode *> &nodes) {
+ ai_assert(current_node);
+
+ for (unsigned int nodeId = 0; nodeId < current_node->mNumChildren; ++nodeId) {
+ aiNode *child = current_node->mChildren[nodeId];
+ ai_assert(child);
+
+ nodes.push_back(child);
+
+ BuildNodeList(child, nodes);
+ }
+}
+
+/* A bone stack allows us to have multiple armatures, with the same bone names
+ * A bone stack allows us also to retrieve bones true transform even with
+ * duplicate names :)
+ */
+void ArmaturePopulate::BuildBoneStack(aiNode *current_node,
+ const aiNode *root_node,
+ const aiScene *scene,
+ const std::vector<aiBone *> &bones,
+ std::map<aiBone *, aiNode *> &bone_stack,
+ std::vector<aiNode *> &node_stack) {
+ ai_assert(scene);
+ ai_assert(root_node);
+ ai_assert(!node_stack.empty());
+
+ for (aiBone *bone : bones) {
+ ai_assert(bone);
+ aiNode *node = GetNodeFromStack(bone->mName, node_stack);
+ if (node == nullptr) {
+ node_stack.clear();
+ BuildNodeList(root_node, node_stack);
+ ASSIMP_LOG_DEBUG_F("Resetting bone stack: nullptr element ", bone->mName.C_Str());
+
+ node = GetNodeFromStack(bone->mName, node_stack);
+
+ if (!node) {
+ ASSIMP_LOG_ERROR("serious import issue node for bone was not detected");
+ continue;
+ }
+ }
+
+ ASSIMP_LOG_DEBUG_F("Successfully added bone[", bone->mName.C_Str(), "] to stack and bone node is: ", node->mName.C_Str());
+
+ bone_stack.insert(std::pair<aiBone *, aiNode *>(bone, node));
+ }
+}
+
+
+/* Returns the armature root node */
+/* This is required to be detected for a bone initially, it will recurse up
+ * until it cannot find another bone and return the node No known failure
+ * points. (yet)
+ */
+aiNode *ArmaturePopulate::GetArmatureRoot(aiNode *bone_node,
+ std::vector<aiBone *> &bone_list) {
+ while (bone_node) {
+ if (!IsBoneNode(bone_node->mName, bone_list)) {
+ ASSIMP_LOG_DEBUG_F("GetArmatureRoot() Found valid armature: ", bone_node->mName.C_Str());
+ return bone_node;
+ }
+
+ bone_node = bone_node->mParent;
+ }
+
+ ASSIMP_LOG_ERROR("GetArmatureRoot() can't find armature!");
+
+ return nullptr;
+}
+
+
+
+/* Simple IsBoneNode check if this could be a bone */
+bool ArmaturePopulate::IsBoneNode(const aiString &bone_name,
+ std::vector<aiBone *> &bones) {
+ for (aiBone *bone : bones) {
+ if (bone->mName == bone_name) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/* Pop this node by name from the stack if found */
+/* Used in multiple armature situations with duplicate node / bone names */
+/* Known flaw: cannot have nodes with bone names, will be fixed in later release
+ */
+/* (serious to be fixed) Known flaw: nodes which have more than one bone could
+ * be prematurely dropped from stack */
+aiNode *ArmaturePopulate::GetNodeFromStack(const aiString &node_name,
+ std::vector<aiNode *> &nodes) {
+ std::vector<aiNode *>::iterator iter;
+ aiNode *found = nullptr;
+ for (iter = nodes.begin(); iter < nodes.end(); ++iter) {
+ aiNode *element = *iter;
+ ai_assert(element);
+ // node valid and node name matches
+ if (element->mName == node_name) {
+ found = element;
+ break;
+ }
+ }
+
+ if (found != nullptr) {
+ ASSIMP_LOG_INFO_F("Removed node from stack: ", found->mName.C_Str());
+ // now pop the element from the node list
+ nodes.erase(iter);
+
+ return found;
+ }
+
+ // unique names can cause this problem
+ ASSIMP_LOG_ERROR("[Serious] GetNodeFromStack() can't find node from stack!");
+
+ return nullptr;
+}
+
+
+
+
+} // Namespace Assimp
diff --git a/thirdparty/assimp/code/PostProcessing/ArmaturePopulate.h b/thirdparty/assimp/code/PostProcessing/ArmaturePopulate.h
new file mode 100644
index 0000000000..aa1ad7c80c
--- /dev/null
+++ b/thirdparty/assimp/code/PostProcessing/ArmaturePopulate.h
@@ -0,0 +1,112 @@
+/*
+Open Asset Import Library (assimp)
+----------------------------------------------------------------------
+
+Copyright (c) 2006-2019, assimp team
+
+
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the
+following conditions are met:
+
+* Redistributions of source code must retain the above
+copyright notice, this list of conditions and the
+following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the
+following disclaimer in the documentation and/or other
+materials provided with the distribution.
+
+* Neither the name of the assimp team, nor the names of its
+contributors may be used to endorse or promote products
+derived from this software without specific prior
+written permission of the assimp team.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+----------------------------------------------------------------------
+*/
+#ifndef ARMATURE_POPULATE_H_
+#define ARMATURE_POPULATE_H_
+
+#include "Common/BaseProcess.h"
+#include <assimp/BaseImporter.h>
+#include <vector>
+#include <map>
+
+
+struct aiNode;
+struct aiBone;
+
+namespace Assimp {
+
+// ---------------------------------------------------------------------------
+/** Armature Populate: This is a post process designed
+ * To save you time when importing models into your game engines
+ * This was originally designed only for fbx but will work with other formats
+ * it is intended to auto populate aiBone data with armature and the aiNode
+ * This is very useful when dealing with skinned meshes
+ * or when dealing with many different skeletons
+ * It's off by default but recommend that you try it and use it
+ * It should reduce down any glue code you have in your
+ * importers
+ * You can contact RevoluPowered <gordon@gordonite.tech>
+ * For more info about this
+*/
+class ASSIMP_API ArmaturePopulate : public BaseProcess {
+public:
+ /// The default class constructor.
+ ArmaturePopulate();
+
+ /// The class destructor.
+ virtual ~ArmaturePopulate();
+
+ /// Overwritten, @see BaseProcess
+ virtual bool IsActive( unsigned int pFlags ) const;
+
+ /// Overwritten, @see BaseProcess
+ virtual void SetupProperties( const Importer* pImp );
+
+ /// Overwritten, @see BaseProcess
+ virtual void Execute( aiScene* pScene );
+
+ static aiNode *GetArmatureRoot(aiNode *bone_node,
+ std::vector<aiBone *> &bone_list);
+
+ static bool IsBoneNode(const aiString &bone_name,
+ std::vector<aiBone *> &bones);
+
+ static aiNode *GetNodeFromStack(const aiString &node_name,
+ std::vector<aiNode *> &nodes);
+
+ static void BuildNodeList(const aiNode *current_node,
+ std::vector<aiNode *> &nodes);
+
+ static void BuildBoneList(aiNode *current_node, const aiNode *root_node,
+ const aiScene *scene,
+ std::vector<aiBone *> &bones);
+
+ static void BuildBoneStack(aiNode *current_node, const aiNode *root_node,
+ const aiScene *scene,
+ const std::vector<aiBone *> &bones,
+ std::map<aiBone *, aiNode *> &bone_stack,
+ std::vector<aiNode *> &node_stack);
+};
+
+} // Namespace Assimp
+
+
+#endif // SCALE_PROCESS_H_ \ No newline at end of file
diff --git a/thirdparty/assimp/code/PostProcessing/ComputeUVMappingProcess.cpp b/thirdparty/assimp/code/PostProcessing/ComputeUVMappingProcess.cpp
index bb571a551b..df4d44337d 100644
--- a/thirdparty/assimp/code/PostProcessing/ComputeUVMappingProcess.cpp
+++ b/thirdparty/assimp/code/PostProcessing/ComputeUVMappingProcess.cpp
@@ -354,12 +354,12 @@ void ComputeUVMappingProcess::ComputePlaneMapping(aiMesh* mesh,const aiVector3D&
}
else if (axis * base_axis_z >= angle_epsilon) {
FindMeshCenter(mesh, center, min, max);
- diffu = max.y - min.y;
- diffv = max.z - min.z;
+ diffu = max.x - min.x;
+ diffv = max.y - min.y;
for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) {
const aiVector3D& pos = mesh->mVertices[pnt];
- out[pnt].Set((pos.y - min.y) / diffu,(pos.x - min.x) / diffv,0.0);
+ out[pnt].Set((pos.x - min.x) / diffu,(pos.y - min.y) / diffv,0.0);
}
}
// slower code path in case the mapping axis is not one of the coordinate system axes
diff --git a/thirdparty/assimp/code/PostProcessing/FindInvalidDataProcess.cpp b/thirdparty/assimp/code/PostProcessing/FindInvalidDataProcess.cpp
index 433f042448..016884c6e7 100644
--- a/thirdparty/assimp/code/PostProcessing/FindInvalidDataProcess.cpp
+++ b/thirdparty/assimp/code/PostProcessing/FindInvalidDataProcess.cpp
@@ -52,7 +52,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FindInvalidDataProcess.h"
#include "ProcessHelper.h"
-#include <assimp/Macros.h>
#include <assimp/Exceptional.h>
#include <assimp/qnan.h>
diff --git a/thirdparty/assimp/code/PostProcessing/JoinVerticesProcess.cpp b/thirdparty/assimp/code/PostProcessing/JoinVerticesProcess.cpp
index 914ec05b46..f121fc60d3 100644
--- a/thirdparty/assimp/code/PostProcessing/JoinVerticesProcess.cpp
+++ b/thirdparty/assimp/code/PostProcessing/JoinVerticesProcess.cpp
@@ -431,31 +431,6 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
bone->mWeights = new aiVertexWeight[bone->mNumWeights];
memcpy( bone->mWeights, &newWeights[0], bone->mNumWeights * sizeof( aiVertexWeight));
}
- else {
-
- /* NOTE:
- *
- * In the algorithm above we're assuming that there are no vertices
- * with a different bone weight setup at the same position. That wouldn't
- * make sense, but it is not absolutely impossible. SkeletonMeshBuilder
- * for example generates such input data if two skeleton points
- * share the same position. Again this doesn't make sense but is
- * reality for some model formats (MD5 for example uses these special
- * nodes as attachment tags for its weapons).
- *
- * Then it is possible that a bone has no weights anymore .... as a quick
- * workaround, we're just removing these bones. If they're animated,
- * model geometry might be modified but at least there's no risk of a crash.
- */
- delete bone;
- --pMesh->mNumBones;
- for (unsigned int n = a; n < pMesh->mNumBones; ++n) {
- pMesh->mBones[n] = pMesh->mBones[n+1];
- }
-
- --a;
- ASSIMP_LOG_WARN("Removing bone -> no weights remaining");
- }
}
return pMesh->mNumVertices;
}
diff --git a/thirdparty/assimp/code/PostProcessing/MakeVerboseFormat.cpp b/thirdparty/assimp/code/PostProcessing/MakeVerboseFormat.cpp
index 50ff5ed93d..41f50a5ba5 100644
--- a/thirdparty/assimp/code/PostProcessing/MakeVerboseFormat.cpp
+++ b/thirdparty/assimp/code/PostProcessing/MakeVerboseFormat.cpp
@@ -224,3 +224,32 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh)
}
return (pcMesh->mNumVertices != iOldNumVertices);
}
+
+
+// ------------------------------------------------------------------------------------------------
+bool IsMeshInVerboseFormat(const aiMesh* mesh) {
+ // avoid slow vector<bool> specialization
+ std::vector<unsigned int> seen(mesh->mNumVertices,0);
+ for(unsigned int i = 0; i < mesh->mNumFaces; ++i) {
+ const aiFace& f = mesh->mFaces[i];
+ for(unsigned int j = 0; j < f.mNumIndices; ++j) {
+ if(++seen[f.mIndices[j]] == 2) {
+ // found a duplicate index
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+// ------------------------------------------------------------------------------------------------
+bool MakeVerboseFormatProcess::IsVerboseFormat(const aiScene* pScene) {
+ for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
+ if(!IsMeshInVerboseFormat(pScene->mMeshes[i])) {
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/thirdparty/assimp/code/PostProcessing/MakeVerboseFormat.h b/thirdparty/assimp/code/PostProcessing/MakeVerboseFormat.h
index 1adf8e2f69..8565d5933a 100644
--- a/thirdparty/assimp/code/PostProcessing/MakeVerboseFormat.h
+++ b/thirdparty/assimp/code/PostProcessing/MakeVerboseFormat.h
@@ -94,6 +94,13 @@ public:
* @param pScene The imported data to work at. */
void Execute( aiScene* pScene);
+public:
+
+ // -------------------------------------------------------------------
+ /** Checks whether the scene is already in verbose format.
+ * @param pScene The data to check.
+ * @return true if the scene is already in verbose format. */
+ static bool IsVerboseFormat(const aiScene* pScene);
private:
diff --git a/thirdparty/assimp/code/PostProcessing/ValidateDataStructure.cpp b/thirdparty/assimp/code/PostProcessing/ValidateDataStructure.cpp
index 712fd6943d..75d1b6ef78 100644
--- a/thirdparty/assimp/code/PostProcessing/ValidateDataStructure.cpp
+++ b/thirdparty/assimp/code/PostProcessing/ValidateDataStructure.cpp
@@ -538,13 +538,17 @@ void ValidateDSProcess::Validate( const aiAnimation* pAnimation)
{
Validate(&pAnimation->mName);
- // validate all materials
- if (pAnimation->mNumChannels)
+ // validate all animations
+ if (pAnimation->mNumChannels || pAnimation->mNumMorphMeshChannels)
{
- if (!pAnimation->mChannels) {
+ if (!pAnimation->mChannels && pAnimation->mNumChannels) {
ReportError("aiAnimation::mChannels is NULL (aiAnimation::mNumChannels is %i)",
pAnimation->mNumChannels);
}
+ if (!pAnimation->mMorphMeshChannels && pAnimation->mNumMorphMeshChannels) {
+ ReportError("aiAnimation::mMorphMeshChannels is NULL (aiAnimation::mNumMorphMeshChannels is %i)",
+ pAnimation->mNumMorphMeshChannels);
+ }
for (unsigned int i = 0; i < pAnimation->mNumChannels;++i)
{
if (!pAnimation->mChannels[i])
@@ -554,6 +558,15 @@ void ValidateDSProcess::Validate( const aiAnimation* pAnimation)
}
Validate(pAnimation, pAnimation->mChannels[i]);
}
+ for (unsigned int i = 0; i < pAnimation->mNumMorphMeshChannels;++i)
+ {
+ if (!pAnimation->mMorphMeshChannels[i])
+ {
+ ReportError("aiAnimation::mMorphMeshChannels[%i] is NULL (aiAnimation::mNumMorphMeshChannels is %i)",
+ i, pAnimation->mNumMorphMeshChannels);
+ }
+ Validate(pAnimation, pAnimation->mMorphMeshChannels[i]);
+ }
}
else {
ReportError("aiAnimation::mNumChannels is 0. At least one node animation channel must be there.");
@@ -903,6 +916,48 @@ void ValidateDSProcess::Validate( const aiAnimation* pAnimation,
}
}
+void ValidateDSProcess::Validate( const aiAnimation* pAnimation,
+ const aiMeshMorphAnim* pMeshMorphAnim)
+{
+ Validate(&pMeshMorphAnim->mName);
+
+ if (!pMeshMorphAnim->mNumKeys) {
+ ReportError("Empty mesh morph animation channel");
+ }
+
+ // otherwise check whether one of the keys exceeds the total duration of the animation
+ if (pMeshMorphAnim->mNumKeys)
+ {
+ if (!pMeshMorphAnim->mKeys)
+ {
+ ReportError("aiMeshMorphAnim::mKeys is NULL (aiMeshMorphAnim::mNumKeys is %i)",
+ pMeshMorphAnim->mNumKeys);
+ }
+ double dLast = -10e10;
+ for (unsigned int i = 0; i < pMeshMorphAnim->mNumKeys;++i)
+ {
+ // ScenePreprocessor will compute the duration if still the default value
+ // (Aramis) Add small epsilon, comparison tended to fail if max_time == duration,
+ // seems to be due the compilers register usage/width.
+ if (pAnimation->mDuration > 0. && pMeshMorphAnim->mKeys[i].mTime > pAnimation->mDuration+0.001)
+ {
+ ReportError("aiMeshMorphAnim::mKeys[%i].mTime (%.5f) is larger "
+ "than aiAnimation::mDuration (which is %.5f)",i,
+ (float)pMeshMorphAnim->mKeys[i].mTime,
+ (float)pAnimation->mDuration);
+ }
+ if (i && pMeshMorphAnim->mKeys[i].mTime <= dLast)
+ {
+ ReportWarning("aiMeshMorphAnim::mKeys[%i].mTime (%.5f) is smaller "
+ "than aiMeshMorphAnim::mKeys[%i] (which is %.5f)",i,
+ (float)pMeshMorphAnim->mKeys[i].mTime,
+ i-1, (float)dLast);
+ }
+ dLast = pMeshMorphAnim->mKeys[i].mTime;
+ }
+ }
+}
+
// ------------------------------------------------------------------------------------------------
void ValidateDSProcess::Validate( const aiNode* pNode)
{
@@ -958,7 +1013,7 @@ void ValidateDSProcess::Validate( const aiString* pString)
{
if (pString->length > MAXLEN)
{
- ReportError("aiString::length is too large (%lu, maximum is %lu)",
+ ReportError("aiString::length is too large (%u, maximum is %lu)",
pString->length,MAXLEN);
}
const char* sz = pString->data;
diff --git a/thirdparty/assimp/code/PostProcessing/ValidateDataStructure.h b/thirdparty/assimp/code/PostProcessing/ValidateDataStructure.h
index 0b891ef414..7b309c9251 100644
--- a/thirdparty/assimp/code/PostProcessing/ValidateDataStructure.h
+++ b/thirdparty/assimp/code/PostProcessing/ValidateDataStructure.h
@@ -55,6 +55,7 @@ struct aiBone;
struct aiMesh;
struct aiAnimation;
struct aiNodeAnim;
+struct aiMeshMorphAnim;
struct aiTexture;
struct aiMaterial;
struct aiNode;
@@ -150,6 +151,13 @@ protected:
void Validate( const aiAnimation* pAnimation,
const aiNodeAnim* pBoneAnim);
+ /** Validates a mesh morph animation channel.
+ * @param pAnimation Input animation.
+ * @param pMeshMorphAnim Mesh morph animation channel.
+ * */
+ void Validate( const aiAnimation* pAnimation,
+ const aiMeshMorphAnim* pMeshMorphAnim);
+
// -------------------------------------------------------------------
/** Validates a node and all of its subnodes
* @param Node Input node*/
diff --git a/thirdparty/assimp/code/revision.h b/thirdparty/assimp/code/revision.h
index 88872aef22..66eb875303 100644
--- a/thirdparty/assimp/code/revision.h
+++ b/thirdparty/assimp/code/revision.h
@@ -1,7 +1,28 @@
#ifndef ASSIMP_REVISION_H_INC
#define ASSIMP_REVISION_H_INC
-#define GitVersion 0x00000000
+#define GitVersion 0x308db73d
#define GitBranch "master"
+#define VER_MAJOR 5
+#define VER_MINOR 0
+#define VER_PATCH 0
+#define VER_BUILD 0
+
+#define STR_HELP(x) #x
+#define STR(x) STR_HELP(x)
+
+#define VER_FILEVERSION VER_MAJOR,VER_MINOR,VER_PATCH,VER_BUILD
+#if (GitVersion == 0)
+#define VER_FILEVERSION_STR STR(VER_MAJOR) "." STR(VER_MINOR) "." STR(VER_PATCH) "." STR(VER_BUILD)
+#else
+#define VER_FILEVERSION_STR STR(VER_MAJOR) "." STR(VER_MINOR) "." STR(VER_PATCH) "." STR(VER_BUILD) " (Commit 308db73d)"
+#endif
+
+#ifdef NDEBUG
+#define VER_ORIGINAL_FILENAME_STR "assimp.dll"
+#else
+#define VER_ORIGINAL_FILENAME_STR "assimp.dll"
+#endif // NDEBUG
+
#endif // ASSIMP_REVISION_H_INC