From e83671f494247501793c9631fe2816e6c0357464 Mon Sep 17 00:00:00 2001 From: Martin Vorbrodt Date: Wed, 24 Apr 2019 18:35:14 -0400 Subject: [PATCH 1/6] Generate attenuation constants if non are privded in the Blender file. Using: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/ --- code/BlenderLoader.cpp | 27 +++++++++++++++++++++++++++ code/BlenderScene.cpp | 5 ++++- code/BlenderScene.h | 4 ++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/code/BlenderLoader.cpp b/code/BlenderLoader.cpp index 90065ceee..d39cb9699 100644 --- a/code/BlenderLoader.cpp +++ b/code/BlenderLoader.cpp @@ -1225,6 +1225,16 @@ aiLight* BlenderImporter::ConvertLight(const Scene& /*in*/, const Object* obj, c case Lamp::Type_Local: out->mType = aiLightSource_POINT; break; + case Lamp::Type_Spot: + out->mType = aiLightSource_SPOT; + + // blender orients directional lights as facing toward -z + out->mDirection = aiVector3D(0.f, 0.f, -1.f); + out->mUp = aiVector3D(0.f, 1.f, 0.f); + + out->mAngleInnerCone = lamp->spotsize * (1.0f - lamp->spotblend); + out->mAngleOuterCone = lamp->spotsize; + break; case Lamp::Type_Sun: out->mType = aiLightSource_DIRECTIONAL; @@ -1255,6 +1265,23 @@ aiLight* BlenderImporter::ConvertLight(const Scene& /*in*/, const Object* obj, c out->mColorAmbient = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy; out->mColorSpecular = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy; out->mColorDiffuse = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy; + + // If default values are supplied, compute the coefficients from light's max distance + // Read this: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/ + // + if (lamp->constant_coefficient == 1.0f && lamp->linear_coefficient == 0.0f && lamp->quadratic_coefficient == 0.0f && lamp->dist > 0.0f) + { + out->mAttenuationConstant = 1.0f; + out->mAttenuationLinear = 2.0f / lamp->dist; + out->mAttenuationQuadratic = 1.0f / (lamp->dist * lamp->dist); + } + else + { + out->mAttenuationConstant = lamp->constant_coefficient; + out->mAttenuationLinear = lamp->linear_coefficient; + out->mAttenuationQuadratic = lamp->quadratic_coefficient; + } + return out.release(); } diff --git a/code/BlenderScene.cpp b/code/BlenderScene.cpp index 4fc353b15..39c2793d5 100644 --- a/code/BlenderScene.cpp +++ b/code/BlenderScene.cpp @@ -211,9 +211,12 @@ template <> void Structure :: Convert ( ReadField(dest.b,"b",db); ReadField(dest.k,"k",db); ReadField(dest.energy,"energy",db); - ReadField(dest.dist,"dist",db); + ReadField(dest.dist,"dist",db); ReadField(dest.spotsize,"spotsize",db); ReadField(dest.spotblend,"spotblend",db); + ReadField(dest.constant_coefficient, "coeff_const", db); + ReadField(dest.linear_coefficient, "coeff_lin", db); + ReadField(dest.quadratic_coefficient, "coeff_quad", db); ReadField(dest.att1,"att1",db); ReadField(dest.att2,"att2",db); ReadField(temp,"falloff_type",db); diff --git a/code/BlenderScene.h b/code/BlenderScene.h index 8e4223eb1..dd3f1444c 100644 --- a/code/BlenderScene.h +++ b/code/BlenderScene.h @@ -538,6 +538,10 @@ struct Lamp : ElemBase { float energy, dist, spotsize, spotblend; //float haint; + float constant_coefficient; + float linear_coefficient; + float quadratic_coefficient; + float att1, att2; //struct CurveMapping *curfalloff; FalloffType falloff_type; From cb0c47764ab1360b06f7db9e8610b741c59d0afd Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 11 May 2019 11:56:28 -1000 Subject: [PATCH 2/6] Set directory and name properties for installing static lib PDB --- code/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 5a7838515..df12695d2 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1138,6 +1138,16 @@ if (ASSIMP_ANDROID_JNIIOSYSTEM) ENDIF(ASSIMP_ANDROID_JNIIOSYSTEM) if(MSVC AND ASSIMP_INSTALL_PDB) + # When only the static library is built, these properties must + # be set to ensure the static lib .pdb is staged for installation. + IF(NOT BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES( assimp PROPERTIES + COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMPILE_PDB_NAME assimp${LIBRARY_SUFFIX} + COMPILE_PDB_NAME_DEBUG assimp${LIBRARY_SUFFIX}${CMAKE_DEBUG_POSTFIX} + ) + ENDIF() + IF(CMAKE_GENERATOR MATCHES "^Visual Studio") install(FILES ${Assimp_BINARY_DIR}/code/Debug/assimp${LIBRARY_SUFFIX}${CMAKE_DEBUG_POSTFIX}.pdb DESTINATION ${ASSIMP_LIB_INSTALL_DIR} From 461e21f66dd331f5d6d47b4abbf9f15525ddfaec Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 12 May 2019 10:56:59 -1000 Subject: [PATCH 3/6] Fix Windows build with external zlib assimp.rc contains an include with a double-parent header search. In a default build configuration, this is resolved via the configuration header path generated for in-tree zlib. When external zlib is used, this header search path is not provided to the RC compiler, therefore fails to find revision.h. This is solved by simply including "revision.h" since the root of the binary directory is already used as a search path. --- code/res/assimp.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/res/assimp.rc b/code/res/assimp.rc index ae0c87b8a..14ffdf4f5 100644 --- a/code/res/assimp.rc +++ b/code/res/assimp.rc @@ -1,7 +1,7 @@ // Microsoft Visual C++ generated resource script. // #include "resource.h" -#include "..\..\revision.h" +#include "revision.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// From 815730c92d432a9535afa526929435b6901649db Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 13 May 2019 21:49:50 +0200 Subject: [PATCH 4/6] Update CMakeLists.txt closes https://github.com/assimp/assimp/issues/2449: fix uwp handling --- code/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 5a7838515..455549c6a 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1077,7 +1077,9 @@ if( MSVC ) endif() if (${CMAKE_SYSTEM_NAME} MATCHES "WindowsStore") - set(WindowsStore TRUE) + target_compile_definitions(assimp PUBLIC WindowsStore) + TARGET_LINK_LIBRARIES(assimp advapi32) + #set(WindowsStore TRUE) endif() SET_TARGET_PROPERTIES( assimp PROPERTIES VERSION ${ASSIMP_VERSION} From 5bca43be743e9ae52b8c507a587cd20bc0bfb250 Mon Sep 17 00:00:00 2001 From: Mike Samsonov Date: Tue, 14 May 2019 11:33:42 +0100 Subject: [PATCH 5/6] Degenerate triangles with small area removing fix --- code/FindDegenerates.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/FindDegenerates.cpp b/code/FindDegenerates.cpp index 365f5d744..50fac46db 100644 --- a/code/FindDegenerates.cpp +++ b/code/FindDegenerates.cpp @@ -228,6 +228,7 @@ bool FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) { if ( area < 1e-6 ) { if ( mConfigRemoveDegenerates ) { remove_me[ a ] = true; + ++deg; goto evil_jump_outside; } From 4e03a2c00dca149e4363eedc864ccd23b045487e Mon Sep 17 00:00:00 2001 From: Mike Samsonov Date: Tue, 14 May 2019 11:55:46 +0100 Subject: [PATCH 6/6] Exception spam fix for FBXMaterial --- code/FBXMaterial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/FBXMaterial.cpp b/code/FBXMaterial.cpp index f16f13440..3778adff6 100644 --- a/code/FBXMaterial.cpp +++ b/code/FBXMaterial.cpp @@ -316,7 +316,7 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std relativeFileName = ParseTokenAsString(GetRequiredToken(*RelativeFilename,0)); } - if(Content) { + if(Content && !Content->Tokens().empty()) { //this field is omitted when the embedded texture is already loaded, let's ignore if it's not found try { const Token& token = GetRequiredToken(*Content, 0);