Skip to content

Commit

Permalink
Merge branch 'master' into slow_xml_load
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardTea committed May 20, 2019
2 parents 45c12cd + b8262c4 commit b1975aa
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 4 deletions.
27 changes: 27 additions & 0 deletions code/BlenderLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}

Expand Down
5 changes: 4 additions & 1 deletion code/BlenderScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,12 @@ template <> void Structure :: Convert<Lamp> (
ReadField<ErrorPolicy_Warn>(dest.b,"b",db);
ReadField<ErrorPolicy_Warn>(dest.k,"k",db);
ReadField<ErrorPolicy_Igno>(dest.energy,"energy",db);
ReadField<ErrorPolicy_Igno>(dest.dist,"dist",db);
ReadField<ErrorPolicy_Warn>(dest.dist,"dist",db);
ReadField<ErrorPolicy_Igno>(dest.spotsize,"spotsize",db);
ReadField<ErrorPolicy_Igno>(dest.spotblend,"spotblend",db);
ReadField<ErrorPolicy_Warn>(dest.constant_coefficient, "coeff_const", db);
ReadField<ErrorPolicy_Warn>(dest.linear_coefficient, "coeff_lin", db);
ReadField<ErrorPolicy_Warn>(dest.quadratic_coefficient, "coeff_quad", db);
ReadField<ErrorPolicy_Igno>(dest.att1,"att1",db);
ReadField<ErrorPolicy_Igno>(dest.att2,"att2",db);
ReadField<ErrorPolicy_Igno>(temp,"falloff_type",db);
Expand Down
4 changes: 4 additions & 0 deletions code/BlenderScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 13 additions & 1 deletion code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -1138,6 +1140,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}
Expand Down
2 changes: 1 addition & 1 deletion code/FBXMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions code/FindDegenerates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ bool FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) {
if ( area < 1e-6 ) {
if ( mConfigRemoveDegenerates ) {
remove_me[ a ] = true;
++deg;
goto evil_jump_outside;
}

Expand Down
2 changes: 1 addition & 1 deletion code/res/assimp.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include "..\..\revision.h"
#include "revision.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit b1975aa

Please sign in to comment.