pull/3955/head
Evangel 2021-06-12 11:46:20 +10:00
commit 6d413444b5
41 changed files with 721 additions and 460 deletions

View File

@ -1,8 +1,8 @@
--- ---
name: Bug report name: Bug report
about: Create a report to help us improve about: Create a report to help us improve
title: '' title: 'Bug:'
labels: '' labels: 'Bug'
assignees: '' assignees: ''
--- ---
@ -23,16 +23,10 @@ A clear and concise description of what you expected to happen.
**Screenshots** **Screenshots**
If applicable, add screenshots to help explain your problem. If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):** **Platform (please complete the following information):**
- OS: [e.g. iOS] - OS: [e.g. iOS]
- Browser [e.g. chrome, safari] - Browser [e.g. chrome, safari]
- Version [e.g. 22] - Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context** **Additional context**
Add any other context about the problem here. Add any other context about the problem here.

View File

@ -2,7 +2,7 @@
name: Feature request name: Feature request
about: Suggest an idea for this project about: Suggest an idea for this project
title: '' title: ''
labels: '' labels: 'Feature-Request'
assignees: '' assignees: ''
--- ---

View File

@ -0,0 +1,25 @@
---
name: Technical debt
about: Create a report to help us to fix and detect tech debts
title: ''
labels: 'Techdebt'
assignees: ''
---
**Describe the technical debt**
A clear and concise description of what the tech debt is about.
**Better solution**
A clear and concise description of what you would expect.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View File

@ -268,6 +268,8 @@ ELSEIF(MSVC)
ADD_COMPILE_OPTIONS(/wd4351) ADD_COMPILE_OPTIONS(/wd4351)
ENDIF() ENDIF()
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG:FULL /PDBALTPATH:%_PDB% /OPT:REF /OPT:ICF")
ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
IF(NOT ASSIMP_HUNTER_ENABLED) IF(NOT ASSIMP_HUNTER_ENABLED)
SET(CMAKE_CXX_STANDARD 11) SET(CMAKE_CXX_STANDARD 11)
@ -334,9 +336,9 @@ INCLUDE (FindPkgMacros)
INCLUDE (PrecompiledHeader) INCLUDE (PrecompiledHeader)
# Set Assimp project output directory variables. # Set Assimp project output directory variables.
SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for runtime output files")
SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for library output files")
SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib" CACHE STRING "Path for archive output files")
# Macro used to set the output directories of a target to the # Macro used to set the output directories of a target to the
# respective Assimp output directories. # respective Assimp output directories.

View File

@ -42,7 +42,7 @@ Take a look into the https://github.com/assimp/assimp/blob/master/Build.md file.
* [.NET](https://bitbucket.org/Starnick/assimpnet/src/master/) * [.NET](https://bitbucket.org/Starnick/assimpnet/src/master/)
* [Pascal](port/AssimpPascal/Readme.md) * [Pascal](port/AssimpPascal/Readme.md)
* [Javascript (Alpha)](https://github.com/makc/assimp2json) * [Javascript (Alpha)](https://github.com/makc/assimp2json)
* [Unity 3d Plugin](https://www.assetstore.unity3d.com/en/#!/content/91777) * [Unity 3d Plugin](https://ricardoreis.net/trilib-2/)
* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (current [status](https://github.com/kotlin-graphics/assimp/wiki/Status)) * [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (current [status](https://github.com/kotlin-graphics/assimp/wiki/Status))
* [HAXE-Port](https://github.com/longde123/assimp-haxe) The Assimp-HAXE-port. * [HAXE-Port](https://github.com/longde123/assimp-haxe) The Assimp-HAXE-port.
* [Rust](https://github.com/jkvargas/russimp) * [Rust](https://github.com/jkvargas/russimp)

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team Copyright (c) 2006-2021, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -63,11 +61,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp; using namespace Assimp;
// AutoCAD Binary DXF<CR><LF><SUB><NULL> // AutoCAD Binary DXF<CR><LF><SUB><NULL>
const std::string AI_DXF_BINARY_IDENT = std::string("AutoCAD Binary DXF\r\n\x1a\0"); static constexpr char AI_DXF_BINARY_IDENT[] = "AutoCAD Binary DXF\r\n\x1a";
const size_t AI_DXF_BINARY_IDENT_LEN = 24u; static constexpr size_t AI_DXF_BINARY_IDENT_LEN = sizeof AI_DXF_BINARY_IDENT;
// default vertex color that all uncolored vertices will receive // default vertex color that all uncolored vertices will receive
const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f)); static const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
// color indices for DXF - 16 are supported, the table is // color indices for DXF - 16 are supported, the table is
// taken directly from the DXF spec. // taken directly from the DXF spec.
@ -156,10 +154,10 @@ void DXFImporter::InternReadFile( const std::string& filename, aiScene* pScene,
} }
// Check whether this is a binary DXF file - we can't read binary DXF files :-( // Check whether this is a binary DXF file - we can't read binary DXF files :-(
char buff[AI_DXF_BINARY_IDENT_LEN+1] = {0}; char buff[AI_DXF_BINARY_IDENT_LEN] = {0};
file->Read(buff,AI_DXF_BINARY_IDENT_LEN,1); file->Read(buff,AI_DXF_BINARY_IDENT_LEN,1);
if (0 == strncmp(AI_DXF_BINARY_IDENT.c_str(),buff,AI_DXF_BINARY_IDENT_LEN)) { if (0 == memcmp(AI_DXF_BINARY_IDENT,buff,AI_DXF_BINARY_IDENT_LEN)) {
throw DeadlyImportError("DXF: Binary files are not supported at the moment"); throw DeadlyImportError("DXF: Binary files are not supported at the moment");
} }

View File

@ -541,10 +541,17 @@ void FBXExporter::WriteReferences ()
// (before any actual data is written) // (before any actual data is written)
// --------------------------------------------------------------- // ---------------------------------------------------------------
size_t count_nodes(const aiNode* n) { size_t count_nodes(const aiNode* n, const aiNode* root) {
size_t count = 1; size_t count;
if (n == root) {
count = n->mNumMeshes; // (not counting root node)
} else if (n->mNumMeshes > 1) {
count = n->mNumMeshes + 1;
} else {
count = 1;
}
for (size_t i = 0; i < n->mNumChildren; ++i) { for (size_t i = 0; i < n->mNumChildren; ++i) {
count += count_nodes(n->mChildren[i]); count += count_nodes(n->mChildren[i], root);
} }
return count; return count;
} }
@ -714,7 +721,7 @@ void FBXExporter::WriteDefinitions ()
// Model / FbxNode // Model / FbxNode
// <~~ node hierarchy // <~~ node hierarchy
count = int32_t(count_nodes(mScene->mRootNode)) - 1; // (not counting root node) count = int32_t(count_nodes(mScene->mRootNode, mScene->mRootNode));
if (count) { if (count) {
n = FBX::Node("ObjectType", "Model"); n = FBX::Node("ObjectType", "Model");
n.AddChild("Count", count); n.AddChild("Count", count);
@ -2625,17 +2632,14 @@ void FBXExporter::WriteModelNodes(
], ],
new_node_uid new_node_uid
); );
// write model node
FBX::Node m("Model"); aiNode new_node;
// take name from mesh name, if it exists // take name from mesh name, if it exists
std::string name = mScene->mMeshes[node->mMeshes[i]]->mName.C_Str(); new_node.mName = mScene->mMeshes[node->mMeshes[i]]->mName;
name += FBX::SEPARATOR + "Model"; // write model node
m.AddProperties(new_node_uid, name, "Mesh"); WriteModelNode(
m.AddChild("Version", int32_t(232)); outstream, binary, &new_node, new_node_uid, "Mesh", std::vector<std::pair<std::string,aiVector3D>>()
FBX::Node p("Properties70"); );
p.AddP70enum("InheritType", 1);
m.AddChild(p);
m.Dump(outstream, binary, 1);
} }
} }

View File

@ -604,15 +604,15 @@ void MeshGeometry::ReadVertexDataTangents(std::vector<aiVector3D>& tangents_out,
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
static const std::string BinormalIndexToken = "BinormalIndex"; static const char * BinormalIndexToken = "BinormalIndex";
static const std::string BinormalsIndexToken = "BinormalsIndex"; static const char * BinormalsIndexToken = "BinormalsIndex";
void MeshGeometry::ReadVertexDataBinormals(std::vector<aiVector3D>& binormals_out, const Scope& source, void MeshGeometry::ReadVertexDataBinormals(std::vector<aiVector3D>& binormals_out, const Scope& source,
const std::string& MappingInformationType, const std::string& MappingInformationType,
const std::string& ReferenceInformationType) const std::string& ReferenceInformationType)
{ {
const char * str = source.Elements().count( "Binormals" ) > 0 ? "Binormals" : "Binormal"; const char * str = source.Elements().count( "Binormals" ) > 0 ? "Binormals" : "Binormal";
const char * strIdx = source.Elements().count( "Binormals" ) > 0 ? BinormalsIndexToken.c_str() : BinormalIndexToken.c_str(); const char * strIdx = source.Elements().count( "Binormals" ) > 0 ? BinormalsIndexToken : BinormalIndexToken;
ResolveVertexDataArray(binormals_out,source,MappingInformationType,ReferenceInformationType, ResolveVertexDataArray(binormals_out,source,MappingInformationType,ReferenceInformationType,
str, str,
strIdx, strIdx,

View File

@ -55,9 +55,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp { namespace Assimp {
namespace Ogre { namespace Ogre {
const std::string MESH_VERSION_1_8 = "[MeshSerializer_v1.8]"; static constexpr auto MESH_VERSION_1_8 = "[MeshSerializer_v1.8]";
const std::string SKELETON_VERSION_1_8 = "[Serializer_v1.80]"; static constexpr auto SKELETON_VERSION_1_8 = "[Serializer_v1.80]";
const std::string SKELETON_VERSION_1_1 = "[Serializer_v1.10]"; static constexpr auto SKELETON_VERSION_1_1 = "[Serializer_v1.10]";
const unsigned short HEADER_CHUNK_ID = 0x1000; const unsigned short HEADER_CHUNK_ID = 0x1000;

View File

@ -749,22 +749,22 @@ enum MeshAttribute {
TexCoord TexCoord
}; };
static const std::string PosToken = "position"; constexpr auto PosToken = "position";
static const std::string ColToken = "color"; constexpr auto ColToken = "color";
static const std::string NormalToken = "normal"; constexpr auto NormalToken = "normal";
static const std::string TexCoordToken = "texcoord"; constexpr auto TexCoordToken = "texcoord";
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
static MeshAttribute getAttributeByName(const char *attribName) { static MeshAttribute getAttributeByName(const char *attribName) {
ai_assert(nullptr != attribName); ai_assert(nullptr != attribName);
if (0 == strncmp(PosToken.c_str(), attribName, PosToken.size())) { if (0 == strcmp(PosToken, attribName)) {
return Position; return Position;
} else if (0 == strncmp(ColToken.c_str(), attribName, ColToken.size())) { } else if (0 == strcmp(ColToken, attribName)) {
return Color; return Color;
} else if (0 == strncmp(NormalToken.c_str(), attribName, NormalToken.size())) { } else if (0 == strcmp(NormalToken, attribName)) {
return Normal; return Normal;
} else if (0 == strncmp(TexCoordToken.c_str(), attribName, TexCoordToken.size())) { } else if (0 == strcmp(TexCoordToken, attribName)) {
return TexCoord; return TexCoord;
} }

View File

@ -419,7 +419,8 @@ bool PLY::DOM::ParseHeader(IOStreamBuffer<char> &streamBuffer, std::vector<char>
if (PLY::Element::ParseElement(streamBuffer, buffer, &out)) { if (PLY::Element::ParseElement(streamBuffer, buffer, &out)) {
// add the element to the list of elements // add the element to the list of elements
alElements.push_back(out); alElements.push_back(out);
} else if (TokenMatch(buffer, "end_header", 10)) { } else if ( TokenMatch(buffer, "end_header\r", 11) || //checks for header end with /r/n ending
TokenMatch(buffer, "end_header", 10)) { //checks for /n ending, if it doesn't end with /r/n
// we have reached the end of the header // we have reached the end of the header
break; break;
} else { } else {

View File

@ -58,7 +58,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma clang diagnostic ignored "-Wsign-compare" #pragma clang diagnostic ignored "-Wsign-compare"
#elif defined(__GNUC__) #elif defined(__GNUC__)
#pragma GCC diagnostic push #pragma GCC diagnostic push
#if (__GNUC__ > 4)
#pragma GCC diagnostic ignored "-Wbool-compare" #pragma GCC diagnostic ignored "-Wbool-compare"
#endif
#pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-compare"
#endif #endif

View File

@ -1137,6 +1137,9 @@ ELSE()
TARGET_COMPILE_OPTIONS(assimp PRIVATE -Werror) TARGET_COMPILE_OPTIONS(assimp PRIVATE -Werror)
ENDIF() ENDIF()
# adds C_FLAGS required to compile zip.c on old GCC 4.x compiler
TARGET_COMPILE_FEATURES(assimp PUBLIC c_std_99)
TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>

View File

@ -169,7 +169,7 @@ void Logger::debug(const char *message) {
// sometimes importers will include data from the input file // sometimes importers will include data from the input file
// (i.e. node names) in their messages. // (i.e. node names) in their messages.
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) { if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
return; return OnDebug("<fixme: long message discarded>");
} }
return OnDebug(message); return OnDebug(message);
} }
@ -179,7 +179,7 @@ void Logger::verboseDebug(const char *message) {
// SECURITY FIX: see above // SECURITY FIX: see above
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) { if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
return; return OnVerboseDebug("<fixme: long message discarded>");
} }
return OnVerboseDebug(message); return OnVerboseDebug(message);
} }
@ -189,7 +189,7 @@ void Logger::info(const char *message) {
// SECURITY FIX: see above // SECURITY FIX: see above
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) { if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
return; return OnInfo("<fixme: long message discarded>");
} }
return OnInfo(message); return OnInfo(message);
} }
@ -199,7 +199,7 @@ void Logger::warn(const char *message) {
// SECURITY FIX: see above // SECURITY FIX: see above
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) { if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
return; return OnWarn("<fixme: long message discarded>");
} }
return OnWarn(message); return OnWarn(message);
} }
@ -208,7 +208,7 @@ void Logger::warn(const char *message) {
void Logger::error(const char *message) { void Logger::error(const char *message) {
// SECURITY FIX: see above // SECURITY FIX: see above
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) { if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
return; return OnError("<fixme: long message discarded>");
} }
return OnError(message); return OnError(message);
} }

View File

@ -343,9 +343,11 @@ const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const cha
delete pimpl->blob; delete pimpl->blob;
pimpl->blob = nullptr; pimpl->blob = nullptr;
} }
auto baseName = pProperties ? pProperties->GetPropertyString(AI_CONFIG_EXPORT_BLOB_NAME, AI_BLOBIO_MAGIC) : AI_BLOBIO_MAGIC;
std::shared_ptr<IOSystem> old = pimpl->mIOSystem; std::shared_ptr<IOSystem> old = pimpl->mIOSystem;
BlobIOSystem* blobio = new BlobIOSystem(); BlobIOSystem *blobio = new BlobIOSystem(baseName);
pimpl->mIOSystem = std::shared_ptr<IOSystem>( blobio ); pimpl->mIOSystem = std::shared_ptr<IOSystem>( blobio );
if (AI_SUCCESS != Export(pScene,pFormatId,blobio->GetMagicFileName(), pPreprocessing, pProperties)) { if (AI_SUCCESS != Export(pScene,pFormatId,blobio->GetMagicFileName(), pPreprocessing, pProperties)) {

View File

@ -1 +0,0 @@
2.3.0

View File

@ -1,31 +0,0 @@
cache: ccache
language: cpp
matrix:
include:
- os: linux
dist: xenial
compiler: clang
- os: linux
dist: xenial
compiler: gcc
- os: osx
compiler: clang
addons:
apt:
packages:
- cmake
script:
# Output version info for compilers, cmake, and make
- ${CC} -v
- ${CXX} -v
- cmake --version
- make --version
# Clone googletest
- pushd .. && git clone https://github.com/google/googletest.git && popd
# Configure and build
- mkdir _travis_build && cd _travis_build
- cmake -G "Unix Makefiles" -DENABLE_TESTS=ON ..
- make -j10
- ./draco_tests

View File

@ -804,7 +804,7 @@ else()
draco_points_enc) draco_points_enc)
# Library targets that consume the object collections. # Library targets that consume the object collections.
if(MSVC OR WIN32) if(MSVC)
# In order to produce a DLL and import library the Windows tools require # In order to produce a DLL and import library the Windows tools require
# that the exported symbols are part of the DLL target. The unfortunate side # that the exported symbols are part of the DLL target. The unfortunate side
# effect of this is that a single configuration cannot output both the # effect of this is that a single configuration cannot output both the
@ -889,9 +889,6 @@ else()
# For Mac, we need to build a .bundle for the unity plugin. # For Mac, we need to build a .bundle for the unity plugin.
if(APPLE) if(APPLE)
set_target_properties(dracodec_unity PROPERTIES BUNDLE true) set_target_properties(dracodec_unity PROPERTIES BUNDLE true)
elseif(NOT unity_decoder_lib_type STREQUAL STATIC)
set_target_properties(dracodec_unity
PROPERTIES SOVERSION ${DRACO_SOVERSION})
endif() endif()
endif() endif()
@ -916,9 +913,6 @@ else()
# For Mac, we need to build a .bundle for the plugin. # For Mac, we need to build a .bundle for the plugin.
if(APPLE) if(APPLE)
set_target_properties(draco_maya_wrapper PROPERTIES BUNDLE true) set_target_properties(draco_maya_wrapper PROPERTIES BUNDLE true)
else()
set_target_properties(draco_maya_wrapper
PROPERTIES SOVERSION ${DRACO_SOVERSION})
endif() endif()
endif() endif()

View File

