Browse Source

Add MikkTSpace Tangets code as 3rdparty lib

Kim Kulling 1 month ago
parent
commit
11899f0120

+ 7 - 0
code/CMakeLists.txt

@@ -961,6 +961,12 @@ ENDIF()
   SOURCE_GROUP( Contrib\\Poly2Tri FILES ${Poly2Tri_SRCS})
 #ENDIF()
 
+# mikktspacetangets
+  SET( MikkTSpaceTangents_SRCS
+    ../contrib/MikkTSpace/mikktspace.c
+    ../contrib/MikkTSpace/mikktspace.h
+  )
+
 # minizip/unzip
 IF(ASSIMP_HUNTER_ENABLED)
   hunter_add_package(minizip)
@@ -1159,6 +1165,7 @@ SET( assimp_src
   ${ziplib_SRCS}
   ${Pugixml_SRCS}
   ${stb_SRCS}
+  ${MikkTSpaceTangents_SRCS}
   # Necessary to show the headers in the project when using the VC++ generator:
 
   ${PUBLIC_HEADERS}

+ 1 - 1
code/PostProcessing/GenerateMikkTSpaceTangents.cpp

@@ -50,7 +50,7 @@ static void get_tex_coords(const SMikkTSpaceContext *context, float outuv[], int
     } else if (currentMesh->mNumUVComponents[iVert] == 3){
         outuv[0] = t.x;
         outuv[1] = t.y;
-        outuv[2] = t.z;
+        outuv[2] = 0.0;
     }
 }
 

+ 2 - 0
code/PostProcessing/GenerateMikkTSpaceTangents.h

@@ -11,9 +11,11 @@ public:
     ~GenerateMikkTSpaceTangents() override = default;
     bool IsActive(unsigned int pFlags) const override;
     void Execute(aiScene* pScene) override;
+    void SetupProperties(const Importer *pImp) override;
     void ExecutePerMesh(aiMesh *mesh);
 
 private:
+    bool mActive = false;
     SMikkTSpaceInterface mIface;
     SMikkTSpaceContext mContext;
 };