Merge branch 'master' into 3mf-mat-col-fix

pull/5681/head
Kim Kulling 2024-08-29 21:10:02 +02:00 committed by GitHub
commit 18ed6097ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 225 additions and 117 deletions

View File

@ -7,10 +7,10 @@ on:
branches: [ master ]
permissions:
contents: read # to fetch code (actions/checkout)
contents: write # to fetch code (actions/checkout),and release
jobs:
job:
build:
name: ${{ matrix.name }}-build-and-test
runs-on: ${{ matrix.os }}
strategy:
@ -70,12 +70,12 @@ jobs:
- name: Set Windows specific CMake arguments
if: contains(matrix.name, 'windows')
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
if: contains(matrix.name, 'hunter')
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
uses: lukka/run-cmake@v3
@ -92,7 +92,7 @@ jobs:
- name: Exclude certain tests in Hunter specific builds
if: contains(matrix.name, 'hunter')
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
run: cd build/bin && ./unit ${{ steps.hunter_extra_test_args.outputs.args }}
@ -101,5 +101,89 @@ jobs:
- uses: actions/upload-artifact@v4
if: matrix.name == 'windows-msvc'
with:
name: 'assimp-bins-${{ matrix.name }}-${{ github.sha }}'
path: build/bin
name: 'assimp-bins-${{ matrix.name }}'
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

@ -306,6 +306,8 @@ ELSEIF(MSVC)
elseif((GENERATOR_IS_MULTI_CONFIG) OR (CMAKE_BUILD_TYPE MATCHES Release))
message("-- MSVC PDB generation disabled. Release binary will not be debuggable.")
endif()
# Source code is encoded in UTF-8
ADD_COMPILE_OPTIONS(/source-charset:utf-8)
ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
IF(NOT ASSIMP_HUNTER_ENABLED)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)

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|metalness", aiTextureType_METALNESS, 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
TrySetTextureProperties(out_mat, _textures, "Maya|TEX_color_map", aiTextureType_BASE_COLOR, mesh);

View File