@ -2,16 +2,16 @@
<img width="350px" src="docs/artwork/draco3d-vert.svg" /> <img width="350px" src="docs/artwork/draco3d-vert.svg" />
</p> </p>
![Build Status: master](https://travis-ci.org/google/draco.svg?branch=master) [![Build Status](https://github.com/google/draco/workflows/Build/badge.svg)](https://github.com/google/draco/actions?query=workflow%3ABuild)
News News
======= =======
### Version 1.4.1 release ### Version 1.4.1 release
* Using the versioned gstatic.com WASM and Javascript decoders is now * Using the versioned www.gstatic.com WASM and Javascript decoders is now
recommended. To use v1.4.1, use this URL: recommended. To use v1.4.1, use this URL:
* https://www.gstatic.com/draco/versioned/decoders/1.4.1/* * https://www.gstatic.com/draco/versioned/decoders/1.4.1/*
* Replace the * with the files to load. E.g. * Replace the * with the files to load. E.g.
* https://gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.js * https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.js
* This works with the v1.3.6 and v1.4.0 releases, and will work with future * This works with the v1.3.6 and v1.4.0 releases, and will work with future
Draco releases. Draco releases.
* Bug fixes * Bug fixes

View File

@ -6,7 +6,7 @@ set(DRACO_CMAKE_DRACO_BUILD_DEFINITIONS_CMAKE_ 1)
# Utility for controlling the main draco library dependency. This changes in # Utility for controlling the main draco library dependency. This changes in
# shared builds, and when an optional target requires a shared library build. # shared builds, and when an optional target requires a shared library build.
macro(set_draco_target) macro(set_draco_target)
if(MSVC OR WIN32) if(MSVC)
set(draco_dependency draco) set(draco_dependency draco)
set(draco_plugin_dependency ${draco_dependency}) set(draco_plugin_dependency ${draco_dependency})
else() else()
@ -63,6 +63,11 @@ macro(draco_set_build_definitions)
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif() endif()
else()
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
# Ensure 64-bit platforms can support large files.
list(APPEND draco_defines "_LARGEFILE_SOURCE" "_FILE_OFFSET_BITS=64")
endif()
endif() endif()
if(ANDROID) if(ANDROID)
@ -114,4 +119,6 @@ macro(draco_set_build_definitions)
draco_check_emscripten_environment() draco_check_emscripten_environment()
draco_get_required_emscripten_flags(FLAG_LIST_VAR draco_base_cxx_flags) draco_get_required_emscripten_flags(FLAG_LIST_VAR draco_base_cxx_flags)
endif() endif()
draco_configure_sanitizer()
endmacro() endmacro()

View File

@ -1,63 +0,0 @@
if(DRACO_CMAKE_DRACO_FEATURES_CMAKE_)
return()
endif()
set(DRACO_CMAKE_DRACO_FEATURES_CMAKE_ 1)
set(draco_features_file_name "${draco_build_dir}/draco/draco_features.h")
set(draco_features_list)
# Macro that handles tracking of Draco preprocessor symbols for the purpose of
# producing draco_features.h.
#
# draco_enable_feature(FEATURE <feature_name> [TARGETS <target_name>]) FEATURE
# is required. It should be a Draco preprocessor symbol. TARGETS is optional. It
# can be one or more draco targets.
#
# When the TARGETS argument is not present the preproc symbol is added to
# draco_features.h. When it is draco_features.h is unchanged, and
# target_compile_options() is called for each target specified.
macro(draco_enable_feature)
set(def_flags)
set(def_single_arg_opts FEATURE)
set(def_multi_arg_opts TARGETS)
cmake_parse_arguments(DEF "${def_flags}" "${def_single_arg_opts}"
"${def_multi_arg_opts}" ${ARGN})
if("${DEF_FEATURE}" STREQUAL "")
message(FATAL_ERROR "Empty FEATURE passed to draco_enable_feature().")
endif()
# Do nothing/return early if $DEF_FEATURE is already in the list.
list(FIND draco_features_list ${DEF_FEATURE} df_index)
if(NOT df_index EQUAL -1)
return()
endif()
list(LENGTH DEF_TARGETS df_targets_list_length)
if(${df_targets_list_length} EQUAL 0)
list(APPEND draco_features_list ${DEF_FEATURE})
else()
foreach(target ${DEF_TARGETS})
target_compile_definitions(${target} PRIVATE ${DEF_FEATURE})
endforeach()
endif()
endmacro()
# Function for generating draco_features.h.
function(draco_generate_features_h)
file(WRITE "${draco_features_file_name}.new"
"// GENERATED FILE -- DO NOT EDIT\n\n" "#ifndef DRACO_FEATURES_H_\n"
"#define DRACO_FEATURES_H_\n\n")
foreach(feature ${draco_features_list})
file(APPEND "${draco_features_file_name}.new" "#define ${feature}\n")
endforeach()
file(APPEND "${draco_features_file_name}.new"
"\n#endif // DRACO_FEATURES_H_")
# Will replace ${draco_features_file_name} only if the file content has
# changed. This prevents forced Draco rebuilds after CMake runs.
configure_file("${draco_features_file_name}.new"
"${draco_features_file_name}")
file(REMOVE "${draco_features_file_name}.new")
endfunction()

View File

@ -80,6 +80,12 @@ macro(draco_test_cxx_flag)
# Run the actual compile test. # Run the actual compile test.
unset(draco_all_cxx_flags_pass CACHE) unset(draco_all_cxx_flags_pass CACHE)
message("--- Running combined CXX flags test, flags: ${all_cxx_flags}") message("--- Running combined CXX flags test, flags: ${all_cxx_flags}")
# check_cxx_compiler_flag() requires that the flags are a string. When flags
# are passed as a list it will remove the list separators, and attempt to run
# a compile command using list entries concatenated together as a single
# argument. Avoid the problem by forcing the argument to be a string.
draco_set_and_stringify(SOURCE_VARS all_cxx_flags DEST all_cxx_flags)
check_cxx_compiler_flag("${all_cxx_flags}" draco_all_cxx_flags_pass) check_cxx_compiler_flag("${all_cxx_flags}" draco_all_cxx_flags_pass)
if(cxx_test_FLAG_REQUIRED AND NOT draco_all_cxx_flags_pass) if(cxx_test_FLAG_REQUIRED AND NOT draco_all_cxx_flags_pass)
@ -194,6 +200,9 @@ macro(draco_test_exe_linker_flag)
else() else()
unset(CMAKE_EXE_LINKER_FLAGS) unset(CMAKE_EXE_LINKER_FLAGS)
endif() endif()
list(APPEND DRACO_EXE_LINKER_FLAGS ${${link_FLAG_LIST_VAR_NAME}})
list(REMOVE_DUPLICATES DRACO_EXE_LINKER_FLAGS)
endmacro() endmacro()
# Runs the draco compiler tests. This macro builds up the list of list var(s) # Runs the draco compiler tests. This macro builds up the list of list var(s)

View File

@ -55,7 +55,7 @@ macro(draco_setup_install_target)
install(TARGETS draco_encoder DESTINATION install(TARGETS draco_encoder DESTINATION
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
if(WIN32) if(MSVC)
install(TARGETS draco DESTINATION install(TARGETS draco DESTINATION
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
else() else()

View File

@ -5,28 +5,28 @@ set(DRACO_CMAKE_DRACO_SANITIZER_CMAKE_ 1)
# Handles the details of enabling sanitizers. # Handles the details of enabling sanitizers.
macro(draco_configure_sanitizer) macro(draco_configure_sanitizer)
if(DRACO_SANITIZE AND NOT MSVC) if(DRACO_SANITIZE AND NOT EMSCRIPTEN AND NOT MSVC)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(DRACO_SANITIZE MATCHES "cfi") if(DRACO_SANITIZE MATCHES "cfi")
list(APPEND DRACO_CXX_FLAGS "-flto" "-fno-sanitize-trap=cfi") list(APPEND SAN_CXX_FLAGS "-flto" "-fno-sanitize-trap=cfi")
list(APPEND DRACO_EXE_LINKER_FLAGS "-flto" "-fno-sanitize-trap=cfi" list(APPEND SAN_LINKER_FLAGS "-flto" "-fno-sanitize-trap=cfi"
"-fuse-ld=gold") "-fuse-ld=gold")
endif() endif()
if(${CMAKE_SIZEOF_VOID_P} EQUAL 4 if(${CMAKE_SIZEOF_VOID_P} EQUAL 4
AND DRACO_SANITIZE MATCHES "integer|undefined") AND DRACO_SANITIZE MATCHES "integer|undefined")
list(APPEND DRACO_EXE_LINKER_FLAGS "--rtlib=compiler-rt" "-lgcc_s") list(APPEND SAN_LINKER_FLAGS "--rtlib=compiler-rt" "-lgcc_s")
endif() endif()
endif() endif()
list(APPEND DRACO_CXX_FLAGS "-fsanitize=${DRACO_SANITIZE}") list(APPEND SAN_CXX_FLAGS "-fsanitize=${DRACO_SANITIZE}")
list(APPEND DRACO_EXE_LINKER_FLAGS "-fsanitize=${DRACO_SANITIZE}") list(APPEND SAN_LINKER_FLAGS "-fsanitize=${DRACO_SANITIZE}")
# Make sanitizer callstacks accurate. # Make sanitizer callstacks accurate.
list(APPEND DRACO_CXX_FLAGS "-fno-omit-frame-pointer" list(APPEND SAN_CXX_FLAGS "-fno-omit-frame-pointer")
"-fno-optimize-sibling-calls") list(APPEND SAN_CXX_FLAGS "-fno-optimize-sibling-calls")
draco_test_cxx_flag(FLAG_LIST_VAR_NAMES DRACO_CXX_FLAGS FLAG_REQUIRED) draco_test_cxx_flag(FLAG_LIST_VAR_NAMES SAN_CXX_FLAGS FLAG_REQUIRED)
draco_test_exe_linker_flag(FLAG_LIST_VAR_NAME DRACO_EXE_LINKER_FLAGS) draco_test_exe_linker_flag(FLAG_LIST_VAR_NAME SAN_LINKER_FLAGS)
endif() endif()
endmacro() endmacro()

View File

@ -87,6 +87,7 @@ macro(draco_add_executable)
endif() endif()
add_executable(${exe_NAME} ${exe_SOURCES}) add_executable(${exe_NAME} ${exe_SOURCES})
set_target_properties(${exe_NAME} PROPERTIES VERSION ${DRACO_VERSION})
if(exe_OUTPUT_NAME) if(exe_OUTPUT_NAME)
set_target_properties(${exe_NAME} PROPERTIES OUTPUT_NAME ${exe_OUTPUT_NAME}) set_target_properties(${exe_NAME} PROPERTIES OUTPUT_NAME ${exe_OUTPUT_NAME})
@ -109,10 +110,11 @@ macro(draco_add_executable)
if(exe_LINK_FLAGS OR DRACO_EXE_LINKER_FLAGS) if(exe_LINK_FLAGS OR DRACO_EXE_LINKER_FLAGS)
if(${CMAKE_VERSION} VERSION_LESS "3.13") if(${CMAKE_VERSION} VERSION_LESS "3.13")
set(link_flags ${exe_LINK_FLAGS} ${DRACO_EXE_LINKER_FLAGS}) list(APPEND exe_LINK_FLAGS "${DRACO_EXE_LINKER_FLAGS}")
# LINK_FLAGS is managed as a string.
draco_set_and_stringify(SOURCE "${exe_LINK_FLAGS}" DEST exe_LINK_FLAGS)
set_target_properties(${exe_NAME} set_target_properties(${exe_NAME}
PROPERTIES LINK_FLAGS ${exe_LINK_FLAGS} PROPERTIES LINK_FLAGS "${exe_LINK_FLAGS}")
${DRACO_EXE_LINKER_FLAGS})
else() else()
target_link_options(${exe_NAME} PRIVATE ${exe_LINK_FLAGS} target_link_options(${exe_NAME} PRIVATE ${exe_LINK_FLAGS}
${DRACO_EXE_LINKER_FLAGS}) ${DRACO_EXE_LINKER_FLAGS})
@ -130,7 +132,7 @@ macro(draco_add_executable)
endif() endif()
if(BUILD_SHARED_LIBS AND (MSVC OR WIN32)) if(BUILD_SHARED_LIBS AND (MSVC OR WIN32))
target_compile_definitions(${lib_NAME} PRIVATE "DRACO_BUILDING_DLL=0") target_compile_definitions(${exe_NAME} PRIVATE "DRACO_BUILDING_DLL=0")
endif() endif()
if(exe_LIB_DEPS) if(exe_LIB_DEPS)
@ -163,8 +165,8 @@ endmacro()
# cmake-format: off # cmake-format: off
# - OUTPUT_NAME: Override output file basename. Target basename defaults to # - OUTPUT_NAME: Override output file basename. Target basename defaults to
# NAME. OUTPUT_NAME is ignored when BUILD_SHARED_LIBS is enabled and CMake # NAME. OUTPUT_NAME is ignored when BUILD_SHARED_LIBS is enabled and CMake
# is generating a build for which MSVC or WIN32 are true. This is to avoid # is generating a build for which MSVC is true. This is to avoid output
# output basename collisions with DLL import libraries. # basename collisions with DLL import libraries.
# - TEST: Flag. Presence means treat library as a test. # - TEST: Flag. Presence means treat library as a test.
# - DEFINES: List of preprocessor macro definitions. # - DEFINES: List of preprocessor macro definitions.
# - INCLUDES: list of include directories for the target. # - INCLUDES: list of include directories for the target.
@ -259,7 +261,7 @@ macro(draco_add_library)
endif() endif()
if(lib_OUTPUT_NAME) if(lib_OUTPUT_NAME)
if(NOT (BUILD_SHARED_LIBS AND (MSVC OR WIN32))) if(NOT (BUILD_SHARED_LIBS AND MSVC))
set_target_properties(${lib_NAME} set_target_properties(${lib_NAME}
PROPERTIES OUTPUT_NAME ${lib_OUTPUT_NAME}) PROPERTIES OUTPUT_NAME ${lib_OUTPUT_NAME})
endif() endif()
@ -318,8 +320,12 @@ macro(draco_add_library)
set_target_properties(${lib_NAME} PROPERTIES PREFIX "") set_target_properties(${lib_NAME} PROPERTIES PREFIX "")
endif() endif()
if(lib_TYPE STREQUAL SHARED AND NOT MSVC) # VERSION and SOVERSION as necessary
set_target_properties(${lib_NAME} PROPERTIES SOVERSION ${DRACO_SOVERSION}) if(NOT lib_TYPE STREQUAL STATIC AND NOT lib_TYPE STREQUAL MODULE)
set_target_properties(${lib_NAME} PROPERTIES VERSION ${DRACO_VERSION})
if(NOT MSVC)
set_target_properties(${lib_NAME} PROPERTIES SOVERSION ${DRACO_SOVERSION})
endif()
endif() endif()
if(BUILD_SHARED_LIBS AND (MSVC OR WIN32)) if(BUILD_SHARED_LIBS AND (MSVC OR WIN32))

View File

@ -17,31 +17,31 @@
namespace draco { namespace draco {
void DracoTimer::Start() { void DracoTimer::Start() {
#ifdef _WIN32 #ifdef _WIN32
QueryPerformanceCounter(&tv_start); QueryPerformanceCounter(&tv_start_);
#else #else
gettimeofday(&tv_start, nullptr); gettimeofday(&tv_start_, nullptr);
#endif #endif
} }
void DracoTimer::Stop() { void DracoTimer::Stop() {
#ifdef _WIN32 #ifdef _WIN32
QueryPerformanceCounter(&tv_end); QueryPerformanceCounter(&tv_end_);
#else #else
gettimeofday(&tv_end, nullptr); gettimeofday(&tv_end_, nullptr);
#endif #endif
} }
int64_t DracoTimer::GetInMs() { int64_t DracoTimer::GetInMs() {
#ifdef _WIN32 #ifdef _WIN32
LARGE_INTEGER elapsed = {0}; LARGE_INTEGER elapsed = {0};
elapsed.QuadPart = tv_end.QuadPart - tv_start.QuadPart; elapsed.QuadPart = tv_end_.QuadPart - tv_start_.QuadPart;
LARGE_INTEGER frequency = {0}; LARGE_INTEGER frequency = {0};
QueryPerformanceFrequency(&frequency); QueryPerformanceFrequency(&frequency);
return elapsed.QuadPart * 1000 / frequency.QuadPart; return elapsed.QuadPart * 1000 / frequency.QuadPart;
#else #else
const int64_t seconds = (tv_end.tv_sec - tv_start.tv_sec) * 1000; const int64_t seconds = (tv_end_.tv_sec - tv_start_.tv_sec) * 1000;
const int64_t milliseconds = (tv_end.tv_usec - tv_start.tv_usec) / 1000; const int64_t milliseconds = (tv_end_.tv_usec - tv_start_.tv_usec) / 1000;
return seconds + milliseconds; return seconds + milliseconds;
#endif #endif
} }

View File

@ -20,9 +20,10 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#endif #endif
#include <windows.h> #include <windows.h>
typedef LARGE_INTEGER timeval; typedef LARGE_INTEGER DracoTimeVal;
#else #else
#include <sys/time.h> #include <sys/time.h>
typedef timeval DracoTimeVal;
#endif #endif
#include <cinttypes> #include <cinttypes>
@ -39,8 +40,8 @@ class DracoTimer {
int64_t GetInMs(); int64_t GetInMs();
private: private:
timeval tv_start; DracoTimeVal tv_start_;
timeval tv_end; DracoTimeVal tv_end_;
}; };
typedef DracoTimer CycleTimer; typedef DracoTimer CycleTimer;

View File

@ -18,6 +18,7 @@
#include <cctype> #include <cctype>
#include <cmath> #include <cmath>
#include <iterator> #include <iterator>
#include <limits>
namespace draco { namespace draco {
namespace parser { namespace parser {
@ -252,7 +253,7 @@ DecoderBuffer ParseLineIntoDecoderBuffer(DecoderBuffer *buffer) {
std::string ToLower(const std::string &str) { std::string ToLower(const std::string &str) {
std::string out; std::string out;
std::transform(str.begin(), str.end(), std::back_inserter(out), [](unsigned char c){return tolower(c);}); std::transform(str.begin(), str.end(), std::back_inserter(out), tolower);
return out; return out;
} }

View File

@ -268,14 +268,14 @@ std::vector<std::string> PlyReader::SplitWords(const std::string &line) {
while ((end = line.find_first_of(" \t\n\v\f\r", start)) != while ((end = line.find_first_of(" \t\n\v\f\r", start)) !=
std::string::npos) { std::string::npos) {
const std::string word(line.substr(start, end - start)); const std::string word(line.substr(start, end - start));
if (!std::all_of(word.begin(), word.end(), [](unsigned char c){return isspace(c);})) { if (!std::all_of(word.begin(), word.end(), isspace)) {
output.push_back(word); output.push_back(word);
} }
start = end + 1; start = end + 1;
} }
const std::string last_word(line.substr(start)); const std::string last_word(line.substr(start));
if (!std::all_of(last_word.begin(), last_word.end(), [](unsigned char c){return isspace(c);})) { if (!std::all_of(last_word.begin(), last_word.end(), isspace)) {
output.push_back(last_word); output.push_back(last_word);
} }
return output; return output;

View File

@ -87,7 +87,14 @@ size_t StdioFileReader::GetFileSize() {
return false; return false;
} }
#if _FILE_OFFSET_BITS == 64
const size_t file_size = static_cast<size_t>(ftello(file_));
#elif defined _WIN64
const size_t file_size = static_cast<size_t>(_ftelli64(file_));
#else
const size_t file_size = static_cast<size_t>(ftell(file_)); const size_t file_size = static_cast<size_t>(ftell(file_));
#endif
rewind(file_); rewind(file_);
return file_size; return file_size;

View File

@ -1,7 +1,7 @@
pugixml 1.9 - an XML processing library pugixml 1.11 - an XML processing library
Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) Copyright (C) 2006-2020, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
Report bugs and download new versions at http://pugixml.org/ Report bugs and download new versions at https://pugixml.org/
This is the distribution of pugixml, which is a C++ XML processing library, This is the distribution of pugixml, which is a C++ XML processing library,
which consists of a DOM-like interface with rich traversal/modification which consists of a DOM-like interface with rich traversal/modification
@ -13,8 +13,6 @@ automatically during parsing/saving).
The distribution contains the following folders: The distribution contains the following folders:
contrib/ - various contributions to pugixml
docs/ - documentation docs/ - documentation
docs/samples - pugixml usage examples docs/samples - pugixml usage examples
docs/quickstart.html - quick start guide docs/quickstart.html - quick start guide
@ -28,7 +26,7 @@ The distribution contains the following folders:
This library is distributed under the MIT License: This library is distributed under the MIT License:
Copyright (c) 2006-2018 Arseny Kapoulkine Copyright (c) 2006-2019 Arseny Kapoulkine
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation

View File

@ -1,8 +1,8 @@
/** /**
* pugixml parser - version 1.9 * pugixml parser - version 1.11
* -------------------------------------------------------- * --------------------------------------------------------
* Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) * Copyright (C) 2006-2020, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at http://pugixml.org/ * Report bugs and download new versions at https://pugixml.org/
* *
* This library is distributed under the MIT License. See notice at the end * This library is distributed under the MIT License. See notice at the end
* of this file. * of this file.
@ -30,10 +30,8 @@
// #define PUGIXML_NO_EXCEPTIONS // #define PUGIXML_NO_EXCEPTIONS
// Set this to control attributes for public classes/functions, i.e.: // Set this to control attributes for public classes/functions, i.e.:
//#ifdef _WIN32 // #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL
//#define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL // #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL
//#define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL
//#endif
// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall // #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall
// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead // In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead
@ -42,16 +40,19 @@
// #define PUGIXML_MEMORY_OUTPUT_STACK 10240 // #define PUGIXML_MEMORY_OUTPUT_STACK 10240
// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 // #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096
// Tune this constant to adjust max nesting for XPath queries
// #define PUGIXML_XPATH_DEPTH_LIMIT 1024
// Uncomment this to switch to header-only version // Uncomment this to switch to header-only version
#define PUGIXML_HEADER_ONLY #define PUGIXML_HEADER_ONLY
// Uncomment this to enable long long support // Uncomment this to enable long long support
//#define PUGIXML_HAS_LONG_LONG // #define PUGIXML_HAS_LONG_LONG
#endif #endif
/** /**
* Copyright (c) 2006-2018 Arseny Kapoulkine * Copyright (c) 2006-2020 Arseny Kapoulkine
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/** /**
* pugixml parser - version 1.9 * pugixml parser - version 1.11
* -------------------------------------------------------- * --------------------------------------------------------
* Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) * Copyright (C) 2006-2020, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at http://pugixml.org/ * Report bugs and download new versions at https://pugixml.org/
* *
* This library is distributed under the MIT License. See notice at the end * This library is distributed under the MIT License. See notice at the end
* of this file. * of this file.
@ -12,8 +12,9 @@
*/ */
#ifndef PUGIXML_VERSION #ifndef PUGIXML_VERSION
// Define version macro; evaluates to major * 100 + minor so that it's safe to use in less-than comparisons // Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons
# define PUGIXML_VERSION 190 // Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits
# define PUGIXML_VERSION 1110
#endif #endif
// Include user configuration file (this can define various configuration macros) // Include user configuration file (this can define various configuration macros)
@ -110,6 +111,15 @@
# endif # endif
#endif #endif
// If C++ is 2011 or higher, use 'nullptr'
#ifndef PUGIXML_NULL
# if __cplusplus >= 201103
# define PUGIXML_NULL nullptr
# else
# define PUGIXML_NULL 0
# endif
#endif
// Character interface macros // Character interface macros
#ifdef PUGIXML_WCHAR_MODE #ifdef PUGIXML_WCHAR_MODE
# define PUGIXML_TEXT(t) L ## t # define PUGIXML_TEXT(t) L ## t
@ -252,10 +262,19 @@ namespace pugi
// Don't output empty element tags, instead writing an explicit start and end tag even if there are no children. This flag is off by default. // Don't output empty element tags, instead writing an explicit start and end tag even if there are no children. This flag is off by default.
const unsigned int format_no_empty_element_tags = 0x80; const unsigned int format_no_empty_element_tags = 0x80;
// Skip characters belonging to range [0; 32) instead of "&#xNN;" encoding. This flag is off by default.
const unsigned int format_skip_control_chars = 0x100;
// Use single quotes ' instead of double quotes " for enclosing attribute values. This flag is off by default.
const unsigned int format_attribute_single_quote = 0x200;
// The default set of formatting flags. // The default set of formatting flags.
// Nodes are indented depending on their depth in DOM tree, a default declaration is output if document has none. // Nodes are indented depending on their depth in DOM tree, a default declaration is output if document has none.
const unsigned int format_default = format_indent; const unsigned int format_default = format_indent;
const int default_double_precision = 17;
const int default_float_precision = 9;
// Forward declarations // Forward declarations
struct xml_attribute_struct; struct xml_attribute_struct;
struct xml_node_struct; struct xml_node_struct;
@ -403,7 +422,9 @@ namespace pugi
bool set_value(long rhs); bool set_value(long rhs);
bool set_value(unsigned long rhs); bool set_value(unsigned long rhs);
bool set_value(double rhs); bool set_value(double rhs);
bool set_value(double rhs, int precision);
bool set_value(float rhs); bool set_value(float rhs);
bool set_value(float rhs, int precision);
bool set_value(bool rhs); bool set_value(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG #ifdef PUGIXML_HAS_LONG_LONG
@ -569,10 +590,16 @@ namespace pugi
bool remove_attribute(const xml_attribute& a); bool remove_attribute(const xml_attribute& a);
bool remove_attribute(const char_t* name); bool remove_attribute(const char_t* name);
// Remove all attributes
bool remove_attributes();
// Remove specified child // Remove specified child
bool remove_child(const xml_node& n); bool remove_child(const xml_node& n);
bool remove_child(const char_t* name); bool remove_child(const char_t* name);
// Remove all children
bool remove_children();
// Parses buffer as an XML document fragment and appends all nodes as children of the current node. // Parses buffer as an XML document fragment and appends all nodes as children of the current node.
// Copies/converts the buffer, so it may be deleted or changed after the function returns. // Copies/converts the buffer, so it may be deleted or changed after the function returns.
// Note: append_buffer allocates memory that has the lifetime of the owning document; removing the appended nodes does not immediately reclaim that memory. // Note: append_buffer allocates memory that has the lifetime of the owning document; removing the appended nodes does not immediately reclaim that memory.
@ -643,15 +670,15 @@ namespace pugi
#ifndef PUGIXML_NO_XPATH #ifndef PUGIXML_NO_XPATH
// Select single node by evaluating XPath query. Returns first node from the resulting node set. // Select single node by evaluating XPath query. Returns first node from the resulting node set.
xpath_node select_node(const char_t* query, xpath_variable_set* variables = 0) const; xpath_node select_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const;
xpath_node select_node(const xpath_query& query) const; xpath_node select_node(const xpath_query& query) const;
// Select node set by evaluating XPath query // Select node set by evaluating XPath query
xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = 0) const; xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const;
xpath_node_set select_nodes(const xpath_query& query) const; xpath_node_set select_nodes(const xpath_query& query) const;
// (deprecated: use select_node instead) Select single node by evaluating XPath query. // (deprecated: use select_node instead) Select single node by evaluating XPath query.
PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const; PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const;
PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const; PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const;
#endif #endif
@ -754,7 +781,9 @@ namespace pugi
bool set(long rhs); bool set(long rhs);
bool set(unsigned long rhs); bool set(unsigned long rhs);
bool set(double rhs); bool set(double rhs);
bool set(double rhs, int precision);
bool set(float rhs); bool set(float rhs);
bool set(float rhs, int precision);
bool set(bool rhs); bool set(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG #ifdef PUGIXML_HAS_LONG_LONG
@ -1192,7 +1221,7 @@ namespace pugi
public: public:
// Construct a compiled object from XPath expression. // Construct a compiled object from XPath expression.
// If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors. // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors.
explicit xpath_query(const char_t* query, xpath_variable_set* variables = 0); explicit xpath_query(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL);
// Constructor // Constructor
xpath_query(); xpath_query();
@ -1251,11 +1280,12 @@ namespace pugi
}; };
#ifndef PUGIXML_NO_EXCEPTIONS #ifndef PUGIXML_NO_EXCEPTIONS
#if defined(_MSC_VER)
#ifdef _MSC_VER // C4275 can be ignored in Visual C++ if you are deriving
# pragma warning(push) // from a type in the Standard C++ Library
# pragma warning( disable: 4275 ) #pragma warning(push)
#endif #pragma warning(disable: 4275)
#endif
// XPath exception class // XPath exception class
class PUGIXML_CLASS xpath_exception: public std::exception class PUGIXML_CLASS xpath_exception: public std::exception
{ {
@ -1272,10 +1302,11 @@ namespace pugi
// Get parse result // Get parse result
const xpath_parse_result& result() const; const xpath_parse_result& result() const;
}; };
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif #endif
#ifdef _MSC_VER
# pragma warning(pop)
#endif
// XPath node class (either xml_node or xml_attribute) // XPath node class (either xml_node or xml_attribute)
class PUGIXML_CLASS xpath_node class PUGIXML_CLASS xpath_node
{ {
@ -1379,7 +1410,7 @@ namespace pugi
private: private:
type_t _type; type_t _type;
xpath_node _storage; xpath_node _storage[1];
xpath_node* _begin; xpath_node* _begin;
xpath_node* _end; xpath_node* _end;
@ -1443,7 +1474,7 @@ namespace std
#endif #endif
/** /**
* Copyright (c) 2006-2018 Arseny Kapoulkine * Copyright (c) 2006-2020 Arseny Kapoulkine
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation

View File

@ -194,8 +194,14 @@ class BlobIOSystem : public IOSystem {
friend class BlobIOStream; friend class BlobIOStream;
typedef std::pair<std::string, aiExportDataBlob *> BlobEntry; typedef std::pair<std::string, aiExportDataBlob *> BlobEntry;
public: public:
BlobIOSystem() { BlobIOSystem() :
baseName{AI_BLOBIO_MAGIC} {
}
BlobIOSystem(const std::string &baseName) :
baseName(baseName) {
} }
virtual ~BlobIOSystem() { virtual ~BlobIOSystem() {
@ -207,27 +213,32 @@ public:
public: public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
const char *GetMagicFileName() const { const char *GetMagicFileName() const {
return AI_BLOBIO_MAGIC; return baseName.c_str();
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
aiExportDataBlob *GetBlobChain() { aiExportDataBlob *GetBlobChain() {
const auto magicName = std::string(this->GetMagicFileName());
const bool hasBaseName = baseName != AI_BLOBIO_MAGIC;
// one must be the master // one must be the master
aiExportDataBlob *master = nullptr, *cur; aiExportDataBlob *master = nullptr, *cur;
for (const BlobEntry &blobby : blobs) { for (const BlobEntry &blobby : blobs) {
if (blobby.first == AI_BLOBIO_MAGIC) { if (blobby.first == magicName) {
master = blobby.second; master = blobby.second;
master->name.Set(hasBaseName ? blobby.first : "");
break; break;
} }
} }
if (!master) { if (!master) {
ASSIMP_LOG_ERROR("BlobIOSystem: no data written or master file was not closed properly."); ASSIMP_LOG_ERROR("BlobIOSystem: no data written or master file was not closed properly.");
return nullptr; return nullptr;
} }
master->name.Set("");
cur = master; cur = master;
for (const BlobEntry &blobby : blobs) { for (const BlobEntry &blobby : blobs) {
if (blobby.second == master) { if (blobby.second == master) {
continue; continue;
@ -236,9 +247,13 @@ public:
cur->next = blobby.second; cur->next = blobby.second;
cur = cur->next; cur = cur->next;
// extract the file extension from the file written if (hasBaseName) {
const std::string::size_type s = blobby.first.find_first_of('.'); cur->name.Set(blobby.first);
cur->name.Set(s == std::string::npos ? blobby.first : blobby.first.substr(s + 1)); } else {
// extract the file extension from the file written
const std::string::size_type s = blobby.first.find_first_of('.');
cur->name.Set(s == std::string::npos ? blobby.first : blobby.first.substr(s + 1));
}
} }
// give up blob ownership // give up blob ownership
@ -283,6 +298,7 @@ private:
} }
private: private:
std::string baseName;
std::set<std::string> created; std::set<std::string> created;
std::vector<BlobEntry> blobs; std::vector<BlobEntry> blobs;
}; };

View File

@ -88,9 +88,17 @@ public:
underlying << sin; underlying << sin;
} }
// Same problem as the copy constructor below, but with root cause is that stream move
// is not permitted on older GCC versions. Small performance impact on those platforms.
#if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ <= 9)
basic_formatter(basic_formatter&& other) {
underlying << (string)other;
}
#else
basic_formatter(basic_formatter&& other) basic_formatter(basic_formatter&& other)
: underlying(std::move(other.underlying)) { : underlying(std::move(other.underlying)) {
} }
#endif
// The problem described here: // The problem described here:
// https://sourceforge.net/tracker/?func=detail&atid=1067632&aid=3358562&group_id=226462 // https://sourceforge.net/tracker/?func=detail&atid=1067632&aid=3358562&group_id=226462

View File

@ -137,7 +137,7 @@ struct aiCamera
*/ */
C_STRUCT aiVector3D mLookAt; C_STRUCT aiVector3D mLookAt;
/** Half horizontal field of view angle, in radians. /** Horizontal field of view angle, in radians.
* *
* The field of view angle is the angle between the center * The field of view angle is the angle between the center
* line of the screen and the left or right border. * line of the screen and the left or right border.

View File

@ -205,16 +205,22 @@ struct aiExportDataBlob {
void *data; void *data;
/** Name of the blob. An empty string always /** Name of the blob. An empty string always
indicates the first (and primary) blob, * indicates the first (and primary) blob,
which contains the actual file data. * which contains the actual file data.
Any other blobs are auxiliary files produced * Any other blobs are auxiliary files produced
by exporters (i.e. material files). Existence * by exporters (i.e. material files). Existence
of such files depends on the file format. Most * of such files depends on the file format. Most
formats don't split assets across multiple files. * formats don't split assets across multiple files.
*
If used, blob names usually contain the file * If used, blob names usually contain the file
extension that should be used when writing * extension that should be used when writing
the data to disc. * the data to disc.
*
* The blob names generated can be influenced by
* setting the #AI_CONFIG_EXPORT_BLOB_NAME export
* property to the name that is used for the master
* blob. All other names are typically derived from
* the base name, by the file format exporter.
*/ */
C_STRUCT aiString name; C_STRUCT aiString name;

View File

@ -1075,6 +1075,23 @@ enum aiComponent
*/ */
#define AI_CONFIG_EXPORT_POINT_CLOUDS "EXPORT_POINT_CLOUDS" #define AI_CONFIG_EXPORT_POINT_CLOUDS "EXPORT_POINT_CLOUDS"
/**
* @brief Specifies the blob name, assimp uses for exporting.
*
* Some formats require auxiliary files to be written, that need to be linked back into
* the original file. For example, OBJ files export materials to a separate MTL file and
* use the `mtllib` keyword to reference this file.
*
* When exporting blobs using #ExportToBlob, assimp does not know the name of the blob
* file and thus outputs `mtllib $blobfile.mtl`, which might not be desired, since the
* MTL file might be called differently.
*
* This property can be used to give the exporter a hint on how to use the magic
* `$blobfile` keyword. If the exporter detects the keyword and is provided with a name
* for the blob, it instead uses this name.
*/
#define AI_CONFIG_EXPORT_BLOB_NAME "EXPORT_BLOB_NAME"
/** /**
* @brief Specifies a gobal key factor for scale, float value * @brief Specifies a gobal key factor for scale, float value
*/ */

View File

@ -211,7 +211,7 @@ def _init(self, target = None, parent = None):
else: # starts with 'm' but not iterable else: # starts with 'm' but not iterable
setattr(target, name, obj) setattr(target, m, obj)
logger.debug("Added " + name + " as self." + name + " (type: " + str(type(obj)) + ")") logger.debug("Added " + name + " as self." + name + " (type: " + str(type(obj)) + ")")
if _is_init_type(obj): if _is_init_type(obj):

View File

@ -489,7 +489,7 @@ int CreateAssetData() {
nidx = 3; nidx = 3;
break; break;
default: default:
ai_assert(false); CLogWindow::Instance().WriteLine("Unknown primitiv type");
break; break;
}; };
@ -500,8 +500,7 @@ int CreateAssetData() {
// check whether we can use 16 bit indices // check whether we can use 16 bit indices
if (numIndices >= 65536) { if (numIndices >= 65536) {
// create 32 bit index buffer // create 32 bit index buffer
if (FAILED(g_piDevice->CreateIndexBuffer(4 * if (FAILED(g_piDevice->CreateIndexBuffer(4 * numIndices,
numIndices,
D3DUSAGE_WRITEONLY | dwUsage, D3DUSAGE_WRITEONLY | dwUsage,
D3DFMT_INDEX32, D3DFMT_INDEX32,
D3DPOOL_DEFAULT, D3DPOOL_DEFAULT,
@ -523,7 +522,7 @@ int CreateAssetData() {
} else { } else {
// create 16 bit index buffer // create 16 bit index buffer
if (FAILED(g_piDevice->CreateIndexBuffer(2 * if (FAILED(g_piDevice->CreateIndexBuffer(2 *
numIndices, numIndices,
D3DUSAGE_WRITEONLY | dwUsage, D3DUSAGE_WRITEONLY | dwUsage,
D3DFMT_INDEX16, D3DFMT_INDEX16,
D3DPOOL_DEFAULT, D3DPOOL_DEFAULT,