Merge branch 'master' into master
commit
2ff9fcb1a4
|
@ -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
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ IF (WIN32)
|
|||
|
||||
IF(MSVC)
|
||||
OPTION( ASSIMP_INSTALL_PDB
|
||||
"Install MSVC debug files."
|
||||
"Create MSVC debug symbol files and add to Install target."
|
||||
ON )
|
||||
IF(NOT (MSVC_VERSION LESS 1900))
|
||||
# Multibyte character set has been deprecated since at least MSVC2015 (possibly earlier)
|
||||
|
@ -299,8 +299,15 @@ ELSEIF(MSVC)
|
|||
# supress warning for double to float conversion if Double precision is activated
|
||||
ADD_COMPILE_OPTIONS(/wd4244)
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG:FULL /PDBALTPATH:%_PDB% /OPT:REF /OPT:ICF")
|
||||
# Allow user to disable PDBs
|
||||
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" )
|
||||
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
@ -643,7 +650,7 @@ ELSE()
|
|||
IF ( ASSIMP_BUILD_DRACO )
|
||||
# Primarily for glTF v2
|
||||
# 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
|
||||
set(DRACO_JS_GLUE 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/DefaultLogger.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
|
|
@ -249,10 +249,10 @@ void D3MFExporter::writeBaseMaterials() {
|
|||
if (color.r <= 1 && color.g <= 1 && color.b <= 1 && color.a <= 1) {
|
||||
|
||||
hexDiffuseColor = ai_rgba2hex(
|
||||
(int)((ai_real)color.r) * 255,
|
||||
(int)((ai_real)color.g) * 255,
|
||||
(int)((ai_real)color.b) * 255,
|
||||
(int)((ai_real)color.a) * 255,
|
||||
(int)(((ai_real)color.r) * 255),
|
||||
(int)(((ai_real)color.g) * 255),
|
||||
(int)(((ai_real)color.b) * 255),
|
||||
(int)(((ai_real)color.a) * 255),
|
||||
true);
|
||||
|
||||
} 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|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);
|
||||
|
|
|
@ -1217,10 +1217,8 @@ void FBXExporter::WriteObjects ()
|
|||
}
|
||||
|
||||
// colors, if any
|
||||
// TODO only one color channel currently
|
||||
const int32_t colorChannelIndex = 0;
|
||||
if (m->HasVertexColors(colorChannelIndex)) {
|
||||
FBX::Node vertexcolors("LayerElementColor", int32_t(colorChannelIndex));
|
||||
for (size_t ci = 0; ci < m->GetNumColorChannels(); ++ci) {
|
||||
FBX::Node vertexcolors("LayerElementColor", int32_t(ci));
|
||||
vertexcolors.Begin(outstream, binary, indent);
|
||||
vertexcolors.DumpProperties(outstream, binary, indent);
|
||||
vertexcolors.EndProperties(outstream, binary, indent);
|
||||
|
@ -1230,7 +1228,7 @@ void FBXExporter::WriteObjects ()
|
|||
"Version", int32_t(101), outstream, binary, indent
|
||||
);
|
||||
char layerName[8];
|
||||
snprintf(layerName, sizeof(layerName), "COLOR_%d", colorChannelIndex);
|
||||
snprintf(layerName, sizeof(layerName), "COLOR_%d", int32_t(ci));
|
||||
FBX::Node::WritePropertyNode(
|
||||
"Name", (const char*)layerName, outstream, binary, indent
|
||||
);
|
||||
|
@ -1247,7 +1245,7 @@ void FBXExporter::WriteObjects ()
|
|||
for (size_t fi = 0; fi < m->mNumFaces; ++fi) {
|
||||
const aiFace &f = m->mFaces[fi];
|
||||
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.g);
|
||||
color_data.push_back(c.b);
|
||||
|
@ -1354,11 +1352,14 @@ void FBXExporter::WriteObjects ()
|
|||
le.AddChild("Type", "LayerElementNormal");
|
||||
le.AddChild("TypedIndex", int32_t(0));
|
||||
layer.AddChild(le);
|
||||
// TODO only 1 color channel currently
|
||||
le = FBX::Node("LayerElement");
|
||||
le.AddChild("Type", "LayerElementColor");
|
||||
le.AddChild("TypedIndex", int32_t(0));
|
||||
layer.AddChild(le);
|
||||
|
||||
for (size_t ci = 0; ci < m->GetNumColorChannels(); ++ci) {
|
||||
le = FBX::Node("LayerElement");
|
||||
le.AddChild("Type", "LayerElementColor");
|
||||
le.AddChild("TypedIndex", int32_t(ci));
|
||||
layer.AddChild(le);
|
||||
}
|
||||
|
||||
le = FBX::Node("LayerElement");
|
||||
le.AddChild("Type", "LayerElementMaterial");
|
||||
le.AddChild("TypedIndex", int32_t(0));
|
||||
|
|
|
@ -63,7 +63,8 @@ struct HL1ImportSettings {
|
|||
read_bone_controllers(false),
|
||||
read_hitboxes(false),
|
||||
read_textures(false),
|
||||
read_misc_global_info(false) {
|
||||
read_misc_global_info(false),
|
||||
transform_coord_system(true) {
|
||||
}
|
||||
|
||||
bool read_animations;
|
||||
|
@ -76,6 +77,7 @@ struct HL1ImportSettings {
|
|||
bool read_hitboxes;
|
||||
bool read_textures;
|
||||
bool read_misc_global_info;
|
||||
bool transform_coord_system;
|
||||
};
|
||||
|
||||
} // namespace HalfLife
|
||||
|
|
|
@ -99,7 +99,7 @@ MDLImporter::MDLImporter() :
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool MDLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||
static const uint32_t tokens[] = {
|
||||
static constexpr uint32_t tokens[] = {
|
||||
AI_MDL_MAGIC_NUMBER_LE_HL2a,
|
||||
AI_MDL_MAGIC_NUMBER_LE_HL2b,
|
||||
AI_MDL_MAGIC_NUMBER_LE_GS7,
|
||||
|
@ -138,6 +138,7 @@ void MDLImporter::SetupProperties(const Importer *pImp) {
|
|||
mHL1ImportSettings.read_bone_controllers = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_BONE_CONTROLLERS, true);
|
||||
mHL1ImportSettings.read_hitboxes = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_HITBOXES, true);
|
||||
mHL1ImportSettings.read_misc_global_info = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO, true);
|
||||
mHL1ImportSettings.transform_coord_system = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_TRANSFORM_COORD_SYSTEM);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -146,6 +147,20 @@ const aiImporterDesc *MDLImporter::GetInfo() const {
|
|||
return &desc;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void transformCoordinateSystem(const aiScene *pScene) {
|
||||
if (pScene == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
pScene->mRootNode->mTransformation = aiMatrix4x4(
|
||||
0.f, -1.f, 0.f, 0.f,
|
||||
0.f, 0.f, 1.f, 0.f,
|
||||
-1.f, 0.f, 0.f, 0.f,
|
||||
0.f, 0.f, 0.f, 1.f
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void MDLImporter::InternReadFile(const std::string &pFile,
|
||||
|
@ -246,18 +261,16 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
|||
". Magic word (", ai_str_toprintable((const char *)&iMagicWord, sizeof(iMagicWord)), ") is not known");
|
||||
}
|
||||
|
||||
if (is_half_life){
|
||||
if (is_half_life && mHL1ImportSettings.transform_coord_system) {
|
||||
// Now rotate the whole scene 90 degrees around the z and x axes to convert to internal coordinate system
|
||||
pScene->mRootNode->mTransformation = aiMatrix4x4(
|
||||
0.f, -1.f, 0.f, 0.f,
|
||||
0.f, 0.f, 1.f, 0.f,
|
||||
-1.f, 0.f, 0.f, 0.f,
|
||||
0.f, 0.f, 0.f, 1.f);
|
||||
}
|
||||
else {
|
||||
transformCoordinateSystem(pScene);
|
||||
} else {
|
||||
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||
pScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f,
|
||||
0.f, 0.f, 1.f, 0.f, 0.f, -1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f);
|
||||
pScene->mRootNode->mTransformation = aiMatrix4x4(
|
||||
1.f, 0.f, 0.f, 0.f,
|
||||
0.f, 0.f, 1.f, 0.f,
|
||||
0.f, -1.f, 0.f, 0.f,
|
||||
0.f, 0.f, 0.f, 1.f);
|
||||
}
|
||||
|
||||
DeleteBufferAndCleanup();
|
||||
|
|
|
@ -730,10 +730,12 @@ void MDLImporter::SkipSkinLump_3DGS_MDL7(
|
|||
// if an ASCII effect description (HLSL?) is contained in the file,
|
||||
// we can simply ignore it ...
|
||||
if (iType & AI_MDL7_SKINTYPE_MATERIAL_ASCDEF) {
|
||||
VALIDATE_FILE_SIZE(szCurrent + sizeof(int32_t));
|
||||
int32_t iMe = 0;
|
||||
::memcpy(&iMe, szCurrent, sizeof(int32_t));
|
||||
AI_SWAP4(iMe);
|
||||
szCurrent += sizeof(char) * iMe + sizeof(int32_t);
|
||||
VALIDATE_FILE_SIZE(szCurrent);
|
||||
}
|
||||
*szCurrentOut = szCurrent;
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -37,11 +36,9 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@author: Richard Steffen, 2015
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_STEP_EXPORTER
|
||||
|
||||
|
|
|
@ -1,43 +1,42 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.cpp
|
||||
* @brief Implementation of the USD importer class
|
||||
|
@ -87,8 +86,7 @@ USDImporter::USDImporter() :
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
bool USDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const {
|
||||
UNUSED(checkSig);
|
||||
bool USDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool) const {
|
||||
// Based on token
|
||||
static const uint32_t usdcTokens[] = { AI_MAKE_MAGIC("PXR-USDC") };
|
||||
bool canRead = CheckMagicToken(pIOHandler, pFile, usdcTokens, AI_COUNT_OF(usdcTokens));
|
||||
|
@ -123,3 +121,4 @@ void USDImporter::InternReadFile(
|
|||
} // namespace Assimp
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_USD_IMPORTER
|
||||
|
||||
|
|
|
@ -4,39 +4,39 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.h
|
||||
* @brief Declaration of the USD importer class.
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.cpp
|
||||
* @brief Implementation of the USD importer class
|
||||
|
@ -72,7 +72,7 @@ Copyright (c) 2006-2024, assimp team
|
|||
#include "../../../contrib/tinyusdz/assimp_tinyusdz_logging.inc"
|
||||
|
||||
namespace {
|
||||
const char *const TAG = "tinyusdz loader";
|
||||
static constexpr char TAG[] = "tinyusdz loader";
|
||||
}
|
||||
|
||||
namespace Assimp {
|
||||
|
@ -81,9 +81,7 @@ using namespace std;
|
|||
void USDImporterImplTinyusdz::InternReadFile(
|
||||
const std::string &pFile,
|
||||
aiScene *pScene,
|
||||
IOSystem *pIOHandler) {
|
||||
UNUSED(pIOHandler);
|
||||
UNUSED(TAG); // Ignore unused variable when -Werror enabled
|
||||
IOSystem *) {
|
||||
// Grab filename for logging purposes
|
||||
size_t pos = pFile.find_last_of('/');
|
||||
string basePath = pFile.substr(0, pos);
|
||||
|
|
|
@ -4,39 +4,40 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.h
|
||||
* @brief Declaration of the USD importer class.
|
||||
|
|
|
@ -1,3 +1,44 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_USD_IMPORTER
|
||||
#include "USDLoaderImplTinyusdzHelper.h"
|
||||
|
||||
|
|
|
@ -1,3 +1,44 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef AI_USDLOADER_IMPL_TINYUSDZ_HELPER_H_INCLUDED
|
||||
#define AI_USDLOADER_IMPL_TINYUSDZ_HELPER_H_INCLUDED
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.cpp
|
||||
* @brief Implementation of the USD importer class
|
||||
|
|
|
@ -4,39 +4,40 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file USDLoader.h
|
||||
* @brief Declaration of the USD importer class.
|
||||
|
@ -45,15 +46,15 @@ Copyright (c) 2006-2024, assimp team
|
|||
#ifndef AI_USDLOADER_UTIL_H_INCLUDED
|
||||
#define AI_USDLOADER_UTIL_H_INCLUDED
|
||||
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/types.h>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
bool isUsda(const std::string &pFile);
|
||||
bool isUsdc(const std::string &pFile);
|
||||
bool isUsdz(const std::string &pFile);
|
||||
bool isUsd(const std::string &pFile);
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // AI_USDLOADER_UTIL_H_INCLUDED
|
||||
|
|
|
@ -1036,10 +1036,10 @@ size_t Accessor::ExtractData(T *&outData, const std::vector<unsigned int> *remap
|
|||
outData = new T[usedCount];
|
||||
|
||||
if (remappingIndices != nullptr) {
|
||||
const unsigned int maxIndex = static_cast<unsigned int>(maxSize / stride - 1);
|
||||
const unsigned int maxIndexCount = static_cast<unsigned int>(maxSize / stride);
|
||||
for (size_t i = 0; i < usedCount; ++i) {
|
||||
size_t srcIdx = (*remappingIndices)[i];
|
||||
if (srcIdx > maxIndex) {
|
||||
if (srcIdx >= maxIndexCount) {
|
||||
throw DeadlyImportError("GLTF: index*stride ", (srcIdx * stride), " > maxSize ", maxSize, " in ", getContextForErrorMessages(id, name));
|
||||
}
|
||||
memcpy(outData + i, data + srcIdx * stride, elemSize);
|
||||
|
|
|
@ -1334,7 +1334,7 @@ ADD_LIBRARY(assimp::assimp ALIAS assimp)
|
|||
IF (BUILD_SHARED_LIBS)
|
||||
TARGET_COMPILE_DEFINITIONS(assimp PRIVATE ASSIMP_BUILD_DLL_EXPORT)
|
||||
ELSE ()
|
||||
TARGET_COMPILE_DEFINITIONS(assimp PRIVATE OPENDDL_STATIC_LIBARY)
|
||||
TARGET_COMPILE_DEFINITIONS(assimp PRIVATE OPENDDL_STATIC_LIBARY P2T_STATIC_EXPORTS)
|
||||
ENDIF ()
|
||||
|
||||
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}
|
||||
)
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -93,6 +93,10 @@ static std::string WideToUtf8(const wchar_t *in) {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Tests for the existence of a file at the given path.
|
||||
bool DefaultIOSystem::Exists(const char *pFile) const {
|
||||
if (pFile == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
struct __stat64 filestat;
|
||||
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 <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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,10 +71,6 @@ SpatialSort::SpatialSort() :
|
|||
mPlaneNormal.Normalize();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor
|
||||
SpatialSort::~SpatialSort() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void SpatialSort::Fill(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
|
|
|
@ -200,8 +200,10 @@ bool CalcTangentsProcess::ProcessMesh(aiMesh *pMesh, unsigned int meshIndex) {
|
|||
localBitangent.NormalizeSafe();
|
||||
|
||||
// reconstruct tangent/bitangent according to normal and bitangent/tangent when it's infinite or NaN.
|
||||
bool invalid_tangent = is_special_float(localTangent.x) || is_special_float(localTangent.y) || is_special_float(localTangent.z);
|
||||
bool invalid_bitangent = is_special_float(localBitangent.x) || is_special_float(localBitangent.y) || is_special_float(localBitangent.z);
|
||||
bool invalid_tangent = is_special_float(localTangent.x) || is_special_float(localTangent.y) || is_special_float(localTangent.z)
|
||||
|| (-0.5f < localTangent.x && localTangent.x < 0.5f && -0.5f < localTangent.y && localTangent.y < 0.5f && -0.5f < localTangent.z && localTangent.z < 0.5f);
|
||||
bool invalid_bitangent = is_special_float(localBitangent.x) || is_special_float(localBitangent.y) || is_special_float(localBitangent.z)
|
||||
|| (-0.5f < localBitangent.x && localBitangent.x < 0.5f && -0.5f < localBitangent.y && localBitangent.y < 0.5f && -0.5f < localBitangent.z && localBitangent.z < 0.5f);
|
||||
if (invalid_tangent != invalid_bitangent) {
|
||||
if (invalid_tangent) {
|
||||
localTangent = meshNorm[p] ^ localBitangent;
|
||||
|
|
|
@ -143,9 +143,13 @@ bool FindDegeneratesProcess::ExecuteOnMesh(aiMesh *mesh) {
|
|||
for (unsigned int a = 0; a < mesh->mNumFaces; ++a) {
|
||||
aiFace &face = mesh->mFaces[a];
|
||||
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
|
||||
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
|
||||
// simulating polygons with holes just with concave polygons. However,
|
||||
// double points may not come directly after another.
|
||||
|
|
|
@ -380,3 +380,4 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh(aiMesh *pMesh, unsigned int mes
|
|||
}
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
|
|
|
@ -192,13 +192,13 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) {
|
|||
|
||||
for( unsigned int a = 0; a < pMesh->mNumFaces; a++) {
|
||||
const aiFace& face = pMesh->mFaces[a];
|
||||
|
||||
if( face.mNumIndices != 3) {
|
||||
bNeed = true;
|
||||
}
|
||||
}
|
||||
if (!bNeed)
|
||||
if (!bNeed) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!(pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON)) {
|
||||
return false;
|
||||
|
@ -213,8 +213,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) {
|
|||
get_normals = false;
|
||||
}
|
||||
if( face.mNumIndices <= 3) {
|
||||
numOut++;
|
||||
|
||||
++numOut;
|
||||
} else {
|
||||
numOut += face.mNumIndices-2;
|
||||
max_out = std::max(max_out,face.mNumIndices);
|
||||
|
@ -222,8 +221,11 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) {
|
|||
}
|
||||
|
||||
// Just another check whether aiMesh::mPrimitiveTypes is correct
|
||||
ai_assert(numOut != pMesh->mNumFaces);
|
||||
|
||||
if (numOut == pMesh->mNumFaces) {
|
||||
ASSIMP_LOG_ERROR( "Invalidation detected in the number of indices: does not fit to the primitive type." );
|
||||
return false;
|
||||
}
|
||||
|
||||
aiVector3D *nor_out = nullptr;
|
||||
|
||||
// if we don't have normals yet, but expect them to be a cheap side
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
http://code.google.com/p/poly2tri/
|
||||
|
||||
Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
==================
|
||||
INSTALLATION GUIDE
|
||||
==================
|
||||
|
||||
------------
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
Core poly2tri lib:
|
||||
- Standard Template Library (STL)
|
||||
|
||||
Testbed:
|
||||
- gcc
|
||||
- OpenGL
|
||||
- GLFW (http://glfw.sf.net)
|
||||
- Python
|
||||
|
||||
Waf (http://code.google.com/p/waf/) is used to compile the testbed.
|
||||
A waf script (86kb) is included in the repositoty.
|
||||
|
||||
----------------------------------------------
|
||||
Building the Testbed
|
||||
----------------------------------------------
|
||||
|
||||
Posix/MSYS environment:
|
||||
|
||||
./waf configure
|
||||
./waf build
|
||||
|
||||
Windows command line:
|
||||
|
||||
python waf configure
|
||||
python waf build
|
||||
|
||||
----------------------------------------------
|
||||
Running the Examples
|
||||
----------------------------------------------
|
||||
|
||||
Load data points from a file:
|
||||
p2t <filename> <center_x> <center_y> <zoom>
|
||||
|
||||
Random distribution of points inside a consrained box:
|
||||
p2t random <num_points> <box_radius> <zoom>
|
||||
|
||||
Examples:
|
||||
|
||||
./p2t dude.dat 300 500 2
|
||||
./p2t nazca_monkey.dat 0 0 9
|
||||
|
||||
./p2t random 10 100 5.0
|
||||
./p2t random 1000 20000 0.025
|
|
@ -0,0 +1,101 @@
|
|||
Since there are no Input validation of the data given for triangulation you need
|
||||
to think about this. Poly2Tri does not support repeat points within epsilon.
|
||||
|
||||
* If you have a cyclic function that generates random points make sure you don't
|
||||
add the same coordinate twice.
|
||||
* If you are given input and aren't sure same point exist twice you need to
|
||||
check for this yourself.
|
||||
* Only simple polygons are supported. You may add holes or interior Steiner points
|
||||
* Interior holes must not touch other holes, nor touch the polyline boundary
|
||||
* Use the library in this order:
|
||||
1. Initialize CDT with a simple polyline (this defines the constrained edges)
|
||||
2. Add holes if necessary (also simple polylines)
|
||||
3. Add Steiner points
|
||||
4. Triangulate
|
||||
|
||||
Make sure you understand the preceding notice before posting an issue. If you have
|
||||
an issue not covered by the above, include your data-set with the problem.
|
||||
The only easy day was yesterday; have a nice day. <Mason Green>
|
||||
|
||||
TESTBED INSTALLATION GUIDE
|
||||
==========================
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
Core poly2tri lib:
|
||||
|
||||
* Standard Template Library (STL)
|
||||
|
||||
Unit tests:
|
||||
* Boost (filesystem, test framework)
|
||||
|
||||
Testbed:
|
||||
|
||||
* OpenGL
|
||||
* [GLFW](http://glfw.sf.net)
|
||||
|
||||
Build the library
|
||||
-----------------
|
||||
|
||||
With the ninja build system installed:
|
||||
|
||||
```
|
||||
mkdir build && cd build
|
||||
cmake -GNinja ..
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
Build and run with unit tests
|
||||
----------------------------
|
||||
|
||||
With the ninja build system:
|
||||
|
||||
```
|
||||
mkdir build && cd build
|
||||
cmake -GNinja -DP2T_BUILD_TESTS=ON ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure
|
||||
```
|
||||
|
||||
Build with the testbed
|
||||
-----------------
|
||||
|
||||
```
|
||||
mkdir build && cd build
|
||||
cmake -GNinja -DP2T_BUILD_TESTBED=ON ..
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
Running the Examples
|
||||
--------------------
|
||||
|
||||
Load data points from a file:
|
||||
```
|
||||
build/testbed/p2t <filename> <center_x> <center_y> <zoom>
|
||||
```
|
||||
Load data points from a file and automatically fit the geometry to the window:
|
||||
```
|
||||
build/testbed/p2t <filename>
|
||||
```
|
||||
Random distribution of points inside a constrained box:
|
||||
```
|
||||
build/testbed/p2t random <num_points> <box_radius> <zoom>
|
||||
```
|
||||
Examples:
|
||||
```
|
||||
build/testbed/p2t testbed/data/dude.dat 350 500 3
|
||||
|
||||
build/testbed/p2t testbed/data/nazca_monkey.dat
|
||||
|
||||
build/testbed/p2t random 10 100 5.0
|
||||
build/testbed/p2t random 1000 20000 0.025
|
||||
```
|
||||
|
||||
References
|
||||
==========
|
||||
|
||||
- Domiter V. and Zalik B. (2008) Sweep‐line algorithm for constrained Delaunay triangulation
|
||||
- FlipScan by library author Thomas Åhlén
|
||||
|
||||

|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2022, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* * Neither the name of Poly2Tri nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(_WIN32)
|
||||
# pragma warning( disable: 4273)
|
||||
# define P2T_COMPILER_DLLEXPORT __declspec(dllexport)
|
||||
# define P2T_COMPILER_DLLIMPORT __declspec(dllimport)
|
||||
#elif defined(__GNUC__)
|
||||
# define P2T_COMPILER_DLLEXPORT __attribute__ ((visibility ("default")))
|
||||
# define P2T_COMPILER_DLLIMPORT __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
# define P2T_COMPILER_DLLEXPORT
|
||||
# define P2T_COMPILER_DLLIMPORT
|
||||
#endif
|
||||
|
||||
// We need to enable shard linkage explicitely
|
||||
#ifdef ASSIMP_BUILD_DLL_EXPORT
|
||||
# define P2T_SHARED_EXPORTS 1
|
||||
#endif
|
||||
|
||||
#ifndef P2T_DLL_SYMBOL
|
||||
# if defined(P2T_STATIC_EXPORTS)
|
||||
# define P2T_DLL_SYMBOL
|
||||
# elif defined(P2T_SHARED_EXPORTS)
|
||||
# define P2T_DLL_SYMBOL P2T_COMPILER_DLLEXPORT
|
||||
# elif defined(BUILD_SHARED_LIBS)
|
||||
# define P2T_DLL_SYMBOL P2T_COMPILER_DLLIMPORT
|
||||
# else
|
||||
# define P2T_DLL_SYMBOL
|
||||
# endif
|
||||
#endif
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -29,14 +29,24 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "shapes.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
namespace p2t {
|
||||
|
||||
Point::Point(double x, double y) : x(x), y(y)
|
||||
{
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Point& point) {
|
||||
return out << point.x << "," << point.y;
|
||||
}
|
||||
|
||||
Triangle::Triangle(Point& a, Point& b, Point& c)
|
||||
{
|
||||
points_[0] = &a; points_[1] = &b; points_[2] = &c;
|
||||
neighbors_[0] = NULL; neighbors_[1] = NULL; neighbors_[2] = NULL;
|
||||
neighbors_[0] = nullptr; neighbors_[1] = nullptr; neighbors_[2] = nullptr;
|
||||
constrained_edge[0] = constrained_edge[1] = constrained_edge[2] = false;
|
||||
delaunay_edge[0] = delaunay_edge[1] = delaunay_edge[2] = false;
|
||||
interior_ = false;
|
||||
|
@ -76,39 +86,37 @@ void Triangle::MarkNeighbor(Triangle& t)
|
|||
void Triangle::Clear()
|
||||
{
|
||||
Triangle *t;
|
||||
for( int i=0; i<3; i++ )
|
||||
{
|
||||
t = neighbors_[i];
|
||||
if( t != NULL )
|
||||
{
|
||||
t->ClearNeighbor( this );
|
||||
}
|
||||
for (auto& neighbor : neighbors_) {
|
||||
t = neighbor;
|
||||
if (t != nullptr) {
|
||||
t->ClearNeighbor(this);
|
||||
}
|
||||
}
|
||||
ClearNeighbors();
|
||||
points_[0]=points_[1]=points_[2] = NULL;
|
||||
points_[0]=points_[1]=points_[2] = nullptr;
|
||||
}
|
||||
|
||||
void Triangle::ClearNeighbor(const Triangle *triangle )
|
||||
{
|
||||
if( neighbors_[0] == triangle )
|
||||
{
|
||||
neighbors_[0] = NULL;
|
||||
neighbors_[0] = nullptr;
|
||||
}
|
||||
else if( neighbors_[1] == triangle )
|
||||
{
|
||||
neighbors_[1] = NULL;
|
||||
neighbors_[1] = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
neighbors_[2] = NULL;
|
||||
neighbors_[2] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Triangle::ClearNeighbors()
|
||||
{
|
||||
neighbors_[0] = NULL;
|
||||
neighbors_[1] = NULL;
|
||||
neighbors_[2] = NULL;
|
||||
neighbors_[0] = nullptr;
|
||||
neighbors_[1] = nullptr;
|
||||
neighbors_[2] = nullptr;
|
||||
}
|
||||
|
||||
void Triangle::ClearDelunayEdges()
|
||||
|
@ -220,7 +228,7 @@ Point* Triangle::PointCW(const Point& point)
|
|||
return points_[1];
|
||||
}
|
||||
assert(0);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// The point counter-clockwise to given point
|
||||
|
@ -234,7 +242,18 @@ Point* Triangle::PointCCW(const Point& point)
|
|||
return points_[0];
|
||||
}
|
||||
assert(0);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// The neighbor across to given point
|
||||
Triangle* Triangle::NeighborAcross(const Point& point)
|
||||
{
|
||||
if (&point == points_[0]) {
|
||||
return neighbors_[0];
|
||||
} else if (&point == points_[1]) {
|
||||
return neighbors_[1];
|
||||
}
|
||||
return neighbors_[2];
|
||||
}
|
||||
|
||||
// The neighbor clockwise to given point
|
||||
|
@ -343,23 +362,50 @@ void Triangle::SetDelunayEdgeCW(const Point& p, bool e)
|
|||
}
|
||||
}
|
||||
|
||||
// The neighbor across to given point
|
||||
Triangle& Triangle::NeighborAcross(const Point& opoint)
|
||||
{
|
||||
if (&opoint == points_[0]) {
|
||||
return *neighbors_[0];
|
||||
} else if (&opoint == points_[1]) {
|
||||
return *neighbors_[1];
|
||||
}
|
||||
return *neighbors_[2];
|
||||
}
|
||||
|
||||
void Triangle::DebugPrint()
|
||||
{
|
||||
using namespace std;
|
||||
cout << points_[0]->x << "," << points_[0]->y << " ";
|
||||
cout << points_[1]->x << "," << points_[1]->y << " ";
|
||||
cout << points_[2]->x << "," << points_[2]->y << endl;
|
||||
std::cout << *points_[0] << " " << *points_[1] << " " << *points_[2] << std::endl;
|
||||
}
|
||||
|
||||
bool Triangle::CircumcicleContains(const Point& point) const
|
||||
{
|
||||
assert(IsCounterClockwise());
|
||||
const double dx = points_[0]->x - point.x;
|
||||
const double dy = points_[0]->y - point.y;
|
||||
const double ex = points_[1]->x - point.x;
|
||||
const double ey = points_[1]->y - point.y;
|
||||
const double fx = points_[2]->x - point.x;
|
||||
const double fy = points_[2]->y - point.y;
|
||||
|
||||
const double ap = dx * dx + dy * dy;
|
||||
const double bp = ex * ex + ey * ey;
|
||||
const double cp = fx * fx + fy * fy;
|
||||
|
||||
return (dx * (fy * bp - cp * ey) - dy * (fx * bp - cp * ex) + ap * (fx * ey - fy * ex)) < 0;
|
||||
}
|
||||
|
||||
bool Triangle::IsCounterClockwise() const
|
||||
{
|
||||
return (points_[1]->x - points_[0]->x) * (points_[2]->y - points_[0]->y) -
|
||||
(points_[2]->x - points_[0]->x) * (points_[1]->y - points_[0]->y) >
|
||||
0;
|
||||
}
|
||||
|
||||
bool IsDelaunay(const std::vector<p2t::Triangle*>& triangles)
|
||||
{
|
||||
for (const auto triangle : triangles) {
|
||||
for (const auto other : triangles) {
|
||||
if (triangle == other) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (triangle->CircumcicleContains(*other->GetPoint(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace p2t
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -29,22 +29,24 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// Include guard
|
||||
#ifndef SHAPES_H
|
||||
#define SHAPES_H
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "dll_symbol.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
# pragma warning( disable: 4251)
|
||||
#endif
|
||||
namespace p2t {
|
||||
|
||||
struct Edge;
|
||||
|
||||
struct Point {
|
||||
struct P2T_DLL_SYMBOL Point {
|
||||
|
||||
double x, y;
|
||||
|
||||
|
@ -59,7 +61,7 @@ struct Point {
|
|||
std::vector<Edge*> edge_list;
|
||||
|
||||
/// Construct using coordinates.
|
||||
Point(double x, double y) : x(x), y(y) {}
|
||||
Point(double x, double y);
|
||||
|
||||
/// Set this point to all zeros.
|
||||
void set_zero()
|
||||
|
@ -121,8 +123,10 @@ struct Point {
|
|||
|
||||
};
|
||||
|
||||
P2T_DLL_SYMBOL std::ostream& operator<<(std::ostream&, const Point&);
|
||||
|
||||
// Represents a simple polygon's edge
|
||||
struct Edge {
|
||||
struct P2T_DLL_SYMBOL Edge {
|
||||
|
||||
Point* p, *q;
|
||||
|
||||
|
@ -138,9 +142,7 @@ struct Edge {
|
|||
p = &p2;
|
||||
} else if (p1.x == p2.x) {
|
||||
// Repeat points
|
||||
// ASSIMP_CHANGE (aramis_acg)
|
||||
throw std::runtime_error(std::string("repeat points"));
|
||||
//assert(false);
|
||||
throw std::runtime_error("Edge::Edge: p1 == p2");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +153,7 @@ struct Edge {
|
|||
// Triangle-based data structures are know to have better performance than quad-edge structures
|
||||
// See: J. Shewchuk, "Triangle: Engineering a 2D Quality Mesh Generator and Delaunay Triangulator"
|
||||
// "Triangulations in CGAL"
|
||||
class Triangle {
|
||||
class P2T_DLL_SYMBOL Triangle {
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
|
@ -178,6 +180,7 @@ void MarkConstrainedEdge(Point* p, Point* q);
|
|||
int Index(const Point* p);
|
||||
int EdgeIndex(const Point* p1, const Point* p2);
|
||||
|
||||
Triangle* NeighborAcross(const Point& point);
|
||||
Triangle* NeighborCW(const Point& point);
|
||||
Triangle* NeighborCCW(const Point& point);
|
||||
bool GetConstrainedEdgeCCW(const Point& p);
|
||||
|
@ -205,12 +208,14 @@ void ClearDelunayEdges();
|
|||
inline bool IsInterior();
|
||||
inline void IsInterior(bool b);
|
||||
|
||||
Triangle& NeighborAcross(const Point& opoint);
|
||||
|
||||
void DebugPrint();
|
||||
|
||||
bool CircumcicleContains(const Point&) const;
|
||||
|
||||
private:
|
||||
|
||||
bool IsCounterClockwise() const;
|
||||
|
||||
/// Triangle points
|
||||
Point* points_[3];
|
||||
/// Neighbor list
|
||||
|
@ -258,7 +263,7 @@ inline bool operator ==(const Point& a, const Point& b)
|
|||
|
||||
inline bool operator !=(const Point& a, const Point& b)
|
||||
{
|
||||
return !(a.x == b.x) && !(a.y == b.y);
|
||||
return !(a.x == b.x) || !(a.y == b.y);
|
||||
}
|
||||
|
||||
/// Peform the dot product on two vectors.
|
||||
|
@ -322,6 +327,7 @@ inline void Triangle::IsInterior(bool b)
|
|||
interior_ = b;
|
||||
}
|
||||
|
||||
}
|
||||
/// Is this set a valid delaunay triangulation?
|
||||
P2T_DLL_SYMBOL bool IsDelaunay(const std::vector<p2t::Triangle*>&);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -29,14 +29,15 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
#pragma once
|
||||
|
||||
// Otherwise #defines like M_PI are undeclared under Visual Studio
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include "shapes.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <exception>
|
||||
#include <math.h>
|
||||
|
||||
// C99 removes M_PI from math.h
|
||||
#ifndef M_PI
|
||||
|
@ -66,7 +67,11 @@ Orientation Orient2d(const Point& pa, const Point& pb, const Point& pc)
|
|||
double detleft = (pa.x - pc.x) * (pb.y - pc.y);
|
||||
double detright = (pa.y - pc.y) * (pb.x - pc.x);
|
||||
double val = detleft - detright;
|
||||
if (val > -EPSILON && val < EPSILON) {
|
||||
|
||||
// Using a tolerance here fails on concave-by-subepsilon boundaries
|
||||
// if (val > -EPSILON && val < EPSILON) {
|
||||
// Using == on double makes -Wfloat-equal warnings yell at us
|
||||
if (std::fpclassify(val) == FP_ZERO) {
|
||||
return COLLINEAR;
|
||||
} else if (val > 0) {
|
||||
return CCW;
|
||||
|
@ -123,5 +128,3 @@ bool InScanArea(const Point& pa, const Point& pb, const Point& pc, const Point&
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -29,10 +29,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef POLY2TRI_H
|
||||
#define POLY2TRI_H
|
||||
#pragma once
|
||||
|
||||
#include "common/shapes.h"
|
||||
#include "sweep/cdt.h"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -30,6 +30,8 @@
|
|||
*/
|
||||
#include "advancing_front.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace p2t {
|
||||
|
||||
AdvancingFront::AdvancingFront(Node& head, Node& tail)
|
||||
|
@ -44,21 +46,21 @@ Node* AdvancingFront::LocateNode(double x)
|
|||
Node* node = search_node_;
|
||||
|
||||
if (x < node->value) {
|
||||
while ((node = node->prev) != NULL) {
|
||||
while ((node = node->prev) != nullptr) {
|
||||
if (x >= node->value) {
|
||||
search_node_ = node;
|
||||
return node;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while ((node = node->next) != NULL) {
|
||||
while ((node = node->next) != nullptr) {
|
||||
if (x < node->value) {
|
||||
search_node_ = node->prev;
|
||||
return node->prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Node* AdvancingFront::FindSearchNode(double x)
|
||||
|
@ -86,13 +88,13 @@ Node* AdvancingFront::LocatePoint(const Point* point)
|
|||
}
|
||||
}
|
||||
} else if (px < nx) {
|
||||
while ((node = node->prev) != NULL) {
|
||||
while ((node = node->prev) != nullptr) {
|
||||
if (point == node->point) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while ((node = node->next) != NULL) {
|
||||
while ((node = node->next) != nullptr) {
|
||||
if (point == node->point)
|
||||
break;
|
||||
}
|
||||
|
@ -105,4 +107,4 @@ AdvancingFront::~AdvancingFront()
|
|||
{
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace p2t
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -29,8 +29,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ADVANCED_FRONT_H
|
||||
#define ADVANCED_FRONT_H
|
||||
#pragma once
|
||||
|
||||
#include "../common/shapes.h"
|
||||
|
||||
|
@ -114,5 +113,3 @@ inline void AdvancingFront::set_search(Node* node)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2021, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -68,4 +68,4 @@ CDT::~CDT()
|
|||
delete sweep_;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace p2t
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -29,13 +29,14 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef CDT_H
|
||||
#define CDT_H
|
||||
#pragma once
|
||||
|
||||
#include "advancing_front.h"
|
||||
#include "sweep_context.h"
|
||||
#include "sweep.h"
|
||||
|
||||
#include "../common/dll_symbol.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Mason Green <mason.green@gmail.com>
|
||||
|
@ -44,7 +45,7 @@
|
|||
|
||||
namespace p2t {
|
||||
|
||||
class CDT
|
||||
class P2T_DLL_SYMBOL CDT
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -101,5 +102,3 @@ public:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -28,24 +28,21 @@
|
|||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdexcept>
|
||||
#include "sweep.h"
|
||||
#include "sweep_context.h"
|
||||
#include "advancing_front.h"
|
||||
#include "../common/utils.h"
|
||||
|
||||
namespace p2t {
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning( disable : 4702 )
|
||||
#endif // _MSC_VER
|
||||
namespace p2t {
|
||||
|
||||
// Triangulate simple polygon with holes
|
||||
void Sweep::Triangulate(SweepContext& tcx)
|
||||
{
|
||||
tcx.InitTriangulation();
|
||||
tcx.CreateAdvancingFront(nodes_);
|
||||
tcx.CreateAdvancingFront();
|
||||
// Sweep points; build mesh
|
||||
SweepPoints(tcx);
|
||||
// Clean up
|
||||
|
@ -57,8 +54,8 @@ void Sweep::SweepPoints(SweepContext& tcx)
|
|||
for (size_t i = 1; i < tcx.point_count(); i++) {
|
||||
Point& point = *tcx.GetPoint(i);
|
||||
Node* node = &PointEvent(tcx, point);
|
||||
for (unsigned int ii = 0; ii < point.edge_list.size(); ii++) {
|
||||
EdgeEvent(tcx, point.edge_list[ii], node);
|
||||
for (auto& j : point.edge_list) {
|
||||
EdgeEvent(tcx, j, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,17 +65,25 @@ void Sweep::FinalizationPolygon(SweepContext& tcx)
|
|||
// Get an Internal triangle to start with
|
||||
Triangle* t = tcx.front()->head()->next->triangle;
|
||||
Point* p = tcx.front()->head()->next->point;
|
||||
while (!t->GetConstrainedEdgeCW(*p)) {
|
||||
while (t && !t->GetConstrainedEdgeCW(*p)) {
|
||||
t = t->NeighborCCW(*p);
|
||||
}
|
||||
|
||||
// Collect interior triangles constrained by edges
|
||||
tcx.MeshClean(*t);
|
||||
if (t) {
|
||||
tcx.MeshClean(*t);
|
||||
}
|
||||
}
|
||||
|
||||
Node& Sweep::PointEvent(SweepContext& tcx, Point& point)
|
||||
{
|
||||
Node& node = tcx.LocateNode(point);
|
||||
Node* node_ptr = tcx.LocateNode(point);
|
||||
if (!node_ptr || !node_ptr->point || !node_ptr->next || !node_ptr->next->point)
|
||||
{
|
||||
throw std::runtime_error("PointEvent - null node");
|
||||
}
|
||||
|
||||
Node& node = *node_ptr;
|
||||
Node& new_node = NewFrontTriangle(tcx, point, node);
|
||||
|
||||
// Only need to check +epsilon since point never have smaller
|
||||
|
@ -111,9 +116,9 @@ void Sweep::EdgeEvent(SweepContext& tcx, Edge* edge, Node* node)
|
|||
|
||||
void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangle, Point& point)
|
||||
{
|
||||
if (triangle == nullptr)
|
||||
return;
|
||||
|
||||
if (triangle == nullptr) {
|
||||
throw std::runtime_error("EdgeEvent - null triangle");
|
||||
}
|
||||
if (IsEdgeSideOfTriangle(*triangle, ep, eq)) {
|
||||
return;
|
||||
}
|
||||
|
@ -121,17 +126,14 @@ void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangl
|
|||
Point* p1 = triangle->PointCCW(point);
|
||||
Orientation o1 = Orient2d(eq, *p1, ep);
|
||||
if (o1 == COLLINEAR) {
|
||||
|
||||
|
||||
if( triangle->Contains(&eq, p1)) {
|
||||
triangle->MarkConstrainedEdge(&eq, p1 );
|
||||
if (triangle->Contains(&eq, p1)) {
|
||||
triangle->MarkConstrainedEdge(&eq, p1);
|
||||
// We are modifying the constraint maybe it would be better to
|
||||
// not change the given constraint and just keep a variable for the new constraint
|
||||
tcx.edge_event.constrained_edge->q = p1;
|
||||
triangle = &triangle->NeighborAcross(point);
|
||||
EdgeEvent( tcx, ep, *p1, triangle, *p1 );
|
||||
triangle = triangle->NeighborAcross(point);
|
||||
EdgeEvent(tcx, ep, *p1, triangle, *p1);
|
||||
} else {
|
||||
// ASSIMP_CHANGE (aramis_acg)
|
||||
throw std::runtime_error("EdgeEvent - collinear points not supported");
|
||||
}
|
||||
return;
|
||||
|
@ -140,18 +142,14 @@ void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangl
|
|||
Point* p2 = triangle->PointCW(point);
|
||||
Orientation o2 = Orient2d(eq, *p2, ep);
|
||||
if (o2 == COLLINEAR) {
|
||||
|
||||
|
||||
|
||||
if( triangle->Contains(&eq, p2)) {
|
||||
triangle->MarkConstrainedEdge(&eq, p2 );
|
||||
if (triangle->Contains(&eq, p2)) {
|
||||
triangle->MarkConstrainedEdge(&eq, p2);
|
||||
// We are modifying the constraint maybe it would be better to
|
||||
// not change the given constraint and just keep a variable for the new constraint
|
||||
tcx.edge_event.constrained_edge->q = p2;
|
||||
triangle = &triangle->NeighborAcross(point);
|
||||
EdgeEvent( tcx, ep, *p2, triangle, *p2 );
|
||||
triangle = triangle->NeighborAcross(point);
|
||||
EdgeEvent(tcx, ep, *p2, triangle, *p2);
|
||||
} else {
|
||||
// ASSIMP_CHANGE (aramis_acg)
|
||||
throw std::runtime_error("EdgeEvent - collinear points not supported");
|
||||
}
|
||||
return;
|
||||
|
@ -162,12 +160,13 @@ void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangl
|
|||
// that will cross edge
|
||||
if (o1 == CW) {
|
||||
triangle = triangle->NeighborCCW(point);
|
||||
} else{
|
||||
} else {
|
||||
triangle = triangle->NeighborCW(point);
|
||||
}
|
||||
EdgeEvent(tcx, ep, eq, triangle, point);
|
||||
} else {
|
||||
// This triangle crosses constraint so lets flippin start!
|
||||
assert(triangle);
|
||||
FlipEdgeEvent(tcx, ep, eq, triangle, point);
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +227,6 @@ void Sweep::Fill(SweepContext& tcx, Node& node)
|
|||
if (!Legalize(tcx, *triangle)) {
|
||||
tcx.MapTriangleToNodes(*triangle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
|
||||
|
@ -237,7 +235,7 @@ void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
|
|||
// Fill right holes
|
||||
Node* node = n.next;
|
||||
|
||||
while (node->next) {
|
||||
while (node && node->next) {
|
||||
// if HoleAngle exceeds 90 degrees then break.
|
||||
if (LargeHole_DontFill(node)) break;
|
||||
Fill(tcx, *node);
|
||||
|
@ -247,7 +245,7 @@ void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
|
|||
// Fill left holes
|
||||
node = n.prev;
|
||||
|
||||
while (node->prev) {
|
||||
while (node && node->prev) {
|
||||
// if HoleAngle exceeds 90 degrees then break.
|
||||
if (LargeHole_DontFill(node)) break;
|
||||
Fill(tcx, *node);
|
||||
|
@ -264,6 +262,35 @@ void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
|
|||
}
|
||||
|
||||
// True if HoleAngle exceeds 90 degrees.
|
||||
// LargeHole_DontFill checks if the advancing front has a large hole.
|
||||
// A "Large hole" is a triangle formed by a sequence of points in the advancing
|
||||
// front where three neighbor points form a triangle.
|
||||
// And angle between left-top, bottom, and right-top points is more than 90 degrees.
|
||||
// The first part of the algorithm reviews only three neighbor points, e.g. named A, B, C.
|
||||
// Additional part of this logic reviews a sequence of 5 points -
|
||||
// additionally reviews one point before and one after the sequence of three (A, B, C),
|
||||
// e.g. named X and Y.
|
||||
// In this case, angles are XBC and ABY and this if angles are negative or more
|
||||
// than 90 degrees LargeHole_DontFill returns true.
|
||||
// But there is a configuration when ABC has a negative angle but XBC or ABY is less
|
||||
// than 90 degrees and positive.
|
||||
// Then function LargeHole_DontFill return false and initiates filling.
|
||||
// This filling creates a triangle ABC and adds it to the advancing front.
|
||||
// But in the case when angle ABC is negative this triangle goes inside the advancing front
|
||||
// and can intersect previously created triangles.
|
||||
// This triangle leads to making wrong advancing front and problems in triangulation in the future.
|
||||
// Looks like such a triangle should not be created.
|
||||
// The simplest way to check and fix it is to check an angle ABC.
|
||||
// If it is negative LargeHole_DontFill should return true and
|
||||
// not initiate creating the ABC triangle in the advancing front.
|
||||
// X______A Y
|
||||
// \ /
|
||||
// \ /
|
||||
// \ B /
|
||||
// | /
|
||||
// | /
|
||||
// |/
|
||||
// C
|
||||
bool Sweep::LargeHole_DontFill(const Node* node) const {
|
||||
|
||||
const Node* nextNode = node->next;
|
||||
|
@ -271,20 +298,28 @@ bool Sweep::LargeHole_DontFill(const Node* node) const {
|
|||
if (!AngleExceeds90Degrees(node->point, nextNode->point, prevNode->point))
|
||||
return false;
|
||||
|
||||
if (AngleIsNegative(node->point, nextNode->point, prevNode->point))
|
||||
return true;
|
||||
|
||||
// Check additional points on front.
|
||||
const Node* next2Node = nextNode->next;
|
||||
// "..Plus.." because only want angles on same side as point being added.
|
||||
if ((next2Node != NULL) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, next2Node->point, prevNode->point))
|
||||
if ((next2Node != nullptr) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, next2Node->point, prevNode->point))
|
||||
return false;
|
||||
|
||||
const Node* prev2Node = prevNode->prev;
|
||||
// "..Plus.." because only want angles on same side as point being added.
|
||||
if ((prev2Node != NULL) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, nextNode->point, prev2Node->point))
|
||||
if ((prev2Node != nullptr) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, nextNode->point, prev2Node->point))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Sweep::AngleIsNegative(const Point* origin, const Point* pa, const Point* pb) const {
|
||||
const double angle = Angle(origin, pa, pb);
|
||||
return angle < 0;
|
||||
}
|
||||
|
||||
bool Sweep::AngleExceeds90Degrees(const Point* origin, const Point* pa, const Point* pb) const {
|
||||
const double angle = Angle(origin, pa, pb);
|
||||
return ((angle > PI_div2) || (angle < -PI_div2));
|
||||
|
@ -306,7 +341,7 @@ double Sweep::Angle(const Point* origin, const Point* pa, const Point* pb) const
|
|||
*/
|
||||
const double px = origin->x;
|
||||
const double py = origin->y;
|
||||
const double ax = pa->x- px;
|
||||
const double ax = pa->x - px;
|
||||
const double ay = pa->y - py;
|
||||
const double bx = pb->x - px;
|
||||
const double by = pb->y - py;
|
||||
|
@ -599,7 +634,7 @@ void Sweep::FillRightBelowEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
|||
if (Orient2d(*node.point, *node.next->point, *node.next->next->point) == CCW) {
|
||||
// Concave
|
||||
FillRightConcaveEdgeEvent(tcx, edge, node);
|
||||
} else{
|
||||
} else {
|
||||
// Convex
|
||||
FillRightConvexEdgeEvent(tcx, edge, node);
|
||||
// Retry this one
|
||||
|
@ -623,7 +658,6 @@ void Sweep::FillRightConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Sweep::FillRightConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
||||
|
@ -632,13 +666,13 @@ void Sweep::FillRightConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
|||
if (Orient2d(*node.next->point, *node.next->next->point, *node.next->next->next->point) == CCW) {
|
||||
// Concave
|
||||
FillRightConcaveEdgeEvent(tcx, edge, *node.next);
|
||||
} else{
|
||||
} else {
|
||||
// Convex
|
||||
// Next above or below edge?
|
||||
if (Orient2d(*edge->q, *node.next->next->point, *edge->p) == CCW) {
|
||||
// Below
|
||||
FillRightConvexEdgeEvent(tcx, edge, *node.next);
|
||||
} else{
|
||||
} else {
|
||||
// Above
|
||||
}
|
||||
}
|
||||
|
@ -677,13 +711,13 @@ void Sweep::FillLeftConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
|||
if (Orient2d(*node.prev->point, *node.prev->prev->point, *node.prev->prev->prev->point) == CW) {
|
||||
// Concave
|
||||
FillLeftConcaveEdgeEvent(tcx, edge, *node.prev);
|
||||
} else{
|
||||
} else {
|
||||
// Convex
|
||||
// Next above or below edge?
|
||||
if (Orient2d(*edge->q, *node.prev->prev->point, *edge->p) == CW) {
|
||||
// Below
|
||||
FillLeftConvexEdgeEvent(tcx, edge, *node.prev);
|
||||
} else{
|
||||
} else {
|
||||
// Above
|
||||
}
|
||||
}
|
||||
|
@ -699,17 +733,22 @@ void Sweep::FillLeftConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
|||
if (Orient2d(*node.point, *node.prev->point, *node.prev->prev->point) == CW) {
|
||||
// Next is concave
|
||||
FillLeftConcaveEdgeEvent(tcx, edge, node);
|
||||
} else{
|
||||
} else {
|
||||
// Next is convex
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* t, Point& p)
|
||||
{
|
||||
Triangle& ot = t->NeighborAcross(p);
|
||||
assert(t);
|
||||
Triangle* ot_ptr = t->NeighborAcross(p);
|
||||
if (ot_ptr == nullptr)
|
||||
{
|
||||
throw std::runtime_error("FlipEdgeEvent - null neighbor across");
|
||||
}
|
||||
Triangle& ot = *ot_ptr;
|
||||
Point& op = *ot.OppositePoint(*t, p);
|
||||
|
||||
if (InScanArea(p, *t->PointCCW(p), *t->PointCW(p), op)) {
|
||||
|
@ -775,10 +814,26 @@ Point& Sweep::NextFlipPoint(Point& ep, Point& eq, Triangle& ot, Point& op)
|
|||
void Sweep::FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle& flip_triangle,
|
||||
Triangle& t, Point& p)
|
||||
{
|
||||
Triangle& ot = t.NeighborAcross(p);
|
||||
Point& op = *ot.OppositePoint(t, p);
|
||||
Triangle* ot_ptr = t.NeighborAcross(p);
|
||||
if (ot_ptr == nullptr) {
|
||||
throw std::runtime_error("FlipScanEdgeEvent - null neighbor across");
|
||||
}
|
||||
|
||||
if (InScanArea(eq, *flip_triangle.PointCCW(eq), *flip_triangle.PointCW(eq), op)) {
|
||||
Point* op_ptr = ot_ptr->OppositePoint(t, p);
|
||||
if (op_ptr == nullptr) {
|
||||
throw std::runtime_error("FlipScanEdgeEvent - null opposing point");
|
||||
}
|
||||
|
||||
Point* p1 = flip_triangle.PointCCW(eq);
|
||||
Point* p2 = flip_triangle.PointCW(eq);
|
||||
if (p1 == nullptr || p2 == nullptr) {
|
||||
throw std::runtime_error("FlipScanEdgeEvent - null on either of points");
|
||||
}
|
||||
|
||||
Triangle& ot = *ot_ptr;
|
||||
Point& op = *op_ptr;
|
||||
|
||||
if (InScanArea(eq, *p1, *p2, op)) {
|
||||
// flip with new edge op->eq
|
||||
FlipEdgeEvent(tcx, eq, op, &ot, op);
|
||||
// TODO: Actually I just figured out that it should be possible to
|
||||
|
@ -788,7 +843,7 @@ void Sweep::FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle&
|
|||
// also need to set a new flip_triangle first
|
||||
// Turns out at first glance that this is somewhat complicated
|
||||
// so it will have to wait.
|
||||
} else{
|
||||
} else {
|
||||
Point& newP = NextFlipPoint(ep, eq, ot, op);
|
||||
FlipScanEdgeEvent(tcx, ep, eq, flip_triangle, ot, newP);
|
||||
}
|
||||
|
@ -797,14 +852,9 @@ void Sweep::FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle&
|
|||
Sweep::~Sweep() {
|
||||
|
||||
// Clean up memory
|
||||
for(size_t i = 0; i < nodes_.size(); i++) {
|
||||
delete nodes_[i];
|
||||
for (auto& node : nodes_) {
|
||||
delete node;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning( pop )
|
||||
#endif // _MSC_VER
|
||||
|
||||
}
|
||||
} // namespace p2t
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -33,11 +33,10 @@
|
|||
* Zalik, B.(2008)'Sweep-line algorithm for constrained Delaunay triangulation',
|
||||
* International Journal of Geographical Information Science
|
||||
*
|
||||
* "FlipScan" Constrained Edge Algorithm invented by Thomas ?hl?n, thahlen@gmail.com
|
||||
* "FlipScan" Constrained Edge Algorithm invented by Thomas Åhlén, thahlen@gmail.com
|
||||
*/
|
||||
|
||||
#ifndef SWEEP_H
|
||||
#define SWEEP_H
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -172,6 +171,7 @@ private:
|
|||
// Decision-making about when to Fill hole.
|
||||
// Contributed by ToolmakerSteve2
|
||||
bool LargeHole_DontFill(const Node* node) const;
|
||||
bool AngleIsNegative(const Point* origin, const Point* pa, const Point* pb) const;
|
||||
bool AngleExceeds90Degrees(const Point* origin, const Point* pa, const Point* pb) const;
|
||||
bool AngleExceedsPlus90DegreesOrIsNegative(const Point* origin, const Point* pa, const Point* pb) const;
|
||||
double Angle(const Point* origin, const Point* pa, const Point* pb) const;
|
||||
|
@ -281,5 +281,3 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2022, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -34,13 +34,13 @@
|
|||
|
||||
namespace p2t {
|
||||
|
||||
SweepContext::SweepContext(const std::vector<Point*>& polyline) : points_(polyline),
|
||||
front_(0),
|
||||
head_(0),
|
||||
tail_(0),
|
||||
af_head_(0),
|
||||
af_middle_(0),
|
||||
af_tail_(0)
|
||||
SweepContext::SweepContext(std::vector<Point*> polyline) : points_(std::move(polyline)),
|
||||
front_(nullptr),
|
||||
head_(nullptr),
|
||||
tail_(nullptr),
|
||||
af_head_(nullptr),
|
||||
af_middle_(nullptr),
|
||||
af_tail_(nullptr)
|
||||
{
|
||||
InitEdges(points_);
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ SweepContext::SweepContext(const std::vector<Point*>& polyline) : points_(polyli
|
|||
void SweepContext::AddHole(const std::vector<Point*>& polyline)
|
||||
{
|
||||
InitEdges(polyline);
|
||||
for(unsigned int i = 0; i < polyline.size(); i++) {
|
||||
points_.push_back(polyline[i]);
|
||||
for (auto i : polyline) {
|
||||
points_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,8 @@ void SweepContext::InitTriangulation()
|
|||
double ymax(points_[0]->y), ymin(points_[0]->y);
|
||||
|
||||
// Calculate bounds.
|
||||
for (unsigned int i = 0; i < points_.size(); i++) {
|
||||
Point& p = *points_[i];
|
||||
for (auto& point : points_) {
|
||||
Point& p = *point;
|
||||
if (p.x > xmax)
|
||||
xmax = p.x;
|
||||
if (p.x < xmin)
|
||||
|
@ -87,8 +87,8 @@ void SweepContext::InitTriangulation()
|
|||
|
||||
double dx = kAlpha * (xmax - xmin);
|
||||
double dy = kAlpha * (ymax - ymin);
|
||||
head_ = new Point(xmax + dx, ymin - dy);
|
||||
tail_ = new Point(xmin - dx, ymin - dy);
|
||||
head_ = new Point(xmin - dx, ymin - dy);
|
||||
tail_ = new Point(xmax + dx, ymin - dy);
|
||||
|
||||
// Sort points along y-axis
|
||||
std::sort(points_.begin(), points_.end(), cmp);
|
||||
|
@ -114,18 +114,17 @@ void SweepContext::AddToMap(Triangle* triangle)
|
|||
map_.push_back(triangle);
|
||||
}
|
||||
|
||||
Node& SweepContext::LocateNode(const Point& point)
|
||||
Node* SweepContext::LocateNode(const Point& point)
|
||||
{
|
||||
// TODO implement search tree
|
||||
return *front_->LocateNode(point.x);
|
||||
return front_->LocateNode(point.x);
|
||||
}
|
||||
|
||||
void SweepContext::CreateAdvancingFront(const std::vector<Node*>& nodes)
|
||||
void SweepContext::CreateAdvancingFront()
|
||||
{
|
||||
|
||||
(void) nodes;
|
||||
// Initial triangle
|
||||
Triangle* triangle = new Triangle(*points_[0], *tail_, *head_);
|
||||
Triangle* triangle = new Triangle(*points_[0], *head_, *tail_);
|
||||
|
||||
map_.push_back(triangle);
|
||||
|
||||
|
@ -172,7 +171,7 @@ void SweepContext::MeshClean(Triangle& triangle)
|
|||
Triangle *t = triangles.back();
|
||||
triangles.pop_back();
|
||||
|
||||
if (t != NULL && !t->IsInterior()) {
|
||||
if (t != nullptr && !t->IsInterior()) {
|
||||
t->IsInterior(true);
|
||||
triangles_.push_back(t);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
@ -195,17 +194,13 @@ SweepContext::~SweepContext()
|
|||
delete af_middle_;
|
||||
delete af_tail_;
|
||||
|
||||
typedef std::list<Triangle*> type_list;
|
||||
|
||||
for(type_list::iterator iter = map_.begin(); iter != map_.end(); ++iter) {
|
||||
Triangle* ptr = *iter;
|
||||
delete ptr;
|
||||
for (auto ptr : map_) {
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < edge_list.size(); i++) {
|
||||
delete edge_list[i];
|
||||
for (auto& i : edge_list) {
|
||||
delete i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace p2t
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
* Poly2Tri Copyright (c) 2009-2022, Poly2Tri Contributors
|
||||
* https://github.com/jhasse/poly2tri
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -29,8 +29,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SWEEP_CONTEXT_H
|
||||
#define SWEEP_CONTEXT_H
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
@ -52,7 +51,7 @@ class SweepContext {
|
|||
public:
|
||||
|
||||
/// Constructor
|
||||
SweepContext(const std::vector<Point*>& polyline);
|
||||
explicit SweepContext(std::vector<Point*> polyline);
|
||||
/// Destructor
|
||||
~SweepContext();
|
||||
|
||||
|
@ -66,11 +65,11 @@ Point* tail() const;
|
|||
|
||||
size_t point_count() const;
|
||||
|
||||
Node& LocateNode(const Point& point);
|
||||
Node* LocateNode(const Point& point);
|
||||
|
||||
void RemoveNode(Node* node);
|
||||
|
||||
void CreateAdvancingFront(const std::vector<Node*>& nodes);
|
||||
void CreateAdvancingFront();
|
||||
|
||||
/// Try to map a node to all sides of this triangle that don't have a neighbor
|
||||
void MapTriangleToNodes(Triangle& t);
|
||||
|
@ -103,15 +102,16 @@ struct Basin {
|
|||
double width;
|
||||
bool left_highest;
|
||||
|
||||
Basin() : left_node(NULL), bottom_node(NULL), right_node(NULL), width(0.0), left_highest(false)
|
||||
Basin()
|
||||
: left_node(nullptr), bottom_node(nullptr), right_node(nullptr), width(0.0), left_highest(false)
|
||||
{
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
left_node = NULL;
|
||||
bottom_node = NULL;
|
||||
right_node = NULL;
|
||||
left_node = nullptr;
|
||||
bottom_node = nullptr;
|
||||
right_node = nullptr;
|
||||
width = 0.0;
|
||||
left_highest = false;
|
||||
}
|
||||
|
@ -182,5 +182,3 @@ inline Point* SweepContext::tail() const
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
unsigned int pElementOffset);
|
||||
|
||||
/** Destructor */
|
||||
~SpatialSort();
|
||||
~SpatialSort() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Sets the input data for the SpatialSort. This replaces existing data, if any.
|
||||
|
|
|
@ -57,7 +57,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/defs.h>
|
||||
|
||||
|
|
|
@ -59,6 +59,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/**
|
||||
*/
|
||||
enum aiAnimInterpolation {
|
||||
/** */
|
||||
aiAnimInterpolation_Step,
|
||||
|
||||
/** */
|
||||
aiAnimInterpolation_Linear,
|
||||
|
||||
/** */
|
||||
aiAnimInterpolation_Spherical_Linear,
|
||||
|
||||
/** */
|
||||
aiAnimInterpolation_Cubic_Spline,
|
||||
|
||||
/** */
|
||||
#ifndef SWIG
|
||||
_aiAnimInterpolation_Force32Bit = INT_MAX
|
||||
#endif
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** A time-value pair specifying a certain 3D vector for the given time. */
|
||||
struct aiVectorKey {
|
||||
|
@ -68,21 +90,18 @@ struct aiVectorKey {
|
|||
/** The value of this key */
|
||||
C_STRUCT aiVector3D mValue;
|
||||
|
||||
/** The interpolation setting of this key */
|
||||
C_ENUM aiAnimInterpolation mInterpolation;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/// @brief The default constructor.
|
||||
aiVectorKey() AI_NO_EXCEPT
|
||||
: mTime(0.0),
|
||||
mValue() {
|
||||
// empty
|
||||
}
|
||||
: mTime(0.0), mValue(), mInterpolation(aiAnimInterpolation_Linear) {}
|
||||
|
||||
/// @brief Construction from a given time and key value.
|
||||
|
||||
aiVectorKey(double time, const aiVector3D &value) :
|
||||
mTime(time), mValue(value) {
|
||||
// empty
|
||||
}
|
||||
mTime(time), mValue(value), mInterpolation(aiAnimInterpolation_Linear){}
|
||||
|
||||
typedef aiVector3D elem_type;
|
||||
|
||||
|
@ -116,16 +135,16 @@ struct aiQuatKey {
|
|||
/** The value of this key */
|
||||
C_STRUCT aiQuaternion mValue;
|
||||
|
||||
/** The interpolation setting of this key */
|
||||
C_ENUM aiAnimInterpolation mInterpolation;
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiQuatKey() AI_NO_EXCEPT
|
||||
: mTime(0.0),
|
||||
mValue() {
|
||||
// empty
|
||||
}
|
||||
: mTime(0.0), mValue(), mInterpolation(aiAnimInterpolation_Linear) {}
|
||||
|
||||
/** Construction from a given time and key value */
|
||||
aiQuatKey(double time, const aiQuaternion &value) :
|
||||
mTime(time), mValue(value) {}
|
||||
mTime(time), mValue(value), mInterpolation(aiAnimInterpolation_Linear) {}
|
||||
|
||||
typedef aiQuaternion elem_type;
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -724,6 +724,12 @@ enum aiComponent
|
|||
*/
|
||||
#define AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATION_EVENTS "IMPORT_MDL_HL1_READ_ANIMATION_EVENTS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether you want to convert the HS1 coordinate system in a special way.
|
||||
* The default value is true (S1)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_MDL_HL1_TRANSFORM_COORD_SYSTEM "TRANSFORM COORDSYSTEM FOR HS! MODELS"
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the MDL (HL1) importer will read blend controllers.
|
||||
* \note This property requires AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS to be set to true.
|
||||
|
|
|
@ -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
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -1527,7 +1535,7 @@ ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(
|
|||
const char *pKey,
|
||||
unsigned int type,
|
||||
unsigned int index,
|
||||
ai_real *pOut,
|
||||
float *pOut,
|
||||
unsigned int *pMax);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -1553,7 +1561,7 @@ inline aiReturn aiGetMaterialFloat(const C_STRUCT aiMaterial *pMat,
|
|||
const char *pKey,
|
||||
unsigned int type,
|
||||
unsigned int index,
|
||||
ai_real *pOut) {
|
||||
float *pOut) {
|
||||
return aiGetMaterialFloatArray(pMat, pKey, type, index, pOut, (unsigned int *)0x0);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::GetTexture( aiTextureType type,
|
|||
C_STRUCT aiString* path,
|
||||
aiTextureMapping* mapping /*= NULL*/,
|
||||
unsigned int* uvindex /*= NULL*/,
|
||||
ai_real* blend /*= NULL*/,
|
||||
float* blend /*= NULL*/,
|
||||
aiTextureOp* op /*= NULL*/,
|
||||
aiTextureMapMode* mapmode /*= NULL*/) const {
|
||||
return ::aiGetMaterialTexture(this,type,index,path,mapping,uvindex,blend,op,mapmode);
|
||||
|
@ -136,9 +136,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
|||
// Specialisation for a single bool.
|
||||
// Casts floating point and integer to bool
|
||||
template <>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn
|
||||
aiMaterial::Get(const char *pKey, unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char *pKey, unsigned int type,
|
||||
unsigned int idx, bool &pOut) const {
|
||||
const aiMaterialProperty *prop;
|
||||
const aiReturn ret = ::aiGetMaterialProperty(this, pKey, type, idx,
|
||||
|
@ -193,7 +191,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
|||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,ai_real& pOut) const {
|
||||
unsigned int idx, float& pOut) const {
|
||||
return aiGetMaterialFloat(this,pKey,type,idx,&pOut);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -312,7 +310,6 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const int* pInput,
|
|||
pKey,type,index,aiPTI_Integer);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// The template specializations below are for backwards compatibility.
|
||||
// The recommended way to add material properties is using the non-template
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -206,3 +206,38 @@ TEST_F(FindDegeneratesProcessTest, meshRemoval) {
|
|||
EXPECT_EQ(scene->mRootNode->mNumMeshes, 1u);
|
||||
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_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:
|
||||
|
|
Loading…
Reference in New Issue