@ -81,6 +81,27 @@ namespace {
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
// ------------------------------------------------------------------------------------------------
@ -92,6 +113,11 @@ PLYImporter::PLYImporter() :
// empty
}
// ------------------------------------------------------------------------------------------------
PLYImporter::~PLYImporter() {
delete mGeneratedMesh;
}
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool PLYImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
@ -104,26 +130,6 @@ const aiImporterDesc *PLYImporter::GetInfo() const {
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.
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
const size_t fileSize(fileStream->FileSize());
const size_t fileSize = fileStream->FileSize();
if (0 == fileSize) {
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)) {
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
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
pScene->mNumMeshes = 1;
pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
pScene->mMeshes[0] = mGeneratedMesh;
pScene->mMeshes[0] = mGeneratedMesh;
// Move the mesh ownership into the scene instance
mGeneratedMesh = nullptr;
// 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) {
ai_assert(nullptr != pcElement);
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 };
ai_uint aiNormal[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
ai_uint aiNormal[3] = { NotSet, NotSet, NotSet };
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 };
unsigned int aiTexcoord[2] = { 0xFFFFFFFF, 0xFFFFFFFF };
unsigned int aiTexcoord[2] = { NotSet, NotSet };
PLY::EDataType aiTexcoordTypes[2] = { EDT_Char, EDT_Char };
// 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) {
// Position
aiVector3D vOut;
if (0xFFFFFFFF != aiPositions[0]) {
if (NotSet != aiPositions[0]) {
vOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiPositions[0]).avList.front(), aiTypes[0]);
}
if (0xFFFFFFFF != aiPositions[1]) {
if (NotSet != aiPositions[1]) {
vOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiPositions[1]).avList.front(), aiTypes[1]);
}
if (0xFFFFFFFF != aiPositions[2]) {
if (NotSet != aiPositions[2]) {
vOut.z = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiPositions[2]).avList.front(), aiTypes[2]);
}
@ -355,19 +365,19 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
// Normals
aiVector3D nOut;
bool haveNormal = false;
if (0xFFFFFFFF != aiNormal[0]) {
if (NotSet != aiNormal[0]) {
nOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiNormal[0]).avList.front(), aiNormalTypes[0]);
haveNormal = true;
}
if (0xFFFFFFFF != aiNormal[1]) {
if (NotSet != aiNormal[1]) {
nOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiNormal[1]).avList.front(), aiNormalTypes[1]);
haveNormal = true;
}
if (0xFFFFFFFF != aiNormal[2]) {
if (NotSet != aiNormal[2]) {
nOut.z = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiNormal[2]).avList.front(), aiNormalTypes[2]);
haveNormal = true;
@ -376,7 +386,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
// Colors
aiColor4D cOut;
bool haveColor = false;
if (0xFFFFFFFF != aiColors[0]) {
if (NotSet != aiColors[0]) {
cOut.r = NormalizeColorValue(GetProperty(instElement->alProperties,
aiColors[0])
.avList.front(),
@ -384,7 +394,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
haveColor = true;
}
if (0xFFFFFFFF != aiColors[1]) {
if (NotSet != aiColors[1]) {
cOut.g = NormalizeColorValue(GetProperty(instElement->alProperties,
aiColors[1])
.avList.front(),
@ -392,7 +402,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
haveColor = true;
}
if (0xFFFFFFFF != aiColors[2]) {
if (NotSet != aiColors[2]) {
cOut.b = NormalizeColorValue(GetProperty(instElement->alProperties,
aiColors[2])
.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
if (0xFFFFFFFF == aiColors[3]) {
if (NotSet == aiColors[3]) {
cOut.a = 1.0;
} else {
cOut.a = NormalizeColorValue(GetProperty(instElement->alProperties,
@ -416,13 +426,13 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
aiVector3D tOut;
tOut.z = 0;
bool haveTextureCoords = false;
if (0xFFFFFFFF != aiTexcoord[0]) {
if (NotSet != aiTexcoord[0]) {
tOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiTexcoord[0]).avList.front(), aiTexcoordTypes[0]);
haveTextureCoords = true;
}
if (0xFFFFFFFF != aiTexcoord[1]) {
if (NotSet != aiTexcoord[1]) {
tOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty(instElement->alProperties, aiTexcoord[1]).avList.front(), aiTexcoordTypes[1]);
haveTextureCoords = true;
@ -504,16 +514,12 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
bool bOne = false;
// index of the vertex index list
unsigned int iProperty = 0xFFFFFFFF;
unsigned int iProperty = NotSet;
PLY::EDataType eType = EDT_Char;
bool bIsTriStrip = false;
// index of the material index property
// unsigned int iMaterialIndex = 0xFFFFFFFF;
// PLY::EDataType eType2 = EDT_Char;
// texture coordinates
unsigned int iTextureCoord = 0xFFFFFFFF;
unsigned int iTextureCoord = NotSet;
PLY::EDataType eType3 = EDT_Char;
// face = unique number of vertex indices
@ -572,7 +578,7 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
if (!bIsTriStrip) {
// parse the list of vertex indices
if (0xFFFFFFFF != iProperty) {
if (NotSet != iProperty) {
const unsigned int iNum = (unsigned int)GetProperty(instElement->alProperties, iProperty).avList.size();
mGeneratedMesh->mFaces[pos].mNumIndices = 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
// 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) {
if (NotSet != iTextureCoord) {
const unsigned int iNum = (unsigned int)GetProperty(instElement->alProperties, iTextureCoord).avList.size();
// should be 6 coords
@ -679,41 +677,29 @@ void PLYImporter::GetMaterialColor(const std::vector<PLY::PropertyInstance> &avL
aiColor4D *clrOut) {
ai_assert(nullptr != clrOut);
if (0xFFFFFFFF == aiPositions[0])
if (NotSet == aiPositions[0]) {
clrOut->r = 0.0f;
else {
clrOut->r = NormalizeColorValue(GetProperty(avList,
aiPositions[0])
.avList.front(),
aiTypes[0]);
} else {
clrOut->r = NormalizeColorValue(GetProperty(avList, aiPositions[0]).avList.front(), aiTypes[0]);
}
if (0xFFFFFFFF == aiPositions[1])
if (NotSet == aiPositions[1]) {
clrOut->g = 0.0f;
else {
clrOut->g = NormalizeColorValue(GetProperty(avList,
aiPositions[1])
.avList.front(),
aiTypes[1]);
} else {
clrOut->g = NormalizeColorValue(GetProperty(avList, aiPositions[1]).avList.front(), aiTypes[1]);
}
if (0xFFFFFFFF == aiPositions[2])
if (NotSet == aiPositions[2])
clrOut->b = 0.0f;
else {
clrOut->b = NormalizeColorValue(GetProperty(avList,
aiPositions[2])
.avList.front(),
aiTypes[2]);
clrOut->b = NormalizeColorValue(GetProperty(avList, aiPositions[2]).avList.front(), aiTypes[2]);
}
// assume 1.0 for the alpha channel ifit is not set
if (0xFFFFFFFF == aiPositions[3])
if (NotSet == aiPositions[3])
clrOut->a = 1.0f;
else {
clrOut->a = NormalizeColorValue(GetProperty(avList,
aiPositions[3])
.avList.front(),
aiTypes[3]);
clrOut->a = NormalizeColorValue(GetProperty(avList, aiPositions[3]).avList.front(), aiTypes[3]);
}
}

View File

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

View File

@ -1575,7 +1575,7 @@ if(MSVC AND ASSIMP_INSTALL_PDB)
COMPILE_PDB_NAME_DEBUG assimp${LIBRARY_SUFFIX}${CMAKE_DEBUG_POSTFIX}
)
IF(GENERATOR_IS_MULTI_CONFIG)
IF(is_multi_config)
install(FILES ${Assimp_BINARY_DIR}/code/Debug/assimp${LIBRARY_SUFFIX}${CMAKE_DEBUG_POSTFIX}.pdb
DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
CONFIGURATIONS Debug

View File

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

View File

@ -63,6 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h>
#include <stdio.h>
#include <assimp/DefaultLogger.hpp>
#include <unordered_set>
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) {
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;
}
@ -259,6 +268,7 @@ void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector<At
if (srcList.empty()) {
if (*_dest) {
SceneCombiner::CopySceneFlat(_dest, master);
delete master;
} else
*_dest = master;
return;
@ -1057,7 +1067,7 @@ void SceneCombiner::CopyScene(aiScene **_dest, const aiScene *src, bool allocate
dest->mFlags = src->mFlags;
// 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;
}
}

View File

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

View File

@ -58,6 +58,7 @@ extern "C" {
#endif
struct aiScene;
struct aiTexture;
struct aiFileIO;
typedef void (*aiLogStreamCallback)(const char * /* message */, char * /* user */);
@ -373,6 +374,13 @@ ASSIMP_API void aiGetMemoryRequirements(
const C_STRUCT aiScene *pIn,
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
* settings.

View File

@ -292,6 +292,14 @@ enum aiTextureType {
aiTextureType_DIFFUSE_ROUGHNESS = 16,
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
* Some modern renderers have further PBR modifiers that may be overlaid
* on top of the 'base' PBR materials for additional realism.
@ -318,20 +326,20 @@ enum aiTextureType {
*/
aiTextureType_TRANSMISSION = 21,
/** 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,
/**
* Maya material declarations
*/
aiTextureType_MAYA_BASE = 22,
aiTextureType_MAYA_SPECULAR = 23,
aiTextureType_MAYA_SPECULAR_COLOR = 24,
aiTextureType_MAYA_SPECULAR_ROUGHNESS = 25,
#ifndef SWIG
_aiTextureType_Force32Bit = INT_MAX
#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
static const char* GetShortFilename(const char* filename) {
const char* lastSlash = strrchr(filename, '/');
if (lastSlash == nullptr) {
lastSlash = strrchr(filename, '\\');
const char* lastBackSlash = strrchr(filename, '\\');
if (lastSlash < lastBackSlash) {
lastSlash = lastBackSlash;
}
const char* shortFilename = lastSlash != nullptr ? lastSlash + 1 : filename;
return shortFilename;

View File

@ -260,6 +260,10 @@ TEST_F(MaterialSystemTest, testMaterialTextureTypeEnum) {
case aiTextureType_METALNESS:
case aiTextureType_DIFFUSE_ROUGHNESS:
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_CLEARCOAT:
case aiTextureType_TRANSMISSION: