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(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
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
IF(NOT ASSIMP_HUNTER_ENABLED)
@ -350,14 +345,6 @@ ELSE()
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
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)
IF (ASSIMP_INJECT_DEBUG_POSTFIX AND (is_multi_config OR CMAKE_BUILD_TYPE STREQUAL "Debug"))
@ -417,6 +404,28 @@ ELSE()
else()
set(BUILD_LIB_TYPE STATIC)
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}/assimpTargets.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" @ONLY IMMEDIATE)
IF (is_multi_config)

View File

@ -1,7 +1,5 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@/
libdir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_LIB_INSTALL_DIR@
includedir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_INCLUDE_INSTALL_DIR@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @CMAKE_PROJECT_NAME@
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"
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(assimp::assimp PROPERTIES
IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/${importLibraryName}"
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/${sharedLibraryName}"
IMPORTED_IMPLIB_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}"
IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}"
)
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 "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" )
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}")
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}" )
else()
set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
# Import target "assimp::assimp" for configuration "Debug"
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
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_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}")
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}")
endif()
else()
@ -75,17 +75,17 @@ else()
endif()
set_target_properties(assimp::assimp PROPERTIES
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_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" )
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" )
else()
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
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_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}" )
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" )
endif()
endif()

View File

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

View File

@ -43,23 +43,13 @@ unset(_targetsDefined)
unset(_targetsNotDefined)
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
add_library(assimp::assimp @BUILD_LIB_TYPE@ IMPORTED)
set_target_properties(assimp::assimp PROPERTIES
COMPATIBLE_INTERFACE_STRING "assimp_MAJOR_VERSION"
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"
)
@ -74,9 +64,6 @@ foreach(f ${CONFIG_FILES})
include(${f})
endforeach()
# Cleanup temporary variables.
set(_IMPORT_PREFIX)
# Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} )
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team
All rights reserved.
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
All rights reserved.
Redistribution and use of this software in source and binary forms,
@ -51,45 +50,44 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXImportSettings.h"
namespace Assimp {
namespace Assimp {
// TinyFormatter.h
namespace Formatter {
template <typename T,typename TR, typename A> class basic_formatter;
typedef class basic_formatter< char, std::char_traits<char>, std::allocator<char> > format;
}
template <typename T, typename TR, typename A>
class basic_formatter;
typedef class basic_formatter<char, std::char_traits<char>, std::allocator<char>> format;
} // namespace Formatter
// -------------------------------------------------------------------------------------------
/** Load the Autodesk FBX file format.
See http://en.wikipedia.org/wiki/FBX
*/
/// Loads the Autodesk FBX file format.
///
/// See http://en.wikipedia.org/wiki/FBX
// -------------------------------------------------------------------------------------------
class FBXImporter : public BaseImporter, public LogFunctions<FBXImporter>
{
class FBXImporter : public BaseImporter, public LogFunctions<FBXImporter> {
public:
FBXImporter();
virtual ~FBXImporter();
// --------------------
bool CanRead( const std::string& pFile,
IOSystem* pIOHandler,
bool checkSig
) const;
bool CanRead(const std::string &pFile,
IOSystem *pIOHandler,
bool checkSig) const;
protected:
// --------------------
const aiImporterDesc *GetInfo() const;
// --------------------
const aiImporterDesc* GetInfo () const;
void SetupProperties(const Importer *pImp);
// --------------------
void SetupProperties(const Importer* pImp);
// --------------------
void InternReadFile( const std::string& pFile,
aiScene* pScene,
IOSystem* pIOHandler
);
void InternReadFile(const std::string &pFile,
aiScene *pScene,
IOSystem *pIOHandler);
private:
FBX::ImportSettings settings;
@ -97,4 +95,3 @@ private:
} // end of namespace Assimp
#endif // !INCLUDED_AI_FBX_IMPORTER_H

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@ -49,29 +47,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_METADATA_H_INC
#ifdef __GNUC__
# pragma GCC system_header
#pragma GCC system_header
#endif
#if defined(_MSC_VER) && (_MSC_VER <= 1500)
# include "Compiler/pstdint.h"
#include "Compiler/pstdint.h"
#else
# include <stdint.h>
#include <stdint.h>
#endif
// -------------------------------------------------------------------------------
/**
* Enum used to distinguish data types
*/
// -------------------------------------------------------------------------------
// -------------------------------------------------------------------------------
typedef enum aiMetadataType {
AI_BOOL = 0,
AI_INT32 = 1,
AI_UINT64 = 2,
AI_FLOAT = 3,
AI_DOUBLE = 4,
AI_AISTRING = 5,
AI_BOOL = 0,
AI_INT32 = 1,
AI_UINT64 = 2,
AI_FLOAT = 3,
AI_DOUBLE = 4,
AI_AISTRING = 5,
AI_AIVECTOR3D = 6,
AI_META_MAX = 7,
AI_META_MAX = 7,
#ifndef SWIG
FORCE_32BIT = INT_MAX
@ -84,10 +82,10 @@ typedef enum aiMetadataType {
*
* The type field uniquely identifies the underlying type of the data field
*/
// -------------------------------------------------------------------------------
// -------------------------------------------------------------------------------
struct aiMetadataEntry {
aiMetadataType mType;
void* mData;
void *mData;
};
#ifdef __cplusplus
@ -98,15 +96,29 @@ struct aiMetadataEntry {
/**
* Helper functions to get the aiType enum entry for a type
*/
// -------------------------------------------------------------------------------
// -------------------------------------------------------------------------------
inline aiMetadataType GetAiType( bool ) { return AI_BOOL; }
inline aiMetadataType GetAiType( int32_t ) { return AI_INT32; }
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; }
inline aiMetadataType GetAiType(bool) {
return AI_BOOL;
}
inline aiMetadataType GetAiType(int32_t) {
return AI_INT32;
}
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
@ -116,17 +128,17 @@ inline aiMetadataType GetAiType( const aiVector3D & ) { return AI_AIVECTOR3D; }
*
* Metadata is a key-value store using string keys and values.
*/
// -------------------------------------------------------------------------------
// -------------------------------------------------------------------------------
struct aiMetadata {
/** Length of the mKeys and mValues arrays, respectively */
unsigned int mNumProperties;
/** Arrays of keys, may not be NULL. Entries in this array may not be NULL as well. */
C_STRUCT aiString* mKeys;
C_STRUCT aiString *mKeys;
/** Arrays of values, may not be NULL. Entries in this array may be NULL if the
* corresponding property key has no assigned value. */
C_STRUCT aiMetadataEntry* mValues;
C_STRUCT aiMetadataEntry *mValues;
#ifdef __cplusplus
@ -134,71 +146,62 @@ struct aiMetadata {
* @brief The default constructor, set all members to zero by default.
*/
aiMetadata() AI_NO_EXCEPT
: mNumProperties(0)
, mKeys(nullptr)
, mValues(nullptr) {
: mNumProperties(0),
mKeys(nullptr),
mValues(nullptr) {
// empty
}
aiMetadata( const aiMetadata &rhs )
: mNumProperties( rhs.mNumProperties )
, mKeys( nullptr )
, mValues( nullptr ) {
mKeys = new aiString[ mNumProperties ];
for ( size_t i = 0; i < static_cast<size_t>( mNumProperties ); ++i ) {
mKeys[ i ] = rhs.mKeys[ i ];
aiMetadata(const aiMetadata &rhs) :
mNumProperties(rhs.mNumProperties), mKeys(nullptr), mValues(nullptr) {
mKeys = new aiString[mNumProperties];
for (size_t i = 0; i < static_cast<size_t>(mNumProperties); ++i) {
mKeys[i] = rhs.mKeys[i];
}
mValues = new aiMetadataEntry[ mNumProperties ];
for ( size_t i = 0; i < static_cast<size_t>(mNumProperties); ++i ) {
mValues[ i ].mType = rhs.mValues[ i ].mType;
switch ( rhs.mValues[ i ].mType ) {
mValues = new aiMetadataEntry[mNumProperties];
for (size_t i = 0; i < static_cast<size_t>(mNumProperties); ++i) {
mValues[i].mType = rhs.mValues[i].mType;
switch (rhs.mValues[i].mType) {
case AI_BOOL:
mValues[ i ].mData = new bool;
::memcpy( mValues[ i ].mData, rhs.mValues[ i ].mData, sizeof(bool) );
mValues[i].mData = new bool;
::memcpy(mValues[i].mData, rhs.mValues[i].mData, sizeof(bool));
break;
case AI_INT32: {
int32_t v;
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( int32_t ) );
mValues[ i ].mData = new int32_t( v );
}
break;
::memcpy(&v, rhs.mValues[i].mData, sizeof(int32_t));
mValues[i].mData = new int32_t(v);
} break;
case AI_UINT64: {
uint64_t v;
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( uint64_t ) );
mValues[ i ].mData = new uint64_t( v );
}
break;
uint64_t v;
::memcpy(&v, rhs.mValues[i].mData, sizeof(uint64_t));
mValues[i].mData = new uint64_t(v);
} break;
case AI_FLOAT: {
float v;
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( float ) );
mValues[ i ].mData = new float( v );
}
break;
float v;
::memcpy(&v, rhs.mValues[i].mData, sizeof(float));
mValues[i].mData = new float(v);
} break;
case AI_DOUBLE: {
double v;
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( double ) );
mValues[ i ].mData = new double( v );
}
break;
double v;
::memcpy(&v, rhs.mValues[i].mData, sizeof(double));
mValues[i].mData = new double(v);
} break;
case AI_AISTRING: {
aiString v;
rhs.Get<aiString>( mKeys[ i ], v );
mValues[ i ].mData = new aiString( v );
}
break;
aiString v;
rhs.Get<aiString>(mKeys[i], v);
mValues[i].mData = new aiString(v);
} break;
case AI_AIVECTOR3D: {
aiVector3D v;
rhs.Get<aiVector3D>( mKeys[ i ], v );
mValues[ i ].mData = new aiVector3D( v );
}
break;
aiVector3D v;
rhs.Get<aiVector3D>(mKeys[i], v);
mValues[i].mData = new aiVector3D(v);
} break;
#ifndef SWIG
case FORCE_32BIT:
#endif
default:
break;
}
}
}
@ -206,33 +209,33 @@ struct aiMetadata {
* @brief The destructor.
*/
~aiMetadata() {
delete [] mKeys;
delete[] mKeys;
mKeys = nullptr;
if (mValues) {
// Delete each metadata entry
for (unsigned i=0; i<mNumProperties; ++i) {
void* data = mValues[i].mData;
for (unsigned i = 0; i < mNumProperties; ++i) {
void *data = mValues[i].mData;
switch (mValues[i].mType) {
case AI_BOOL:
delete static_cast< bool* >( data );
delete static_cast<bool *>(data);
break;
case AI_INT32:
delete static_cast< int32_t* >( data );
delete static_cast<int32_t *>(data);
break;
case AI_UINT64:
delete static_cast< uint64_t* >( data );
delete static_cast<uint64_t *>(data);
break;
case AI_FLOAT:
delete static_cast< float* >( data );
delete static_cast<float *>(data);
break;
case AI_DOUBLE:
delete static_cast< double* >( data );
delete static_cast<double *>(data);
break;
case AI_AISTRING:
delete static_cast< aiString* >( data );
delete static_cast<aiString *>(data);
break;
case AI_AIVECTOR3D:
delete static_cast< aiVector3D* >( data );
delete static_cast<aiVector3D *>(data);
break;
#ifndef SWIG
case FORCE_32BIT:
@ -243,7 +246,7 @@ struct aiMetadata {
}
// Delete the metadata array
delete [] mValues;
delete[] mValues;
mValues = nullptr;
}
}
@ -252,16 +255,15 @@ struct aiMetadata {
* @brief Allocates property fields + keys.
* @param numProperties Number of requested properties.
*/
static inline
aiMetadata *Alloc( unsigned int numProperties ) {
if ( 0 == numProperties ) {
static inline aiMetadata *Alloc(unsigned int numProperties) {
if (0 == numProperties) {
return nullptr;
}
aiMetadata *data = new aiMetadata;
data->mNumProperties = numProperties;
data->mKeys = new aiString[ data->mNumProperties ]();
data->mValues = new aiMetadataEntry[ data->mNumProperties ]();
data->mKeys = new aiString[data->mNumProperties]();
data->mValues = new aiMetadataEntry[data->mNumProperties]();
return data;
}
@ -269,44 +271,40 @@ struct aiMetadata {
/**
* @brief Deallocates property fields + keys.
*/
static inline
void Dealloc( aiMetadata *metadata ) {
static inline void Dealloc(aiMetadata *metadata) {
delete metadata;
}
template<typename T>
inline
void Add(const std::string& key, const T& value) {
aiString* new_keys = new aiString[mNumProperties + 1];
aiMetadataEntry* new_values = new aiMetadataEntry[mNumProperties + 1];
template <typename T>
inline void Add(const std::string &key, const T &value) {
aiString *new_keys = new aiString[mNumProperties + 1];
aiMetadataEntry *new_values = new aiMetadataEntry[mNumProperties + 1];
for(unsigned int i = 0; i < mNumProperties; ++i)
{
new_keys[i] = mKeys[i];
new_values[i] = mValues[i];
}
for (unsigned int i = 0; i < mNumProperties; ++i) {
new_keys[i] = mKeys[i];
new_values[i] = mValues[i];
}
delete[] mKeys;
delete[] mValues;
delete[] mKeys;
delete[] mValues;
mKeys = new_keys;
mValues = new_values;
mKeys = new_keys;
mValues = new_values;
mNumProperties++;
mNumProperties++;
Set(mNumProperties - 1, key, value);
}
Set(mNumProperties - 1, key, value);
}
template<typename T>
inline
bool Set( unsigned index, const std::string& key, const T& value ) {
template <typename T>
inline bool Set(unsigned index, const std::string &key, const T &value) {
// In range assertion
if ( index >= mNumProperties ) {
if (index >= mNumProperties) {
return false;
}
// Ensure that we have a valid key.
if ( key.empty() ) {
if (key.empty()) {
return false;
}
@ -321,73 +319,86 @@ struct aiMetadata {
return true;
}
template<typename T>
inline
bool Get( unsigned index, T& value ) const {
template <typename T>
inline bool Set( const std::string &key, const T &value ) {
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
if ( index >= mNumProperties ) {
if (index >= mNumProperties) {
return false;
}
// Return false if the output data type does
// not match the found value's data type
if ( GetAiType( value ) != mValues[ index ].mType ) {
if (GetAiType(value) != mValues[index].mType) {
return false;
}
// Otherwise, output the found value and
// return true
value = *static_cast<T*>(mValues[index].mData);
value = *static_cast<T *>(mValues[index].mData);
return true;
}
template<typename T>
inline
bool Get( const aiString& key, T& value ) const {
template <typename T>
inline bool Get(const aiString &key, T &value) const {
// Search for the given key
for ( unsigned int i = 0; i < mNumProperties; ++i ) {
if ( mKeys[ i ] == key ) {
return Get( i, value );
for (unsigned int i = 0; i < mNumProperties; ++i) {
if (mKeys[i] == key) {
return Get(i, value);
}
}
return false;
}
template<typename T>
inline
bool Get( const std::string& key, T& value ) const {
template <typename T>
inline bool Get(const std::string &key, T &value) const {
return Get(aiString(key), value);
}
/// Return metadata entry for analyzing it by user.
/// \param [in] pIndex - index of the entry.
/// \param [out] pKey - pointer to the key value.
/// \param [out] pEntry - pointer to the entry: type and value.
/// \return false - if pIndex is out of range, else - true.
inline
bool Get(size_t index, const aiString*& key, const aiMetadataEntry*& entry) const {
if ( index >= mNumProperties ) {
/// Return metadata entry for analyzing it by user.
/// \param [in] pIndex - index of the entry.
/// \param [out] pKey - pointer to the key value.
/// \param [out] pEntry - pointer to the entry: type and value.
/// \return false - if pIndex is out of range, else - true.
inline bool Get(size_t index, const aiString *&key, const aiMetadataEntry *&entry) const {
if (index >= mNumProperties) {
return false;
}
key = &mKeys[index];
entry = &mValues[index];
key = &mKeys[index];
entry = &mValues[index];
return true;
}
return true;
}
/// Check whether there is a metadata entry for the given key.
/// \param [in] Key - the key value value to check for.
inline
bool HasKey(const char* key) {
if ( nullptr == key ) {
inline bool HasKey(const char *key) {
if (nullptr == key) {
return false;
}
// Search for the given key
for (unsigned int i = 0; i < mNumProperties; ++i) {
if ( 0 == strncmp(mKeys[i].C_Str(), key, mKeys[i].length ) ) {
if (0 == strncmp(mKeys[i].C_Str(), key, mKeys[i].length)) {
return true;
}
}
@ -395,7 +406,6 @@ struct aiMetadata {
}
#endif // __cplusplus
};
#endif // AI_METADATA_H_INC

View File

@ -213,6 +213,10 @@ TEST_F(utFBXImporterExporter, importUnitScaleFactor) {
double factor(0.0);
scene->mMetaData->Get("UnitScaleFactor", 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) {

View File

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

View File

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

View File

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