2
0
Эх сурвалжийг харах

Merge pull request #75 from aws-lumberyard-dev/Assimp_to_3P

bringing assimp over to this repository
AMZN-stankowi 3 жил өмнө
parent
commit
ec6e90098a

+ 39 - 1
Scripts/extras/pull_and_build_from_git.py

@@ -36,7 +36,8 @@ be different by platform, and all are required. The keys are:
 The following keys can exist at the root level or the target-platform level:
 
 * git_url               : The git clone url for the source to pull for building
-* git_tag               : The git tag to identify the branch to pull from for building
+* git_tag               : The git tag or branch to identify the branch to pull from for building
+* git_commit            : (optional) A specific git commit to check out. This is useful for upstream repos that do not tag their releases.
 * package_version       : (required) The string to describe the package version. This string is used to build the full package name. 
                           This can be uniform for all platforms or can be set for a specific platform
 * prebuilt_source       : (optional) If the 3rd party library files are prebuilt and accessible, then setting this key to the relative location of 
@@ -83,6 +84,8 @@ The following keys can only exist at the target platform level as they describe
                                             this argument is optional.  You could do the install in your custom build command instead.
                                             see the note about environment variables below.
 
+* custom_install_json                     : A list of files to copy into the target package folder from the built SDK. This argument is optional.
+
 * custom_test_cmd                         : after making the package, it will run this and expect exit code 0
                                             this argument is optional.
                                             see the note about environment variables below.
@@ -513,6 +516,7 @@ class BuildInfo(object):
 
             patch_cmd = ['git',
                          'apply',
+                         "--ignore-whitespace",
                          str(patch_file_path.absolute())]
 
             patch_result = subprocess.run(subp_args(patch_cmd),
@@ -700,6 +704,40 @@ class BuildInfo(object):
                                          env=env_to_use)
             if call_result.returncode != 0:
                 raise BuildError(f"Error executing custom install command {custom_install_cmd}")
