Merge branch 'master' into ccache
commit
3976faec62
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ IF (WIN32)
|
||||||
|
|
||||||
IF(MSVC)
|
IF(MSVC)
|
||||||
OPTION( ASSIMP_INSTALL_PDB
|
OPTION( ASSIMP_INSTALL_PDB
|
||||||
"Install MSVC debug files."
|
"Create MSVC debug symbol files and add to Install target."
|
||||||
ON )
|
ON )
|
||||||
IF(NOT (MSVC_VERSION LESS 1900))
|
IF(NOT (MSVC_VERSION LESS 1900))
|
||||||
# Multibyte character set has been deprecated since at least MSVC2015 (possibly earlier)
|
# Multibyte character set has been deprecated since at least MSVC2015 (possibly earlier)
|
||||||
|
@ -308,8 +308,15 @@ ELSEIF(MSVC)
|
||||||
# supress warning for double to float conversion if Double precision is activated
|
# supress warning for double to float conversion if Double precision is activated
|
||||||
ADD_COMPILE_OPTIONS(/wd4244)
|
ADD_COMPILE_OPTIONS(/wd4244)
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
|
||||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
# Allow user to disable PDBs
|
||||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG:FULL /PDBALTPATH:%_PDB% /OPT:REF /OPT:ICF")
|
if(ASSIMP_INSTALL_PDB)
|
||||||
|
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
|
||||||
|
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG:FULL /PDBALTPATH:%_PDB% /OPT:REF /OPT:ICF")
|
||||||
|
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" )
|
ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||||
IF(NOT ASSIMP_HUNTER_ENABLED)
|
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||||
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
@ -652,7 +659,7 @@ ELSE()
|
||||||
IF ( ASSIMP_BUILD_DRACO )
|
IF ( ASSIMP_BUILD_DRACO )
|
||||||
# Primarily for glTF v2
|
# Primarily for glTF v2
|
||||||
# Enable Draco glTF feature set
|
# Enable Draco glTF feature set
|
||||||
set(DRACO_GLTF ON CACHE BOOL "" FORCE)
|
set(DRACO_GLTF_BITSTREAM ON CACHE BOOL "" FORCE)
|
||||||
# Disable unnecessary or omitted components
|
# Disable unnecessary or omitted components
|
||||||
set(DRACO_JS_GLUE OFF CACHE BOOL "" FORCE)
|
set(DRACO_JS_GLUE OFF CACHE BOOL "" FORCE)
|
||||||
set(DRACO_WASM OFF CACHE BOOL "" FORCE)
|
set(DRACO_WASM OFF CACHE BOOL "" FORCE)
|
||||||
|
|
|
@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/StringComparison.h>
|
#include <assimp/StringComparison.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/Exporter.hpp>
|
#include <assimp/Exporter.hpp>
|
||||||
|
#include <assimp/Exceptional.h>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
|
@ -249,10 +249,10 @@ void D3MFExporter::writeBaseMaterials() {
|
||||||
if (color.r <= 1 && color.g <= 1 && color.b <= 1 && color.a <= 1) {
|
if (color.r <= 1 && color.g <= 1 && color.b <= 1 && color.a <= 1) {
|
||||||
|
|
||||||
hexDiffuseColor = ai_rgba2hex(
|
hexDiffuseColor = ai_rgba2hex(
|
||||||
(int)((ai_real)color.r) * 255,
|
(int)(((ai_real)color.r) * 255),
|
||||||
(int)((ai_real)color.g) * 255,
|
(int)(((ai_real)color.g) * 255),
|
||||||
(int)((ai_real)color.b) * 255,
|
(int)(((ai_real)color.b) * 255),
|
||||||
(int)((ai_real)color.a) * 255,
|
(int)(((ai_real)color.a) * 255),
|
||||||
true);
|
true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -1217,10 +1217,8 @@ void FBXExporter::WriteObjects ()
|
||||||
}
|
}
|
||||||
|
|
||||||
// colors, if any
|
// colors, if any
|
||||||
// TODO only one color channel currently
|
for (size_t ci = 0; ci < m->GetNumColorChannels(); ++ci) {
|
||||||
const int32_t colorChannelIndex = 0;
|
FBX::Node vertexcolors("LayerElementColor", int32_t(ci));
|
||||||
if (m->HasVertexColors(colorChannelIndex)) {
|
|
||||||
FBX::Node vertexcolors("LayerElementColor", int32_t(colorChannelIndex));
|
|
||||||
vertexcolors.Begin(outstream, binary, indent);
|
vertexcolors.Begin(outstream, binary, indent);
|
||||||
vertexcolors.DumpProperties(outstream, binary, indent);
|
vertexcolors.DumpProperties(outstream, binary, indent);
|
||||||
vertexcolors.EndProperties(outstream, binary, indent);
|
vertexcolors.EndProperties(outstream, binary, indent);
|
||||||
|
@ -1230,7 +1228,7 @@ void FBXExporter::WriteObjects ()
|
||||||
"Version", int32_t(101), outstream, binary, indent
|
"Version", int32_t(101), outstream, binary, indent
|
||||||
);
|
);
|
||||||
char layerName[8];
|
char layerName[8];
|
||||||
snprintf(layerName, sizeof(layerName), "COLOR_%d", colorChannelIndex);
|
snprintf(layerName, sizeof(layerName), "COLOR_%d", int32_t(ci));
|
||||||
FBX::Node::WritePropertyNode(
|
FBX::Node::WritePropertyNode(
|
||||||
"Name", (const char*)layerName, outstream, binary, indent
|
"Name", (const char*)layerName, outstream, binary, indent
|
||||||
);
|
);
|
||||||
|
@ -1247,7 +1245,7 @@ void FBXExporter::WriteObjects ()
|
||||||
for (size_t fi = 0; fi < m->mNumFaces; ++fi) {
|
for (size_t fi = 0; fi < m->mNumFaces; ++fi) {
|
||||||
const aiFace &f = m->mFaces[fi];
|
const aiFace &f = m->mFaces[fi];
|
||||||
for (size_t pvi = 0; pvi < f.mNumIndices; ++pvi) {
|
for (size_t pvi = 0; pvi < f.mNumIndices; ++pvi) {
|
||||||
const aiColor4D &c = m->mColors[colorChannelIndex][f.mIndices[pvi]];
|
const aiColor4D &c = m->mColors[ci][f.mIndices[pvi]];
|
||||||
color_data.push_back(c.r);
|
color_data.push_back(c.r);
|
||||||
color_data.push_back(c.g);
|
color_data.push_back(c.g);
|
||||||
color_data.push_back(c.b);
|
color_data.push_back(c.b);
|
||||||
|
@ -1354,11 +1352,14 @@ void FBXExporter::WriteObjects ()
|
||||||
le.AddChild("Type", "LayerElementNormal");
|
le.AddChild("Type", "LayerElementNormal");
|
||||||
le.AddChild("TypedIndex", int32_t(0));
|
le.AddChild("TypedIndex", int32_t(0));
|
||||||
layer.AddChild(le);
|
layer.AddChild(le);
|
||||||
// TODO only 1 color channel currently
|
|
||||||
le = FBX::Node("LayerElement");
|
for (size_t ci = 0; ci < m->GetNumColorChannels(); ++ci) {
|
||||||
le.AddChild("Type", "LayerElementColor");
|
le = FBX::Node("LayerElement");
|
||||||
le.AddChild("TypedIndex", int32_t(0));
|
le.AddChild("Type", "LayerElementColor");
|
||||||
layer.AddChild(le);
|
le.AddChild("TypedIndex", int32_t(ci));
|
||||||
|
layer.AddChild(le);
|
||||||
|
}
|
||||||
|
|
||||||
le = FBX::Node("LayerElement");
|
le = FBX::Node("LayerElement");
|
||||||
le.AddChild("Type", "LayerElementMaterial");
|
le.AddChild("Type", "LayerElementMaterial");
|
||||||
le.AddChild("TypedIndex", int32_t(0));
|
le.AddChild("TypedIndex", int32_t(0));
|
||||||
|
|
|
@ -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]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "../../../contrib/tinyusdz/assimp_tinyusdz_logging.inc"
|
#include "../../../contrib/tinyusdz/assimp_tinyusdz_logging.inc"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
static constexpr char Tag[] = "tinyusdz loader";
|
static constexpr char TAG[] = "tinyusdz loader";
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
|
@ -1334,7 +1334,7 @@ ADD_LIBRARY(assimp::assimp ALIAS assimp)
|
||||||
IF (BUILD_SHARED_LIBS)
|
IF (BUILD_SHARED_LIBS)
|
||||||
TARGET_COMPILE_DEFINITIONS(assimp PRIVATE ASSIMP_BUILD_DLL_EXPORT)
|
TARGET_COMPILE_DEFINITIONS(assimp PRIVATE ASSIMP_BUILD_DLL_EXPORT)
|
||||||
ELSE ()
|
ELSE ()
|
||||||
TARGET_COMPILE_DEFINITIONS(assimp PRIVATE OPENDDL_STATIC_LIBARY)
|
TARGET_COMPILE_DEFINITIONS(assimp PRIVATE OPENDDL_STATIC_LIBARY P2T_STATIC_EXPORTS)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp)
|
TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp)
|
||||||
|
@ -1575,7 +1575,7 @@ if(MSVC AND ASSIMP_INSTALL_PDB)
|
||||||
COMPILE_PDB_NAME_DEBUG assimp${LIBRARY_SUFFIX}${CMAKE_DEBUG_POSTFIX}
|
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
|
install(FILES ${Assimp_BINARY_DIR}/code/Debug/assimp${LIBRARY_SUFFIX}${CMAKE_DEBUG_POSTFIX}.pdb
|
||||||
DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||||
CONFIGURATIONS Debug
|
CONFIGURATIONS Debug
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -93,6 +93,10 @@ static std::string WideToUtf8(const wchar_t *in) {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Tests for the existence of a file at the given path.
|
// Tests for the existence of a file at the given path.
|
||||||
bool DefaultIOSystem::Exists(const char *pFile) const {
|
bool DefaultIOSystem::Exists(const char *pFile) const {
|
||||||
|
if (pFile == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
struct __stat64 filestat;
|
struct __stat64 filestat;
|
||||||
if (_wstat64(Utf8ToWide(pFile).c_str(), &filestat) != 0) {
|
if (_wstat64(Utf8ToWide(pFile).c_str(), &filestat) != 0) {
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,9 +143,13 @@ bool FindDegeneratesProcess::ExecuteOnMesh(aiMesh *mesh) {
|
||||||
for (unsigned int a = 0; a < mesh->mNumFaces; ++a) {
|
for (unsigned int a = 0; a < mesh->mNumFaces; ++a) {
|
||||||
aiFace &face = mesh->mFaces[a];
|
aiFace &face = mesh->mFaces[a];
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
auto vertex_in_range = [numVertices = mesh->mNumVertices](unsigned int vertex_idx) { return vertex_idx < numVertices; };
|
||||||
|
|
||||||
// check whether the face contains degenerated entries
|
// check whether the face contains degenerated entries
|
||||||
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
|
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
|
||||||
|
if (!std::all_of(face.mIndices, face.mIndices + face.mNumIndices, vertex_in_range))
|
||||||
|
continue;
|
||||||
|
|
||||||
// Polygons with more than 4 points are allowed to have double points, that is
|
// Polygons with more than 4 points are allowed to have double points, that is
|
||||||
// simulating polygons with holes just with concave polygons. However,
|
// simulating polygons with holes just with concave polygons. However,
|
||||||
// double points may not come directly after another.
|
// double points may not come directly after another.
|
||||||
|
|
|
@ -380,3 +380,4 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh(aiMesh *pMesh, unsigned int mes
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Assimp
|
} // namespace Assimp
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,9 @@
|
||||||
# define P2T_DLL_SYMBOL
|
# define P2T_DLL_SYMBOL
|
||||||
# elif defined(P2T_SHARED_EXPORTS)
|
# elif defined(P2T_SHARED_EXPORTS)
|
||||||
# define P2T_DLL_SYMBOL P2T_COMPILER_DLLEXPORT
|
# define P2T_DLL_SYMBOL P2T_COMPILER_DLLEXPORT
|
||||||
# else
|
# elif defined(BUILD_SHARED_LIBS)
|
||||||
# define P2T_DLL_SYMBOL P2T_COMPILER_DLLIMPORT
|
# define P2T_DLL_SYMBOL P2T_COMPILER_DLLIMPORT
|
||||||
|
# else
|
||||||
|
# define P2T_DLL_SYMBOL
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,7 +57,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#pragma GCC system_header
|
#pragma GCC system_header
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assimp/StringComparison.h>
|
|
||||||
#include <assimp/ai_assert.h>
|
#include <assimp/ai_assert.h>
|
||||||
#include <assimp/defs.h>
|
#include <assimp/defs.h>
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -206,3 +206,38 @@ TEST_F(FindDegeneratesProcessTest, meshRemoval) {
|
||||||
EXPECT_EQ(scene->mRootNode->mNumMeshes, 1u);
|
EXPECT_EQ(scene->mRootNode->mNumMeshes, 1u);
|
||||||
EXPECT_EQ(scene->mRootNode->mMeshes[0], 0u);
|
EXPECT_EQ(scene->mRootNode->mMeshes[0], 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(FindDegeneratesProcessTest, invalidVertexIndex) {
|
||||||
|
mProcess->EnableAreaCheck(true);
|
||||||
|
mProcess->EnableInstantRemoval(true);
|
||||||
|
mProcess->ExecuteOnMesh(mMesh);
|
||||||
|
|
||||||
|
std::unique_ptr<aiScene> scene(new aiScene);
|
||||||
|
scene->mNumMeshes = 1;
|
||||||
|
scene->mMeshes = new aiMesh *[1];
|
||||||
|
|
||||||
|
std::unique_ptr<aiMesh> mesh(new aiMesh);
|
||||||
|
mesh->mNumVertices = 1;
|
||||||
|
mesh->mVertices = new aiVector3D[1];
|
||||||
|
mesh->mVertices[0] = aiVector3D{ 0.0f, 0.0f, 0.0f };
|
||||||
|
mesh->mNumFaces = 1;
|
||||||
|
mesh->mFaces = new aiFace[1];
|
||||||
|
mesh->mFaces[0].mNumIndices = 3;
|
||||||
|
mesh->mFaces[0].mIndices = new unsigned int[3];
|
||||||
|
mesh->mFaces[0].mIndices[0] = 0;
|
||||||
|
mesh->mFaces[0].mIndices[1] = 1;
|
||||||
|
mesh->mFaces[0].mIndices[2] = 99999;
|
||||||
|
|
||||||
|
scene->mMeshes[0] = mesh.release();
|
||||||
|
|
||||||
|
scene->mRootNode = new aiNode;
|
||||||
|
scene->mRootNode->mNumMeshes = 1;
|
||||||
|
scene->mRootNode->mMeshes = new unsigned int[1];
|
||||||
|
scene->mRootNode->mMeshes[0] = 0;
|
||||||
|
|
||||||
|
mProcess->Execute(scene.get());
|
||||||
|
|
||||||
|
EXPECT_EQ(scene->mNumMeshes, 1u);
|
||||||
|
EXPECT_EQ(scene->mRootNode->mNumMeshes, 1u);
|
||||||
|
EXPECT_EQ(scene->mRootNode->mMeshes[0], 0u);
|
||||||
|
}
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue