diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15ceb2177..fc1366a1a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -269,6 +269,8 @@ ELSEIF(MSVC)
ADD_COMPILE_OPTIONS(/wd4351)
ENDIF()
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
+ SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
+ SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG:FULL /PDBALTPATH:%_PDB% /OPT:REF /OPT:ICF")
ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
IF(NOT ASSIMP_HUNTER_ENABLED)
SET(CMAKE_CXX_STANDARD 11)
diff --git a/code/AssetLib/3DS/3DSHelper.h b/code/AssetLib/3DS/3DSHelper.h
index 1930c0c40..e8efbf949 100644
--- a/code/AssetLib/3DS/3DSHelper.h
+++ b/code/AssetLib/3DS/3DSHelper.h
@@ -348,16 +348,16 @@ struct Texture {
// empty
}
- Texture(Texture &&other) AI_NO_EXCEPT : mTextureBlend(std::move(other.mTextureBlend)),
+ Texture(Texture &&other) AI_NO_EXCEPT : mTextureBlend(other.mTextureBlend),
mMapName(std::move(other.mMapName)),
- mOffsetU(std::move(other.mOffsetU)),
- mOffsetV(std::move(other.mOffsetV)),
- mScaleU(std::move(other.mScaleU)),
- mScaleV(std::move(other.mScaleV)),
- mRotation(std::move(other.mRotation)),
- mMapMode(std::move(other.mMapMode)),
- bPrivate(std::move(other.bPrivate)),
- iUVSrc(std::move(other.iUVSrc)) {
+ mOffsetU(other.mOffsetU),
+ mOffsetV(other.mOffsetV),
+ mScaleU(other.mScaleU),
+ mScaleV(other.mScaleV),
+ mRotation(other.mRotation),
+ mMapMode(other.mMapMode),
+ bPrivate(other.bPrivate),
+ iUVSrc(other.iUVSrc) {
// empty
}
@@ -366,16 +366,16 @@ struct Texture {
return *this;
}
- mTextureBlend = std::move(other.mTextureBlend);
+ mTextureBlend = other.mTextureBlend;
mMapName = std::move(other.mMapName);
- mOffsetU = std::move(other.mOffsetU);
- mOffsetV = std::move(other.mOffsetV);
- mScaleU = std::move(other.mScaleU);
- mScaleV = std::move(other.mScaleV);
- mRotation = std::move(other.mRotation);
- mMapMode = std::move(other.mMapMode);
- bPrivate = std::move(other.bPrivate);
- iUVSrc = std::move(other.iUVSrc);
+ mOffsetU = other.mOffsetU;
+ mOffsetV = other.mOffsetV;
+ mScaleU = other.mScaleU;
+ mScaleV = other.mScaleV;
+ mRotation = other.mRotation;
+ mMapMode = other.mMapMode;
+ bPrivate = other.bPrivate;
+ iUVSrc = other.iUVSrc;
return *this;
}
@@ -461,13 +461,13 @@ struct Material {
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
Material(Material &&other) AI_NO_EXCEPT : mName(std::move(other.mName)),
- mDiffuse(std::move(other.mDiffuse)),
- mSpecularExponent(std::move(other.mSpecularExponent)),
- mShininessStrength(std::move(other.mShininessStrength)),
- mSpecular(std::move(other.mSpecular)),
- mAmbient(std::move(other.mAmbient)),
- mShading(std::move(other.mShading)),
- mTransparency(std::move(other.mTransparency)),
+ mDiffuse(other.mDiffuse),
+ mSpecularExponent(other.mSpecularExponent),
+ mShininessStrength(other.mShininessStrength),
+ mSpecular(other.mSpecular),
+ mAmbient(other.mAmbient),
+ mShading(other.mShading),
+ mTransparency(other.mTransparency),
sTexDiffuse(std::move(other.sTexDiffuse)),
sTexOpacity(std::move(other.sTexOpacity)),
sTexSpecular(std::move(other.sTexSpecular)),
@@ -475,10 +475,10 @@ struct Material {
sTexBump(std::move(other.sTexBump)),
sTexEmissive(std::move(other.sTexEmissive)),
sTexShininess(std::move(other.sTexShininess)),
- mBumpHeight(std::move(other.mBumpHeight)),
- mEmissive(std::move(other.mEmissive)),
+ mBumpHeight(other.mBumpHeight),
+ mEmissive(other.mEmissive),
sTexAmbient(std::move(other.sTexAmbient)),
- mTwoSided(std::move(other.mTwoSided)) {
+ mTwoSided(other.mTwoSided) {
// empty
}
@@ -488,13 +488,13 @@ struct Material {
}
mName = std::move(other.mName);
- mDiffuse = std::move(other.mDiffuse);
- mSpecularExponent = std::move(other.mSpecularExponent);
- mShininessStrength = std::move(other.mShininessStrength),
- mSpecular = std::move(other.mSpecular);
- mAmbient = std::move(other.mAmbient);
- mShading = std::move(other.mShading);
- mTransparency = std::move(other.mTransparency);
+ mDiffuse = other.mDiffuse;
+ mSpecularExponent = other.mSpecularExponent;
+ mShininessStrength = other.mShininessStrength,
+ mSpecular = other.mSpecular;
+ mAmbient = other.mAmbient;
+ mShading = other.mShading;
+ mTransparency = other.mTransparency;
sTexDiffuse = std::move(other.sTexDiffuse);
sTexOpacity = std::move(other.sTexOpacity);
sTexSpecular = std::move(other.sTexSpecular);
@@ -502,10 +502,10 @@ struct Material {
sTexBump = std::move(other.sTexBump);
sTexEmissive = std::move(other.sTexEmissive);
sTexShininess = std::move(other.sTexShininess);
- mBumpHeight = std::move(other.mBumpHeight);
- mEmissive = std::move(other.mEmissive);
+ mBumpHeight = other.mBumpHeight;
+ mEmissive = other.mEmissive;
sTexAmbient = std::move(other.sTexAmbient);
- mTwoSided = std::move(other.mTwoSided);
+ mTwoSided = other.mTwoSided;
return *this;
}
diff --git a/code/AssetLib/ASE/ASEParser.h b/code/AssetLib/ASE/ASEParser.h
index d04fc0662..f49cfc36f 100644
--- a/code/AssetLib/ASE/ASEParser.h
+++ b/code/AssetLib/ASE/ASEParser.h
@@ -95,8 +95,8 @@ struct Material : public D3DS::Material {
Material(Material &&other) AI_NO_EXCEPT
: D3DS::Material(std::move(other)),
avSubMaterials(std::move(other.avSubMaterials)),
- pcInstance(std::move(other.pcInstance)),
- bNeed(std::move(other.bNeed)) {
+ pcInstance(other.pcInstance),
+ bNeed(other.bNeed) {
other.pcInstance = nullptr;
}
@@ -108,8 +108,8 @@ struct Material : public D3DS::Material {
//D3DS::Material::operator=(std::move(other));
avSubMaterials = std::move(other.avSubMaterials);
- pcInstance = std::move(other.pcInstance);
- bNeed = std::move(other.bNeed);
+ pcInstance = other.pcInstance;
+ bNeed = other.bNeed;
other.pcInstance = nullptr;
diff --git a/code/AssetLib/B3D/B3DImporter.cpp b/code/AssetLib/B3D/B3DImporter.cpp
index 3d9a5075a..11f7bcd14 100644
--- a/code/AssetLib/B3D/B3DImporter.cpp
+++ b/code/AssetLib/B3D/B3DImporter.cpp
@@ -143,7 +143,7 @@ AI_WONT_RETURN void B3DImporter::Oops() {
}
// ------------------------------------------------------------------------------------------------
-AI_WONT_RETURN void B3DImporter::Fail(string str) {
+AI_WONT_RETURN void B3DImporter::Fail(const string &str) {
#ifdef DEBUG_B3D
ASSIMP_LOG_ERROR("Error in B3D file data: ", str);
#endif
diff --git a/code/AssetLib/B3D/B3DImporter.h b/code/AssetLib/B3D/B3DImporter.h
index e2a75abdf..a7ed65c3b 100644
--- a/code/AssetLib/B3D/B3DImporter.h
+++ b/code/AssetLib/B3D/B3DImporter.h
@@ -96,7 +96,7 @@ private:
};
AI_WONT_RETURN void Oops() AI_WONT_RETURN_SUFFIX;
- AI_WONT_RETURN void Fail( std::string str ) AI_WONT_RETURN_SUFFIX;
+ AI_WONT_RETURN void Fail(const std::string &str) AI_WONT_RETURN_SUFFIX;
void ReadTEXS();
void ReadBRUS();
diff --git a/code/AssetLib/Blender/BlenderLoader.cpp b/code/AssetLib/Blender/BlenderLoader.cpp
index 7cf4e070e..42a7a1723 100644
--- a/code/AssetLib/Blender/BlenderLoader.cpp
+++ b/code/AssetLib/Blender/BlenderLoader.cpp
@@ -679,7 +679,7 @@ void BlenderImporter::BuildMaterials(ConversionData &conv_data) {
BuildDefaultMaterial(conv_data);
- for (std::shared_ptr mat : conv_data.materials_raw) {
+ for (const std::shared_ptr &mat : conv_data.materials_raw) {
// reset per material global counters
for (size_t i = 0; i < sizeof(conv_data.next_texture) / sizeof(conv_data.next_texture[0]); ++i) {
diff --git a/code/AssetLib/COB/COBLoader.cpp b/code/AssetLib/COB/COBLoader.cpp
index 94327c683..822bce16d 100644
--- a/code/AssetLib/COB/COBLoader.cpp
+++ b/code/AssetLib/COB/COBLoader.cpp
@@ -230,7 +230,7 @@ void COBImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
}
// ------------------------------------------------------------------------------------------------
-void ConvertTexture(std::shared_ptr tex, aiMaterial *out, aiTextureType type) {
+void ConvertTexture(const std::shared_ptr &tex, aiMaterial *out, aiTextureType type) {
const aiString path(tex->path);
out->AddProperty(&path, AI_MATKEY_TEXTURE(type, 0));
out->AddProperty(&tex->transform, 1, AI_MATKEY_UVTRANSFORM(type, 0));
diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp
index 5dbf0a567..3166136b2 100644
--- a/code/AssetLib/Collada/ColladaParser.cpp
+++ b/code/AssetLib/Collada/ColladaParser.cpp
@@ -453,7 +453,7 @@ void ColladaParser::PostProcessRootAnimations() {
temp.mSubAnims.push_back(clip);
- for (std::string animationID : it.second) {
+ for (const std::string &animationID : it.second) {
AnimationLibrary::iterator animation = mAnimationLibrary.find(animationID);
if (animation != mAnimationLibrary.end()) {
diff --git a/code/AssetLib/DXF/DXFLoader.cpp b/code/AssetLib/DXF/DXFLoader.cpp
index 5d32ed121..49d572b0b 100644
--- a/code/AssetLib/DXF/DXFLoader.cpp
+++ b/code/AssetLib/DXF/DXFLoader.cpp
@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team
-
-
All rights reserved.
Redistribution and use of this software in source and binary forms,
diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp
index a564b3e9b..f489e37a4 100644
--- a/code/AssetLib/FBX/FBXConverter.cpp
+++ b/code/AssetLib/FBX/FBXConverter.cpp
@@ -1766,6 +1766,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const TextureMap
// XXX handle all kinds of UV transformations
uvTrafo.mScaling = tex->UVScaling();
uvTrafo.mTranslation = tex->UVTranslation();
+ uvTrafo.mRotation = tex->UVRotation();
out_mat->AddProperty(&uvTrafo, 1, _AI_MATKEY_UVTRANSFORM_BASE, target, 0);
const PropertyTable &props = tex->Props();
@@ -1885,6 +1886,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const LayeredTex
// XXX handle all kinds of UV transformations
uvTrafo.mScaling = tex->UVScaling();
uvTrafo.mTranslation = tex->UVTranslation();
+ uvTrafo.mRotation = tex->UVRotation();
out_mat->AddProperty(&uvTrafo, 1, _AI_MATKEY_UVTRANSFORM_BASE, target, texIndex);
const PropertyTable &props = tex->Props();
@@ -2324,6 +2326,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTa
// XXX handle all kinds of UV transformations
uvTrafo.mScaling = tex->UVScaling();
uvTrafo.mTranslation = tex->UVTranslation();
+ uvTrafo.mRotation = tex->UVRotation();
out_mat->AddProperty(&uvTrafo, 1, (name + "|uvtrafo").c_str(), aiTextureType_UNKNOWN, 0);
int uvIndex = 0;
@@ -2599,7 +2602,7 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) {
anim->mMorphMeshChannels = new aiMeshMorphAnim *[numMorphMeshChannels];
anim->mNumMorphMeshChannels = numMorphMeshChannels;
unsigned int i = 0;
- for (auto morphAnimIt : morphAnimDatas) {
+ for (const auto &morphAnimIt : morphAnimDatas) {
morphAnimData *animData = morphAnimIt.second;
unsigned int numKeys = static_cast(animData->size());
aiMeshMorphAnim *meshMorphAnim = new aiMeshMorphAnim();
diff --git a/code/AssetLib/FBX/FBXDocument.cpp b/code/AssetLib/FBX/FBXDocument.cpp
index 7adaadf6c..0c4435348 100644
--- a/code/AssetLib/FBX/FBXDocument.cpp
+++ b/code/AssetLib/FBX/FBXDocument.cpp
@@ -57,9 +57,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
-#include
#include
#include
-![Build Status: master](https://travis-ci.org/google/draco.svg?branch=master)
+[![Build Status](https://github.com/google/draco/workflows/Build/badge.svg)](https://github.com/google/draco/actions?query=workflow%3ABuild)
News
=======
### Version 1.4.1 release
-* Using the versioned gstatic.com WASM and Javascript decoders is now
+* Using the versioned www.gstatic.com WASM and Javascript decoders is now
recommended. To use v1.4.1, use this URL:
* https://www.gstatic.com/draco/versioned/decoders/1.4.1/*
* Replace the * with the files to load. E.g.
- * https://gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.js
+ * https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.js
* This works with the v1.3.6 and v1.4.0 releases, and will work with future
Draco releases.
* Bug fixes
diff --git a/contrib/draco/cmake/draco_build_definitions.cmake b/contrib/draco/cmake/draco_build_definitions.cmake
index c1ada6206..f7354c15f 100644
--- a/contrib/draco/cmake/draco_build_definitions.cmake
+++ b/contrib/draco/cmake/draco_build_definitions.cmake
@@ -6,7 +6,7 @@ set(DRACO_CMAKE_DRACO_BUILD_DEFINITIONS_CMAKE_ 1)
# Utility for controlling the main draco library dependency. This changes in
# shared builds, and when an optional target requires a shared library build.
macro(set_draco_target)
- if(MSVC OR WIN32)
+ if(MSVC)
set(draco_dependency draco)
set(draco_plugin_dependency ${draco_dependency})
else()
@@ -63,6 +63,11 @@ macro(draco_set_build_definitions)
if(BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()
+ else()
+ if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
+ # Ensure 64-bit platforms can support large files.
+ list(APPEND draco_defines "_LARGEFILE_SOURCE" "_FILE_OFFSET_BITS=64")
+ endif()
endif()
if(ANDROID)
@@ -114,4 +119,6 @@ macro(draco_set_build_definitions)
draco_check_emscripten_environment()
draco_get_required_emscripten_flags(FLAG_LIST_VAR draco_base_cxx_flags)
endif()
+
+ draco_configure_sanitizer()
endmacro()
diff --git a/contrib/draco/cmake/draco_features.cmake b/contrib/draco/cmake/draco_features.cmake
deleted file mode 100644
index be444bf24..000000000
--- a/contrib/draco/cmake/draco_features.cmake
+++ /dev/null
@@ -1,63 +0,0 @@
-if(DRACO_CMAKE_DRACO_FEATURES_CMAKE_)
- return()
-endif()
-set(DRACO_CMAKE_DRACO_FEATURES_CMAKE_ 1)
-
-set(draco_features_file_name "${draco_build_dir}/draco/draco_features.h")
-set(draco_features_list)
-
-# Macro that handles tracking of Draco preprocessor symbols for the purpose of
-# producing draco_features.h.
-#
-# draco_enable_feature(FEATURE [TARGETS ]) FEATURE
-# is required. It should be a Draco preprocessor symbol. TARGETS is optional. It
-# can be one or more draco targets.
-#
-# When the TARGETS argument is not present the preproc symbol is added to
-# draco_features.h. When it is draco_features.h is unchanged, and
-# target_compile_options() is called for each target specified.
-macro(draco_enable_feature)
- set(def_flags)
- set(def_single_arg_opts FEATURE)
- set(def_multi_arg_opts TARGETS)
- cmake_parse_arguments(DEF "${def_flags}" "${def_single_arg_opts}"
- "${def_multi_arg_opts}" ${ARGN})
- if("${DEF_FEATURE}" STREQUAL "")
- message(FATAL_ERROR "Empty FEATURE passed to draco_enable_feature().")
- endif()
-
- # Do nothing/return early if $DEF_FEATURE is already in the list.
- list(FIND draco_features_list ${DEF_FEATURE} df_index)
- if(NOT df_index EQUAL -1)
- return()
- endif()
-
- list(LENGTH DEF_TARGETS df_targets_list_length)
- if(${df_targets_list_length} EQUAL 0)
- list(APPEND draco_features_list ${DEF_FEATURE})
- else()
- foreach(target ${DEF_TARGETS})
- target_compile_definitions(${target} PRIVATE ${DEF_FEATURE})
- endforeach()
- endif()
-endmacro()
-
-# Function for generating draco_features.h.
-function(draco_generate_features_h)
- file(WRITE "${draco_features_file_name}.new"
- "// GENERATED FILE -- DO NOT EDIT\n\n" "#ifndef DRACO_FEATURES_H_\n"
- "#define DRACO_FEATURES_H_\n\n")
-
- foreach(feature ${draco_features_list})
- file(APPEND "${draco_features_file_name}.new" "#define ${feature}\n")
- endforeach()
-
- file(APPEND "${draco_features_file_name}.new"
- "\n#endif // DRACO_FEATURES_H_")
-
- # Will replace ${draco_features_file_name} only if the file content has
- # changed. This prevents forced Draco rebuilds after CMake runs.
- configure_file("${draco_features_file_name}.new"
- "${draco_features_file_name}")
- file(REMOVE "${draco_features_file_name}.new")
-endfunction()
diff --git a/contrib/draco/cmake/draco_flags.cmake b/contrib/draco/cmake/draco_flags.cmake
index cb9d489e6..0397859a4 100644
--- a/contrib/draco/cmake/draco_flags.cmake
+++ b/contrib/draco/cmake/draco_flags.cmake
@@ -80,6 +80,12 @@ macro(draco_test_cxx_flag)
# Run the actual compile test.
unset(draco_all_cxx_flags_pass CACHE)
message("--- Running combined CXX flags test, flags: ${all_cxx_flags}")
+
+ # check_cxx_compiler_flag() requires that the flags are a string. When flags
+ # are passed as a list it will remove the list separators, and attempt to run
+ # a compile command using list entries concatenated together as a single
+ # argument. Avoid the problem by forcing the argument to be a string.
+ draco_set_and_stringify(SOURCE_VARS all_cxx_flags DEST all_cxx_flags)
check_cxx_compiler_flag("${all_cxx_flags}" draco_all_cxx_flags_pass)
if(cxx_test_FLAG_REQUIRED AND NOT draco_all_cxx_flags_pass)
@@ -194,6 +200,9 @@ macro(draco_test_exe_linker_flag)
else()
unset(CMAKE_EXE_LINKER_FLAGS)
endif()
+
+ list(APPEND DRACO_EXE_LINKER_FLAGS ${${link_FLAG_LIST_VAR_NAME}})
+ list(REMOVE_DUPLICATES DRACO_EXE_LINKER_FLAGS)
endmacro()
# Runs the draco compiler tests. This macro builds up the list of list var(s)
diff --git a/contrib/draco/cmake/draco_install.cmake b/contrib/draco/cmake/draco_install.cmake
index 5c63ecb4a..09bfb591d 100644
--- a/contrib/draco/cmake/draco_install.cmake
+++ b/contrib/draco/cmake/draco_install.cmake
@@ -55,7 +55,7 @@ macro(draco_setup_install_target)
install(TARGETS draco_encoder DESTINATION
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
- if(WIN32)
+ if(MSVC)
install(TARGETS draco DESTINATION
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
else()
diff --git a/contrib/draco/cmake/draco_sanitizer.cmake b/contrib/draco/cmake/draco_sanitizer.cmake
index ca8e23176..d2e41a6cb 100644
--- a/contrib/draco/cmake/draco_sanitizer.cmake
+++ b/contrib/draco/cmake/draco_sanitizer.cmake
@@ -5,28 +5,28 @@ set(DRACO_CMAKE_DRACO_SANITIZER_CMAKE_ 1)
# Handles the details of enabling sanitizers.
macro(draco_configure_sanitizer)
- if(DRACO_SANITIZE AND NOT MSVC)
+ if(DRACO_SANITIZE AND NOT EMSCRIPTEN AND NOT MSVC)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(DRACO_SANITIZE MATCHES "cfi")
- list(APPEND DRACO_CXX_FLAGS "-flto" "-fno-sanitize-trap=cfi")
- list(APPEND DRACO_EXE_LINKER_FLAGS "-flto" "-fno-sanitize-trap=cfi"
+ list(APPEND SAN_CXX_FLAGS "-flto" "-fno-sanitize-trap=cfi")
+ list(APPEND SAN_LINKER_FLAGS "-flto" "-fno-sanitize-trap=cfi"
"-fuse-ld=gold")
endif()
if(${CMAKE_SIZEOF_VOID_P} EQUAL 4
AND DRACO_SANITIZE MATCHES "integer|undefined")
- list(APPEND DRACO_EXE_LINKER_FLAGS "--rtlib=compiler-rt" "-lgcc_s")
+ list(APPEND SAN_LINKER_FLAGS "--rtlib=compiler-rt" "-lgcc_s")
endif()
endif()
- list(APPEND DRACO_CXX_FLAGS "-fsanitize=${DRACO_SANITIZE}")
- list(APPEND DRACO_EXE_LINKER_FLAGS "-fsanitize=${DRACO_SANITIZE}")
+ list(APPEND SAN_CXX_FLAGS "-fsanitize=${DRACO_SANITIZE}")
+ list(APPEND SAN_LINKER_FLAGS "-fsanitize=${DRACO_SANITIZE}")
# Make sanitizer callstacks accurate.
- list(APPEND DRACO_CXX_FLAGS "-fno-omit-frame-pointer"
- "-fno-optimize-sibling-calls")
+ list(APPEND SAN_CXX_FLAGS "-fno-omit-frame-pointer")
+ list(APPEND SAN_CXX_FLAGS "-fno-optimize-sibling-calls")
- draco_test_cxx_flag(FLAG_LIST_VAR_NAMES DRACO_CXX_FLAGS FLAG_REQUIRED)
- draco_test_exe_linker_flag(FLAG_LIST_VAR_NAME DRACO_EXE_LINKER_FLAGS)
+ draco_test_cxx_flag(FLAG_LIST_VAR_NAMES SAN_CXX_FLAGS FLAG_REQUIRED)
+ draco_test_exe_linker_flag(FLAG_LIST_VAR_NAME SAN_LINKER_FLAGS)
endif()
endmacro()
diff --git a/contrib/draco/cmake/draco_targets.cmake b/contrib/draco/cmake/draco_targets.cmake
index 6dfa6a0c4..0456c4d7b 100644
--- a/contrib/draco/cmake/draco_targets.cmake
+++ b/contrib/draco/cmake/draco_targets.cmake
@@ -87,6 +87,7 @@ macro(draco_add_executable)
endif()
add_executable(${exe_NAME} ${exe_SOURCES})
+ set_target_properties(${exe_NAME} PROPERTIES VERSION ${DRACO_VERSION})
if(exe_OUTPUT_NAME)
set_target_properties(${exe_NAME} PROPERTIES OUTPUT_NAME ${exe_OUTPUT_NAME})
@@ -109,10 +110,11 @@ macro(draco_add_executable)
if(exe_LINK_FLAGS OR DRACO_EXE_LINKER_FLAGS)
if(${CMAKE_VERSION} VERSION_LESS "3.13")
- set(link_flags ${exe_LINK_FLAGS} ${DRACO_EXE_LINKER_FLAGS})
+ list(APPEND exe_LINK_FLAGS "${DRACO_EXE_LINKER_FLAGS}")
+ # LINK_FLAGS is managed as a string.
+ draco_set_and_stringify(SOURCE "${exe_LINK_FLAGS}" DEST exe_LINK_FLAGS)
set_target_properties(${exe_NAME}
- PROPERTIES LINK_FLAGS ${exe_LINK_FLAGS}
- ${DRACO_EXE_LINKER_FLAGS})
+ PROPERTIES LINK_FLAGS "${exe_LINK_FLAGS}")
else()
target_link_options(${exe_NAME} PRIVATE ${exe_LINK_FLAGS}
${DRACO_EXE_LINKER_FLAGS})
@@ -130,7 +132,7 @@ macro(draco_add_executable)
endif()
if(BUILD_SHARED_LIBS AND (MSVC OR WIN32))
- target_compile_definitions(${lib_NAME} PRIVATE "DRACO_BUILDING_DLL=0")
+ target_compile_definitions(${exe_NAME} PRIVATE "DRACO_BUILDING_DLL=0")
endif()
if(exe_LIB_DEPS)
@@ -163,8 +165,8 @@ endmacro()
# cmake-format: off
# - OUTPUT_NAME: Override output file basename. Target basename defaults to
# NAME. OUTPUT_NAME is ignored when BUILD_SHARED_LIBS is enabled and CMake
-# is generating a build for which MSVC or WIN32 are true. This is to avoid
-# output basename collisions with DLL import libraries.
+# is generating a build for which MSVC is true. This is to avoid output
+# basename collisions with DLL import libraries.
# - TEST: Flag. Presence means treat library as a test.
# - DEFINES: List of preprocessor macro definitions.
# - INCLUDES: list of include directories for the target.
@@ -259,7 +261,7 @@ macro(draco_add_library)
endif()
if(lib_OUTPUT_NAME)
- if(NOT (BUILD_SHARED_LIBS AND (MSVC OR WIN32)))
+ if(NOT (BUILD_SHARED_LIBS AND MSVC))
set_target_properties(${lib_NAME}
PROPERTIES OUTPUT_NAME ${lib_OUTPUT_NAME})
endif()
@@ -318,8 +320,12 @@ macro(draco_add_library)
set_target_properties(${lib_NAME} PROPERTIES PREFIX "")
endif()
- if(lib_TYPE STREQUAL SHARED AND NOT MSVC)
- set_target_properties(${lib_NAME} PROPERTIES SOVERSION ${DRACO_SOVERSION})
+ # VERSION and SOVERSION as necessary
+ if(NOT lib_TYPE STREQUAL STATIC AND NOT lib_TYPE STREQUAL MODULE)
+ set_target_properties(${lib_NAME} PROPERTIES VERSION ${DRACO_VERSION})
+ if(NOT MSVC)
+ set_target_properties(${lib_NAME} PROPERTIES SOVERSION ${DRACO_SOVERSION})
+ endif()
endif()
if(BUILD_SHARED_LIBS AND (MSVC OR WIN32))
diff --git a/contrib/draco/src/draco/core/cycle_timer.cc b/contrib/draco/src/draco/core/cycle_timer.cc
index 94b4b28b2..58df4df77 100644
--- a/contrib/draco/src/draco/core/cycle_timer.cc
+++ b/contrib/draco/src/draco/core/cycle_timer.cc
@@ -17,31 +17,31 @@
namespace draco {
void DracoTimer::Start() {
#ifdef _WIN32
- QueryPerformanceCounter(&tv_start);
+ QueryPerformanceCounter(&tv_start_);
#else
- gettimeofday(&tv_start, nullptr);
+ gettimeofday(&tv_start_, nullptr);
#endif
}
void DracoTimer::Stop() {
#ifdef _WIN32
- QueryPerformanceCounter(&tv_end);
+ QueryPerformanceCounter(&tv_end_);
#else
- gettimeofday(&tv_end, nullptr);
+ gettimeofday(&tv_end_, nullptr);
#endif
}
int64_t DracoTimer::GetInMs() {
#ifdef _WIN32
LARGE_INTEGER elapsed = {0};
- elapsed.QuadPart = tv_end.QuadPart - tv_start.QuadPart;
+ elapsed.QuadPart = tv_end_.QuadPart - tv_start_.QuadPart;
LARGE_INTEGER frequency = {0};
QueryPerformanceFrequency(&frequency);
return elapsed.QuadPart * 1000 / frequency.QuadPart;
#else
- const int64_t seconds = (tv_end.tv_sec - tv_start.tv_sec) * 1000;
- const int64_t milliseconds = (tv_end.tv_usec - tv_start.tv_usec) / 1000;
+ const int64_t seconds = (tv_end_.tv_sec - tv_start_.tv_sec) * 1000;
+ const int64_t milliseconds = (tv_end_.tv_usec - tv_start_.tv_usec) / 1000;
return seconds + milliseconds;
#endif
}
diff --git a/contrib/draco/src/draco/core/cycle_timer.h b/contrib/draco/src/draco/core/cycle_timer.h
index 172f1c2e9..f480cc9d3 100644
--- a/contrib/draco/src/draco/core/cycle_timer.h
+++ b/contrib/draco/src/draco/core/cycle_timer.h
@@ -20,9 +20,10 @@
#define WIN32_LEAN_AND_MEAN
#endif
#include
-typedef LARGE_INTEGER timeval;
+typedef LARGE_INTEGER DracoTimeVal;
#else
#include
+typedef timeval DracoTimeVal;
#endif
#include
@@ -39,8 +40,8 @@ class DracoTimer {
int64_t GetInMs();
private:
- timeval tv_start;
- timeval tv_end;
+ DracoTimeVal tv_start_;
+ DracoTimeVal tv_end_;
};
typedef DracoTimer CycleTimer;
diff --git a/contrib/draco/src/draco/io/parser_utils.cc b/contrib/draco/src/draco/io/parser_utils.cc
index 4f95f6f84..12afacff6 100644
--- a/contrib/draco/src/draco/io/parser_utils.cc
+++ b/contrib/draco/src/draco/io/parser_utils.cc
@@ -18,6 +18,7 @@
#include
#include
#include
+#include
namespace draco {
namespace parser {
@@ -252,7 +253,7 @@ DecoderBuffer ParseLineIntoDecoderBuffer(DecoderBuffer *buffer) {
std::string ToLower(const std::string &str) {
std::string out;
- std::transform(str.begin(), str.end(), std::back_inserter(out), [](unsigned char c){return tolower(c);});
+ std::transform(str.begin(), str.end(), std::back_inserter(out), tolower);
return out;
}
diff --git a/contrib/draco/src/draco/io/ply_reader.cc b/contrib/draco/src/draco/io/ply_reader.cc
index cb32df225..ea7f2689a 100644
--- a/contrib/draco/src/draco/io/ply_reader.cc
+++ b/contrib/draco/src/draco/io/ply_reader.cc
@@ -268,14 +268,14 @@ std::vector PlyReader::SplitWords(const std::string &line) {
while ((end = line.find_first_of(" \t\n\v\f\r", start)) !=
std::string::npos) {
const std::string word(line.substr(start, end - start));
- if (!std::all_of(word.begin(), word.end(), [](unsigned char c){return isspace(c);})) {
+ if (!std::all_of(word.begin(), word.end(), isspace)) {
output.push_back(word);
}
start = end + 1;
}
const std::string last_word(line.substr(start));
- if (!std::all_of(last_word.begin(), last_word.end(), [](unsigned char c){return isspace(c);})) {
+ if (!std::all_of(last_word.begin(), last_word.end(), isspace)) {
output.push_back(last_word);
}
return output;
diff --git a/contrib/draco/src/draco/io/stdio_file_reader.cc b/contrib/draco/src/draco/io/stdio_file_reader.cc
index 560c3e9e8..a99c96f8f 100644
--- a/contrib/draco/src/draco/io/stdio_file_reader.cc
+++ b/contrib/draco/src/draco/io/stdio_file_reader.cc
@@ -87,7 +87,14 @@ size_t StdioFileReader::GetFileSize() {
return false;
}
+#if _FILE_OFFSET_BITS == 64
+ const size_t file_size = static_cast(ftello(file_));
+#elif defined _WIN64
+ const size_t file_size = static_cast(_ftelli64(file_));
+#else
const size_t file_size = static_cast(ftell(file_));
+#endif
+
rewind(file_);
return file_size;
diff --git a/contrib/poly2tri/poly2tri/sweep/sweep.cc b/contrib/poly2tri/poly2tri/sweep/sweep.cc
index 23aeb6b57..8e3d794c0 100644
--- a/contrib/poly2tri/poly2tri/sweep/sweep.cc
+++ b/contrib/poly2tri/poly2tri/sweep/sweep.cc
@@ -129,7 +129,7 @@ void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangl
EdgeEvent( tcx, ep, *p1, triangle, *p1 );
} else {
// ASSIMP_CHANGE (aramis_acg)
- std::runtime_error("EdgeEvent - collinear points not supported");
+ throw std::runtime_error("EdgeEvent - collinear points not supported");
}
return;
}
diff --git a/include/assimp/material.h b/include/assimp/material.h
index 08c0491c0..f0207c6de 100644
--- a/include/assimp/material.h
+++ b/include/assimp/material.h
@@ -144,7 +144,7 @@ enum aiTextureMapMode {
enum aiTextureMapping {
/** The mapping coordinates are taken from an UV channel.
*
- * The #AI_MATKEY_UVWSRC key specifies from which UV channel
+ * #AI_MATKEY_UVWSRC property specifies from which UV channel
* the texture coordinates are to be taken from (remember,
* meshes can have more than one UV channel).
*/
@@ -202,11 +202,15 @@ enum aiTextureType {
/** The texture is combined with the result of the diffuse
* lighting equation.
+ * OR
+ * PBR Specular/Glossiness
*/
aiTextureType_DIFFUSE = 1,
/** The texture is combined with the result of the specular
* lighting equation.
+ * OR
+ * PBR Specular/Glossiness
*/
aiTextureType_SPECULAR = 2,
@@ -288,6 +292,32 @@ enum aiTextureType {
aiTextureType_DIFFUSE_ROUGHNESS = 16,
aiTextureType_AMBIENT_OCCLUSION = 17,
+ /** PBR Material Modifiers
+ * Some modern renderers have further PBR modifiers that may be overlaid
+ * on top of the 'base' PBR materials for additional realism.
+ * These use multiple texture maps, so only the base type is directly defined
+ */
+
+ /** Sheen
+ * Generally used to simulate textiles that are covered in a layer of microfibers
+ * eg velvet
+ * https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_sheen
+ */
+ aiTextureType_SHEEN = 19,
+
+ /** Clearcoat
+ * Simulates a layer of 'polish' or 'laquer' layered on top of a PBR substrate
+ * https://autodesk.github.io/standard-surface/#closures/coating
+ * https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
+ */
+ aiTextureType_CLEARCOAT = 20,
+
+ /** Transmission
+ * Simulates transmission through the surface
+ * May include further information such as wall thickness
+ */
+ aiTextureType_TRANSMISSION = 21,
+
/** Unknown texture
*
* A texture reference that does not match any of the definitions
@@ -309,7 +339,9 @@ ASSIMP_API const char *TextureTypeToString(enum aiTextureType in);
// ---------------------------------------------------------------------------
/** @brief Defines all shading models supported by the library
- *
+ *
+ * Property: #AI_MATKEY_SHADING_MODEL
+ *
* The list of shading modes has been taken from Blender.
* See Blender documentation for more information. The API does
* not distinguish between "specular" and "diffuse" shaders (thus the
@@ -318,6 +350,7 @@ ASSIMP_API const char *TextureTypeToString(enum aiTextureType in);
* Again, this value is just a hint. Assimp tries to select the shader whose
* most common implementation matches the original rendering results of the
* 3D modeler which wrote a particular model as closely as possible.
+ *
*/
enum aiShadingMode {
/** Flat shading. Shading is done on per-face base,
@@ -364,13 +397,28 @@ enum aiShadingMode {
aiShadingMode_CookTorrance = 0x8,
/** No shading at all. Constant light influence of 1.0.
+ * Also known as "Unlit"
*/
aiShadingMode_NoShading = 0x9,
+ aiShadingMode_Unlit = aiShadingMode_NoShading, // Alias
/** Fresnel shading
*/
aiShadingMode_Fresnel = 0xa,
+ /** Physically-Based Rendering (PBR) shading using
+ * Bidirectional scattering/reflectance distribution function (BSDF/BRDF)
+ * There are multiple methods under this banner, and model files may provide
+ * data for more than one PBR-BRDF method.
+ * Applications should use the set of provided properties to determine which
+ * of their preferred PBR rendering methods are likely to be available
+ * eg:
+ * - If AI_MATKEY_METALLIC_FACTOR is set, then a Metallic/Roughness is available
+ * - If AI_MATKEY_GLOSSINESS_FACTOR is set, then a Specular/Glossiness is available
+ * Note that some PBR methods allow layering of techniques
+ */
+ aiShadingMode_PBR_BRDF = 0xb,
+
#ifndef SWIG
_aiShadingMode_Force32Bit = INT_MAX
#endif
@@ -922,12 +970,66 @@ extern "C" {
// ---------------------------------------------------------------------------
// PBR material support
+// --------------------
+// Properties defining PBR rendering techniques
#define AI_MATKEY_USE_COLOR_MAP "$mat.useColorMap", 0, 0
+
+// Metallic/Roughness Workflow
+// ---------------------------
+// Base RGBA color factor. Will be multiplied by final base color texture values if extant
+// Note: Importers may choose to copy this into AI_MATKEY_COLOR_DIFFUSE for compatibility
+// with renderers and formats that do not support Metallic/Roughness PBR
#define AI_MATKEY_BASE_COLOR "$clr.base", 0, 0
+#define AI_MATKEY_BASE_COLOR_TEXTURE aiTextureType_BASE_COLOR, 0
#define AI_MATKEY_USE_METALLIC_MAP "$mat.useMetallicMap", 0, 0
+// Metallic factor. 0.0 = Full Dielectric, 1.0 = Full Metal
#define AI_MATKEY_METALLIC_FACTOR "$mat.metallicFactor", 0, 0
+#define AI_MATKEY_METALLIC_TEXTURE aiTextureType_METALNESS, 0
#define AI_MATKEY_USE_ROUGHNESS_MAP "$mat.useRoughnessMap", 0, 0
+// Roughness factor. 0.0 = Perfectly Smooth, 1.0 = Completely Rough
#define AI_MATKEY_ROUGHNESS_FACTOR "$mat.roughnessFactor", 0, 0
+#define AI_MATKEY_ROUGHNESS_TEXTURE aiTextureType_DIFFUSE_ROUGHNESS, 0
+
+// Specular/Glossiness Workflow
+// ---------------------------
+// Diffuse/Albedo Color. Note: Pure Metals have a diffuse of {0,0,0}
+// AI_MATKEY_COLOR_DIFFUSE
+// Specular Color.
+// Note: Metallic/Roughness may also have a Specular Color
+// AI_MATKEY_COLOR_SPECULAR
+#define AI_MATKEY_SPECULAR_FACTOR "$mat.specularFactor", 0, 0
+// Glossiness factor. 0.0 = Completely Rough, 1.0 = Perfectly Smooth
+#define AI_MATKEY_GLOSSINESS_FACTOR "$mat.glossinessFactor", 0, 0
+
+// Sheen
+// -----
+// Sheen base RGB color. Default {0,0,0}
+#define AI_MATKEY_SHEEN_COLOR_FACTOR "$clr.sheen.factor", 0, 0
+// Sheen Roughness Factor.
+#define AI_MATKEY_SHEEN_ROUGHNESS_FACTOR "$mat.sheen.roughnessFactor", 0, 0
+#define AI_MATKEY_SHEEN_COLOR_TEXTURE aiTextureType_SHEEN, 0
+#define AI_MATKEY_SHEEN_ROUGHNESS_TEXTURE aiTextureType_SHEEN, 1
+
+// Clearcoat
+// ---------
+// Clearcoat layer intensity. 0.0 = none (disabled)
+#define AI_MATKEY_CLEARCOAT_FACTOR "$mat.clearcoat.factor", 0, 0
+#define AI_MATKEY_CLEARCOAT_ROUGHNESS_FACTOR "$mat.clearcoat.roughnessFactor", 0, 0
+#define AI_MATKEY_CLEARCOAT_TEXTURE aiTextureType_CLEARCOAT, 0
+#define AI_MATKEY_CLEARCOAT_ROUGHNESS_TEXTURE aiTextureType_CLEARCOAT, 1
+#define AI_MATKEY_CLEARCOAT_NORMAL_TEXTURE aiTextureType_CLEARCOAT, 2
+
+// Transmission
+// ------------
+// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
+// Base percentage of light transmitted through the surface. 0.0 = Opaque, 1.0 = Fully transparent
+#define AI_MATKEY_TRANSMISSION_FACTOR "$mat.transmission.factor", 0, 0
+// Texture defining percentage of light transmitted through the surface.
+// Multiplied by AI_MATKEY_TRANSMISSION_FACTOR
+#define AI_MATKEY_TRANSMISSION_TEXTURE aiTextureType_TRANSMISSION, 0
+
+// Emissive
+// --------
#define AI_MATKEY_USE_EMISSIVE_MAP "$mat.useEmissiveMap", 0, 0
#define AI_MATKEY_EMISSIVE_INTENSITY "$mat.emissiveIntensity", 0, 0
#define AI_MATKEY_USE_AO_MAP "$mat.useAOMap", 0, 0
@@ -1397,8 +1499,6 @@ ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(
ai_real *pOut,
unsigned int *pMax);
-#ifdef __cplusplus
-
// ---------------------------------------------------------------------------
/** @brief Retrieve a single float property with a specific key from the material.
*
@@ -1418,7 +1518,7 @@ ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(
* @return Specifies whether the key has been found. If not, the output
* float remains unmodified.*/
// ---------------------------------------------------------------------------
-inline aiReturn aiGetMaterialFloat(const aiMaterial *pMat,
+inline aiReturn aiGetMaterialFloat(const C_STRUCT aiMaterial *pMat,
const char *pKey,
unsigned int type,
unsigned int index,
@@ -1426,14 +1526,6 @@ inline aiReturn aiGetMaterialFloat(const aiMaterial *pMat,
return aiGetMaterialFloatArray(pMat, pKey, type, index, pOut, (unsigned int *)0x0);
}
-#else
-
-// Use our friend, the C preprocessor
-#define aiGetMaterialFloat (pMat, type, index, pKey, pOut) \
- aiGetMaterialFloatArray(pMat, type, index, pKey, pOut, NULL)
-
-#endif //!__cplusplus
-
// ---------------------------------------------------------------------------
/** @brief Retrieve an array of integer values with a specific key
* from a material
@@ -1446,8 +1538,6 @@ ASSIMP_API C_ENUM aiReturn aiGetMaterialIntegerArray(const C_STRUCT aiMaterial *
int *pOut,
unsigned int *pMax);
-#ifdef __cplusplus
-
// ---------------------------------------------------------------------------
/** @brief Retrieve an integer property with a specific key from a material
*
@@ -1461,14 +1551,6 @@ inline aiReturn aiGetMaterialInteger(const C_STRUCT aiMaterial *pMat,
return aiGetMaterialIntegerArray(pMat, pKey, type, index, pOut, (unsigned int *)0x0);
}
-#else
-
-// use our friend, the C preprocessor
-#define aiGetMaterialInteger (pMat, type, index, pKey, pOut) \
- aiGetMaterialIntegerArray(pMat, type, index, pKey, pOut, NULL)
-
-#endif //!__cplusplus
-
// ---------------------------------------------------------------------------
/** @brief Retrieve a color value from the material property table
*
diff --git a/include/assimp/metadata.h b/include/assimp/metadata.h
index 551a9aba4..57fedfbfc 100644
--- a/include/assimp/metadata.h
+++ b/include/assimp/metadata.h
@@ -432,7 +432,7 @@ struct aiMetadata {
/// Check whether there is a metadata entry for the given key.
/// \param [in] Key - the key value value to check for.
- inline bool HasKey(const char *key) {
+ inline bool HasKey(const char *key) const {
if (nullptr == key) {
return false;
}
diff --git a/include/assimp/pbrmaterial.h b/include/assimp/pbrmaterial.h
index 2e41b8b6d..93e7e3095 100644
--- a/include/assimp/pbrmaterial.h
+++ b/include/assimp/pbrmaterial.h
@@ -50,32 +50,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# pragma GCC system_header
#endif
-#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR "$mat.gltf.pbrMetallicRoughness.baseColorFactor", 0, 0
-#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLIC_FACTOR "$mat.gltf.pbrMetallicRoughness.metallicFactor", 0, 0
-#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_ROUGHNESS_FACTOR "$mat.gltf.pbrMetallicRoughness.roughnessFactor", 0, 0
-#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_TEXTURE aiTextureType_DIFFUSE, 1
+//#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR "$mat.gltf.pbrMetallicRoughness.baseColorFactor", 0, 0
+//#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLIC_FACTOR "$mat.gltf.pbrMetallicRoughness.metallicFactor", 0, 0
+//#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_ROUGHNESS_FACTOR "$mat.gltf.pbrMetallicRoughness.roughnessFactor", 0, 0
+//#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_TEXTURE aiTextureType_DIFFUSE, 1
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 0
#define AI_MATKEY_GLTF_ALPHAMODE "$mat.gltf.alphaMode", 0, 0
#define AI_MATKEY_GLTF_ALPHACUTOFF "$mat.gltf.alphaCutoff", 0, 0
-#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS "$mat.gltf.pbrSpecularGlossiness", 0, 0
-#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR "$mat.gltf.pbrMetallicRoughness.glossinessFactor", 0, 0
-#define AI_MATKEY_GLTF_UNLIT "$mat.gltf.unlit", 0, 0
-#define AI_MATKEY_GLTF_MATERIAL_SHEEN "$mat.gltf.materialSheen", 0, 0
-#define AI_MATKEY_GLTF_MATERIAL_SHEEN_COLOR_FACTOR "$mat.gltf.materialSheen.sheenColorFactor", 0, 0
-#define AI_MATKEY_GLTF_MATERIAL_SHEEN_ROUGHNESS_FACTOR "$mat.gltf.materialSheen.sheenRoughnessFactor", 0, 0
-#define AI_MATKEY_GLTF_MATERIAL_SHEEN_COLOR_TEXTURE aiTextureType_UNKNOWN, 1
-#define AI_MATKEY_GLTF_MATERIAL_SHEEN_ROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 2
-#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT "$mat.gltf.materialClearcoat", 0, 0
-#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_FACTOR "$mat.gltf.materialClearcoat.clearcoatFactor", 0, 0
-#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_FACTOR "$mat.gltf.materialClearcoat.clearcoatRoughnessFactor", 0, 0
-#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_TEXTURE aiTextureType_UNKNOWN, 3
-#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 4
-#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_NORMAL_TEXTURE aiTextureType_NORMALS, 1
-#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION "$mat.gltf.materialTransmission", 0, 0
-#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_FACTOR "$mat.gltf.materialTransmission.transmissionFactor", 0, 0
-#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_TEXTURE aiTextureType_UNKNOWN, 5
+//#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS "$mat.gltf.pbrSpecularGlossiness", 0, 0
+//#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR "$mat.gltf.pbrMetallicRoughness.glossinessFactor", 0, 0
+//#define AI_MATKEY_GLTF_UNLIT "$mat.gltf.unlit", 0, 0
+//#define AI_MATKEY_GLTF_MATERIAL_SHEEN "$mat.gltf.materialSheen", 0, 0
+//#define AI_MATKEY_GLTF_MATERIAL_SHEEN_COLOR_FACTOR "$mat.gltf.materialSheen.sheenColorFactor", 0, 0
+//#define AI_MATKEY_GLTF_MATERIAL_SHEEN_ROUGHNESS_FACTOR "$mat.gltf.materialSheen.sheenRoughnessFactor", 0, 0
+//#define AI_MATKEY_GLTF_MATERIAL_SHEEN_COLOR_TEXTURE aiTextureType_UNKNOWN, 1
+//#define AI_MATKEY_GLTF_MATERIAL_SHEEN_ROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 2
+//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT "$mat.gltf.materialClearcoat", 0, 0
+//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_FACTOR "$mat.gltf.materialClearcoat.clearcoatFactor", 0, 0
+//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_FACTOR "$mat.gltf.materialClearcoat.clearcoatRoughnessFactor", 0, 0
+//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_TEXTURE aiTextureType_UNKNOWN, 3
+//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 4
+//#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_NORMAL_TEXTURE aiTextureType_NORMALS, 1
+//#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION "$mat.gltf.materialTransmission", 0, 0
+//#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_FACTOR "$mat.gltf.materialTransmission.transmissionFactor", 0, 0
+//#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_TEXTURE aiTextureType_UNKNOWN, 5
-#define _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE "$tex.file.texCoord"
+//#define _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE "$tex.file.texCoord"
#define _AI_MATKEY_GLTF_MAPPINGNAME_BASE "$tex.mappingname"
#define _AI_MATKEY_GLTF_MAPPINGID_BASE "$tex.mappingid"
#define _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE "$tex.mappingfiltermag"
@@ -83,7 +83,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define _AI_MATKEY_GLTF_SCALE_BASE "$tex.scale"
#define _AI_MATKEY_GLTF_STRENGTH_BASE "$tex.strength"
-#define AI_MATKEY_GLTF_TEXTURE_TEXCOORD(type, N) _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE, type, N
+//#define AI_MATKEY_GLTF_TEXTURE_TEXCOORD(type, N) _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGNAME(type, N) _AI_MATKEY_GLTF_MAPPINGNAME_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGID(type, N) _AI_MATKEY_GLTF_MAPPINGID_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGFILTER_MAG(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE, type, N
diff --git a/include/assimp/scene.h b/include/assimp/scene.h
index 769499a27..522ddc6dc 100644
--- a/include/assimp/scene.h
+++ b/include/assimp/scene.h
@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team
-
-
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -397,22 +395,35 @@ struct aiScene
//! Returns an embedded texture
const aiTexture* GetEmbeddedTexture(const char* filename) const {
+ return GetEmbeddedTextureAndIndex(filename).first;
+ }
+
+ //! Returns an embedded texture and its index
+ std::pair GetEmbeddedTextureAndIndex(const char* filename) const {
+ if(nullptr==filename) {
+ return std::make_pair(nullptr, -1);
+ }
// lookup using texture ID (if referenced like: "*1", "*2", etc.)
if ('*' == *filename) {
int index = std::atoi(filename + 1);
- if (0 > index || mNumTextures <= static_cast(index))
- return nullptr;
- return mTextures[index];
+ if (0 > index || mNumTextures <= static_cast(index)) {
+ return std::make_pair(nullptr, -1);
+ }
+ return std::make_pair(mTextures[index], index);
}
// lookup using filename
const char* shortFilename = GetShortFilename(filename);
+ if (nullptr == shortFilename) {
+ return std::make_pair(nullptr, -1);
+ }
+
for (unsigned int i = 0; i < mNumTextures; i++) {
const char* shortTextureFilename = GetShortFilename(mTextures[i]->mFilename.C_Str());
if (strcmp(shortTextureFilename, shortFilename) == 0) {
- return mTextures[i];
+ return std::make_pair(mTextures[i], i);
}
}
- return nullptr;
+ return std::make_pair(nullptr, -1);
}
#endif // __cplusplus
diff --git a/test/models/glTF2/ClearCoat-glTF/ClearCoatLabels.png b/test/models/glTF2/ClearCoat-glTF/ClearCoatLabels.png
new file mode 100644
index 000000000..d47f2f5e1
Binary files /dev/null and b/test/models/glTF2/ClearCoat-glTF/ClearCoatLabels.png differ
diff --git a/test/models/glTF2/ClearCoat-glTF/ClearCoatTest.bin b/test/models/glTF2/ClearCoat-glTF/ClearCoatTest.bin
new file mode 100644
index 000000000..e7c6a93a4
Binary files /dev/null and b/test/models/glTF2/ClearCoat-glTF/ClearCoatTest.bin differ
diff --git a/test/models/glTF2/ClearCoat-glTF/ClearCoatTest.gltf b/test/models/glTF2/ClearCoat-glTF/ClearCoatTest.gltf
new file mode 100644
index 000000000..ae12bfc11
--- /dev/null
+++ b/test/models/glTF2/ClearCoat-glTF/ClearCoatTest.gltf
@@ -0,0 +1,1669 @@
+{
+ "asset" : {
+ "generator" : "Khronos glTF Blender I/O v1.2.8 with hand-edits for clearcoat",
+ "version" : "2.0"
+ },
+ "extensionsUsed": [
+ "KHR_materials_clearcoat"
+ ],
+ "scene" : 0,
+ "scenes" : [
+ {
+ "name" : "Scene",
+ "nodes" : [
+ 3,
+ 7,
+ 11,
+ 15,
+ 19,
+ 23,
+ 24,
+ 25,
+ 26,
+ 27,
+ 28,
+ 29,
+ 30,
+ 31,
+ 32
+ ]
+ }
+ ],
+ "nodes" : [
+ {
+ "mesh" : 0,
+ "name" : "BaseLayerSample",
+ "translation" : [
+ -2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "mesh" : 1,
+ "name" : "ClearCoatSample"
+ },
+ {
+ "mesh" : 2,
+ "name" : "CoatOnlySample",
+ "translation" : [
+ 2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "children" : [
+ 0,
+ 1,
+ 2
+ ],
+ "name" : "R0_SimpleCoatTest",
+ "translation" : [
+ 0,
+ 5.25,
+ 0
+ ]
+ },
+ {
+ "mesh" : 3,
+ "name" : "R1_BaseLayerSample",
+ "translation" : [
+ -2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "mesh" : 4,
+ "name" : "R1_ClearCoatSample"
+ },
+ {
+ "mesh" : 5,
+ "name" : "R1_CoatOnlySample",
+ "translation" : [
+ 2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "children" : [
+ 4,
+ 5,
+ 6
+ ],
+ "name" : "R1_PartialCoatTest",
+ "translation" : [
+ 0,
+ 3.1500000953674316,
+ 0
+ ]
+ },
+ {
+ "mesh" : 6,
+ "name" : "R2_BaseLayerSample",
+ "translation" : [
+ -2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "mesh" : 7,
+ "name" : "R2_ClearCoatSample"
+ },
+ {
+ "mesh" : 8,
+ "name" : "R2_CoatOnlySample",
+ "translation" : [
+ 2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "children" : [
+ 8,
+ 9,
+ 10
+ ],
+ "name" : "R2_RoughnessVariations",
+ "translation" : [
+ 0,
+ 1.0499999523162842,
+ 0
+ ]
+ },
+ {
+ "mesh" : 9,
+ "name" : "R3_BaseLayerSample",
+ "translation" : [
+ -2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "mesh" : 10,
+ "name" : "R3_ClearCoatSample"
+ },
+ {
+ "mesh" : 11,
+ "name" : "R3_CoatOnlySample",
+ "translation" : [
+ 2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "children" : [
+ 12,
+ 13,
+ 14
+ ],
+ "name" : "R3_BaseNormals",
+ "translation" : [
+ 0,
+ -1.0499999523162842,
+ 0
+ ]
+ },
+ {
+ "mesh" : 12,
+ "name" : "R4_BaseLayerSample",
+ "translation" : [
+ -2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "mesh" : 13,
+ "name" : "R4_ClearCoatSample"
+ },
+ {
+ "mesh" : 14,
+ "name" : "R4_CoatOnlySample",
+ "translation" : [
+ 2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "children" : [
+ 16,
+ 17,
+ 18
+ ],
+ "name" : "R4_CoatNormals",
+ "translation" : [
+ 0,
+ -5.25,
+ 0
+ ]
+ },
+ {
+ "mesh" : 15,
+ "name" : "R5_BaseLayerSample",
+ "translation" : [
+ -2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "mesh" : 16,
+ "name" : "R5_ClearCoatSample"
+ },
+ {
+ "mesh" : 17,
+ "name" : "R5_CoatOnlySample",
+ "translation" : [
+ 2.0999999046325684,
+ 0,
+ 0
+ ]
+ },
+ {
+ "children" : [
+ 20,
+ 21,
+ 22
+ ],
+ "name" : "R5_SharedNormals",
+ "translation" : [
+ 0,
+ -3.1500000953674316,
+ 0
+ ]
+ },
+ {
+ "mesh" : 18,
+ "name" : "X2_Label_CoatingOnly",
+ "translation" : [
+ 2.0712804794311523,
+ 6.619500160217285,
+ 0
+ ]
+ },
+ {
+ "mesh" : 19,
+ "name" : "Y0_Label_SimpleCoating",
+ "translation" : [
+ -5.3578033447265625,
+ 5.25,
+ 0
+ ]
+ },
+ {
+ "mesh" : 20,
+ "name" : "Y1_Label_PartialCoating",
+ "translation" : [
+ -5.3578033447265625,
+ 3.1673200130462646,
+ 0
+ ]
+ },
+ {
+ "mesh" : 21,
+ "name" : "Y2_Label_Roughness",
+ "translation" : [
+ -5.3578033447265625,
+ 1.1383899450302124,
+ 0
+ ]
+ },
+ {
+ "mesh" : 22,
+ "name" : "Y3_Label_BaseNormals",
+ "translation" : [
+ -5.3578033447265625,
+ -1.099429965019226,
+ 0
+ ]
+ },
+ {
+ "mesh" : 23,
+ "name" : "Y4_Label_CoatNormals",
+ "translation" : [
+ -5.3578033447265625,
+ -5.252500057220459,
+ 0
+ ]
+ },
+ {
+ "mesh" : 24,
+ "name" : "Y5_Label_SharedNormals",
+ "translation" : [
+ -5.3578033447265625,
+ -3.1963000297546387,
+ 0
+ ]
+ },
+ {
+ "mesh" : 25,
+ "name" : "X0_Label_BaseLayer",
+ "translation" : [
+ -2.087031602859497,
+ 6.616230010986328,
+ 0
+ ]
+ },
+ {
+ "mesh" : 26,
+ "name" : "X1_Label_Coated",
+ "translation" : [
+ 0,
+ 6.614150047302246,
+ 0
+ ]
+ }
+ ],
+ "materials" : [
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "Simple_Base",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.5,
+ 0.019999999552965164,
+ 0.009999999776482582,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.4399999976158142
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "Simple_Coated",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.5,
+ 0.019999999552965164,
+ 0.009999999776482582,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.4399999976158142
+ },
+ "extensions": {
+ "KHR_materials_clearcoat": {
+ "clearcoatFactor": 1,
+ "clearcoatRoughnessFactor": 0.03
+ }
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "Simple_Coating",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0,
+ 0,
+ 0,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.029999999329447746
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "Partial_Base",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.012983020395040512,
+ 0.022173883393406868,
+ 0.10946174710988998,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.4399999976158142
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "Partial_Coated",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.012983020395040512,
+ 0.022173883393406868,
+ 0.10946174710988998,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.4399999976158142
+ },
+ "extensions": {
+ "KHR_materials_clearcoat": {
+ "clearcoatFactor": 1,
+ "clearcoatRoughnessFactor": 0.03,
+ "clearcoatTexture": {
+ "index": 0,
+ "texCoord": 0
+ }
+ }
+ }
+ },
+ {
+ "alphaMode" : "BLEND",
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "Partial_Coating",
+ "pbrMetallicRoughness" : {
+ "baseColorTexture" : {
+ "index" : 1,
+ "texCoord" : 0
+ },
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.029999999329447746
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "RoughVariations_Base",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.012983020395040512,
+ 0.022173883393406868,
+ 0.10946174710988998,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.6000000238418579
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "RoughVariations_Coated",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.012983020395040512,
+ 0.022173883393406868,
+ 0.10946174710988998,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.6000000238418579
+ },
+ "extensions": {
+ "KHR_materials_clearcoat": {
+ "clearcoatFactor": 1,
+ "clearcoatRoughnessFactor": 1,
+ "clearcoatRoughnessTexture": {
+ "index": 2,
+ "texCoord": 0
+ }
+ }
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "RoughVariations_Coating",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0,
+ 0,
+ 0,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "metallicRoughnessTexture" : {
+ "index" : 2,
+ "texCoord" : 0
+ }
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "BaseNorm_Base",
+ "normalTexture" : {
+ "index" : 3,
+ "texCoord" : 0
+ },
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.012983020395040512,
+ 0.022173883393406868,
+ 0.10946174710988998,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.4399999976158142
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "BaseNorm_Coated",
+ "normalTexture" : {
+ "index" : 4,
+ "texCoord" : 0
+ },
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.012848637998104095,
+ 0.021861059591174126,
+ 0.11068868637084961,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.4399999976158142
+ },
+ "extensions": {
+ "KHR_materials_clearcoat": {
+ "clearcoatFactor": 1,
+ "clearcoatRoughnessFactor": 0.03
+ }
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "BaseNorm_Coating",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0,
+ 0,
+ 0,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.029999999329447746
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "CoatNorm_Base",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.012983020395040512,
+ 0.022173883393406868,
+ 0.10946174710988998,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.4399999976158142
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "CoatNorm_Coated",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.012983020395040512,
+ 0.022173883393406868,
+ 0.10946174710988998,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.4399999976158142
+ },
+ "extensions": {
+ "KHR_materials_clearcoat": {
+ "clearcoatFactor": 1,
+ "clearcoatRoughnessFactor": 0.03,
+ "clearcoatNormalTexture": {
+ "index": 5,
+ "texCoord": 0,
+ "scale": 1
+ }
+ }
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "CoatNorm_Coating",
+ "normalTexture" : {
+ "index" : 5,
+ "texCoord" : 0
+ },
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0,
+ 0,
+ 0,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.029999999329447746
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "SharedNorm_Base",
+ "normalTexture" : {
+ "index" : 6,
+ "texCoord" : 0
+ },
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.012983020395040512,
+ 0.022173883393406868,
+ 0.10946174710988998,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.4399999976158142
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "SharedNorm_Coated",
+ "normalTexture" : {
+ "index" : 7,
+ "texCoord" : 0
+ },
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0.012983020395040512,
+ 0.022173883393406868,
+ 0.10946174710988998,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.4399999976158142
+ },
+ "extensions": {
+ "KHR_materials_clearcoat": {
+ "clearcoatFactor": 1,
+ "clearcoatRoughnessFactor": 0.03,
+ "clearcoatNormalTexture": {
+ "index": 7,
+ "texCoord": 0
+ }
+ }
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 0,
+ 0,
+ 0
+ ],
+ "name" : "SharedNorm_Coating",
+ "normalTexture" : {
+ "index" : 8,
+ "texCoord" : 0
+ },
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0,
+ 0,
+ 0,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.029999999329447746
+ }
+ },
+ {
+ "emissiveFactor" : [
+ 1,
+ 1,
+ 1
+ ],
+ "emissiveTexture" : {
+ "index" : 9,
+ "texCoord" : 0
+ },
+ "name" : "LabelMaterial",
+ "pbrMetallicRoughness" : {
+ "baseColorFactor" : [
+ 0,
+ 0,
+ 0,
+ 1
+ ],
+ "metallicFactor" : 0,
+ "roughnessFactor" : 0.8999999761581421
+ }
+ }
+ ],
+ "meshes" : [
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 0
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 1
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 2
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 3
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 4
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 5
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 6
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 7
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 8
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 9
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 10
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 11
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 12
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 13
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 14
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 15
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 16
+ }
+ ]
+ },
+ {
+ "name" : "ClearCoatSampleMesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 0,
+ "NORMAL" : 1,
+ "TEXCOORD_0" : 2
+ },
+ "indices" : 3,
+ "material" : 17
+ }
+ ]
+ },
+ {
+ "name" : "Labels_Mesh",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 4,
+ "NORMAL" : 5,
+ "TEXCOORD_0" : 6
+ },
+ "indices" : 7,
+ "material" : 18
+ }
+ ]
+ },
+ {
+ "name" : "Labels_Mesh.001",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 8,
+ "NORMAL" : 9,
+ "TEXCOORD_0" : 10
+ },
+ "indices" : 7,
+ "material" : 18
+ }
+ ]
+ },
+ {
+ "name" : "Labels_Mesh.002",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 11,
+ "NORMAL" : 12,
+ "TEXCOORD_0" : 13
+ },
+ "indices" : 14,
+ "material" : 18
+ }
+ ]
+ },
+ {
+ "name" : "Labels_Mesh.003",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 15,
+ "NORMAL" : 16,
+ "TEXCOORD_0" : 17
+ },
+ "indices" : 14,
+ "material" : 18
+ }
+ ]
+ },
+ {
+ "name" : "Labels_Mesh.004",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 18,
+ "NORMAL" : 19,
+ "TEXCOORD_0" : 20
+ },
+ "indices" : 14,
+ "material" : 18
+ }
+ ]
+ },
+ {
+ "name" : "Labels_Mesh.005",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 21,
+ "NORMAL" : 22,
+ "TEXCOORD_0" : 23
+ },
+ "indices" : 14,
+ "material" : 18
+ }
+ ]
+ },
+ {
+ "name" : "Labels_Mesh.006",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 24,
+ "NORMAL" : 25,
+ "TEXCOORD_0" : 26
+ },
+ "indices" : 14,
+ "material" : 18
+ }
+ ]
+ },
+ {
+ "name" : "Labels_Mesh.007",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 27,
+ "NORMAL" : 28,
+ "TEXCOORD_0" : 29
+ },
+ "indices" : 14,
+ "material" : 18
+ }
+ ]
+ },
+ {
+ "name" : "Labels_Mesh.008",
+ "primitives" : [
+ {
+ "attributes" : {
+ "POSITION" : 30,
+ "NORMAL" : 31,
+ "TEXCOORD_0" : 32
+ },
+ "indices" : 7,
+ "material" : 18
+ }
+ ]
+ }
+ ],
+ "textures" : [
+ {
+ "source" : 0
+ },
+ {
+ "source" : 1
+ },
+ {
+ "source" : 2
+ },
+ {
+ "source" : 3
+ },
+ {
+ "source" : 3
+ },
+ {
+ "source" : 4
+ },
+ {
+ "source" : 3
+ },
+ {
+ "source" : 3
+ },
+ {
+ "source" : 3
+ },
+ {
+ "source" : 5
+ }
+ ],
+ "images" : [
+ {
+ "mimeType" : "image/png",
+ "name" : "PartialCoating",
+ "uri" : "PartialCoating.png"
+ },
+ {
+ "mimeType" : "image/png",
+ "name" : "PartialCoating_Alpha",
+ "uri" : "PartialCoating_Alpha.png"
+ },
+ {
+ "mimeType" : "image/png",
+ "name" : "RoughnessStripes",
+ "uri" : "RoughnessStripes.png"
+ },
+ {
+ "mimeType" : "image/png",
+ "name" : "RibsNormal",
+ "uri" : "RibsNormal.png"
+ },
+ {
+ "mimeType" : "image/jpeg",
+ "name" : "PlasticWrap_normals",
+ "uri" : "PlasticWrap_normals.jpg"
+ },
+ {
+ "mimeType" : "image/png",
+ "name" : "ClearCoatLabels",
+ "uri" : "ClearCoatLabels.png"
+ }
+ ],
+ "accessors" : [
+ {
+ "bufferView" : 0,
+ "componentType" : 5126,
+ "count" : 1113,
+ "max" : [
+ 1,
+ 1,
+ 1.0499999523162842
+ ],
+ "min" : [
+ -1,
+ -1,
+ -0.06000000983476639
+ ],
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 1,
+ "componentType" : 5126,
+ "count" : 1113,
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 2,
+ "componentType" : 5126,
+ "count" : 1113,
+ "type" : "VEC2"
+ },
+ {
+ "bufferView" : 3,
+ "componentType" : 5123,
+ "count" : 6180,
+ "type" : "SCALAR"
+ },
+ {
+ "bufferView" : 4,
+ "componentType" : 5126,
+ "count" : 8,
+ "max" : [
+ 1.0280373096466064,
+ 0.23501670360565186,
+ 3.8289083903464416e-08
+ ],
+ "min" : [
+ -0.968224287033081,
+ -0.2350165843963623,
+ -0.010000125505030155
+ ],
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 5,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 6,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC2"
+ },
+ {
+ "bufferView" : 7,
+ "componentType" : 5123,
+ "count" : 12,
+ "type" : "SCALAR"
+ },
+ {
+ "bufferView" : 8,
+ "componentType" : 5126,
+ "count" : 8,
+ "max" : [
+ 2,
+ 0.23026323318481445,
+ 3.751463495405005e-08
+ ],
+ "min" : [
+ -2,
+ -0.23026317358016968,
+ -0.010000579059123993
+ ],
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 9,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 10,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC2"
+ },
+ {
+ "bufferView" : 11,
+ "componentType" : 5126,
+ "count" : 8,
+ "max" : [
+ 2,
+ 0.2302631139755249,
+ 3.7514624295909016e-08
+ ],
+ "min" : [
+ -2,
+ -0.23026323318481445,
+ -0.010000428184866905
+ ],
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 12,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 13,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC2"
+ },
+ {
+ "bufferView" : 14,
+ "componentType" : 5123,
+ "count" : 12,
+ "type" : "SCALAR"
+ },
+ {
+ "bufferView" : 15,
+ "componentType" : 5126,
+ "count" : 8,
+ "max" : [
+ 2,
+ 0.22039484977722168,
+ 3.590687924770464e-08
+ ],
+ "min" : [
+ -2,
+ -0.22039473056793213,
+ -0.010000280104577541
+ ],
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 16,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 17,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC2"
+ },
+ {
+ "bufferView" : 18,
+ "componentType" : 5126,
+ "count" : 8,
+ "max" : [
+ 2,
+ 0.21764808893203735,
+ 3.545937588000925e-08
+ ],
+ "min" : [
+ -2,
+ -0.21764802932739258,
+ -0.010000137612223625
+ ],
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 19,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 20,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC2"
+ },
+ {
+ "bufferView" : 21,
+ "componentType" : 5126,
+ "count" : 8,
+ "max" : [
+ 2,
+ 0.20775499939918518,
+ 3.3847587843638394e-08
+ ],
+ "min" : [
+ -2,
+ -0.20775499939918518,
+ -0.009999996051192284
+ ],
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 22,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 23,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC2"
+ },
+ {
+ "bufferView" : 24,
+ "componentType" : 5126,
+ "count" : 8,
+ "max" : [
+ 2,
+ 0.22341907024383545,
+ 3.6399587344249085e-08
+ ],
+ "min" : [
+ -2,
+ -0.22341907024383545,
+ -0.009999859146773815
+ ],
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 25,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 26,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC2"
+ },
+ {
+ "bufferView" : 27,
+ "componentType" : 5126,
+ "count" : 8,
+ "max" : [
+ 0.9169960618019104,
+ 0.22670458257198334,
+ 3.69348676088066e-08
+ ],
+ "min" : [
+ -0.9199233651161194,
+ -0.22670456767082214,
+ -0.010000176727771759
+ ],
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 28,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 29,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC2"
+ },
+ {
+ "bufferView" : 30,
+ "componentType" : 5126,
+ "count" : 8,
+ "max" : [
+ 0.8968609571456909,
+ 0.20853587985038757,
+ 3.397480696776256e-08
+ ],
+ "min" : [
+ -0.9147982001304626,
+ -0.2085357904434204,
+ -0.010000113397836685
+ ],
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 31,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC3"
+ },
+ {
+ "bufferView" : 32,
+ "componentType" : 5126,
+ "count" : 8,
+ "type" : "VEC2"
+ }
+ ],
+ "bufferViews" : [
+ {
+ "buffer" : 0,
+ "byteLength" : 13356,
+ "byteOffset" : 0
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 13356,
+ "byteOffset" : 13356
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 8904,
+ "byteOffset" : 26712
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 12360,
+ "byteOffset" : 35616
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 47976
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 48072
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 64,
+ "byteOffset" : 48168
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 24,
+ "byteOffset" : 48232
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 48256
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 48352
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 64,
+ "byteOffset" : 48448
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 48512
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 48608
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 64,
+ "byteOffset" : 48704
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 24,
+ "byteOffset" : 48768
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 48792
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 48888
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 64,
+ "byteOffset" : 48984
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 49048
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 49144
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 64,
+ "byteOffset" : 49240
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 49304
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 49400
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 64,
+ "byteOffset" : 49496
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 49560
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 49656
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 64,
+ "byteOffset" : 49752
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 49816
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 49912
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 64,
+ "byteOffset" : 50008
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 50072
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 96,
+ "byteOffset" : 50168
+ },
+ {
+ "buffer" : 0,
+ "byteLength" : 64,
+ "byteOffset" : 50264
+ }
+ ],
+ "buffers" : [
+ {
+ "byteLength" : 50328,
+ "uri" : "ClearCoatTest.bin"
+ }
+ ]
+}
diff --git a/test/models/glTF2/ClearCoat-glTF/PartialCoating.png b/test/models/glTF2/ClearCoat-glTF/PartialCoating.png
new file mode 100644
index 000000000..d579bbebb
Binary files /dev/null and b/test/models/glTF2/ClearCoat-glTF/PartialCoating.png differ
diff --git a/test/models/glTF2/ClearCoat-glTF/PartialCoating_Alpha.png b/test/models/glTF2/ClearCoat-glTF/PartialCoating_Alpha.png
new file mode 100644
index 000000000..b1911d9f0
Binary files /dev/null and b/test/models/glTF2/ClearCoat-glTF/PartialCoating_Alpha.png differ
diff --git a/test/models/glTF2/ClearCoat-glTF/PlasticWrap_normals.jpg b/test/models/glTF2/ClearCoat-glTF/PlasticWrap_normals.jpg
new file mode 100644
index 000000000..73e6260ef
Binary files /dev/null and b/test/models/glTF2/ClearCoat-glTF/PlasticWrap_normals.jpg differ
diff --git a/test/models/glTF2/ClearCoat-glTF/RibsNormal.png b/test/models/glTF2/ClearCoat-glTF/RibsNormal.png
new file mode 100644
index 000000000..30c393dd7
Binary files /dev/null and b/test/models/glTF2/ClearCoat-glTF/RibsNormal.png differ
diff --git a/test/models/glTF2/ClearCoat-glTF/RoughnessStripes.png b/test/models/glTF2/ClearCoat-glTF/RoughnessStripes.png
new file mode 100644
index 000000000..f3ab3570f
Binary files /dev/null and b/test/models/glTF2/ClearCoat-glTF/RoughnessStripes.png differ
diff --git a/test/unit/utTypes.cpp b/test/unit/utTypes.cpp
index cc354eb3d..1ac9a1d5e 100644
--- a/test/unit/utTypes.cpp
+++ b/test/unit/utTypes.cpp
@@ -53,8 +53,8 @@ class utTypes : public ::testing::Test {
TEST_F( utTypes, Color3dCpmpareOpTest ) {
aiColor3D col1( 1, 2, 3 );
aiColor3D col2( 4, 5, 6 );
- aiColor3D col3( col1 );
-
+ const aiColor3D &col3(col1);
+
EXPECT_FALSE( col1 == col2 );
EXPECT_FALSE( col2 == col3 );
EXPECT_TRUE( col1 == col3 );
diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp
index 4110edcfc..2c000bb37 100644
--- a/test/unit/utglTF2ImportExport.cpp
+++ b/test/unit/utglTF2ImportExport.cpp
@@ -57,10 +57,9 @@ using namespace Assimp;
class utglTF2ImportExport : public AbstractImportExportBase {
public:
- virtual bool importerTest() {
+ virtual bool importerMatTest(const char *file, bool spec_gloss, std::array exp_modes = { aiTextureMapMode_Wrap, aiTextureMapMode_Wrap }) {
Assimp::Importer importer;
- const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf",
- aiProcess_ValidateDataStructure);
+ const aiScene *scene = importer.ReadFile(file, aiProcess_ValidateDataStructure);
EXPECT_NE(scene, nullptr);
if (!scene) {
return false;
@@ -72,13 +71,49 @@ public:
}
const aiMaterial *material = scene->mMaterials[0];
+ // This Material should be a PBR
+ aiShadingMode shadingMode;
+ EXPECT_EQ(aiReturn_SUCCESS, material->Get(AI_MATKEY_SHADING_MODEL, shadingMode));
+ EXPECT_EQ(aiShadingMode_PBR_BRDF, shadingMode);
+
+ // Should import the texture as diffuse and as base color
aiString path;
- aiTextureMapMode modes[2];
+ std::array modes;
EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr,
- nullptr, nullptr, modes));
+ nullptr, nullptr, modes.data()));
EXPECT_STREQ(path.C_Str(), "CesiumLogoFlat.png");
- EXPECT_EQ(modes[0], aiTextureMapMode_Mirror);
- EXPECT_EQ(modes[1], aiTextureMapMode_Clamp);
+ EXPECT_EQ(exp_modes, modes);
+
+ // Also as Base Color
+ EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(aiTextureType_BASE_COLOR, 0, &path, nullptr, nullptr,
+ nullptr, nullptr, modes.data()));
+ EXPECT_STREQ(path.C_Str(), "CesiumLogoFlat.png");
+ EXPECT_EQ(exp_modes, modes);
+
+ // Should have a MetallicFactor (default is 1.0)
+ ai_real metal_factor = ai_real(0.5);
+ EXPECT_EQ(aiReturn_SUCCESS, material->Get(AI_MATKEY_METALLIC_FACTOR, metal_factor));
+ EXPECT_EQ(ai_real(0.0), metal_factor);
+
+ // And a roughness factor (default is 1.0)
+ ai_real roughness_factor = ai_real(0.5);
+ EXPECT_EQ(aiReturn_SUCCESS, material->Get(AI_MATKEY_ROUGHNESS_FACTOR, roughness_factor));
+ EXPECT_EQ(ai_real(1.0), roughness_factor);
+
+ aiColor3D spec_color = { 0, 0, 0 };
+ ai_real glossiness = ai_real(0.5);
+ if (spec_gloss) {
+ EXPECT_EQ(aiReturn_SUCCESS, material->Get(AI_MATKEY_COLOR_SPECULAR, spec_color));
+ constexpr ai_real spec_val(0.20000000298023225); // From the file
+ EXPECT_EQ(spec_val, spec_color.r);
+ EXPECT_EQ(spec_val, spec_color.g);
+ EXPECT_EQ(spec_val, spec_color.b);
+ EXPECT_EQ(aiReturn_SUCCESS, material->Get(AI_MATKEY_GLOSSINESS_FACTOR, glossiness));
+ EXPECT_EQ(ai_real(1.0), glossiness);
+ } else {
+ EXPECT_EQ(aiReturn_FAILURE, material->Get(AI_MATKEY_COLOR_SPECULAR, spec_color));
+ EXPECT_EQ(aiReturn_FAILURE, material->Get(AI_MATKEY_GLOSSINESS_FACTOR, glossiness));
+ }
return true;
}
@@ -105,14 +140,89 @@ public:
};
TEST_F(utglTF2ImportExport, importglTF2FromFileTest) {
- EXPECT_TRUE(importerTest());
+ EXPECT_TRUE(importerMatTest(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf", false, {aiTextureMapMode_Mirror, aiTextureMapMode_Clamp}));
}
TEST_F(utglTF2ImportExport, importBinaryglTF2FromFileTest) {
EXPECT_TRUE(binaryImporterTest());
}
+TEST_F(utglTF2ImportExport, importglTF2_KHR_materials_pbrSpecularGlossiness) {
+ EXPECT_TRUE(importerMatTest(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF-pbrSpecularGlossiness/BoxTextured.gltf", true));
+}
+
+void VerifyClearCoatScene(const aiScene *scene) {
+ ASSERT_NE(nullptr, scene);
+
+ ASSERT_TRUE(scene->HasMaterials());
+
+ // Find a specific Clearcoat material and check the values
+ const aiString partial_coated("Partial_Coated");
+ bool found_partial_coat = false;
+ for (size_t i = 0; i < scene->mNumMaterials; ++i) {
+ const aiMaterial *material = scene->mMaterials[i];
+ ASSERT_NE(nullptr, material);
+ if (material->GetName() == partial_coated) {
+ found_partial_coat = true;
+
+ ai_real clearcoat_factor(0.0f);
+ EXPECT_EQ(aiReturn_SUCCESS, material->Get(AI_MATKEY_CLEARCOAT_FACTOR, clearcoat_factor));
+ EXPECT_EQ(ai_real(1.0f), clearcoat_factor);
+
+ ai_real clearcoat_rough_factor(0.0f);
+ EXPECT_EQ(aiReturn_SUCCESS, material->Get(AI_MATKEY_CLEARCOAT_ROUGHNESS_FACTOR, clearcoat_rough_factor));
+ EXPECT_EQ(ai_real(0.03f), clearcoat_rough_factor);
+
+ // Should import the texture as diffuse and as base color
+ aiString path;
+ std::array modes;
+ static const std::array exp_modes = { aiTextureMapMode_Wrap, aiTextureMapMode_Wrap };
+ EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(AI_MATKEY_CLEARCOAT_TEXTURE, &path, nullptr, nullptr,
+ nullptr, nullptr, modes.data()));
+ EXPECT_STREQ(path.C_Str(), "PartialCoating.png");
+ EXPECT_EQ(exp_modes, modes);
+ }
+ }
+ EXPECT_TRUE(found_partial_coat);
+}
+
+TEST_F(utglTF2ImportExport, importglTF2_KHR_materials_clearcoat) {
+ Assimp::Importer importer;
+ const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/ClearCoat-glTF/ClearCoatTest.gltf", aiProcess_ValidateDataStructure);
+ VerifyClearCoatScene(scene);
+}
+
#ifndef ASSIMP_BUILD_NO_EXPORT
+
+TEST_F(utglTF2ImportExport, importglTF2AndExport_KHR_materials_clearcoat) {
+ {
+ Assimp::Importer importer;
+ Assimp::Exporter exporter;
+ const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/ClearCoat-glTF/ClearCoatTest.gltf", aiProcess_ValidateDataStructure);
+ ASSERT_NE(nullptr, scene);
+ // Export
+ EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2", ASSIMP_TEST_MODELS_DIR "/glTF2/ClearCoat-glTF/ClearCoatTest_out.glb"));
+ }
+
+ // And re-import
+ Assimp::Importer importer;
+ const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/ClearCoat-glTF/ClearCoatTest_out.glb", aiProcess_ValidateDataStructure);
+ VerifyClearCoatScene(scene);
+}
+
+TEST_F(utglTF2ImportExport, importglTF2AndExport_KHR_materials_pbrSpecularGlossiness) {
+ Assimp::Importer importer;
+ Assimp::Exporter exporter;
+ const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF-pbrSpecularGlossiness/BoxTextured.gltf",
+ aiProcess_ValidateDataStructure);
+ EXPECT_NE(nullptr, scene);
+ // Export
+ EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF-pbrSpecularGlossiness/BoxTextured_out.glb"));
+
+ // And re-import
+ EXPECT_TRUE(importerMatTest(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF-pbrSpecularGlossiness/BoxTextured_out.glb", true));
+}
+
TEST_F(utglTF2ImportExport, importglTF2AndExportToOBJ) {
Assimp::Importer importer;
Assimp::Exporter exporter;
@@ -130,6 +240,7 @@ TEST_F(utglTF2ImportExport, importglTF2EmbeddedAndExportToOBJ) {
EXPECT_NE(nullptr, scene);
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "obj", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF-Embedded/BoxTextured_out.obj"));
}
+
#endif // ASSIMP_BUILD_NO_EXPORT
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModePointsWithoutIndices) {
@@ -492,32 +603,58 @@ TEST_F(utglTF2ImportExport, sceneMetadata) {
}
TEST_F(utglTF2ImportExport, texcoords) {
+
Assimp::Importer importer;
- const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTexcoords-glTF/boxTexcoords.gltf",
- aiProcess_ValidateDataStructure);
+ const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTexcoords-glTF/boxTexcoords.gltf", aiProcess_ValidateDataStructure);
+ ASSERT_NE(scene, nullptr);
+ ASSERT_TRUE(scene->HasMaterials());
+ const aiMaterial *material = scene->mMaterials[0];
+
+ aiString path;
+ unsigned int uvIndex = 255;
+ aiTextureMapMode modes[2];
+ EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(AI_MATKEY_BASE_COLOR_TEXTURE, &path, nullptr, &uvIndex, nullptr, nullptr, modes));
+ EXPECT_STREQ(path.C_Str(), "texture.png");
+ EXPECT_EQ(uvIndex, 0);
+
+ uvIndex = 255;
+ EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE, &path, nullptr, &uvIndex, nullptr, nullptr, modes));
+ EXPECT_STREQ(path.C_Str(), "texture.png");
+ EXPECT_EQ(uvIndex, 1);
+}
+
+#ifndef ASSIMP_BUILD_NO_EXPORT
+
+TEST_F(utglTF2ImportExport, texcoords_export) {
+ {
+ Assimp::Importer importer;
+ Assimp::Exporter exporter;
+ const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTexcoords-glTF/boxTexcoords.gltf", aiProcess_ValidateDataStructure);
+ ASSERT_NE(scene, nullptr);
+ ASSERT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTexcoords-glTF/boxTexcoords.gltf_out.glb"));
+ }
+
+ Assimp::Importer importer;
+ const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTexcoords-glTF/boxTexcoords.gltf", aiProcess_ValidateDataStructure);
ASSERT_NE(scene, nullptr);
ASSERT_TRUE(scene->HasMaterials());
const aiMaterial *material = scene->mMaterials[0];
aiString path;
+ unsigned int uvIndex = 255;
aiTextureMapMode modes[2];
- EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr,
- nullptr, nullptr, modes));
+ EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(AI_MATKEY_BASE_COLOR_TEXTURE, &path, nullptr, &uvIndex, nullptr, nullptr, modes));
EXPECT_STREQ(path.C_Str(), "texture.png");
-
- int uvIndex = -1;
- EXPECT_EQ(aiGetMaterialInteger(material, AI_MATKEY_GLTF_TEXTURE_TEXCOORD(aiTextureType_DIFFUSE, 0), &uvIndex), aiReturn_SUCCESS);
EXPECT_EQ(uvIndex, 0);
- // Using manual macro expansion of AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE here.
- // The following works with some but not all compilers:
- // #define APPLY(X, Y) X(Y)
- // ..., APPLY(AI_MATKEY_GLTF_TEXTURE_TEXCOORD, AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE), ...
- EXPECT_EQ(aiGetMaterialInteger(material, AI_MATKEY_GLTF_TEXTURE_TEXCOORD(aiTextureType_UNKNOWN, 0), &uvIndex), aiReturn_SUCCESS);
+ uvIndex = 255;
+ EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE, &path, nullptr, &uvIndex, nullptr, nullptr, modes));
+ EXPECT_STREQ(path.C_Str(), "texture.png");
EXPECT_EQ(uvIndex, 1);
}
+#endif // ASSIMP_BUILD_NO_EXPORT
TEST_F(utglTF2ImportExport, recursive_nodes) {
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/RecursiveNodes/RecursiveNodes.gltf", aiProcess_ValidateDataStructure);
diff --git a/tools/assimp_view/AnimEvaluator.cpp b/tools/assimp_view/AnimEvaluator.cpp
index df5167923..5a2ddc182 100644
--- a/tools/assimp_view/AnimEvaluator.cpp
+++ b/tools/assimp_view/AnimEvaluator.cpp
@@ -39,9 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
-#include "assimp_view.h"
+#include "AnimEvaluator.h"
-#include
+#include
+#include
using namespace AssimpView;
diff --git a/tools/assimp_view/AnimEvaluator.h b/tools/assimp_view/AnimEvaluator.h
index 950763081..566247604 100644
--- a/tools/assimp_view/AnimEvaluator.h
+++ b/tools/assimp_view/AnimEvaluator.h
@@ -1,4 +1,3 @@
-/** Calculates a pose for a given time of an animation */
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
@@ -40,11 +39,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
+#pragma once
#ifndef AV_ANIMEVALUATOR_H_INCLUDED
#define AV_ANIMEVALUATOR_H_INCLUDED
+/** Calculates a pose for a given time of an animation */
+
#include
#include
+#include
+
+struct aiAnimation;
namespace AssimpView {
@@ -63,18 +68,19 @@ public:
/// @brief The class destructor.
~AnimEvaluator();
- /** Evaluates the animation tracks for a given time stamp. The calculated pose can be retrieved as a
- * array of transformation matrices afterwards by calling GetTransformations().
- * @param pTime The time for which you want to evaluate the animation, in seconds. Will be mapped into the animation cycle, so
- * it can be an arbitrary value. Best use with ever-increasing time stamps.
- */
+ /// @brief Evaluates the animation tracks for a given time stamp.
+ /// The calculated pose can be retrieved as an array of transformation
+ /// matrices afterwards by calling GetTransformations().
+ /// @param pTime The time for which you want to evaluate the animation, in seconds.
+ /// Will be mapped into the animation cycle, so it can get an arbitrary
+ /// value. Best use with ever-increasing time stamps.
void Evaluate(double pTime);
- /** Returns the transform matrices calculated at the last Evaluate() call. The array matches the mChannels array of
- * the aiAnimation. */
+ /// @brief Returns the transform matrices calculated at the last Evaluate() call.
+ /// The array matches the mChannels array of the aiAnimation.
const std::vector &GetTransformations() const { return mTransforms; }
-protected:
+private:
const aiAnimation *mAnim;
double mLastTime;
std::vector> mLastPositions;
diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp
index 260b22941..5ab7c53ad 100644
--- a/tools/assimp_view/assimp_view.cpp
+++ b/tools/assimp_view/assimp_view.cpp
@@ -489,7 +489,7 @@ int CreateAssetData() {
nidx = 3;
break;
default:
- ai_assert(false);
+ CLogWindow::Instance().WriteLine("Unknown primitiv type");
break;
};
@@ -500,8 +500,7 @@ int CreateAssetData() {
// check whether we can use 16 bit indices
if (numIndices >= 65536) {
// create 32 bit index buffer
- if (FAILED(g_piDevice->CreateIndexBuffer(4 *
- numIndices,
+ if (FAILED(g_piDevice->CreateIndexBuffer(4 * numIndices,
D3DUSAGE_WRITEONLY | dwUsage,
D3DFMT_INDEX32,
D3DPOOL_DEFAULT,
@@ -523,7 +522,7 @@ int CreateAssetData() {
} else {
// create 16 bit index buffer
if (FAILED(g_piDevice->CreateIndexBuffer(2 *
- numIndices,
+numIndices,
D3DUSAGE_WRITEONLY | dwUsage,
D3DFMT_INDEX16,
D3DPOOL_DEFAULT,