Merge branch 'master' into master

pull/3111/head
György Straub 2020-04-07 11:46:14 +01:00 committed by GitHub
commit 755f3748f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 601 additions and 641 deletions

View File

@ -238,11 +238,6 @@ SET(LIBASSIMP-DEV_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_M
SET(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev) SET(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev)
SET(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names") SET(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names")
IF( UNIX )
# Use GNUInstallDirs for Unix predefined directories
INCLUDE(GNUInstallDirs)
ENDIF()
# Grouped compiler settings # Grouped compiler settings
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW) IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
IF(NOT ASSIMP_HUNTER_ENABLED) IF(NOT ASSIMP_HUNTER_ENABLED)
@ -350,14 +345,6 @@ ELSE()
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
ENDIF () ENDIF ()
# Cache these to allow the user to override them manually.
SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE STRING
"Path the built library files are installed to." )
SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE STRING
"Path the header files are installed to." )
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE STRING
"Path the tool executables are installed to." )
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG) get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
IF (ASSIMP_INJECT_DEBUG_POSTFIX AND (is_multi_config OR CMAKE_BUILD_TYPE STREQUAL "Debug")) IF (ASSIMP_INJECT_DEBUG_POSTFIX AND (is_multi_config OR CMAKE_BUILD_TYPE STREQUAL "Debug"))
@ -417,6 +404,28 @@ ELSE()
else() else()
set(BUILD_LIB_TYPE STATIC) set(BUILD_LIB_TYPE STATIC)
endif() endif()
IF( UNIX )
# Use GNUInstallDirs for Unix predefined directories
INCLUDE(GNUInstallDirs)
SET( ASSIMP_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
SET( ASSIMP_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
SET( ASSIMP_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
ELSE()
# Cache these to allow the user to override them on non-Unix platforms
SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE STRING
"Path the built library files are installed to." )
SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE STRING
"Path the header files are installed to." )
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE STRING
"Path the tool executables are installed to." )
SET(CMAKE_INSTALL_FULL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_INCLUDE_INSTALL_DIR})
SET(CMAKE_INSTALL_FULL_LIBDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_LIB_INSTALL_DIR})
SET(CMAKE_INSTALL_FULL_BINDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_BIN_INSTALL_DIR})
ENDIF()
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE) CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" @ONLY IMMEDIATE) CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" @ONLY IMMEDIATE)
IF (is_multi_config) IF (is_multi_config)

View File

@ -1,7 +1,5 @@
prefix=@CMAKE_INSTALL_PREFIX@ libdir=@CMAKE_INSTALL_FULL_LIBDIR@
exec_prefix=@CMAKE_INSTALL_PREFIX@/ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
libdir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_LIB_INSTALL_DIR@
includedir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_INCLUDE_INSTALL_DIR@
Name: @CMAKE_PROJECT_NAME@ Name: @CMAKE_PROJECT_NAME@
Description: Import various well-known 3D model formats in an uniform manner. Description: Import various well-known 3D model formats in an uniform manner.

View File

@ -44,22 +44,22 @@ if(MSVC)
# Import target "assimp::assimp" for configuration "Debug" # Import target "assimp::assimp" for configuration "Debug"
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(assimp::assimp PROPERTIES set_target_properties(assimp::assimp PROPERTIES
IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/${importLibraryName}" IMPORTED_IMPLIB_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}"
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}"
) )
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}") list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}")
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" ) list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}" )
else() else()
set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@") set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
# Import target "assimp::assimp" for configuration "Debug" # Import target "assimp::assimp" for configuration "Debug"
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(assimp::assimp PROPERTIES set_target_properties(assimp::assimp PROPERTIES
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${staticLibraryName}" IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}"
) )
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}") list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}")
endif() endif()
else() else()
@ -75,17 +75,17 @@ else()
endif() endif()
set_target_properties(assimp::assimp PROPERTIES set_target_properties(assimp::assimp PROPERTIES
IMPORTED_SONAME_DEBUG "${sharedLibraryName}" IMPORTED_SONAME_DEBUG "${sharedLibraryName}"
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}"
) )
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" ) list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" )
else() else()
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@") set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
set_target_properties(assimp::assimp PROPERTIES set_target_properties(assimp::assimp PROPERTIES
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${staticLibraryName}" IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}"
) )
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}" ) list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" )
endif() endif()
endif() endif()

View File

@ -44,12 +44,12 @@ if(MSVC)
# Import target "assimp::assimp" for configuration "Release" # Import target "assimp::assimp" for configuration "Release"
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(assimp::assimp PROPERTIES set_target_properties(assimp::assimp PROPERTIES
IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/${importLibraryName}" IMPORTED_IMPLIB_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}"
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}"
) )
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}") list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}")
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" ) list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}" )
else() else()
set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@") set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@")
@ -59,7 +59,7 @@ if(MSVC)
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}" IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}"
) )
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}") list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}")
endif() endif()
else() else()
@ -75,18 +75,17 @@ else()
endif() endif()
set_target_properties(assimp::assimp PROPERTIES set_target_properties(assimp::assimp PROPERTIES
IMPORTED_SONAME_RELEASE "${sharedLibraryName}" IMPORTED_SONAME_RELEASE "${sharedLibraryName}"
IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}"
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${sharedLibraryName}"
) )
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" ) list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" )
else() else()
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@") set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@")
set_target_properties(assimp::assimp PROPERTIES set_target_properties(assimp::assimp PROPERTIES
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}" IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}"
) )
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}" ) list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" )
endif() endif()
endif() endif()

View File

@ -43,23 +43,13 @@ unset(_targetsDefined)
unset(_targetsNotDefined) unset(_targetsNotDefined)
unset(_expectedTargets) unset(_expectedTargets)
# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
# Create imported target assimp::assimp # Create imported target assimp::assimp
add_library(assimp::assimp @BUILD_LIB_TYPE@ IMPORTED) add_library(assimp::assimp @BUILD_LIB_TYPE@ IMPORTED)
set_target_properties(assimp::assimp PROPERTIES set_target_properties(assimp::assimp PROPERTIES
COMPATIBLE_INTERFACE_STRING "assimp_MAJOR_VERSION" COMPATIBLE_INTERFACE_STRING "assimp_MAJOR_VERSION"
INTERFACE_assimp_MAJOR_VERSION "1" INTERFACE_assimp_MAJOR_VERSION "1"
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include" INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_FULL_INCLUDEDIR@"
#INTERFACE_LINK_LIBRARIES "TxtUtils::TxtUtils;MealyMachine::MealyMachine" #INTERFACE_LINK_LIBRARIES "TxtUtils::TxtUtils;MealyMachine::MealyMachine"
) )
@ -74,9 +64,6 @@ foreach(f ${CONFIG_FILES})
include(${f}) include(${f})
endforeach() endforeach()
# Cleanup temporary variables.
set(_IMPORT_PREFIX)
# Loop over all imported files and verify that they actually exist # Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} ) foreach(target ${_IMPORT_CHECK_TARGETS} )
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )

View File

@ -44,15 +44,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief Implementation of the Plain-C API * @brief Implementation of the Plain-C API
*/ */
#include <assimp/BaseImporter.h>
#include <assimp/Exceptional.h>
#include <assimp/GenericProperty.h>
#include <assimp/cimport.h> #include <assimp/cimport.h>
#include <assimp/LogStream.hpp>
#include <assimp/DefaultLogger.hpp>
#include <assimp/Importer.hpp>
#include <assimp/importerdesc.h> #include <assimp/importerdesc.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/GenericProperty.h> #include <assimp/DefaultLogger.hpp>
#include <assimp/Exceptional.h> #include <assimp/Importer.hpp>
#include <assimp/BaseImporter.h> #include <assimp/LogStream.hpp>
#include "CApi/CInterfaceIOWrapper.h" #include "CApi/CInterfaceIOWrapper.h"
#include "Importer.h" #include "Importer.h"
@ -62,8 +62,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#ifndef ASSIMP_BUILD_SINGLETHREADED #ifndef ASSIMP_BUILD_SINGLETHREADED
# include <thread>
#include <mutex> #include <mutex>
#include <thread>
#endif #endif
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
using namespace Assimp; using namespace Assimp;
@ -100,8 +100,7 @@ namespace Assimp {
/** will delete all registered importers. */ /** will delete all registered importers. */
void DeleteImporterInstanceList(std::vector<BaseImporter *> &out); void DeleteImporterInstanceList(std::vector<BaseImporter *> &out);
} // namespace assimp } // namespace Assimp
#ifndef ASSIMP_BUILD_SINGLETHREADED #ifndef ASSIMP_BUILD_SINGLETHREADED
/** Global mutex to manage the access to the log-stream map */ /** Global mutex to manage the access to the log-stream map */
@ -112,8 +111,8 @@ static std::mutex gLogStreamMutex;
// Custom LogStream implementation for the C-API // Custom LogStream implementation for the C-API
class LogToCallbackRedirector : public LogStream { class LogToCallbackRedirector : public LogStream {
public: public:
explicit LogToCallbackRedirector(const aiLogStream& s) explicit LogToCallbackRedirector(const aiLogStream &s) :
: stream (s) { stream(s) {
ai_assert(NULL != s.callback); ai_assert(NULL != s.callback);
} }
@ -212,8 +211,7 @@ const aiScene* aiImportFileFromMemory(
const char *pBuffer, const char *pBuffer,
unsigned int pLength, unsigned int pLength,
unsigned int pFlags, unsigned int pFlags,
const char* pHint) const char *pHint) {
{
return aiImportFileFromMemoryWithProperties(pBuffer, pLength, pFlags, pHint, NULL); return aiImportFileFromMemoryWithProperties(pBuffer, pLength, pFlags, pHint, NULL);
} }
@ -223,8 +221,7 @@ const aiScene* aiImportFileFromMemoryWithProperties(
unsigned int pLength, unsigned int pLength,
unsigned int pFlags, unsigned int pFlags,
const char *pHint, const char *pHint,
const aiPropertyStore* props) const aiPropertyStore *props) {
{
ai_assert(NULL != pBuffer); ai_assert(NULL != pBuffer);
ai_assert(0 != pLength); ai_assert(0 != pLength);
@ -251,8 +248,7 @@ const aiScene* aiImportFileFromMemoryWithProperties(
if (scene) { if (scene) {
ScenePrivateData *priv = const_cast<ScenePrivateData *>(ScenePriv(scene)); ScenePrivateData *priv = const_cast<ScenePrivateData *>(ScenePriv(scene));
priv->mOrigImporter = imp; priv->mOrigImporter = imp;
} } else {
else {
// if failed, extract error code and destroy the import // if failed, extract error code and destroy the import
gLastErrorString = imp->GetErrorString(); gLastErrorString = imp->GetErrorString();
delete imp; delete imp;
@ -264,8 +260,7 @@ const aiScene* aiImportFileFromMemoryWithProperties(
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Releases all resources associated with the given import process. // Releases all resources associated with the given import process.
void aiReleaseImport( const aiScene* pScene) void aiReleaseImport(const aiScene *pScene) {
{
if (!pScene) { if (!pScene) {
return; return;
} }
@ -276,8 +271,7 @@ void aiReleaseImport( const aiScene* pScene)
const ScenePrivateData *priv = ScenePriv(pScene); const ScenePrivateData *priv = ScenePriv(pScene);
if (!priv || !priv->mOrigImporter) { if (!priv || !priv->mOrigImporter) {
delete pScene; delete pScene;
} } else {
else {
// deleting the Importer also deletes the scene // deleting the Importer also deletes the scene
// Note: the reason that this is not written as 'delete priv->mOrigImporter' // Note: the reason that this is not written as 'delete priv->mOrigImporter'
// is a suspected bug in gcc 4.4+ (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52339) // is a suspected bug in gcc 4.4+ (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52339)
@ -290,11 +284,9 @@ void aiReleaseImport( const aiScene* pScene)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API const aiScene *aiApplyPostProcessing(const aiScene *pScene, ASSIMP_API const aiScene *aiApplyPostProcessing(const aiScene *pScene,
unsigned int pFlags) unsigned int pFlags) {
{
const aiScene *sc = NULL; const aiScene *sc = NULL;
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
// find the importer associated with this data // find the importer associated with this data
@ -343,8 +335,7 @@ ASSIMP_API const aiScene *aiApplyCustomizedPostProcessing( const aiScene *scene,
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CallbackToLogRedirector (const char* msg, char* dt) void CallbackToLogRedirector(const char *msg, char *dt) {
{
ai_assert(NULL != msg); ai_assert(NULL != msg);
ai_assert(NULL != dt); ai_assert(NULL != dt);
LogStream *s = (LogStream *)dt; LogStream *s = (LogStream *)dt;
@ -353,8 +344,7 @@ void CallbackToLogRedirector (const char* msg, char* dt)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API aiLogStream aiGetPredefinedLogStream(aiDefaultLogStream pStream,const char* file) ASSIMP_API aiLogStream aiGetPredefinedLogStream(aiDefaultLogStream pStream, const char *file) {
{
aiLogStream sout; aiLogStream sout;
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
@ -362,8 +352,7 @@ ASSIMP_API aiLogStream aiGetPredefinedLogStream(aiDefaultLogStream pStream,const
if (!stream) { if (!stream) {
sout.callback = NULL; sout.callback = NULL;
sout.user = NULL; sout.user = NULL;
} } else {
else {
sout.callback = &CallbackToLogRedirector; sout.callback = &CallbackToLogRedirector;
sout.user = (char *)stream; sout.user = (char *)stream;
} }
@ -373,8 +362,7 @@ ASSIMP_API aiLogStream aiGetPredefinedLogStream(aiDefaultLogStream pStream,const
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API void aiAttachLogStream( const aiLogStream* stream ) ASSIMP_API void aiAttachLogStream(const aiLogStream *stream) {
{
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
#ifndef ASSIMP_BUILD_SINGLETHREADED #ifndef ASSIMP_BUILD_SINGLETHREADED
@ -392,8 +380,7 @@ ASSIMP_API void aiAttachLogStream( const aiLogStream* stream )
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API aiReturn aiDetachLogStream( const aiLogStream* stream) ASSIMP_API aiReturn aiDetachLogStream(const aiLogStream *stream) {
{
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
#ifndef ASSIMP_BUILD_SINGLETHREADED #ifndef ASSIMP_BUILD_SINGLETHREADED
@ -418,8 +405,7 @@ ASSIMP_API aiReturn aiDetachLogStream( const aiLogStream* stream)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API void aiDetachAllLogStreams(void) ASSIMP_API void aiDetachAllLogStreams(void) {
{
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
#ifndef ASSIMP_BUILD_SINGLETHREADED #ifndef ASSIMP_BUILD_SINGLETHREADED
std::lock_guard<std::mutex> lock(gLogStreamMutex); std::lock_guard<std::mutex> lock(gLogStreamMutex);
@ -440,8 +426,7 @@ ASSIMP_API void aiDetachAllLogStreams(void)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API void aiEnableVerboseLogging(aiBool d) ASSIMP_API void aiEnableVerboseLogging(aiBool d) {
{
if (!DefaultLogger::isNullLogger()) { if (!DefaultLogger::isNullLogger()) {
DefaultLogger::get()->setLogSeverity((d == AI_TRUE ? Logger::VERBOSE : Logger::NORMAL)); DefaultLogger::get()->setLogSeverity((d == AI_TRUE ? Logger::VERBOSE : Logger::NORMAL));
} }
@ -450,29 +435,25 @@ ASSIMP_API void aiEnableVerboseLogging(aiBool d)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Returns the error text of the last failed import process. // Returns the error text of the last failed import process.
const char* aiGetErrorString() const char *aiGetErrorString() {
{
return gLastErrorString.c_str(); return gLastErrorString.c_str();
} }
// ----------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
// Return the description of a importer given its index // Return the description of a importer given its index
const aiImporterDesc* aiGetImportFormatDescription( size_t pIndex) const aiImporterDesc *aiGetImportFormatDescription(size_t pIndex) {
{
return Importer().GetImporterInfo(pIndex); return Importer().GetImporterInfo(pIndex);
} }
// ----------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
// Return the number of importers // Return the number of importers
size_t aiGetImportFormatCount(void) size_t aiGetImportFormatCount(void) {
{
return Importer().GetImporterCount(); return Importer().GetImporterCount();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Returns the error text of the last failed import process. // Returns the error text of the last failed import process.
aiBool aiIsExtensionSupported(const char* szExtension) aiBool aiIsExtensionSupported(const char *szExtension) {
{
ai_assert(NULL != szExtension); ai_assert(NULL != szExtension);
aiBool candoit = AI_FALSE; aiBool candoit = AI_FALSE;
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
@ -487,8 +468,7 @@ aiBool aiIsExtensionSupported(const char* szExtension)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Get a list of all file extensions supported by ASSIMP // Get a list of all file extensions supported by ASSIMP
void aiGetExtensionList(aiString* szOut) void aiGetExtensionList(aiString *szOut) {
{
ai_assert(NULL != szOut); ai_assert(NULL != szOut);
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
@ -502,8 +482,7 @@ void aiGetExtensionList(aiString* szOut)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Get the memory requirements for a particular import. // Get the memory requirements for a particular import.
void aiGetMemoryRequirements(const C_STRUCT aiScene *pIn, void aiGetMemoryRequirements(const C_STRUCT aiScene *pIn,
C_STRUCT aiMemoryInfo* in) C_STRUCT aiMemoryInfo *in) {
{
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
// find the importer associated with this data // find the importer associated with this data
@ -518,21 +497,18 @@ void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn,
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API aiPropertyStore* aiCreatePropertyStore(void) ASSIMP_API aiPropertyStore *aiCreatePropertyStore(void) {
{
return reinterpret_cast<aiPropertyStore *>(new PropertyMap()); return reinterpret_cast<aiPropertyStore *>(new PropertyMap());
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API void aiReleasePropertyStore(aiPropertyStore* p) ASSIMP_API void aiReleasePropertyStore(aiPropertyStore *p) {
{
delete reinterpret_cast<PropertyMap *>(p); delete reinterpret_cast<PropertyMap *>(p);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Importer::SetPropertyInteger // Importer::SetPropertyInteger
ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szName, int value) ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore *p, const char *szName, int value) {
{
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
PropertyMap *pp = reinterpret_cast<PropertyMap *>(p); PropertyMap *pp = reinterpret_cast<PropertyMap *>(p);
SetGenericProperty<int>(pp->ints, szName, value); SetGenericProperty<int>(pp->ints, szName, value);
@ -541,8 +517,7 @@ ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szNam
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Importer::SetPropertyFloat // Importer::SetPropertyFloat
ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName, ai_real value) ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore *p, const char *szName, ai_real value) {
{
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
PropertyMap *pp = reinterpret_cast<PropertyMap *>(p); PropertyMap *pp = reinterpret_cast<PropertyMap *>(p);
SetGenericProperty<ai_real>(pp->floats, szName, value); SetGenericProperty<ai_real>(pp->floats, szName, value);
@ -552,8 +527,7 @@ ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName,
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Importer::SetPropertyString // Importer::SetPropertyString
ASSIMP_API void aiSetImportPropertyString(aiPropertyStore *p, const char *szName, ASSIMP_API void aiSetImportPropertyString(aiPropertyStore *p, const char *szName,
const C_STRUCT aiString* st) const C_STRUCT aiString *st) {
{
if (!st) { if (!st) {
return; return;
} }
@ -566,8 +540,7 @@ ASSIMP_API void aiSetImportPropertyString(aiPropertyStore* p, const char* szName
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Importer::SetPropertyMatrix // Importer::SetPropertyMatrix
ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore *p, const char *szName, ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore *p, const char *szName,
const C_STRUCT aiMatrix4x4* mat) const C_STRUCT aiMatrix4x4 *mat) {
{
if (!mat) { if (!mat) {
return; return;
} }
@ -579,8 +552,7 @@ ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore* p, const char* szName
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Rotation matrix to quaternion // Rotation matrix to quaternion
ASSIMP_API void aiCreateQuaternionFromMatrix(aiQuaternion* quat,const aiMatrix3x3* mat) ASSIMP_API void aiCreateQuaternionFromMatrix(aiQuaternion *quat, const aiMatrix3x3 *mat) {
{
ai_assert(NULL != quat); ai_assert(NULL != quat);
ai_assert(NULL != mat); ai_assert(NULL != mat);
*quat = aiQuaternion(*mat); *quat = aiQuaternion(*mat);
@ -590,8 +562,7 @@ ASSIMP_API void aiCreateQuaternionFromMatrix(aiQuaternion* quat,const aiMatrix3x
// Matrix decomposition // Matrix decomposition
ASSIMP_API void aiDecomposeMatrix(const aiMatrix4x4 *mat, aiVector3D *scaling, ASSIMP_API void aiDecomposeMatrix(const aiMatrix4x4 *mat, aiVector3D *scaling,
aiQuaternion *rotation, aiQuaternion *rotation,
aiVector3D* position) aiVector3D *position) {
{
ai_assert(NULL != rotation); ai_assert(NULL != rotation);
ai_assert(NULL != position); ai_assert(NULL != position);
ai_assert(NULL != scaling); ai_assert(NULL != scaling);
@ -601,15 +572,13 @@ ASSIMP_API void aiDecomposeMatrix(const aiMatrix4x4* mat,aiVector3D* scaling,
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Matrix transpose // Matrix transpose
ASSIMP_API void aiTransposeMatrix3(aiMatrix3x3* mat) ASSIMP_API void aiTransposeMatrix3(aiMatrix3x3 *mat) {
{
ai_assert(NULL != mat); ai_assert(NULL != mat);
mat->Transpose(); mat->Transpose();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API void aiTransposeMatrix4(aiMatrix4x4* mat) ASSIMP_API void aiTransposeMatrix4(aiMatrix4x4 *mat) {
{
ai_assert(NULL != mat); ai_assert(NULL != mat);
mat->Transpose(); mat->Transpose();
} }
@ -617,8 +586,7 @@ ASSIMP_API void aiTransposeMatrix4(aiMatrix4x4* mat)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Vector transformation // Vector transformation
ASSIMP_API void aiTransformVecByMatrix3(aiVector3D *vec, ASSIMP_API void aiTransformVecByMatrix3(aiVector3D *vec,
const aiMatrix3x3* mat) const aiMatrix3x3 *mat) {
{
ai_assert(NULL != mat); ai_assert(NULL != mat);
ai_assert(NULL != vec); ai_assert(NULL != vec);
*vec *= (*mat); *vec *= (*mat);
@ -626,8 +594,7 @@ ASSIMP_API void aiTransformVecByMatrix3(aiVector3D* vec,
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API void aiTransformVecByMatrix4(aiVector3D *vec, ASSIMP_API void aiTransformVecByMatrix4(aiVector3D *vec,
const aiMatrix4x4* mat) const aiMatrix4x4 *mat) {
{
ai_assert(NULL != mat); ai_assert(NULL != mat);
ai_assert(NULL != vec); ai_assert(NULL != vec);
@ -638,8 +605,7 @@ ASSIMP_API void aiTransformVecByMatrix4(aiVector3D* vec,
// Matrix multiplication // Matrix multiplication
ASSIMP_API void aiMultiplyMatrix4( ASSIMP_API void aiMultiplyMatrix4(
aiMatrix4x4 *dst, aiMatrix4x4 *dst,
const aiMatrix4x4* src) const aiMatrix4x4 *src) {
{
ai_assert(NULL != dst); ai_assert(NULL != dst);
ai_assert(NULL != src); ai_assert(NULL != src);
*dst = (*dst) * (*src); *dst = (*dst) * (*src);
@ -648,8 +614,7 @@ ASSIMP_API void aiMultiplyMatrix4(
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API void aiMultiplyMatrix3( ASSIMP_API void aiMultiplyMatrix3(
aiMatrix3x3 *dst, aiMatrix3x3 *dst,
const aiMatrix3x3* src) const aiMatrix3x3 *src) {
{
ai_assert(NULL != dst); ai_assert(NULL != dst);
ai_assert(NULL != src); ai_assert(NULL != src);
*dst = (*dst) * (*src); *dst = (*dst) * (*src);
@ -658,16 +623,14 @@ ASSIMP_API void aiMultiplyMatrix3(
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Matrix identity // Matrix identity
ASSIMP_API void aiIdentityMatrix3( ASSIMP_API void aiIdentityMatrix3(
aiMatrix3x3* mat) aiMatrix3x3 *mat) {
{
ai_assert(NULL != mat); ai_assert(NULL != mat);
*mat = aiMatrix3x3(); *mat = aiMatrix3x3();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API void aiIdentityMatrix4( ASSIMP_API void aiIdentityMatrix4(
aiMatrix4x4* mat) aiMatrix4x4 *mat) {
{
ai_assert(NULL != mat); ai_assert(NULL != mat);
*mat = aiMatrix4x4(); *mat = aiMatrix4x4();
} }

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, 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,
@ -50,27 +49,25 @@ namespace Assimp {
namespace FBX { namespace FBX {
/** FBX import settings, parts of which are publicly accessible via their corresponding AI_CONFIG constants */ /** FBX import settings, parts of which are publicly accessible via their corresponding AI_CONFIG constants */
struct ImportSettings struct ImportSettings {
{ ImportSettings() :
ImportSettings() strictMode(true),
: strictMode(true) readAllLayers(true),
, readAllLayers(true) readAllMaterials(false),
, readAllMaterials(false) readMaterials(true),
, readMaterials(true) readTextures(true),
, readTextures(true) readCameras(true),
, readCameras(true) readLights(true),
, readLights(true) readAnimations(true),
, readAnimations(true) readWeights(true),
, readWeights(true) preservePivots(true),
, preservePivots(true) optimizeEmptyAnimationCurves(true),
, optimizeEmptyAnimationCurves(true) useLegacyEmbeddedTextureNaming(false),
, useLegacyEmbeddedTextureNaming(false) removeEmptyBones(true),
, removeEmptyBones( true ) convertToMeters(false) {
, convertToMeters( false ) {
// empty // empty
} }
/** enable strict mode: /** enable strict mode:
* - only accept fbx 2012, 2013 files * - only accept fbx 2012, 2013 files
* - on the slightest error, give up. * - on the slightest error, give up.
@ -94,7 +91,6 @@ struct ImportSettings
* This bit is ignored unless readMaterials=true*/ * This bit is ignored unless readMaterials=true*/
bool readAllMaterials; bool readAllMaterials;
/** import materials (true) or skip them and assign a default /** import materials (true) or skip them and assign a default
* material. The default value is true.*/ * material. The default value is true.*/
bool readMaterials; bool readMaterials;
@ -156,9 +152,7 @@ struct ImportSettings
bool convertToMeters; bool convertToMeters;
}; };
} // namespace FBX
} // !FBX } // namespace Assimp
} // !Assimp
#endif #endif

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, 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,

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, 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,
@ -55,18 +54,20 @@ namespace Assimp {
// TinyFormatter.h // TinyFormatter.h
namespace Formatter { namespace Formatter {
template <typename T,typename TR, typename A> class basic_formatter;
template <typename T, typename TR, typename A>
class basic_formatter;
typedef class basic_formatter<char, std::char_traits<char>, std::allocator<char>> format; typedef class basic_formatter<char, std::char_traits<char>, std::allocator<char>> format;
}
} // namespace Formatter
// ------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------
/** Load the Autodesk FBX file format. /// Loads the Autodesk FBX file format.
///
See http://en.wikipedia.org/wiki/FBX /// See http://en.wikipedia.org/wiki/FBX
*/
// ------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------
class FBXImporter : public BaseImporter, public LogFunctions<FBXImporter> class FBXImporter : public BaseImporter, public LogFunctions<FBXImporter> {
{
public: public:
FBXImporter(); FBXImporter();
virtual ~FBXImporter(); virtual ~FBXImporter();
@ -74,11 +75,9 @@ public:
// -------------------- // --------------------
bool CanRead(const std::string &pFile, bool CanRead(const std::string &pFile,
IOSystem *pIOHandler, IOSystem *pIOHandler,
bool checkSig bool checkSig) const;
) const;
protected: protected:
// -------------------- // --------------------
const aiImporterDesc *GetInfo() const; const aiImporterDesc *GetInfo() const;
@ -88,8 +87,7 @@ protected:
// -------------------- // --------------------
void InternReadFile(const std::string &pFile, void InternReadFile(const std::string &pFile,
aiScene *pScene, aiScene *pScene,
IOSystem* pIOHandler IOSystem *pIOHandler);
);
private: private:
FBX::ImportSettings settings; FBX::ImportSettings settings;
@ -97,4 +95,3 @@ private:
} // end of namespace Assimp } // end of namespace Assimp
#endif // !INCLUDED_AI_FBX_IMPORTER_H #endif // !INCLUDED_AI_FBX_IMPORTER_H

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, 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,
@ -100,13 +98,27 @@ struct aiMetadataEntry {
*/ */
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
inline aiMetadataType GetAiType( bool ) { return AI_BOOL; } inline aiMetadataType GetAiType(bool) {
inline aiMetadataType GetAiType( int32_t ) { return AI_INT32; } return AI_BOOL;
inline aiMetadataType GetAiType( uint64_t ) { return AI_UINT64; } }
inline aiMetadataType GetAiType( float ) { return AI_FLOAT; } inline aiMetadataType GetAiType(int32_t) {
inline aiMetadataType GetAiType( double ) { return AI_DOUBLE; } return AI_INT32;
inline aiMetadataType GetAiType( const aiString & ) { return AI_AISTRING; } }
inline aiMetadataType GetAiType( const aiVector3D & ) { return AI_AIVECTOR3D; } inline aiMetadataType GetAiType(uint64_t) {
return AI_UINT64;
}
inline aiMetadataType GetAiType(float) {
return AI_FLOAT;
}
inline aiMetadataType GetAiType(double) {
return AI_DOUBLE;
}
inline aiMetadataType GetAiType(const aiString &) {
return AI_AISTRING;
}
inline aiMetadataType GetAiType(const aiVector3D &) {
return AI_AIVECTOR3D;
}
#endif // __cplusplus #endif // __cplusplus
@ -134,16 +146,14 @@ struct aiMetadata {
* @brief The default constructor, set all members to zero by default. * @brief The default constructor, set all members to zero by default.
*/ */
aiMetadata() AI_NO_EXCEPT aiMetadata() AI_NO_EXCEPT
: mNumProperties(0) : mNumProperties(0),
, mKeys(nullptr) mKeys(nullptr),
, mValues(nullptr) { mValues(nullptr) {
// empty // empty
} }
aiMetadata( const aiMetadata &rhs ) aiMetadata(const aiMetadata &rhs) :
: mNumProperties( rhs.mNumProperties ) mNumProperties(rhs.mNumProperties), mKeys(nullptr), mValues(nullptr) {
, mKeys( nullptr )
, mValues( nullptr ) {
mKeys = new aiString[mNumProperties]; mKeys = new aiString[mNumProperties];
for (size_t i = 0; i < static_cast<size_t>(mNumProperties); ++i) { for (size_t i = 0; i < static_cast<size_t>(mNumProperties); ++i) {
mKeys[i] = rhs.mKeys[i]; mKeys[i] = rhs.mKeys[i];
@ -160,45 +170,38 @@ struct aiMetadata {
int32_t v; int32_t v;
::memcpy(&v, rhs.mValues[i].mData, sizeof(int32_t)); ::memcpy(&v, rhs.mValues[i].mData, sizeof(int32_t));
mValues[i].mData = new int32_t(v); mValues[i].mData = new int32_t(v);
} } break;
break;
case AI_UINT64: { case AI_UINT64: {
uint64_t v; uint64_t v;
::memcpy(&v, rhs.mValues[i].mData, sizeof(uint64_t)); ::memcpy(&v, rhs.mValues[i].mData, sizeof(uint64_t));
mValues[i].mData = new uint64_t(v); mValues[i].mData = new uint64_t(v);
} } break;
break;
case AI_FLOAT: { case AI_FLOAT: {
float v; float v;
::memcpy(&v, rhs.mValues[i].mData, sizeof(float)); ::memcpy(&v, rhs.mValues[i].mData, sizeof(float));
mValues[i].mData = new float(v); mValues[i].mData = new float(v);
} } break;
break;
case AI_DOUBLE: { case AI_DOUBLE: {
double v; double v;
::memcpy(&v, rhs.mValues[i].mData, sizeof(double)); ::memcpy(&v, rhs.mValues[i].mData, sizeof(double));
mValues[i].mData = new double(v); mValues[i].mData = new double(v);
} } break;
break;
case AI_AISTRING: { case AI_AISTRING: {
aiString v; aiString v;
rhs.Get<aiString>(mKeys[i], v); rhs.Get<aiString>(mKeys[i], v);
mValues[i].mData = new aiString(v); mValues[i].mData = new aiString(v);
} } break;
break;
case AI_AIVECTOR3D: { case AI_AIVECTOR3D: {
aiVector3D v; aiVector3D v;
rhs.Get<aiVector3D>(mKeys[i], v); rhs.Get<aiVector3D>(mKeys[i], v);
mValues[i].mData = new aiVector3D(v); mValues[i].mData = new aiVector3D(v);
} } break;
break;
#ifndef SWIG #ifndef SWIG
case FORCE_32BIT: case FORCE_32BIT:
#endif #endif
default: default:
break; break;
} }
} }
} }
@ -252,8 +255,7 @@ struct aiMetadata {
* @brief Allocates property fields + keys. * @brief Allocates property fields + keys.
* @param numProperties Number of requested properties. * @param numProperties Number of requested properties.
*/ */
static inline static inline aiMetadata *Alloc(unsigned int numProperties) {
aiMetadata *Alloc( unsigned int numProperties ) {
if (0 == numProperties) { if (0 == numProperties) {
return nullptr; return nullptr;
} }
@ -269,19 +271,16 @@ struct aiMetadata {
/** /**
* @brief Deallocates property fields + keys. * @brief Deallocates property fields + keys.
*/ */
static inline static inline void Dealloc(aiMetadata *metadata) {
void Dealloc( aiMetadata *metadata ) {
delete metadata; delete metadata;
} }
template <typename T> template <typename T>
inline inline void Add(const std::string &key, const T &value) {
void Add(const std::string& key, const T& value) {
aiString *new_keys = new aiString[mNumProperties + 1]; aiString *new_keys = new aiString[mNumProperties + 1];
aiMetadataEntry *new_values = new aiMetadataEntry[mNumProperties + 1]; aiMetadataEntry *new_values = new aiMetadataEntry[mNumProperties + 1];
for(unsigned int i = 0; i < mNumProperties; ++i) for (unsigned int i = 0; i < mNumProperties; ++i) {
{
new_keys[i] = mKeys[i]; new_keys[i] = mKeys[i];
new_values[i] = mValues[i]; new_values[i] = mValues[i];
} }
@ -298,8 +297,7 @@ struct aiMetadata {
} }
template <typename T> template <typename T>
inline inline bool Set(unsigned index, const std::string &key, const T &value) {
bool Set( unsigned index, const std::string& key, const T& value ) {
// In range assertion // In range assertion
if (index >= mNumProperties) { if (index >= mNumProperties) {
return false; return false;
@ -322,8 +320,25 @@ struct aiMetadata {
} }
template <typename T> template <typename T>
inline inline bool Set( const std::string &key, const T &value ) {
bool Get( unsigned index, T& value ) const { if (key.empty()) {
return false;
}
bool result = false;
for (unsigned int i = 0; i < mNumProperties; ++i) {
if (key == mKeys[i].C_Str()) {
Set(i, key, value);
result = true;
break;
}
}
return result;
}
template <typename T>
inline bool Get(unsigned index, T &value) const {
// In range assertion // In range assertion
if (index >= mNumProperties) { if (index >= mNumProperties) {
return false; return false;
@ -343,8 +358,7 @@ struct aiMetadata {
} }
template <typename T> template <typename T>
inline inline bool Get(const aiString &key, T &value) const {
bool Get( const aiString& key, T& value ) const {
// Search for the given key // Search for the given key
for (unsigned int i = 0; i < mNumProperties; ++i) { for (unsigned int i = 0; i < mNumProperties; ++i) {
if (mKeys[i] == key) { if (mKeys[i] == key) {
@ -355,8 +369,7 @@ struct aiMetadata {
} }
template <typename T> template <typename T>
inline inline bool Get(const std::string &key, T &value) const {
bool Get( const std::string& key, T& value ) const {
return Get(aiString(key), value); return Get(aiString(key), value);
} }
@ -365,8 +378,7 @@ struct aiMetadata {
/// \param [out] pKey - pointer to the key value. /// \param [out] pKey - pointer to the key value.
/// \param [out] pEntry - pointer to the entry: type and value. /// \param [out] pEntry - pointer to the entry: type and value.
/// \return false - if pIndex is out of range, else - true. /// \return false - if pIndex is out of range, else - true.
inline inline bool Get(size_t index, const aiString *&key, const aiMetadataEntry *&entry) const {
bool Get(size_t index, const aiString*& key, const aiMetadataEntry*& entry) const {
if (index >= mNumProperties) { if (index >= mNumProperties) {
return false; return false;
} }
@ -379,8 +391,7 @@ struct aiMetadata {
/// Check whether there is a metadata entry for the given key. /// Check whether there is a metadata entry for the given key.
/// \param [in] Key - the key value value to check for. /// \param [in] Key - the key value value to check for.
inline inline bool HasKey(const char *key) {
bool HasKey(const char* key) {
if (nullptr == key) { if (nullptr == key) {
return false; return false;
} }
@ -395,7 +406,6 @@ struct aiMetadata {
} }
#endif // __cplusplus #endif // __cplusplus
}; };
#endif // AI_METADATA_H_INC #endif // AI_METADATA_H_INC

View File

@ -213,6 +213,10 @@ TEST_F(utFBXImporterExporter, importUnitScaleFactor) {
double factor(0.0); double factor(0.0);
scene->mMetaData->Get("UnitScaleFactor", factor); scene->mMetaData->Get("UnitScaleFactor", factor);
EXPECT_DOUBLE_EQ(500.0, factor); EXPECT_DOUBLE_EQ(500.0, factor);
scene->mMetaData->Set("UnitScaleFactor", factor * 2);
scene->mMetaData->Get("UnitScaleFactor", factor);
EXPECT_DOUBLE_EQ(1000.0, factor);
} }
TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) { TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {

View File

@ -275,7 +275,7 @@ int CDisplay::ReplaceCurrentTexture(const char* szPath)
IDirect3DTexture9* piTexture = NULL; IDirect3DTexture9* piTexture = NULL;
aiString szString; aiString szString;
strcpy(szString.data,szPath); strcpy(szString.data,szPath);
szString.length = strlen(szPath); szString.length = static_cast<ai_uint32>(strlen(szPath));
CMaterialManager::Instance().LoadTexture(&piTexture,&szString); CMaterialManager::Instance().LoadTexture(&piTexture,&szString);
if (!piTexture) { if (!piTexture) {
@ -388,8 +388,8 @@ int CDisplay::AddTextureToDisplayList(unsigned int iType,
{ {
if ('*' == *szPath->data) if ('*' == *szPath->data)
{ {
int iIndex = atoi(szPath->data+1); int iIndex2 = atoi(szPath->data+1);
ai_snprintf(chTempEmb,256,"Embedded #%i",iIndex); ai_snprintf(chTempEmb,256,"Embedded #%i",iIndex2);
sz = chTempEmb; sz = chTempEmb;
} }
else else
@ -1308,7 +1308,7 @@ int CALLBACK TreeViewCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSo
return 0; return 0;
} }
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam) int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM /*lParam*/)
{ {
char szFileName[MAX_PATH]; char szFileName[MAX_PATH];
DWORD dwTemp = MAX_PATH; DWORD dwTemp = MAX_PATH;
@ -1795,11 +1795,11 @@ int CDisplay::RenderFullScene()
g_piDevice->SetVertexDeclaration( gDefaultVertexDecl); g_piDevice->SetVertexDeclaration( gDefaultVertexDecl);
// this is very similar to the code in SetupMaterial() // this is very similar to the code in SetupMaterial()
ID3DXEffect* piEnd = g_piNormalsEffect; ID3DXEffect* piEnd = g_piNormalsEffect;
aiMatrix4x4 pcProj = m * mViewProjection; aiMatrix4x4 pcProj2 = m * mViewProjection;
D3DXVECTOR4 vVector(1.f,0.f,0.f,1.f); D3DXVECTOR4 vVector(1.f,0.f,0.f,1.f);
piEnd->SetVector("OUTPUT_COLOR",&vVector); piEnd->SetVector("OUTPUT_COLOR",&vVector);
piEnd->SetMatrix("WorldViewProjection", (const D3DXMATRIX*)&pcProj); piEnd->SetMatrix("WorldViewProjection", (const D3DXMATRIX*)&pcProj2);
UINT dwPasses = 0; UINT dwPasses = 0;
piEnd->Begin(&dwPasses,0); piEnd->Begin(&dwPasses,0);

View File

@ -70,7 +70,7 @@ static const char* AI_VIEW_RTF_LOG_HEADER =
// Message procedure for the log window // Message procedure for the log window
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg, INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
WPARAM wParam,LPARAM lParam) WPARAM /*wParam*/,LPARAM lParam)
{ {
(void)lParam; (void)lParam;
switch (uMsg) switch (uMsg)

View File

@ -287,7 +287,7 @@ bool CMaterialManager::TryLongerPath(char* szTemp,aiString* p_szString)
size_t iLen2 = iLen+1; size_t iLen2 = iLen+1;
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2; iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
memcpy(p_szString->data,szTempB,iLen2); memcpy(p_szString->data,szTempB,iLen2);
p_szString->length = iLen; p_szString->length = static_cast<ai_uint32>(iLen);
return true; return true;
} }
} }
@ -301,7 +301,7 @@ bool CMaterialManager::TryLongerPath(char* szTemp,aiString* p_szString)
size_t iLen2 = iLen+1; size_t iLen2 = iLen+1;
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2; iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
memcpy(p_szString->data,szTempB,iLen2); memcpy(p_szString->data,szTempB,iLen2);
p_szString->length = iLen; p_szString->length = static_cast<ai_uint32>(iLen);
return true; return true;
} }
} }
@ -389,10 +389,10 @@ int CMaterialManager::FindValidPath(aiString* p_szString)
if( !q ) q=strrchr( tmp2,'\\' ); if( !q ) q=strrchr( tmp2,'\\' );
if( q ){ if( q ){
strcpy( q+1,p+1 ); strcpy( q+1,p+1 );
if((pFile=fopen( tmp2,"r" ))){ if((pFile=fopen( tmp2,"r" )) != nullptr){
fclose( pFile ); fclose( pFile );
strcpy(p_szString->data,tmp2); strcpy(p_szString->data,tmp2);
p_szString->length = strlen(tmp2); p_szString->length = static_cast<ai_uint32>(strlen(tmp2));
return 1; return 1;
} }
} }
@ -407,7 +407,7 @@ int CMaterialManager::FindValidPath(aiString* p_szString)
size_t iLen2 = iLen+1; size_t iLen2 = iLen+1;
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2; iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
memcpy(p_szString->data,szTemp,iLen2); memcpy(p_szString->data,szTemp,iLen2);
p_szString->length = iLen; p_szString->length = static_cast<ai_uint32>(iLen);
} }
return 1; return 1;
@ -627,7 +627,7 @@ void CMaterialManager::HMtoNMIfNecessary(
{ {
union union
{ {
struct {unsigned char b,g,r,a;}; struct {unsigned char b,g,r,a;} data;
char _array[4]; char _array[4];
}; };
}; };
@ -646,7 +646,7 @@ void CMaterialManager::HMtoNMIfNecessary(
{ {
for (unsigned int x = 0; x < sDesc.Width;++x) for (unsigned int x = 0; x < sDesc.Width;++x)
{ {
if (pcPointer->b != pcPointer->r || pcPointer->b != pcPointer->g) if (pcPointer->data.b != pcPointer->data.r || pcPointer->data.b != pcPointer->data.g)
{ {
bIsEqual = false; bIsEqual = false;
break; break;
@ -705,9 +705,9 @@ void CMaterialManager::HMtoNMIfNecessary(
aiColor3D clrColorLine; aiColor3D clrColorLine;
for (unsigned int x = 0; x < sDesc.Width;++x) for (unsigned int x = 0; x < sDesc.Width;++x)
{ {
clrColorLine.r += pcPointer->r; clrColorLine.r += pcPointer->data.r;
clrColorLine.g += pcPointer->g; clrColorLine.g += pcPointer->data.g;
clrColorLine.b += pcPointer->b; clrColorLine.b += pcPointer->data.b;
pcPointer++; pcPointer++;
} }
clrColor.r += clrColorLine.r /= (float)sDesc.Width; clrColor.r += clrColorLine.r /= (float)sDesc.Width;
@ -739,17 +739,17 @@ void CMaterialManager::HMtoNMIfNecessary(
// need to convert it NOW // need to convert it NOW
if (bMustConvert) if (bMustConvert)
{ {
D3DSURFACE_DESC sDesc; D3DSURFACE_DESC sDesc2;
piTexture->GetLevelDesc(0, &sDesc); piTexture->GetLevelDesc(0, &sDesc2);
IDirect3DTexture9* piTempTexture; IDirect3DTexture9* piTempTexture;
if(FAILED(g_piDevice->CreateTexture( if(FAILED(g_piDevice->CreateTexture(
sDesc.Width, sDesc2.Width,
sDesc.Height, sDesc2.Height,
piTexture->GetLevelCount(), piTexture->GetLevelCount(),
sDesc.Usage, sDesc2.Usage,
sDesc.Format, sDesc2.Format,
sDesc.Pool, &piTempTexture, NULL))) sDesc2.Pool, &piTempTexture, NULL)))
{ {
CLogDisplay::Instance().AddEntry( CLogDisplay::Instance().AddEntry(
"[ERROR] Unable to create normal map texture", "[ERROR] Unable to create normal map texture",

View File

@ -107,7 +107,7 @@ void MakeFileAssociations() {
RegCreateKeyEx(HKEY_CURRENT_USER,buf,0,NULL,0,KEY_ALL_ACCESS, NULL, &hRegistry,NULL); RegCreateKeyEx(HKEY_CURRENT_USER,buf,0,NULL,0,KEY_ALL_ACCESS, NULL, &hRegistry,NULL);
RegSetValueEx(hRegistry,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1); RegSetValueEx(hRegistry,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
RegCloseKey(hRegistry); RegCloseKey(hRegistry);
} while ((sz = strtok(NULL,";"))); } while ((sz = strtok(nullptr,";")) != nullptr);
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS",0,NULL,0,KEY_ALL_ACCESS, NULL, &hRegistry,NULL); RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS",0,NULL,0,KEY_ALL_ACCESS, NULL, &hRegistry,NULL);
RegCloseKey(hRegistry); RegCloseKey(hRegistry);

View File

@ -505,7 +505,7 @@ int CreateAssetData()
if (g_pcAsset->apcMeshes[i]->piOpacityTexture || 1.0f != g_pcAsset->apcMeshes[i]->fOpacity) if (g_pcAsset->apcMeshes[i]->piOpacityTexture || 1.0f != g_pcAsset->apcMeshes[i]->fOpacity)
dwUsage |= D3DUSAGE_DYNAMIC; dwUsage |= D3DUSAGE_DYNAMIC;
unsigned int nidx; unsigned int nidx = 0;
switch (mesh->mPrimitiveTypes) { switch (mesh->mPrimitiveTypes) {
case aiPrimitiveType_POINT: case aiPrimitiveType_POINT:
nidx = 1; nidx = 1;
@ -639,7 +639,7 @@ int CreateAssetData()
ai_assert( weightsPerVertex[x].size() <= 4); ai_assert( weightsPerVertex[x].size() <= 4);
for( unsigned int a = 0; a < weightsPerVertex[x].size(); a++) for( unsigned int a = 0; a < weightsPerVertex[x].size(); a++)
{ {
boneIndices[a] = weightsPerVertex[x][a].mVertexId; boneIndices[a] = static_cast<unsigned char>(weightsPerVertex[x][a].mVertexId);
boneWeights[a] = (unsigned char) (weightsPerVertex[x][a].mWeight * 255.0f); boneWeights[a] = (unsigned char) (weightsPerVertex[x][a].mWeight * 255.0f);
} }
@ -802,10 +802,10 @@ int ShutdownD3D(void)
template<class TComPtr> template<class TComPtr>
inline inline
void SafeRelease(TComPtr *ptr) { void SafeRelease(TComPtr *&ptr) {
if (nullptr != g_piPassThroughEffect) { if (nullptr != ptr) {
g_piPassThroughEffect->Release(); ptr->Release();
g_piPassThroughEffect = nullptr; ptr = nullptr;
} }
} }