Merge branch 'master' into fix-msvc-install-error

pull/5720/head
Kim Kulling 2024-08-29 11:23:21 +02:00 committed by GitHub
commit b5b25d6a9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 222 additions and 116 deletions

View File

@ -7,10 +7,10 @@ on:
branches: [ master ] branches: [ master ]
permissions: permissions:
contents: read # to fetch code (actions/checkout) contents: write # to fetch code (actions/checkout),and release
jobs: jobs:
job: build:
name: ${{ matrix.name }}-build-and-test name: ${{ matrix.name }}-build-and-test
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
@ -70,12 +70,12 @@ jobs:
- name: Set Windows specific CMake arguments - name: Set Windows specific CMake arguments
if: contains(matrix.name, 'windows') if: contains(matrix.name, 'windows')
id: windows_extra_cmake_args id: windows_extra_cmake_args
run: echo "::set-output name=args::-DASSIMP_BUILD_ASSIMP_TOOLS=1 -DASSIMP_BUILD_ASSIMP_VIEW=1 -DASSIMP_BUILD_ZLIB=1" run: echo ":set-output name=args::=-DASSIMP_BUILD_ASSIMP_TOOLS=1 -DASSIMP_BUILD_ASSIMP_VIEW=1" >> $GITHUB_OUTPUT
- name: Set Hunter specific CMake arguments - name: Set Hunter specific CMake arguments
if: contains(matrix.name, 'hunter') if: contains(matrix.name, 'hunter')
id: hunter_extra_cmake_args id: hunter_extra_cmake_args
run: echo "::set-output name=args::-DBUILD_SHARED_LIBS=OFF -DASSIMP_HUNTER_ENABLED=ON -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/polly/${{ matrix.toolchain }}.cmake" run: echo "args=-DBUILD_SHARED_LIBS=OFF -DASSIMP_HUNTER_ENABLED=ON -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/polly/${{ matrix.toolchain }}.cmake" >> $GITHUB_OUTPUT
- name: configure and build - name: configure and build
uses: lukka/run-cmake@v3 uses: lukka/run-cmake@v3
@ -92,7 +92,7 @@ jobs:
- name: Exclude certain tests in Hunter specific builds - name: Exclude certain tests in Hunter specific builds
if: contains(matrix.name, 'hunter') if: contains(matrix.name, 'hunter')
id: hunter_extra_test_args id: hunter_extra_test_args
run: echo "::set-output name=args::--gtest_filter=-utOpenGEXImportExport.Importissue1340_EmptyCameraObject:utColladaZaeImportExport.importBlenFromFileTest" run: echo "args=--gtest_filter=-utOpenGEXImportExport.Importissue1340_EmptyCameraObject:utColladaZaeImportExport.importBlenFromFileTest" >> $GITHUB_OUTPUT
- name: test - name: test
run: cd build/bin && ./unit ${{ steps.hunter_extra_test_args.outputs.args }} run: cd build/bin && ./unit ${{ steps.hunter_extra_test_args.outputs.args }}
@ -101,5 +101,89 @@ jobs:
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: matrix.name == 'windows-msvc' if: matrix.name == 'windows-msvc'
with: with:
name: 'assimp-bins-${{ matrix.name }}-${{ github.sha }}' name: 'assimp-bins-${{ matrix.name }}'
path: build/bin path: build/bin/assimp*.exe
- uses: marvinpinto/action-automatic-releases@latest
if: contains(matrix.name, 'windows-msvc-hunter')
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "master"
prerelease: true
title: "AutoRelease"
files: |
build/bin/assimp*.exe
create-release:
needs: [build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: '${{secrets.GITHUB_TOKEN}}'
with:
tag_name: '${{github.ref}}'
release_name: 'Release ${{github.ref}}'
draft: false
prerelease: true
- run: |
echo '${{steps.create-release.outputs.upload_url}}' > release_upload_url.txt
- uses: actions/upload-artifact@v4
with:
name: create-release
path: release_upload_url.txt
upload-release:
strategy:
matrix:
name: [ubuntu-latest-g++, macos-latest-clang++, windows-latest-cl.exe, ubuntu-latest-clang++, ubuntu-gcc-hunter, macos-clang-hunter, windows-msvc-hunter]
# For Windows msvc, for Linux and macOS let's use the clang compiler, use gcc for Linux.
include:
- name: windows-latest-cl.exe
os: windows-latest
cxx: cl.exe
cc: cl.exe
- name: ubuntu-latest-clang++
os: ubuntu-latest
cxx: clang++
cc: clang
- name: macos-latest-clang++
os: macos-latest
cxx: clang++
cc: clang
- name: ubuntu-latest-g++
os: ubuntu-latest
cxx: g++
cc: gcc
- name: ubuntu-gcc-hunter
os: ubuntu-latest
toolchain: ninja-gcc-cxx17-fpic
- name: macos-clang-hunter
os: macos-latest
toolchain: ninja-clang-cxx17-fpic
- name: windows-msvc-hunter
os: windows-latest
toolchain: ninja-vs-win64-cxx17
needs: [create-release]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: softprops/action-gh-release@v2
with:
name: create-release
- id: upload-url
run: |
echo "url=$(cat create-release/release_upload_url.txt)" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v4
with:
name: 'assimp-bins-${{ matrix.name }}-${{ github.sha }}'
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: '${{secrets.GITHUB_TOKEN}}'
with:
files: |
*.zip

View File

@ -2128,6 +2128,10 @@ void FBXConverter::SetTextureProperties(aiMaterial *out_mat, const TextureMap &_
TrySetTextureProperties(out_mat, _textures, "Maya|emissionColor", aiTextureType_EMISSION_COLOR, mesh); TrySetTextureProperties(out_mat, _textures, "Maya|emissionColor", aiTextureType_EMISSION_COLOR, mesh);
TrySetTextureProperties(out_mat, _textures, "Maya|metalness", aiTextureType_METALNESS, mesh); TrySetTextureProperties(out_mat, _textures, "Maya|metalness", aiTextureType_METALNESS, mesh);
TrySetTextureProperties(out_mat, _textures, "Maya|diffuseRoughness", aiTextureType_DIFFUSE_ROUGHNESS, mesh); TrySetTextureProperties(out_mat, _textures, "Maya|diffuseRoughness", aiTextureType_DIFFUSE_ROUGHNESS, mesh);
TrySetTextureProperties(out_mat, _textures, "Maya|base", aiTextureType_MAYA_BASE, mesh);
TrySetTextureProperties(out_mat, _textures, "Maya|specular", aiTextureType_MAYA_SPECULAR, mesh);
TrySetTextureProperties(out_mat, _textures, "Maya|specularColor", aiTextureType_MAYA_SPECULAR_COLOR, mesh);
TrySetTextureProperties(out_mat, _textures, "Maya|specularRoughness", aiTextureType_MAYA_SPECULAR_ROUGHNESS, mesh);
// Maya stingray // Maya stingray
TrySetTextureProperties(out_mat, _textures, "Maya|TEX_color_map", aiTextureType_BASE_COLOR, mesh); TrySetTextureProperties(out_mat, _textures, "Maya|TEX_color_map", aiTextureType_BASE_COLOR, mesh);

View File

@ -81,6 +81,27 @@ namespace {
return props[idx]; return props[idx];
} }
// ------------------------------------------------------------------------------------------------
static bool isBigEndian(const char *szMe) {
ai_assert(nullptr != szMe);
// binary_little_endian
// binary_big_endian
bool isBigEndian{ false };
#if (defined AI_BUILD_BIG_ENDIAN)
if ('l' == *szMe || 'L' == *szMe) {
isBigEndian = true;
}
#else
if ('b' == *szMe || 'B' == *szMe) {
isBigEndian = true;
}
#endif // ! AI_BUILD_BIG_ENDIAN
return isBigEndian;
}
} // namespace } // namespace
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -92,6 +113,11 @@ PLYImporter::PLYImporter() :
// empty // empty
} }
// ------------------------------------------------------------------------------------------------
PLYImporter::~PLYImporter() {
delete mGeneratedMesh;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file. // Returns whether the class can handle the format of the given file.
bool PLYImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const { bool PLYImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
@ -104,26 +130,6 @@ const aiImporterDesc *PLYImporter::GetInfo() const {
return &desc; return &desc;
} }
// ------------------------------------------------------------------------------------------------
static bool isBigEndian(const char *szMe) {
ai_assert(nullptr != szMe);
// binary_little_endian
// binary_big_endian
bool isBigEndian(false);
#if (defined AI_BUILD_BIG_ENDIAN)
if ('l' == *szMe || 'L' == *szMe) {
isBigEndian = true;
}
#else
if ('b' == *szMe || 'B' == *szMe) {
isBigEndian = true;
}
#endif // ! AI_BUILD_BIG_ENDIAN
return isBigEndian;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure. // Imports the given file into the given scene structure.
void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) { void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
@ -134,7 +140,7 @@ void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
} }
// Get the file-size // Get the file-size
const size_t fileSize(fileStream->FileSize()); const size_t fileSize = fileStream->FileSize();
if (0 == fileSize) { if (0 == fileSize) {
throw DeadlyImportError("File ", pFile, " is empty."); throw DeadlyImportError("File ", pFile, " is empty.");
} }
@ -180,7 +186,7 @@ void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
} }
} else if (!::strncmp(szMe, "binary_", 7)) { } else if (!::strncmp(szMe, "binary_", 7)) {
szMe += 7; szMe += 7;
const bool bIsBE(isBigEndian(szMe)); const bool bIsBE = isBigEndian(szMe);
// skip the line, parse the rest of the header and build the DOM // skip the line, parse the rest of the header and build the DOM
if (!PLY::DOM::ParseInstanceBinary(streamedBuffer, &sPlyDom, this, bIsBE)) { if (!PLY::DOM::ParseInstanceBinary(streamedBuffer, &sPlyDom, this, bIsBE)) {
@ -241,7 +247,9 @@ void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// fill the mesh list // fill the mesh list
pScene->mNumMeshes = 1; pScene->mNumMeshes = 1;
pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]; pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
pScene->mMeshes[0] = mGeneratedMesh; pScene->mMeshes[0] = mGeneratedMesh;
// Move the mesh ownership into the scene instance
mGeneratedMesh = nullptr; mGeneratedMesh = nullptr;
// generate a simple node structure // generate a simple node structure
@ -254,20 +262,22 @@ void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
} }
} }
static constexpr ai_uint NotSet = 0xFFFFFFFF;
void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementInstance *instElement, unsigned int pos) { void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementInstance *instElement, unsigned int pos) {
ai_assert(nullptr != pcElement); ai_assert(nullptr != pcElement);
ai_assert(nullptr != instElement); ai_assert(nullptr != instElement);
ai_uint aiPositions[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; ai_uint aiPositions[3] = { NotSet, NotSet, NotSet };
PLY::EDataType aiTypes[3] = { EDT_Char, EDT_Char, EDT_Char }; PLY::EDataType aiTypes[3] = { EDT_Char, EDT_Char, EDT_Char };
ai_uint aiNormal[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; ai_uint aiNormal[3] = { NotSet, NotSet, NotSet };
PLY::EDataType aiNormalTypes[3] = { EDT_Char, EDT_Char, EDT_Char }; PLY::EDataType aiNormalTypes[3] = { EDT_Char, EDT_Char, EDT_Char };
unsigned int aiColors[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; unsigned int aiColors[4] = { NotSet, NotSet, NotSet, NotSet };
PLY::EDataType aiColorsTypes[4] = { EDT_Char, EDT_Char, EDT_Char, EDT_Char }; PLY::EDataType aiColorsTypes[4] = { EDT_Char, EDT_Char, EDT_Char, EDT_Char };
unsigned int aiTexcoord[2] = { 0xFFFFFFFF, 0xFFFFFFFF }; unsigned int aiTexcoord[2] = { NotSet, NotSet };
PLY::EDataType aiTexcoordTypes[2] = { EDT_Char, EDT_Char }; PLY::EDataType aiTexcoordTypes[2] = { EDT_Char, EDT_Char };
// now check whether which normal components are available // now check whether which normal components are available
@ -337,17 +347,17 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
if (0 != cnt) { if (0 != cnt) {
// Position // Position
aiVector3D vOut; aiVector3D vOut;
if (0xFFFFFFFF != aiPositions[0]) { if (NotSet != aiPositions[0]) {
vOut.x = PLY::PropertyInstance::ConvertTo<ai_real>( vOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiPositions[0]).avList.front(), aiTypes[0]); GetProperty(instElement->alProperties, aiPositions[0]).avList.front(), aiTypes[0]);
} }
if (0xFFFFFFFF != aiPositions[1]) { if (NotSet != aiPositions[1]) {
vOut.y = PLY::PropertyInstance::ConvertTo<ai_real>( vOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiPositions[1]).avList.front(), aiTypes[1]); GetProperty(instElement->alProperties, aiPositions[1]).avList.front(), aiTypes[1]);
} }
if (0xFFFFFFFF != aiPositions[2]) { if (NotSet != aiPositions[2]) {
vOut.z = PLY::PropertyInstance::ConvertTo<ai_real>( vOut.z = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiPositions[2]).avList.front(), aiTypes[2]); GetProperty(instElement->alProperties, aiPositions[2]).avList.front(), aiTypes[2]);
} }
@ -355,19 +365,19 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
// Normals // Normals
aiVector3D nOut; aiVector3D nOut;
bool haveNormal = false; bool haveNormal = false;
if (0xFFFFFFFF != aiNormal[0]) { if (NotSet != aiNormal[0]) {
nOut.x = PLY::PropertyInstance::ConvertTo<ai_real>( nOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiNormal[0]).avList.front(), aiNormalTypes[0]); GetProperty(instElement->alProperties, aiNormal[0]).avList.front(), aiNormalTypes[0]);
haveNormal = true; haveNormal = true;
} }
if (0xFFFFFFFF != aiNormal[1]) { if (NotSet != aiNormal[1]) {
nOut.y = PLY::PropertyInstance::ConvertTo<ai_real>( nOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiNormal[1]).avList.front(), aiNormalTypes[1]); GetProperty(instElement->alProperties, aiNormal[1]).avList.front(), aiNormalTypes[1]);
haveNormal = true; haveNormal = true;
} }
if (0xFFFFFFFF != aiNormal[2]) { if (NotSet != aiNormal[2]) {
nOut.z = PLY::PropertyInstance::ConvertTo<ai_real>( nOut.z = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiNormal[2]).avList.front(), aiNormalTypes[2]); GetProperty(instElement->alProperties, aiNormal[2]).avList.front(), aiNormalTypes[2]);
haveNormal = true; haveNormal = true;
@ -376,7 +386,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
// Colors // Colors
aiColor4D cOut; aiColor4D cOut;
bool haveColor = false; bool haveColor = false;
if (0xFFFFFFFF != aiColors[0]) { if (NotSet != aiColors[0]) {
cOut.r = NormalizeColorValue(GetProperty(instElement->alProperties, cOut.r = NormalizeColorValue(GetProperty(instElement->alProperties,
aiColors[0]) aiColors[0])
.avList.front(), .avList.front(),
@ -384,7 +394,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
haveColor = true; haveColor = true;
} }
if (0xFFFFFFFF != aiColors[1]) { if (NotSet != aiColors[1]) {
cOut.g = NormalizeColorValue(GetProperty(instElement->alProperties, cOut.g = NormalizeColorValue(GetProperty(instElement->alProperties,
aiColors[1]) aiColors[1])
.avList.front(), .avList.front(),
@ -392,7 +402,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
haveColor = true; haveColor = true;
} }
if (0xFFFFFFFF != aiColors[2]) { if (NotSet != aiColors[2]) {
cOut.b = NormalizeColorValue(GetProperty(instElement->alProperties, cOut.b = NormalizeColorValue(GetProperty(instElement->alProperties,
aiColors[2]) aiColors[2])
.avList.front(), .avList.front(),
@ -401,7 +411,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
} }
// assume 1.0 for the alpha channel if it is not set // assume 1.0 for the alpha channel if it is not set
if (0xFFFFFFFF == aiColors[3]) { if (NotSet == aiColors[3]) {
cOut.a = 1.0; cOut.a = 1.0;
} else { } else {
cOut.a = NormalizeColorValue(GetProperty(instElement->alProperties, cOut.a = NormalizeColorValue(GetProperty(instElement->alProperties,
@ -416,13 +426,13 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
aiVector3D tOut; aiVector3D tOut;
tOut.z = 0; tOut.z = 0;
bool haveTextureCoords = false; bool haveTextureCoords = false;
if (0xFFFFFFFF != aiTexcoord[0]) { if (NotSet != aiTexcoord[0]) {
tOut.x = PLY::PropertyInstance::ConvertTo<ai_real>( tOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiTexcoord[0]).avList.front(), aiTexcoordTypes[0]); GetProperty(instElement->alProperties, aiTexcoord[0]).avList.front(), aiTexcoordTypes[0]);
haveTextureCoords = true; haveTextureCoords = true;
} }
if (0xFFFFFFFF != aiTexcoord[1]) { if (NotSet != aiTexcoord[1]) {
tOut.y = PLY::PropertyInstance::ConvertTo<ai_real>( tOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiTexcoord[1]).avList.front(), aiTexcoordTypes[1]); GetProperty(instElement->alProperties, aiTexcoord[1]).avList.front(), aiTexcoordTypes[1]);
haveTextureCoords = true; haveTextureCoords = true;
@ -504,16 +514,12 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
bool bOne = false; bool bOne = false;
// index of the vertex index list // index of the vertex index list
unsigned int iProperty = 0xFFFFFFFF; unsigned int iProperty = NotSet;
PLY::EDataType eType = EDT_Char; PLY::EDataType eType = EDT_Char;
bool bIsTriStrip = false; bool bIsTriStrip = false;
// index of the material index property
// unsigned int iMaterialIndex = 0xFFFFFFFF;
// PLY::EDataType eType2 = EDT_Char;
// texture coordinates // texture coordinates
unsigned int iTextureCoord = 0xFFFFFFFF; unsigned int iTextureCoord = NotSet;
PLY::EDataType eType3 = EDT_Char; PLY::EDataType eType3 = EDT_Char;
// face = unique number of vertex indices // face = unique number of vertex indices
@ -572,7 +578,7 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
if (!bIsTriStrip) { if (!bIsTriStrip) {
// parse the list of vertex indices // parse the list of vertex indices
if (0xFFFFFFFF != iProperty) { if (NotSet != iProperty) {
const unsigned int iNum = (unsigned int)GetProperty(instElement->alProperties, iProperty).avList.size(); const unsigned int iNum = (unsigned int)GetProperty(instElement->alProperties, iProperty).avList.size();
mGeneratedMesh->mFaces[pos].mNumIndices = iNum; mGeneratedMesh->mFaces[pos].mNumIndices = iNum;
mGeneratedMesh->mFaces[pos].mIndices = new unsigned int[iNum]; mGeneratedMesh->mFaces[pos].mIndices = new unsigned int[iNum];
@ -585,15 +591,7 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
} }
} }
// parse the material index if (NotSet != iTextureCoord) {
// cannot be handled without processing the whole file first
/*if (0xFFFFFFFF != iMaterialIndex)
{
mGeneratedMesh->mFaces[pos]. = PLY::PropertyInstance::ConvertTo<unsigned int>(
GetProperty(instElement->alProperties, iMaterialIndex).avList.front(), eType2);
}*/
if (0xFFFFFFFF != iTextureCoord) {
const unsigned int iNum = (unsigned int)GetProperty(instElement->alProperties, iTextureCoord).avList.size(); const unsigned int iNum = (unsigned int)GetProperty(instElement->alProperties, iTextureCoord).avList.size();
// should be 6 coords // should be 6 coords
@ -679,41 +677,29 @@ void PLYImporter::GetMaterialColor(const std::vector<PLY::PropertyInstance> &avL
aiColor4D *clrOut) { aiColor4D *clrOut) {
ai_assert(nullptr != clrOut); ai_assert(nullptr != clrOut);
if (0xFFFFFFFF == aiPositions[0]) if (NotSet == aiPositions[0]) {
clrOut->r = 0.0f; clrOut->r = 0.0f;
else { } else {
clrOut->r = NormalizeColorValue(GetProperty(avList, clrOut->r = NormalizeColorValue(GetProperty(avList, aiPositions[0]).avList.front(), aiTypes[0]);
aiPositions[0])
.avList.front(),
aiTypes[0]);
} }
if (0xFFFFFFFF == aiPositions[1]) if (NotSet == aiPositions[1]) {
clrOut->g = 0.0f; clrOut->g = 0.0f;
else { } else {
clrOut->g = NormalizeColorValue(GetProperty(avList, clrOut->g = NormalizeColorValue(GetProperty(avList, aiPositions[1]).avList.front(), aiTypes[1]);
aiPositions[1])
.avList.front(),
aiTypes[1]);
} }
if (0xFFFFFFFF == aiPositions[2]) if (NotSet == aiPositions[2])
clrOut->b = 0.0f; clrOut->b = 0.0f;
else { else {
clrOut->b = NormalizeColorValue(GetProperty(avList, clrOut->b = NormalizeColorValue(GetProperty(avList, aiPositions[2]).avList.front(), aiTypes[2]);
aiPositions[2])
.avList.front(),
aiTypes[2]);
} }
// assume 1.0 for the alpha channel ifit is not set // assume 1.0 for the alpha channel ifit is not set
if (0xFFFFFFFF == aiPositions[3]) if (NotSet == aiPositions[3])
clrOut->a = 1.0f; clrOut->a = 1.0f;
else { else {
clrOut->a = NormalizeColorValue(GetProperty(avList, clrOut->a = NormalizeColorValue(GetProperty(avList, aiPositions[3]).avList.front(), aiTypes[3]);
aiPositions[3])
.avList.front(),
aiTypes[3]);
} }
} }

View File

@ -62,10 +62,10 @@ using namespace PLY;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** Importer class to load the stanford PLY file format /** Importer class to load the stanford PLY file format
*/ */
class PLYImporter : public BaseImporter { class PLYImporter final : public BaseImporter {
public: public:
PLYImporter(); PLYImporter();
~PLYImporter() override = default; ~PLYImporter() override;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file. /** Returns whether the class can handle the format of the given file.
@ -120,13 +120,9 @@ protected:
PLY::PropertyInstance::ValueUnion val, PLY::PropertyInstance::ValueUnion val,
PLY::EDataType eType); PLY::EDataType eType);
/** Buffer to hold the loaded file */ private:
unsigned char *mBuffer; unsigned char *mBuffer;
/** Document object model representation extracted from the file */
PLY::DOM *pcDOM; PLY::DOM *pcDOM;
/** Mesh generated by loader */
aiMesh *mGeneratedMesh; aiMesh *mGeneratedMesh;
}; };

View File

@ -512,6 +512,11 @@ void aiGetMemoryRequirements(const C_STRUCT aiScene *pIn,
ASSIMP_END_EXCEPTION_REGION(void); ASSIMP_END_EXCEPTION_REGION(void);
} }
// ------------------------------------------------------------------------------------------------
ASSIMP_API const C_STRUCT aiTexture *aiGetEmbeddedTexture(const C_STRUCT aiScene *pIn, const char *filename) {
return pIn->GetEmbeddedTexture(filename);
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API aiPropertyStore *aiCreatePropertyStore(void) { ASSIMP_API aiPropertyStore *aiCreatePropertyStore(void) {
return reinterpret_cast<aiPropertyStore *>(new PropertyMap()); return reinterpret_cast<aiPropertyStore *>(new PropertyMap());
@ -1268,7 +1273,6 @@ ASSIMP_API void aiQuaternionInterpolate(
aiQuaternion::Interpolate(*dst, *start, *end, factor); aiQuaternion::Interpolate(*dst, *start, *end, factor);
} }
// stb_image is a lightweight image loader. It is shared by: // stb_image is a lightweight image loader. It is shared by:
// - M3D import // - M3D import
// - PBRT export // - PBRT export
@ -1279,21 +1283,21 @@ ASSIMP_API void aiQuaternionInterpolate(
#define ASSIMP_HAS_M3D ((!ASSIMP_BUILD_NO_EXPORT && !ASSIMP_BUILD_NO_M3D_EXPORTER) || !ASSIMP_BUILD_NO_M3D_IMPORTER) #define ASSIMP_HAS_M3D ((!ASSIMP_BUILD_NO_EXPORT && !ASSIMP_BUILD_NO_M3D_EXPORTER) || !ASSIMP_BUILD_NO_M3D_IMPORTER)
#ifndef STB_USE_HUNTER #ifndef STB_USE_HUNTER
# if ASSIMP_HAS_PBRT_EXPORT #if ASSIMP_HAS_PBRT_EXPORT
# define ASSIMP_NEEDS_STB_IMAGE 1 #define ASSIMP_NEEDS_STB_IMAGE 1
# elif ASSIMP_HAS_M3D #elif ASSIMP_HAS_M3D
# define ASSIMP_NEEDS_STB_IMAGE 1 #define ASSIMP_NEEDS_STB_IMAGE 1
# define STBI_ONLY_PNG #define STBI_ONLY_PNG
# endif #endif
#endif #endif
// Ensure all symbols are linked correctly // Ensure all symbols are linked correctly
#if ASSIMP_NEEDS_STB_IMAGE #if ASSIMP_NEEDS_STB_IMAGE
// Share stb_image's PNG loader with other importers/exporters instead of bringing our own copy. // Share stb_image's PNG loader with other importers/exporters instead of bringing our own copy.
# define STBI_ONLY_PNG #define STBI_ONLY_PNG
# ifdef ASSIMP_USE_STB_IMAGE_STATIC #ifdef ASSIMP_USE_STB_IMAGE_STATIC
# define STB_IMAGE_STATIC #define STB_IMAGE_STATIC
# endif #endif
# define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
# include "Common/StbCommon.h" #include "Common/StbCommon.h"
#endif #endif

View File

@ -63,6 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h> #include <assimp/scene.h>
#include <stdio.h> #include <stdio.h>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <unordered_set>
namespace Assimp { namespace Assimp {
@ -252,6 +253,14 @@ void SceneCombiner::AttachToGraph(aiScene *master, std::vector<NodeAttachmentInf
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector<AttachmentInfo> &srcList, unsigned int flags) { void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector<AttachmentInfo> &srcList, unsigned int flags) {
if (nullptr == _dest) { if (nullptr == _dest) {
std::unordered_set<aiScene *> uniqueScenes;
uniqueScenes.insert(master);
for (const auto &item : srcList) {
uniqueScenes.insert(item.scene);
}
for (const auto &item : uniqueScenes) {
delete item;
}
return; return;
} }
@ -259,6 +268,7 @@ void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector<At
if (srcList.empty()) { if (srcList.empty()) {
if (*_dest) { if (*_dest) {
SceneCombiner::CopySceneFlat(_dest, master); SceneCombiner::CopySceneFlat(_dest, master);
delete master;
} else } else
*_dest = master; *_dest = master;
return; return;
@ -1057,7 +1067,7 @@ void SceneCombiner::CopyScene(aiScene **_dest, const aiScene *src, bool allocate
dest->mFlags = src->mFlags; dest->mFlags = src->mFlags;
// source private data might be nullptr if the scene is user-allocated (i.e. for use with the export API) // source private data might be nullptr if the scene is user-allocated (i.e. for use with the export API)
if (dest->mPrivate != nullptr) { if (src->mPrivate != nullptr) {
ScenePriv(dest)->mPPStepsApplied = ScenePriv(src) ? ScenePriv(src)->mPPStepsApplied : 0; ScenePriv(dest)->mPPStepsApplied = ScenePriv(src) ? ScenePriv(src)->mPPStepsApplied : 0;
} }
} }

View File

@ -380,3 +380,4 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh(aiMesh *pMesh, unsigned int mes
} }
} // namespace Assimp } // namespace Assimp

View File

@ -58,6 +58,7 @@ extern "C" {
#endif #endif
struct aiScene; struct aiScene;
struct aiTexture;
struct aiFileIO; struct aiFileIO;
typedef void (*aiLogStreamCallback)(const char * /* message */, char * /* user */); typedef void (*aiLogStreamCallback)(const char * /* message */, char * /* user */);
@ -373,6 +374,13 @@ ASSIMP_API void aiGetMemoryRequirements(
const C_STRUCT aiScene *pIn, const C_STRUCT aiScene *pIn,
C_STRUCT aiMemoryInfo *in); C_STRUCT aiMemoryInfo *in);
// --------------------------------------------------------------------------------
/** Returns an embedded texture, or nullptr.
* @param pIn Input asset.
* @param filename Texture path extracted from aiGetMaterialString.
*/
ASSIMP_API const C_STRUCT aiTexture *aiGetEmbeddedTexture(const C_STRUCT aiScene *pIn, const char *filename);
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
/** Create an empty property store. Property stores are used to collect import /** Create an empty property store. Property stores are used to collect import
* settings. * settings.

View File

@ -292,6 +292,14 @@ enum aiTextureType {
aiTextureType_DIFFUSE_ROUGHNESS = 16, aiTextureType_DIFFUSE_ROUGHNESS = 16,
aiTextureType_AMBIENT_OCCLUSION = 17, aiTextureType_AMBIENT_OCCLUSION = 17,
/** Unknown texture
*
* A texture reference that does not match any of the definitions
* above is considered to be 'unknown'. It is still imported,
* but is excluded from any further post-processing.
*/
aiTextureType_UNKNOWN = 18,
/** PBR Material Modifiers /** PBR Material Modifiers
* Some modern renderers have further PBR modifiers that may be overlaid * Some modern renderers have further PBR modifiers that may be overlaid
* on top of the 'base' PBR materials for additional realism. * on top of the 'base' PBR materials for additional realism.
@ -318,20 +326,20 @@ enum aiTextureType {
*/ */
aiTextureType_TRANSMISSION = 21, aiTextureType_TRANSMISSION = 21,
/** Unknown texture /**
* * Maya material declarations
* A texture reference that does not match any of the definitions */
* above is considered to be 'unknown'. It is still imported, aiTextureType_MAYA_BASE = 22,
* but is excluded from any further post-processing. aiTextureType_MAYA_SPECULAR = 23,
*/ aiTextureType_MAYA_SPECULAR_COLOR = 24,
aiTextureType_UNKNOWN = 18, aiTextureType_MAYA_SPECULAR_ROUGHNESS = 25,
#ifndef SWIG #ifndef SWIG
_aiTextureType_Force32Bit = INT_MAX _aiTextureType_Force32Bit = INT_MAX
#endif #endif
}; };
#define AI_TEXTURE_TYPE_MAX aiTextureType_TRANSMISSION #define AI_TEXTURE_TYPE_MAX aiTextureType_MAYA_SPECULAR_ROUGHNESS
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
/** /**

View File

@ -401,8 +401,9 @@ struct ASSIMP_API aiScene {
//! Returns a short filename from a full path //! Returns a short filename from a full path
static const char* GetShortFilename(const char* filename) { static const char* GetShortFilename(const char* filename) {
const char* lastSlash = strrchr(filename, '/'); const char* lastSlash = strrchr(filename, '/');
if (lastSlash == nullptr) { const char* lastBackSlash = strrchr(filename, '\\');
lastSlash = strrchr(filename, '\\'); if (lastSlash < lastBackSlash) {
lastSlash = lastBackSlash;
} }
const char* shortFilename = lastSlash != nullptr ? lastSlash + 1 : filename; const char* shortFilename = lastSlash != nullptr ? lastSlash + 1 : filename;
return shortFilename; return shortFilename;

View File

@ -260,6 +260,10 @@ TEST_F(MaterialSystemTest, testMaterialTextureTypeEnum) {
case aiTextureType_METALNESS: case aiTextureType_METALNESS:
case aiTextureType_DIFFUSE_ROUGHNESS: case aiTextureType_DIFFUSE_ROUGHNESS:
case aiTextureType_AMBIENT_OCCLUSION: case aiTextureType_AMBIENT_OCCLUSION:
case aiTextureType_MAYA_BASE:
case aiTextureType_MAYA_SPECULAR:
case aiTextureType_MAYA_SPECULAR_COLOR:
case aiTextureType_MAYA_SPECULAR_ROUGHNESS:
case aiTextureType_SHEEN: case aiTextureType_SHEEN:
case aiTextureType_CLEARCOAT: case aiTextureType_CLEARCOAT:
case aiTextureType_TRANSMISSION: case aiTextureType_TRANSMISSION: