Merge branch 'master' into dev/gltf-KHR_materials

pull/3552/head
Danny-Kint 2020-12-23 11:33:04 +01:00 committed by GitHub
commit dbffe25c9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 33 deletions

View File

@ -53,7 +53,7 @@ const MetaKeyPairVector MakeColladaAssimpMetaKeys() {
result.emplace_back("authoring_tool", AI_METADATA_SOURCE_GENERATOR); result.emplace_back("authoring_tool", AI_METADATA_SOURCE_GENERATOR);
result.emplace_back("copyright", AI_METADATA_SOURCE_COPYRIGHT); result.emplace_back("copyright", AI_METADATA_SOURCE_COPYRIGHT);
return result; return result;
}; }
const MetaKeyPairVector &GetColladaAssimpMetaKeys() { const MetaKeyPairVector &GetColladaAssimpMetaKeys() {
static const MetaKeyPairVector result = MakeColladaAssimpMetaKeys(); static const MetaKeyPairVector result = MakeColladaAssimpMetaKeys();
@ -66,7 +66,7 @@ const MetaKeyPairVector MakeColladaAssimpMetaKeysCamelCase() {
ToCamelCase(val.first); ToCamelCase(val.first);
} }
return result; return result;
}; }
const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase() { const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase() {
static const MetaKeyPairVector result = MakeColladaAssimpMetaKeysCamelCase(); static const MetaKeyPairVector result = MakeColladaAssimpMetaKeysCamelCase();

View File

@ -1305,9 +1305,6 @@ inline Ref<Accessor> GetSamplerInputRef(Asset& asset, std::string& animId, Ref<B
inline void ExtractTranslationSampler(Asset& asset, std::string& animId, Ref<Buffer>& buffer, const aiNodeAnim* nodeChannel, float ticksPerSecond, Animation::Sampler& sampler) inline void ExtractTranslationSampler(Asset& asset, std::string& animId, Ref<Buffer>& buffer, const aiNodeAnim* nodeChannel, float ticksPerSecond, Animation::Sampler& sampler)
{ {
const unsigned int numKeyframes = nodeChannel->mNumPositionKeys; const unsigned int numKeyframes = nodeChannel->mNumPositionKeys;
if (numKeyframes == 0) {
return;
}
std::vector<float> times(numKeyframes); std::vector<float> times(numKeyframes);
std::vector<float> values(numKeyframes * 3); std::vector<float> values(numKeyframes * 3);
@ -1328,9 +1325,6 @@ inline void ExtractTranslationSampler(Asset& asset, std::string& animId, Ref<Buf
inline void ExtractScaleSampler(Asset& asset, std::string& animId, Ref<Buffer>& buffer, const aiNodeAnim* nodeChannel, float ticksPerSecond, Animation::Sampler& sampler) inline void ExtractScaleSampler(Asset& asset, std::string& animId, Ref<Buffer>& buffer, const aiNodeAnim* nodeChannel, float ticksPerSecond, Animation::Sampler& sampler)
{ {
const unsigned int numKeyframes = nodeChannel->mNumScalingKeys; const unsigned int numKeyframes = nodeChannel->mNumScalingKeys;
if (numKeyframes == 0) {
return;
}
std::vector<float> times(numKeyframes); std::vector<float> times(numKeyframes);
std::vector<float> values(numKeyframes * 3); std::vector<float> values(numKeyframes * 3);
@ -1351,9 +1345,6 @@ inline void ExtractScaleSampler(Asset& asset, std::string& animId, Ref<Buffer>&
inline void ExtractRotationSampler(Asset& asset, std::string& animId, Ref<Buffer>& buffer, const aiNodeAnim* nodeChannel, float ticksPerSecond, Animation::Sampler& sampler) inline void ExtractRotationSampler(Asset& asset, std::string& animId, Ref<Buffer>& buffer, const aiNodeAnim* nodeChannel, float ticksPerSecond, Animation::Sampler& sampler)
{ {
const unsigned int numKeyframes = nodeChannel->mNumRotationKeys; const unsigned int numKeyframes = nodeChannel->mNumRotationKeys;
if (numKeyframes == 0) {
return;
}
std::vector<float> times(numKeyframes); std::vector<float> times(numKeyframes);
std::vector<float> values(numKeyframes * 4); std::vector<float> values(numKeyframes * 4);
@ -1394,30 +1385,37 @@ void glTF2Exporter::ExportAnimations()
if (anim->mName.length > 0) { if (anim->mName.length > 0) {
nameAnim = anim->mName.C_Str(); nameAnim = anim->mName.C_Str();
} }
Ref<Animation> animRef = mAsset->animations.Create(nameAnim);
for (unsigned int channelIndex = 0; channelIndex < anim->mNumChannels; ++channelIndex) { for (unsigned int channelIndex = 0; channelIndex < anim->mNumChannels; ++channelIndex) {
const aiNodeAnim* nodeChannel = anim->mChannels[channelIndex]; const aiNodeAnim* nodeChannel = anim->mChannels[channelIndex];
// It appears that assimp stores this type of animation as multiple animations.
// where each aiNodeAnim in mChannels animates a specific node.
std::string name = nameAnim + "_" + to_string(channelIndex); std::string name = nameAnim + "_" + to_string(channelIndex);
name = mAsset->FindUniqueID(name, "animation"); name = mAsset->FindUniqueID(name, "animation");
Ref<Animation> animRef = mAsset->animations.Create(name);
Ref<Node> animNode = mAsset->nodes.Get(nodeChannel->mNodeName.C_Str()); Ref<Node> animNode = mAsset->nodes.Get(nodeChannel->mNodeName.C_Str());
if (nodeChannel->mNumPositionKeys > 0)
{
Animation::Sampler translationSampler; Animation::Sampler translationSampler;
ExtractTranslationSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, translationSampler); ExtractTranslationSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, translationSampler);
AddSampler(animRef, animNode, translationSampler, AnimationPath_TRANSLATION); AddSampler(animRef, animNode, translationSampler, AnimationPath_TRANSLATION);
}
if (nodeChannel->mNumRotationKeys > 0)
{
Animation::Sampler rotationSampler; Animation::Sampler rotationSampler;
ExtractRotationSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, rotationSampler); ExtractRotationSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, rotationSampler);
AddSampler(animRef, animNode, rotationSampler, AnimationPath_ROTATION); AddSampler(animRef, animNode, rotationSampler, AnimationPath_ROTATION);
}
if (nodeChannel->mNumScalingKeys > 0)
{
Animation::Sampler scaleSampler; Animation::Sampler scaleSampler;
ExtractScaleSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, scaleSampler); ExtractScaleSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, scaleSampler);
AddSampler(animRef, animNode, scaleSampler, AnimationPath_SCALE); AddSampler(animRef, animNode, scaleSampler, AnimationPath_SCALE);
} }
}
// Assimp documentation staes this is not used (not implemented) // Assimp documentation staes this is not used (not implemented)
// for (unsigned int channelIndex = 0; channelIndex < anim->mNumMeshChannels; ++channelIndex) { // for (unsigned int channelIndex = 0; channelIndex < anim->mNumMeshChannels; ++channelIndex) {

View File

@ -1015,7 +1015,7 @@ ENDIF()
# RT-extensions is used in "contrib/Open3DGC/o3dgcTimer.h" for collecting statistics. Pointed file # RT-extensions is used in "contrib/Open3DGC/o3dgcTimer.h" for collecting statistics. Pointed file
# has implementation for different platforms: WIN32, __MACH__ and other ("else" block). # has implementation for different platforms: WIN32, __MACH__ and other ("else" block).
FIND_PACKAGE(RT QUIET) FIND_PACKAGE(RT QUIET)
IF (NOT ASSIMP_HUNTER_ENABLED AND (RT_FOUND OR MSVC)) IF (NOT ASSIMP_HUNTER_ENABLED AND (RT_FOUND OR WIN32))
SET( ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC 1 ) SET( ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC 1 )
ADD_DEFINITIONS( -DASSIMP_IMPORTER_GLTF_USE_OPEN3DGC=1 ) ADD_DEFINITIONS( -DASSIMP_IMPORTER_GLTF_USE_OPEN3DGC=1 )
ELSE () ELSE ()

View File

@ -183,9 +183,10 @@ void SceneCombiner::MergeScenes(aiScene **_dest, std::vector<aiScene *> &src, un
*_dest = src[0]; *_dest = src[0];
return; return;
} }
if (*_dest) if (*_dest) {
(*_dest)->~aiScene(); (*_dest)->~aiScene();
else new (*_dest) aiScene();
} else
*_dest = new aiScene(); *_dest = new aiScene();
// Create a dummy scene to serve as master for the others // Create a dummy scene to serve as master for the others

View File

@ -146,7 +146,7 @@ int IOSystem2Unzip::testerror(voidpf /*opaque*/, voidpf /*stream*/) {
zlib_filefunc_def IOSystem2Unzip::get(IOSystem *pIOHandler) { zlib_filefunc_def IOSystem2Unzip::get(IOSystem *pIOHandler) {
zlib_filefunc_def mapping; zlib_filefunc_def mapping;
#ifdef ASSIMP_USE_HUNTER #if defined (ASSIMP_USE_HUNTER) || defined (__MINGW32__) // GH#3144
mapping.zopen_file = (open_file_func)open; mapping.zopen_file = (open_file_func)open;
mapping.zread_file = (read_file_func)read; mapping.zread_file = (read_file_func)read;
mapping.zwrite_file = (write_file_func)write; mapping.zwrite_file = (write_file_func)write;

View File

@ -175,7 +175,7 @@ namespace o3dgc
m_data[2] = rhs.m_data[2]; m_data[2] = rhs.m_data[2];
} }
template <typename T> template <typename T>
inline Vec3<T>::~Vec3(void){}; inline Vec3<T>::~Vec3(void){}
template <typename T> template <typename T>
inline Vec3<T>::Vec3() {} inline Vec3<T>::Vec3() {}
@ -308,7 +308,7 @@ namespace o3dgc
m_data[1] = rhs.m_data[1]; m_data[1] = rhs.m_data[1];
} }
template <typename T> template <typename T>
inline Vec2<T>::~Vec2(void){}; inline Vec2<T>::~Vec2(void){}
template <typename T> template <typename T>
inline Vec2<T>::Vec2() {} inline Vec2<T>::Vec2() {}

View File

@ -763,7 +763,7 @@ void cleanup()
if (g_hWnd) if (g_hWnd)
KillGLWindow(); KillGLWindow();
}; }
LRESULT CALLBACK WndProc(HWND hWnd, // Handles for this Window LRESULT CALLBACK WndProc(HWND hWnd, // Handles for this Window
UINT uMsg, // Message for this Window UINT uMsg, // Message for this Window

View File

@ -161,4 +161,4 @@ int CMeshRenderer::DrawSorted(unsigned int iIndex,const aiMatrix4x4& mWorld) {
return 1; return 1;
} }
}; }

View File

@ -2143,7 +2143,7 @@ INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
} }
return FALSE; return FALSE;
} }
}; }
using namespace AssimpView; using namespace AssimpView;