+                
+        # Allow libraries to define a list of files to include via a json script that stores folder paths and
+        # individual files in the "Install_Paths" array
+        custom_install_jsons = self.platform_config.get('custom_install_json', [])
+        for custom_install_json_file in custom_install_jsons:
+            custom_json_full_path = os.path.join(self.base_folder, custom_install_json_file)
+            print(f"Running custom install json file {custom_json_full_path}")
+            custom_json_full_path_file = open(custom_json_full_path)
+            custom_install_json = json.loads(custom_json_full_path_file.read())
+            if not custom_install_json:
+                raise BuildError(f"Error loading custom install json file {custom_install_json_file}")
+            source_subfolder = None
+            if "Source_Subfolder" in custom_install_json:
+                source_subfolder = custom_install_json["Source_Subfolder"]
+            for install_path in custom_install_json["Install_Paths"]:
+                install_src_path = install_path
+                if source_subfolder is not None:
+                    install_src_path = os.path.join(source_subfolder, install_src_path)
+                resolved_src_path = os.path.join(env_to_use['TEMP_FOLDER'], install_src_path)
+                resolved_target_path = os.path.join(env_to_use['TARGET_INSTALL_ROOT'], install_path)
+                if os.path.isdir(resolved_src_path):
+                    # Newer versions of Python support the parameter dirs_exist_ok=True,
+                    # but that's not available in earlier Python versions.
+                    # It's useful to treat it as an error if the target exists, because that means that something has
+                    # already touched that folder and there might be unexpected behavior copying an entire tree into it.
+                    print(f"    Copying directory '{resolved_src_path}' to '{resolved_target_path}'")
+                    shutil.copytree(resolved_src_path, resolved_target_path)
+                elif os.path.isfile(resolved_src_path):
+                    print(f"    Copying file '{resolved_src_path}' to '{resolved_target_path}'")
+                    os.makedirs(os.path.dirname(resolved_target_path), exist_ok=True)
+                    shutil.copy2(resolved_src_path, resolved_target_path)
+                else:
+                    raise BuildError(f"Error executing custom install json {custom_install_json_file}, found invalid source path {resolved_src_path}")
+
 
     def check_build_keys(self, keys_to_check):
         """

+ 1 - 0
package-system/.gitignore

@@ -1,3 +1,4 @@
+assimp-*
 astc-encoder-*
 AwsIotDeviceSdkCpp-*
 azslc-*

+ 317 - 0
package-system/assimp/0001-O3DE-fixes-applied-on-top-of-376e46887780e5090af0198.patch

@@ -0,0 +1,317 @@
+From a8f0333acd438ce3038b64245a004f0f8a049f25 Mon Sep 17 00:00:00 2001
+From: AMZN-stankowi <[email protected]>
+Date: Tue, 7 Dec 2021 07:32:09 -0800
+Subject: [PATCH] O3DE fixes applied on top of
+ 376e46887780e5090af0198e4e5577446159104d, the base version O3DE started with.
+ mesh.h - added texture coordinate names material.h - added PBR material
+ properties- these have already been submitted to a later revision of assimp
+ FBXProperties.cpp - added support for properties with capital F Float, we had
+ some FBX files coming in with those. FBXConverter.cpp - this is the majority
+ of our changes. A lot of this is fixing how the transform hierarchy is
+ calculated to better preserve the default pose. The texture coordinate names
+ support is here, PBR materials, and a crash on keyframe list population is
+ downgraded to an error instead. AssxmlFileWriter.cpp - texture coordinate
+ names are added to the output here.
+
+Signed-off-by: AMZN-stankowi <[email protected]>
+---
+ code/AssetLib/Assxml/AssxmlFileWriter.cpp |   7 +-
+ code/AssetLib/FBX/FBXConverter.cpp        | 142 ++++++++++++++++------
+ code/AssetLib/FBX/FBXProperties.cpp       |   2 +-
+ include/assimp/material.h                 |  12 ++
+ include/assimp/mesh.h                     |   2 +
+ 5 files changed, 125 insertions(+), 40 deletions(-)
+
+diff --git a/code/AssetLib/Assxml/AssxmlFileWriter.cpp b/code/AssetLib/Assxml/AssxmlFileWriter.cpp
+index 05661d3fc..23d863cf0 100644
+--- a/code/AssetLib/Assxml/AssxmlFileWriter.cpp
++++ b/code/AssetLib/Assxml/AssxmlFileWriter.cpp
+@@ -598,8 +598,11 @@ static void WriteDump(const char *pFile, const char *cmd, const aiScene *scene,
+                 if (!mesh->mTextureCoords[a])
+                     break;
+ 
+-                ioprintf(io, "\t\t<TextureCoords num=\"%u\" set=\"%u\" num_components=\"%u\"> \n", mesh->mNumVertices,
+-                        a, mesh->mNumUVComponents[a]);
++                ioprintf(io, "\t\t<TextureCoords num=\"%u\" set=\"%u\" name=\"%s\" num_components=\"%u\"> \n",
++                    mesh->mNumVertices,
++                    a,
++                    mesh->mTextureCoordsNames[a].C_Str(),
++                    mesh->mNumUVComponents[a]);
+ 
+                 if (!shortened) {
+                     if (mesh->mNumUVComponents[a] == 3) {
+diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp
+index c7bc57d97..d9ccaf8ab 100644
+--- a/code/AssetLib/FBX/FBXConverter.cpp
++++ b/code/AssetLib/FBX/FBXConverter.cpp
+@@ -855,6 +855,11 @@ bool FBXConverter::GenerateTransformationNodeChain(const Model &model, const std
+     // for (const auto &transform : chain) {
+     // skip inverse chain for no preservePivots
+     for (unsigned int i = TransformationComp_Translation; i < TransformationComp_MAXIMUM; i++) {
++
++        if (i == TransformationComp_PostRotation) {
++            chain[i] = chain[i].Inverse();
++        }
++
+       nd->mTransformation = nd->mTransformation * chain[i];
+     }
+     return false;
+@@ -1122,6 +1127,9 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c
+         for (const aiVector2D &v : uvs) {
+             *out_uv++ = aiVector3D(v.x, v.y, 0.0f);
+         }
++        
++        out_mesh->mTextureCoordsNames[i] = mesh.GetTextureCoordChannelName(i);
++
+ 
+         out_mesh->mNumUVComponents[i] = 2;
+     }
+@@ -1538,56 +1546,51 @@ void FBXConverter::ConvertCluster(std::vector<aiBone *> &local_mesh_bones, const
+ 
+     aiBone *bone = nullptr;
+ 
+-    if (bone_map.count(deformer_name)) {
+-        ASSIMP_LOG_VERBOSE_DEBUG_F("retrieved bone from lookup ", bone_name.C_Str(), ". Deformer:", deformer_name);
+-        bone = bone_map[deformer_name];
+-    } else {
+-        ASSIMP_LOG_VERBOSE_DEBUG_F("created new bone ", bone_name.C_Str(), ". Deformer: ", deformer_name);
+-        bone = new aiBone();
+-        bone->mName = bone_name;
++    ASSIMP_LOG_VERBOSE_DEBUG_F("created new bone ", bone_name.C_Str(), ". Deformer: ", deformer_name);
++    bone = new aiBone();
++    bone->mName = bone_name;
+ 
+-        // store local transform link for post processing
+-        bone->mOffsetMatrix = cl->TransformLink();
+-        bone->mOffsetMatrix.Inverse();
++    // store local transform link for post processing
++    bone->mOffsetMatrix = cl->TransformLink();
++    bone->mOffsetMatrix.Inverse();
+ 
+-        aiMatrix4x4 matrix = (aiMatrix4x4)absolute_transform;
++    aiMatrix4x4 matrix = (aiMatrix4x4)absolute_transform;
+ 
+-        bone->mOffsetMatrix = bone->mOffsetMatrix * matrix; // * mesh_offset
++    bone->mOffsetMatrix = bone->mOffsetMatrix * matrix; // * mesh_offset
+ 
+-        //
+-        // Now calculate the aiVertexWeights
+-        //
++    //
++    // Now calculate the aiVertexWeights
++    //
+ 
+-        aiVertexWeight *cursor = nullptr;
++    aiVertexWeight *cursor = nullptr;
+ 
+-        bone->mNumWeights = static_cast<unsigned int>(out_indices.size());
+-        cursor = bone->mWeights = new aiVertexWeight[out_indices.size()];
++    bone->mNumWeights = static_cast<unsigned int>(out_indices.size());
++    cursor = bone->mWeights = new aiVertexWeight[out_indices.size()];
+ 
+-        const size_t no_index_sentinel = std::numeric_limits<size_t>::max();
+-        const WeightArray &weights = cl->GetWeights();
++    const size_t no_index_sentinel = std::numeric_limits<size_t>::max();
++    const WeightArray &weights = cl->GetWeights();
+ 
+-        const size_t c = index_out_indices.size();
+-        for (size_t i = 0; i < c; ++i) {
+-            const size_t index_index = index_out_indices[i];
++    const size_t c = index_out_indices.size();
++    for (size_t i = 0; i < c; ++i) {
++        const size_t index_index = index_out_indices[i];
+ 
+-            if (index_index == no_index_sentinel) {
+-                continue;
+-            }
++        if (index_index == no_index_sentinel) {
++            continue;
++        }
+ 
+-            const size_t cc = count_out_indices[i];
+-            for (size_t j = 0; j < cc; ++j) {
+-                // cursor runs from first element relative to the start
+-                // or relative to the start of the next indexes.
+-                aiVertexWeight &out_weight = *cursor++;
++        const size_t cc = count_out_indices[i];
++        for (size_t j = 0; j < cc; ++j) {
++            // cursor runs from first element relative to the start
++            // or relative to the start of the next indexes.
++            aiVertexWeight &out_weight = *cursor++;
+ 
+-                out_weight.mVertexId = static_cast<unsigned int>(out_indices[index_index + j]);
+-                out_weight.mWeight = weights[i];
+-            }
++            out_weight.mVertexId = static_cast<unsigned int>(out_indices[index_index + j]);
++            out_weight.mWeight = weights[i];
+         }
+-
+-        bone_map.insert(std::pair<const std::string, aiBone *>(deformer_name, bone));
+     }
+ 
++    bone_map.insert(std::pair<const std::string, aiBone *>(deformer_name, bone));
++
+     ASSIMP_LOG_DEBUG_F("bone research: Indicies size: ", out_indices.size());
+ 
+     // lookup must be populated in case something goes wrong
+@@ -2095,6 +2098,11 @@ void FBXConverter::SetShadingPropertiesCommon(aiMaterial *out_mat, const Propert
+     const aiColor3D &Emissive = GetColorPropertyFromMaterial(props, "Emissive", ok);
+     if (ok) {
+         out_mat->AddProperty(&Emissive, 1, AI_MATKEY_COLOR_EMISSIVE);
++    } else {
++        const aiColor3D &emissiveColor = GetColorPropertyFromMaterial(props, "Maya|emissive", ok);
++        if (ok) {
++            out_mat->AddProperty(&emissiveColor, 1, AI_MATKEY_COLOR_EMISSIVE);
++        }
+     }
+ 
+     const aiColor3D &Ambient = GetColorPropertyFromMaterial(props, "Ambient", ok);
+@@ -2176,6 +2184,52 @@ void FBXConverter::SetShadingPropertiesCommon(aiMaterial *out_mat, const Propert
+     if (ok) {
+         out_mat->AddProperty(&DispFactor, 1, "$mat.displacementscaling", 0, 0);
+     }
++
++    // PBR material information
++    const aiColor3D &baseColor = GetColorProperty(props, "Maya|base_color", ok);
++    if (ok) {
++        out_mat->AddProperty(&baseColor, 1, AI_MATKEY_BASE_COLOR);
++    }
++
++    const float useColorMap = PropertyGet<float>(props, "Maya|use_color_map", ok);
++    if (ok) {
++        out_mat->AddProperty(&useColorMap, 1, AI_MATKEY_USE_COLOR_MAP);
++    }
++
++    const float useMetallicMap = PropertyGet<float>(props, "Maya|use_metallic_map", ok);
++    if (ok) {
++        out_mat->AddProperty(&useMetallicMap, 1, AI_MATKEY_USE_METALLIC_MAP);
++    }
++
++    const float metallicFactor = PropertyGet<float>(props, "Maya|metallic", ok);
++    if (ok) {
++        out_mat->AddProperty(&metallicFactor, 1, AI_MATKEY_METALLIC_FACTOR);
++    }
++
++    const float useRoughnessMap = PropertyGet<float>(props, "Maya|use_roughness_map", ok);
++    if (ok) {
++        out_mat->AddProperty(&useRoughnessMap, 1, AI_MATKEY_USE_ROUGHNESS_MAP);
++    }
++
++    const float roughnessFactor = PropertyGet<float>(props, "Maya|roughness", ok);
++    if (ok) {
++        out_mat->AddProperty(&roughnessFactor, 1, AI_MATKEY_ROUGHNESS_FACTOR);
++    }
++
++    const float useEmissiveMap = PropertyGet<float>(props, "Maya|use_emissive_map", ok);
++    if (ok) {
++        out_mat->AddProperty(&useEmissiveMap, 1, AI_MATKEY_USE_EMISSIVE_MAP);
++    }
++
++    const float emissiveIntensity = PropertyGet<float>(props, "Maya|emissive_intensity", ok);
++    if (ok) {
++        out_mat->AddProperty(&emissiveIntensity, 1, AI_MATKEY_EMISSIVE_INTENSITY);
++    }
++
++    const float useAOMap = PropertyGet<float>(props, "Maya|use_ao_map", ok);
++    if (ok) {
++        out_mat->AddProperty(&useAOMap, 1, AI_MATKEY_USE_AO_MAP);
++    }
+ }
+ 
+ void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTable &props, const TextureMap &_textures, const MeshGeometry *const mesh) {
+@@ -3031,6 +3085,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
+     const PropertyTable &props = target.Props();
+ 
+     // collect unique times and keyframe lists
++    bool anyKeyframeListsPopulated = false;
+     KeyFrameListList keyframeLists[TransformationComp_MAXIMUM];
+     KeyTimeList keytimes;
+ 
+@@ -3039,6 +3094,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
+             continue;
+ 
+         keyframeLists[i] = GetKeyframeList((*chain[i]).second, start, stop);
++        anyKeyframeListsPopulated = true;
+ 
+         for (KeyFrameListList::const_iterator it = keyframeLists[i].begin(); it != keyframeLists[i].end(); ++it) {
+             const KeyTimeList& times = *std::get<0>(*it);
+@@ -3055,6 +3111,14 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
+     const Model::RotOrder rotOrder = target.RotationOrder();
+     const size_t keyCount = keytimes.size();
+ 
++    if (keyCount == 0 && anyKeyframeListsPopulated)
++    {
++        // Later code will assert and potentially crash if the keyCount is zero and there are keyframeLists, so check now and error out.
++        FBXImporter::LogError(Formatter::format("Animation has a key frame list with zero animation keys and cannot be loaded: ") << name);
++        // The call site asserts on the return value, and cleans it up if all keys are empty, which they will be in this error case.
++        return na.release();
++    }
++
+     aiVector3D defTranslate = PropertyGet(props, "Lcl Translation", aiVector3D(0.f, 0.f, 0.f));
+     aiVector3D defRotation = PropertyGet(props, "Lcl Rotation", aiVector3D(0.f, 0.f, 0.f));
+     aiVector3D defScale = PropertyGet(props, "Lcl Scaling", aiVector3D(1.f, 1.f, 1.f));
+@@ -3104,7 +3168,11 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
+ 
+     const aiVector3D& postRotation = PropertyGet<aiVector3D>(props, "PostRotation", ok);
+     if (ok && postRotation.SquareLength() > zero_epsilon) {
+-        const aiQuaternion postQuat = EulerToQuaternion(postRotation, Model::RotOrder_EulerXYZ);
++        aiMatrix4x4 rotationMatrix;
++        GetRotationMatrix(Model::RotOrder_EulerXYZ, postRotation, rotationMatrix);
++        rotationMatrix.Inverse();
++        const auto postQuat = aiQuaternion(aiMatrix3x3(rotationMatrix));
++        
+         for (size_t i = 0; i < keyCount; ++i) {
+             outRotations[i].mValue = outRotations[i].mValue * postQuat;
+         }
+diff --git a/code/AssetLib/FBX/FBXProperties.cpp b/code/AssetLib/FBX/FBXProperties.cpp
+index a3a95228e..c33452197 100644
+--- a/code/AssetLib/FBX/FBXProperties.cpp
++++ b/code/AssetLib/FBX/FBXProperties.cpp
+@@ -117,7 +117,7 @@ Property* ReadTypedProperty(const Element& element)
+             ParseTokenAsFloat(*tok[6]))
+         );
+     }
+-    else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) {
++    else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"float") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) {
+         ai_assert(tok.size() >= 5);
+         return new TypedProperty<float>(ParseTokenAsFloat(*tok[4]));
+     }
+diff --git a/include/assimp/material.h b/include/assimp/material.h
+index 75695e50b..d4cb329db 100644
+--- a/include/assimp/material.h
++++ b/include/assimp/material.h
+@@ -949,6 +949,18 @@ extern "C" {
+ #define AI_MATKEY_SHADER_PRIMITIVE "?sh.ps",0,0
+ #define AI_MATKEY_SHADER_COMPUTE "?sh.cs",0,0
+ 
++// ---------------------------------------------------------------------------
++// PBR material support
++#define AI_MATKEY_USE_COLOR_MAP "$mat.useColorMap", 0, 0
++#define AI_MATKEY_BASE_COLOR "$clr.base", 0, 0
++#define AI_MATKEY_USE_METALLIC_MAP "$mat.useMetallicMap", 0, 0
++#define AI_MATKEY_METALLIC_FACTOR "$mat.metallicFactor", 0, 0
++#define AI_MATKEY_USE_ROUGHNESS_MAP "$mat.useRoughnessMap", 0, 0
++#define AI_MATKEY_ROUGHNESS_FACTOR "$mat.roughnessFactor", 0, 0
++#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
++
+ // ---------------------------------------------------------------------------
+ // Pure key names for all texture-related properties
+ //! @cond MATS_DOC_FULL
+diff --git a/include/assimp/mesh.h b/include/assimp/mesh.h
+index 4b5af97ce..829a1e992 100644
+--- a/include/assimp/mesh.h
++++ b/include/assimp/mesh.h
+@@ -656,6 +656,8 @@ struct aiMesh {
+     */
+     C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
+ 
++    C_STRUCT aiString mTextureCoordsNames[AI_MAX_NUMBER_OF_TEXTURECOORDS];
++
+     /** Specifies the number of components for a given UV channel.
+     * Up to three channels are supported (UVW, for accessing volume
+     * or cube maps). If the value is 2 for a given channel n, the
+-- 
+2.31.1.windows.1
+

+ 81 - 0
package-system/assimp/Findassimplib.cmake

@@ -0,0 +1,81 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+# assimp depends on ZLIB.  For maximum compatibility here, we use the
+# official ZLIB library name, ie, ZLIB::ZLIB and not o3de 3rdParty::ZLIB.
+# O3DE's zlib package will define both.  If we're in O3DE we can also
+# auto-download ZLIB.
+if (NOT TARGET ZLIB::ZLIB)
+    if (COMMAND ly_download_associated_package)
+        ly_download_associated_package(ZLIB REQUIRED MODULE)
+    endif()
+    find_package(ZLIB)
+endif()
+
+# this file actually ingests the library and defines targets.
+set(TARGET_WITH_NAMESPACE "3rdParty::assimplib")
+if (TARGET ${TARGET_WITH_NAMESPACE})
+    return()
+endif()
+
+set(LIB_NAME "assimp")
+
+set(${LIB_NAME}_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/assimp/include)
+set(${LIB_NAME}_BIN_DIR ${CMAKE_CURRENT_LIST_DIR}/assimp/bin)
+set(${LIB_NAME}_LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/assimp/lib)
+
+if (${PAL_PLATFORM_NAME} STREQUAL "Linux")
+    set(${LIB_NAME}_LIBRARY_DEBUG   ${${LIB_NAME}_BIN_DIR}/libassimp.so.5.0.1)
+    set(${LIB_NAME}_LIBRARY_RELEASE ${${LIB_NAME}_BIN_DIR}/libassimp.so.5.0.1)
+    set(${LIB_NAME}_STATIC_LIBRARY_DEBUG   ${${LIB_NAME}_LIBS_DIR}/libassimp.a)
+    set(${LIB_NAME}_STATIC_LIBRARY_RELEASE ${${LIB_NAME}_LIBS_DIR}/libassimp.a)
+elseif (${PAL_PLATFORM_NAME} STREQUAL "Mac")
+    set(${LIB_NAME}_LIBRARY_DEBUG   ${${LIB_NAME}_BIN_DIR}/libassimp.5.0.1.dylib)
+    set(${LIB_NAME}_LIBRARY_RELEASE ${${LIB_NAME}_BIN_DIR}/libassimp.5.0.1.dylib)
+    set(${LIB_NAME}_STATIC_LIBRARY_DEBUG   ${${LIB_NAME}_LIBS_DIR}/libassimp.a)
+    set(${LIB_NAME}_STATIC_LIBRARY_RELEASE ${${LIB_NAME}_LIBS_DIR}/libassimp.a)
+elseif (${PAL_PLATFORM_NAME} STREQUAL "Windows")
+    set(${LIB_NAME}_LIBRARY_DEBUG   ${${LIB_NAME}_BIN_DIR}/debug/assimp-vc142-mtd.dll)
+    set(${LIB_NAME}_LIBRARY_RELEASE ${${LIB_NAME}_BIN_DIR}/release/assimp-vc142-mt.dll)
+    set(${LIB_NAME}_STATIC_LIBRARY_DEBUG   ${${LIB_NAME}_LIBS_DIR}/debug/assimp-vc142-mtd.lib)
+    set(${LIB_NAME}_STATIC_LIBRARY_RELEASE ${${LIB_NAME}_LIBS_DIR}/release/assimp-vc142-mt.lib)
+endif()
+
+# set it to a generator expression for multi-config situations
+set(${LIB_NAME}_DYNLIB $<IF:$<CONFIG:Debug>,${${LIB_NAME}_LIBRARY_DEBUG},${${LIB_NAME}_LIBRARY_RELEASE}>)
+
+# Order of linking is not enforced by target_link_libraries  on some compilers
+# To workaround this problem, we wrap the static lib in an imported lib and mark the dependency there. That makes
+# the DAG algorithm to sort them in the order we need.
+add_library(${TARGET_WITH_NAMESPACE}::imported STATIC IMPORTED)
+
+set_target_properties(${TARGET_WITH_NAMESPACE}::imported
+    PROPERTIES
+        IMPORTED_LOCATION_DEBUG ${${LIB_NAME}_STATIC_LIBRARY_DEBUG}
+        IMPORTED_LOCATION_PROFILE ${${LIB_NAME}_STATIC_LIBRARY_RELEASE}
+        IMPORTED_LOCATION_RELEASE ${${LIB_NAME}_STATIC_LIBRARY_RELEASE}
+)
+target_link_libraries(${TARGET_WITH_NAMESPACE}::imported
+                            INTERFACE 3rdParty::zlib
+)
+
+add_library(${TARGET_WITH_NAMESPACE} INTERFACE IMPORTED GLOBAL)
+ly_target_include_system_directories(TARGET ${TARGET_WITH_NAMESPACE} INTERFACE ${${LIB_NAME}_INCLUDE_DIR})
+set_target_properties(${TARGET_WITH_NAMESPACE} PROPERTIES
+    INTERFACE_IMPORTED_LOCATION "${${LIB_NAME}_DYNLIB}"
+)
+target_link_libraries(${TARGET_WITH_NAMESPACE}
+                            INTERFACE ${TARGET_WITH_NAMESPACE}::imported
+)
+
+set(3RDPARTY_ASSIMP_RUNTIME_DEPENDENCIES "${${LIB_NAME}_DYNLIB}")
+
+# install Python bindings to AssImp (i.e. PyAssImp)
+ly_pip_install_local_package_editable(${CMAKE_CURRENT_LIST_DIR}/assimp/port/PyAssimp pyassimp)
+
+set(${LIB_NAME}_FOUND True)

+ 6 - 0
package-system/assimp/PackageInfo.json

@@ -0,0 +1,6 @@
+{
+  "PackageName": "assimp-5.0.1-rev12",
+  "URL": "https://github.com/assimp/assimp/blob/master/LICENSE",
+  "License": "BSD-3-Clause",
+  "LicenseFile": "LICENSE"
+}

+ 24 - 0
package-system/assimp/build_assimp_unix_like.sh

@@ -0,0 +1,24 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+cmake -S temp/src -B temp/build \
+    -DBUILD_SHARED_LIBS=OFF \
+    -DCMAKE_BUILD_TYPE=Release \
+    -DCMAKE_MODULE_PATH="$DOWNLOADED_PACKAGE_FOLDERS" \
+    -DASSIMP_BUILD_ZLIB=OFF \
+    temp/src/CMakeLists.txt || exit 1
+cmake --build temp/src --config release || exit 1
+
+cmake -S temp/src -B temp/build \
+    -DBUILD_SHARED_LIBS=ON \
+    -DCMAKE_BUILD_TYPE=Release \
+    -DCMAKE_MODULE_PATH="$DOWNLOADED_PACKAGE_FOLDERS" \
+    -DASSIMP_BUILD_ZLIB=OFF \
+    temp/src/CMakeLists.txt || exit 1
+cmake --build temp/src --config release || exit 1
+

+ 33 - 0
package-system/assimp/build_assimp_windows.cmd

@@ -0,0 +1,33 @@
+@rem #
+@rem # Copyright (c) Contributors to the Open 3D Engine Project.
+@rem # For complete copyright and license terms please see the LICENSE at the root of this distribution.
+@rem # 
+@rem # SPDX-License-Identifier: Apache-2.0 OR MIT
+@rem #
+
+@rem # note that we explicitly turn off the compilation of all features that rely on 3rd Party Libraries
+@rem # except the ones we want.  This prevents the cmake build system from automatically finding things
+@rem # if they happen to be installed locally, which we don't want.
+
+@rem # cmake expects fowardslashes:
+set "DOWNLOADED_PACKAGE_FOLDERS=%DOWNLOADED_PACKAGE_FOLDERS:\=/%"
+
+cmake -S temp/src ^
+    -DBUILD_SHARED_LIBS=OFF ^
+    -DCMAKE_BUILD_TYPE=Release ^
+    -DCMAKE_MODULE_PATH="%DOWNLOADED_PACKAGE_FOLDERS%" ^
+    -DASSIMP_BUILD_ZLIB=OFF ^
+    temp/src/CMakeLists.txt || exit /b 1
+cmake --build temp/src --config release || exit /b 1
+cmake --build temp/src --config debug || exit /b 1
+
+cmake -S temp/src ^
+    -DBUILD_SHARED_LIBS=ON ^
+    -DCMAKE_BUILD_TYPE=Release ^
+    -DCMAKE_MODULE_PATH="%DOWNLOADED_PACKAGE_FOLDERS%" ^
+    -DASSIMP_BUILD_ZLIB=OFF ^
+    temp/src/CMakeLists.txt || exit /b 1
+cmake --build temp/src --config release || exit /b 1
+cmake --build temp/src --config debug || exit /b 1
+
+exit /b 0

+ 64 - 0
package-system/assimp/build_config.json

@@ -0,0 +1,64 @@
+{
+    "git_url":"https://github.com/assimp/assimp",
+    "git_tag": "master",
+    "git_commit": "376e46887780e5090af0198e4e5577446159104d",  
+    "package_name":"assimp",
+    "package_version":"5.0.1-rev12",
+    "package_url":"https://github.com/assimp/assimp",
+    "package_license":"BSD-3-Clause",
+    "package_license_file":"LICENSE",
+    "cmake_find_source":"Findassimplib.cmake",
+    "cmake_find_target":"Findassimplib.cmake",
+    "patch_file" : "0001-O3DE-fixes-applied-on-top-of-376e46887780e5090af0198.patch",
+    "Platforms":{
+        "Windows":{
+            "Windows":{
+                "depends_on_packages" :[ 
+                    ["zlib-1.2.11-rev5-windows", "8847112429744eb11d92c44026fc5fc53caa4a06709382b5f13978f3c26c4cbd", ""]
+                ],
+                "custom_build_cmd" : [
+                    "build_assimp_windows.cmd"
+                ],
+                "custom_install_json": [
+                    "install_assimp_windows.json"
+                ],
+                "custom_test_cmd" : [
+                    "test_assimp_windows.cmd"
+                ]
+            }
+        },
+        "Darwin":{
+            "Mac":{
+                "depends_on_packages" :[ 
+                    ["zlib-1.2.11-rev5-mac", "b6fea9c79b8bf106d4703b67fecaa133f832ad28696c2ceef45fb5f20013c096", ""]
+                ],
+                "custom_build_cmd": [
+                    "./build_assimp_unix_like.sh"
+                 ],
+                 "custom_install_json": [
+                    "./install_assimp_mac.json"
+                 ],
+                 "custom_test_cmd" : [
+                    "./test_assimp_mac.sh"
+                ]
+            }
+        },
+        "Linux":{
+            "Linux":{
+                "depends_on_packages" :[ 
+                    ["zlib-1.2.11-rev5-linux", "9be5ea85722fc27a8645a9c8a812669d107c68e6baa2ca0740872eaeb6a8b0fc", ""]
+                ],
+                "custom_build_cmd": [
+                    "./build_assimp_unix_like.sh"
+                ],
+                "custom_install_json": [
+                    "./install_assimp_linux.json"
+                ],
+                "custom_test_cmd" : [
+                   "./test_assimp_linux.sh"
+               ]
+            }
+        }
+    }
+}
+

+ 11 - 0
package-system/assimp/install_assimp_linux.json

@@ -0,0 +1,11 @@
+{
+  "Source_Subfolder": "src",
+  "Install_Paths": [
+    "include/",
+    "lib/libassimp.a",
+    "bin/assimp",
+    "bin/libassimp.so.5.0.1",
+    "bin/unit",
+    "port/PyAssimp/"
+  ]
+}

+ 13 - 0
package-system/assimp/install_assimp_mac.json

@@ -0,0 +1,13 @@
+{
+  "Source_Subfolder": "src",
+  "Install_Paths": [
+    "include/",
+    "lib/libassimp.a",
+    "bin/libassimp.5.0.1.dylib",
+    "bin/libassimp.5.dylib",
+    "bin/libassimp.dylib",
+    "bin/assimp",
+    "bin/unit",
+    "port/PyAssimp/"
+  ]
+}

+ 18 - 0
package-system/assimp/install_assimp_windows.json

@@ -0,0 +1,18 @@
+{
+  "Source_Subfolder": "src",
+  "Install_Paths": [
+    "include/",
+    "lib/Debug/assimp-vc142-mtd.lib",
+    "lib/Debug/assimp-vc142-mtd.pdb",
+    "lib/Release/assimp-vc142-mt.lib",
+    "bin/Release/assimp.exe",
+    "bin/Release/assimp-vc142-mt.dll",
+    "bin/Release/unit.exe",
+    "bin/Debug/assimpd.exe",
+    "bin/Debug/assimpd.pdb",
+    "bin/Debug/assimp-vc142-mtd.dll",
+    "bin/Debug/assimp-vc142-mtd.pdb",
+    "bin/Debug/unit.exe",
+    "port/PyAssimp/"
+  ]
+}

+ 18 - 0
package-system/assimp/test_assimp_linux.sh

@@ -0,0 +1,18 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+# The tests leave behind temp files in the current working directory.
+# Change to a temp subdirectory to keep the working directory clean.
+cd temp
+rm -rf test_out
+mkdir test_out
+cd test_out
+
+../src/bin/unit || exit 1
+exit 0
+

+ 17 - 0
package-system/assimp/test_assimp_mac.sh

@@ -0,0 +1,17 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+# The tests leave behind temp files in the current working directory.
+# Change to a temp subdirectory to keep the working directory clean.
+cd temp
+rm -rf test_out
+mkdir test_out
+cd test_out
+
+../src/bin/unit || exit 1
+exit 0

+ 24 - 0
package-system/assimp/test_assimp_windows.cmd

@@ -0,0 +1,24 @@
+@rem #
+@rem # Copyright (c) Contributors to the Open 3D Engine Project.
+@rem # For complete copyright and license terms please see the LICENSE at the root of this distribution.
+@rem # 
+@rem # SPDX-License-Identifier: Apache-2.0 OR MIT
+@rem #
+
+set curdir=%cd%
+
+rem The tests leave behind a lot of temp files in the current working directory,
+rem so change to a directory in temp to keep things clean
+cd temp
+mkdir test_out
+cd test_out
+
+%TARGET_INSTALL_ROOT%\bin\Debug\unit.exe || goto ExitWithError
+%TARGET_INSTALL_ROOT%\bin\Release\unit.exe || goto ExitWithError
+
+cd %curdir%
+exit /b 0
+
+:ExitWithError
+cd %curdir%
+exit /b 1

+ 2 - 0
package_build_list_host_darwin.json

@@ -4,6 +4,7 @@
     "comment3" : "build_from_folder is package name --> folder containing built image of package",
     "comment4" : "Note:  Build from source occurs before build_from_folder",
     "build_from_source": {
+        "assimp-5.0.1-rev12-mac":  "Scripts/extras/pull_and_build_from_git.py ../../package-system/assimp --platform-name Mac --package-root ../../package-system --clean",
         "AWSNativeSDK-1.9.50-rev1-mac": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AWSNativeSDK --platform-name Mac --package-root ../../package-system --clean",
         "AWSNativeSDK-1.7.167-rev4-ios": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AWSNativeSDK --platform-name iOS --package-root ../../package-system --clean",
         "Lua-5.3.5-rev7-mac": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Lua --platform-name Mac --package-root ../../package-system --clean",
@@ -49,6 +50,7 @@
         "tiff-4.2.0.15-rev3-ios": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name iOS --package-root ../../package-system --clean"
     },
     "build_from_folder": {
+        "assimp-5.0.1-rev12-mac": "package-system/assimp-mac",
         "AWSNativeSDK-1.9.50-rev1-mac": "package-system/AWSNativeSDK-mac",
         "AWSNativeSDK-1.7.167-rev4-ios": "package-system/AWSNativeSDK-ios",
         "Lua-5.3.5-rev7-mac": "package-system/Lua-mac",

+ 2 - 0
package_build_list_host_linux.json

@@ -4,6 +4,7 @@
     "comment3" : "build_from_folder is package name --> folder containing built image of package",
     "comment4" : "Note:  Build from source occurs before build_from_folder",
     "build_from_source": {
+        "assimp-5.0.1-rev12-linux":  "Scripts/extras/pull_and_build_from_git.py ../../package-system/assimp --platform-name Linux --package-root ../../package-system --clean",
         "AWSNativeSDK-1.9.50-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AWSNativeSDK --platform-name Linux --package-root ../../package-system --clean",
         "Lua-5.3.5-rev7-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Lua --platform-name Linux --package-root ../../package-system --clean",
         "AwsIotDeviceSdkCpp-1.12.2-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AwsIotDeviceSdkCpp --platform-name Linux --package-root ../../package-system --clean",
@@ -36,6 +37,7 @@
         "lz4-1.9.3-vcpkg-rev4-linux": "package-system/lz4/build_package_image.py --platform-name linux"
     },
     "build_from_folder": {
+        "assimp-5.0.1-rev12-linux": "package-system/assimp-linux",
         "AWSGameLiftServerSDK-3.4.1-rev1-linux": "package-system/AWSGameLiftServerSDK/linux",
         "AWSNativeSDK-1.9.50-rev1-linux": "package-system/AWSNativeSDK-linux",
         "Lua-5.3.5-rev7-linux": "package-system/Lua-linux",

+ 7 - 5
package_build_list_host_windows.json

@@ -4,6 +4,7 @@
     "comment3" : "build_from_folder is package name --> folder containing built image of package",
     "comment4" : "Note:  Build from source occurs before build_from_folder",
     "build_from_source": {
+        "assimp-5.0.1-rev12-windows":  "Scripts/extras/pull_and_build_from_git.py ../../package-system/assimp --platform-name Windows --package-root ../../package-system --clean",
         "AWSNativeSDK-1.9.50-rev2-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AWSNativeSDK --platform-name Windows --package-root ../../package-system --clean",
         "AWSNativeSDK-1.9.50-rev1-android": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AWSNativeSDK --platform-name Android --package-root ../../package-system --clean",
         "Blast-v1.1.7_rc2-9-geb169fe-rev2-windows": "package-system/Blast/build_package_image.py --platform-name windows",
@@ -50,12 +51,13 @@
         "zlib-1.2.11-rev1-android": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Android --package-root ../../package-system --clean"
       },
   "build_from_folder": {
-    "astc-encoder-3.2-rev2-windows" : "package-system/astc-encoder-windows",
-    "AWSGameLiftServerSDK-3.4.1-rev1-windows" : "package-system/AWSGameLiftServerSDK/windows",
+    "assimp-5.0.1-rev12-windows": "package-system/assimp-windows",
+    "astc-encoder-3.2-rev2-windows": "package-system/astc-encoder-windows",
+    "AWSGameLiftServerSDK-3.4.1-rev1-windows": "package-system/AWSGameLiftServerSDK/windows",
     "AWSNativeSDK-1.9.50-rev2-windows": "package-system/AWSNativeSDK-windows",
     "AWSNativeSDK-1.9.50-rev1-android": "package-system/AWSNativeSDK-android",
     "Blast-v1.1.7_rc2-9-geb169fe-rev1-windows": "package-system/Blast-windows",
-    "Crashpad-0.8.0-rev1-windows" : "package-system/Crashpad-windows",
+    "Crashpad-0.8.0-rev1-windows": "package-system/Crashpad-windows",
     "Lua-5.3.5-rev7-windows": "package-system/Lua-windows",
     "Lua-5.3.5-rev7-android": "package-system/Lua-android",
     "AwsIotDeviceSdkCpp-1.12.2-rev1-windows": "package-system/AwsIotDeviceSdkCpp-windows",
@@ -87,8 +89,8 @@
     "md5-2.0-multiplatform": "package-system/md5-multiplatform",
     "RapidJSON-1.1.0-multiplatform": "package-system/RapidJSON-multiplatform",
     "RapidXML-1.13-multiplatform": "package-system/RapidXML-multiplatform",
-    "PhysX-4.1.2.29882248-rev5-windows" : "package-system/PhysX-windows",
-    "PhysX-4.1.2.29882248-rev5-android" : "package-system/PhysX-android",
+    "PhysX-4.1.2.29882248-rev5-windows": "package-system/PhysX-windows",
+    "PhysX-4.1.2.29882248-rev5-android": "package-system/PhysX-android",
     "NvCloth-v1.1.6-4-gd243404-pr58-rev1-windows": "package-system/NvCloth-windows",
     "NvCloth-v1.1.6-4-gd243404-pr58-rev1-android": "package-system/NvCloth-android",
     "mikkelsen-1.0.0.4-windows": "package-system/mikkelsen-windows",