Merge branch 'master' of github.com:assimp/assimp

pull/279/head
Alexander Gessler 2014-05-16 14:58:01 +02:00
commit d531945888
16 changed files with 75 additions and 25 deletions

View File

@ -4,6 +4,8 @@ before_install:
env: env:
- TRAVIS_NO_EXPORT=YES - TRAVIS_NO_EXPORT=YES
- TRAVIS_NO_EXPORT=NO - TRAVIS_NO_EXPORT=NO
- TRAVIS_STATIC_BUILD=ON
- TRAVIS_STATIC_BUILD=OFF
language: cpp language: cpp
@ -11,7 +13,7 @@ compiler:
- gcc - gcc
- clang - clang
script: cmake -G "Unix Makefiles" -DASSIMP_ENABLE_BOOST_WORKAROUND=YES -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT && make script: cmake -G "Unix Makefiles" -DASSIMP_ENABLE_BOOST_WORKAROUND=YES -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT -STATIC_BUILD=$TRAVIS_STATIC_BUILD && make

View File

@ -0,0 +1,25 @@
FIND_PATH(
assimp_INCLUDE_DIRS
NAMES postprocess.h scene.h version.h config.h cimport.h
PATHS /usr/local/include/
)
FIND_LIBRARY(
assimp_LIBRARIES
NAMES assimp
PATHS /usr/local/lib/
)
IF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
SET(assimp_FOUND TRUE)
ENDIF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
IF (assimp_FOUND)
IF (NOT assimp_FIND_QUIETLY)
MESSAGE(STATUS "Found asset importer library: ${assimp_LIBRARIES}")
ENDIF (NOT assimp_FIND_QUIETLY)
ELSE (assimp_FOUND)
IF (assimp_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find asset importer library")
ENDIF (assimp_FIND_REQUIRED)
ENDIF (assimp_FOUND)

View File

@ -4,6 +4,7 @@
# 3) Add libassimp using the file lists (eliminates duplication of file names between # 3) Add libassimp using the file lists (eliminates duplication of file names between
# source groups and library command) # source groups and library command)
# #
cmake_minimum_required( VERSION 2.6 )
SET( HEADER_PATH ../include/assimp ) SET( HEADER_PATH ../include/assimp )
SET( COMPILER_HEADERS SET( COMPILER_HEADERS

View File

@ -95,7 +95,7 @@ Exporter::ExportFormatEntry gExporters[] =
Exporter::ExportFormatEntry( "stl", "Stereolithography", "stl" , &ExportSceneSTL, Exporter::ExportFormatEntry( "stl", "Stereolithography", "stl" , &ExportSceneSTL,
aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices
), ),
Exporter::ExportFormatEntry( "stlb", "Stereolithography(binary)", "stlb" , &ExportSceneSTLBinary, Exporter::ExportFormatEntry( "stlb", "Stereolithography (binary)", "stl" , &ExportSceneSTLBinary,
aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices
), ),
#endif #endif

View File

@ -86,7 +86,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
{ {
DefaultLogger::get()->debug("RemoveRedundantMatsProcess begin"); DefaultLogger::get()->debug("RemoveRedundantMatsProcess begin");
unsigned int iCnt = 0, unreferenced = 0; unsigned int redundantRemoved = 0, unreferencedRemoved = 0;
if (pScene->mNumMaterials) if (pScene->mNumMaterials)
{ {
// Find out which materials are referenced by meshes // Find out which materials are referenced by meshes
@ -125,9 +125,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
} }
} }
// TODO: reimplement this algorithm to work in-place // TODO: reimplement this algorithm to work in-place
unsigned int* aiMappingTable = new unsigned int[pScene->mNumMaterials]; unsigned int* aiMappingTable = new unsigned int[pScene->mNumMaterials];
unsigned int iNewNum = 0; unsigned int iNewNum = 0;
@ -139,37 +137,42 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
aiHashes = new uint32_t[pScene->mNumMaterials]; aiHashes = new uint32_t[pScene->mNumMaterials];
for (unsigned int i = 0; i < pScene->mNumMaterials;++i) for (unsigned int i = 0; i < pScene->mNumMaterials;++i)
{ {
// if the material is not referenced ... remove it // No mesh is referencing this material, remove it.
if (!abReferenced[i]) { if (!abReferenced[i]) {
++unreferenced; ++unreferencedRemoved;
delete pScene->mMaterials[i]; delete pScene->mMaterials[i];
continue; continue;
} }
// Check all previously mapped materials for a matching hash.
// On a match we can delete this material and just make it ref to the same index.
uint32_t me = aiHashes[i] = ComputeMaterialHash(pScene->mMaterials[i]); uint32_t me = aiHashes[i] = ComputeMaterialHash(pScene->mMaterials[i]);
for (unsigned int a = 0; a < i;++a) for (unsigned int a = 0; a < i;++a)
{ {
if (abReferenced[a] && me == aiHashes[a]) { if (abReferenced[a] && me == aiHashes[a]) {
++iCnt; ++redundantRemoved;
me = 0; me = 0;
aiMappingTable[i] = aiMappingTable[a]; aiMappingTable[i] = aiMappingTable[a];
delete pScene->mMaterials[i]; delete pScene->mMaterials[i];
break; break;
} }
} }
// This is a new material that is referenced, add to the map.
if (me) { if (me) {
aiMappingTable[i] = iNewNum++; aiMappingTable[i] = iNewNum++;
} }
} }
if (iCnt) { // If the new material count differs from the original,
// build an output material list // we need to rebuild the material list and remap mesh material indexes.
if (iNewNum != pScene->mNumMaterials) {
aiMaterial** ppcMaterials = new aiMaterial*[iNewNum]; aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];
::memset(ppcMaterials,0,sizeof(void*)*iNewNum); ::memset(ppcMaterials,0,sizeof(void*)*iNewNum);
for (unsigned int p = 0; p < pScene->mNumMaterials;++p) for (unsigned int p = 0; p < pScene->mNumMaterials;++p)
{ {
// if the material is not referenced ... remove it // if the material is not referenced ... remove it
if (!abReferenced[p]) if (!abReferenced[p]) {
continue; continue;
}
// generate new names for all modified materials // generate new names for all modified materials
const unsigned int idx = aiMappingTable[p]; const unsigned int idx = aiMappingTable[p];
@ -179,10 +182,11 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
sz.length = ::sprintf(sz.data,"JoinedMaterial_#%i",p); sz.length = ::sprintf(sz.data,"JoinedMaterial_#%i",p);
((aiMaterial*)ppcMaterials[idx])->AddProperty(&sz,AI_MATKEY_NAME); ((aiMaterial*)ppcMaterials[idx])->AddProperty(&sz,AI_MATKEY_NAME);
} }
else ppcMaterials[idx] = pScene->mMaterials[p]; else
ppcMaterials[idx] = pScene->mMaterials[p];
} }
// update all material indices // update all material indices
for (unsigned int p = 0; p < pScene->mNumMeshes;++p) { for (unsigned int p = 0; p < pScene->mNumMeshes;++p) {
aiMesh* mesh = pScene->mMeshes[p]; aiMesh* mesh = pScene->mMeshes[p];
mesh->mMaterialIndex = aiMappingTable[mesh->mMaterialIndex]; mesh->mMaterialIndex = aiMappingTable[mesh->mMaterialIndex];
} }
@ -195,12 +199,15 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
delete[] aiHashes; delete[] aiHashes;
delete[] aiMappingTable; delete[] aiMappingTable;
} }
if (!iCnt)DefaultLogger::get()->debug("RemoveRedundantMatsProcess finished "); if (redundantRemoved == 0 && unreferencedRemoved == 0)
{
DefaultLogger::get()->debug("RemoveRedundantMatsProcess finished ");
}
else else
{ {
char szBuffer[128]; // should be sufficiently large char szBuffer[128]; // should be sufficiently large
::sprintf(szBuffer,"RemoveRedundantMatsProcess finished. %i redundant and %i unused materials", ::sprintf(szBuffer,"RemoveRedundantMatsProcess finished. Removed %i redundant and %i unused materials.",
iCnt,unreferenced); redundantRemoved,unreferencedRemoved);
DefaultLogger::get()->info(szBuffer); DefaultLogger::get()->info(szBuffer);
} }
} }

View File

@ -136,6 +136,9 @@ XFileParser::XFileParser( const std::vector<char>& pBuffer)
ThrowException( boost::str( boost::format( "Unknown float size %1% specified in xfile header.") ThrowException( boost::str( boost::format( "Unknown float size %1% specified in xfile header.")
% mBinaryFloatSize)); % mBinaryFloatSize));
// The x format specifies size in bits, but we work in bytes
mBinaryFloatSize /= 8;
P += 16; P += 16;
// If this is a compressed X file, apply the inflate algorithm to it // If this is a compressed X file, apply the inflate algorithm to it

View File

@ -144,7 +144,7 @@ protected:
protected: protected:
unsigned int mMajorVersion, mMinorVersion; ///< version numbers unsigned int mMajorVersion, mMinorVersion; ///< version numbers
bool mIsBinaryFormat; ///< true if the file is in binary, false if it's in text form bool mIsBinaryFormat; ///< true if the file is in binary, false if it's in text form
unsigned int mBinaryFloatSize; ///< float size, either 32 or 64 bits unsigned int mBinaryFloatSize; ///< float size in bytes, either 4 or 8
// counter for number arrays in binary format // counter for number arrays in binary format
unsigned int mBinaryNumCount; unsigned int mBinaryNumCount;

View File

@ -211,10 +211,10 @@ struct aiExportDataBlob
extension that should be used when writing extension that should be used when writing
the data to disc. the data to disc.
*/ */
aiString name; C_STRUCT aiString name;
/** Pointer to the next blob in the chain or NULL if there is none. */ /** Pointer to the next blob in the chain or NULL if there is none. */
aiExportDataBlob * next; C_STRUCT aiExportDataBlob * next;
#ifdef __cplusplus #ifdef __cplusplus
/// Default constructor /// Default constructor
@ -247,7 +247,7 @@ ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const C_STRUCT
* returned by aiExportScene(). * returned by aiExportScene().
* @param pData the data blob returned by #aiExportSceneToBlob * @param pData the data blob returned by #aiExportSceneToBlob
*/ */
ASSIMP_API C_STRUCT void aiReleaseExportBlob( const C_STRUCT aiExportDataBlob* pData ); ASSIMP_API void aiReleaseExportBlob( const C_STRUCT aiExportDataBlob* pData );
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -371,7 +371,7 @@ struct aiString
/** Standard return type for some library functions. /** Standard return type for some library functions.
* Rarely used, and if, mostly in the C API. * Rarely used, and if, mostly in the C API.
*/ */
enum aiReturn typedef enum aiReturn
{ {
/** Indicates that a function was successful */ /** Indicates that a function was successful */
aiReturn_SUCCESS = 0x0, aiReturn_SUCCESS = 0x0,
@ -388,7 +388,7 @@ enum aiReturn
* Force 32-bit size enum * Force 32-bit size enum
*/ */
_AI_ENFORCE_ENUM_SIZE = 0x7fffffff _AI_ENFORCE_ENUM_SIZE = 0x7fffffff
}; // !enum aiReturn } aiReturn; // !enum aiReturn
// just for backwards compatibility, don't use these constants anymore // just for backwards compatibility, don't use these constants anymore
#define AI_SUCCESS aiReturn_SUCCESS #define AI_SUCCESS aiReturn_SUCCESS

View File

@ -88,6 +88,7 @@ public:
// comparison // comparison
bool operator== (const aiVector3t& other) const; bool operator== (const aiVector3t& other) const;
bool operator!= (const aiVector3t& other) const; bool operator!= (const aiVector3t& other) const;
bool operator < (const aiVector3t& other) const;
bool Equal(const aiVector3t& other, TReal epsilon = 1e-6) const; bool Equal(const aiVector3t& other, TReal epsilon = 1e-6) const;

View File

@ -159,6 +159,11 @@ AI_FORCE_INLINE bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TR
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
AI_FORCE_INLINE bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
return x != other.x ? x < other.x : y != other.y ? y < other.y : z < other.z;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) { AI_FORCE_INLINE const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
return aiVector3t<TReal>(x*o.x,y*o.y,z*o.z); return aiVector3t<TReal>(x*o.x,y*o.y,z*o.z);
} }

View File

@ -1,3 +1,5 @@
cmake_minimum_required( VERSION 2.6 )
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${Assimp_SOURCE_DIR}/include ${Assimp_SOURCE_DIR}/include
${Assimp_SOURCE_DIR}/code ${Assimp_SOURCE_DIR}/code

Binary file not shown.

View File

@ -5,4 +5,5 @@
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/version.h> #include <assimp/version.h>
#include <assimp/config.h> #include <assimp/config.h>
#include <assimp/cimport.h> #include <assimp/cimport.h>
#include <assimp/cexport.h>

View File

@ -1,3 +1,5 @@
cmake_minimum_required( VERSION 2.6 )
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${Assimp_SOURCE_DIR}/include ${Assimp_SOURCE_DIR}/include
${Assimp_SOURCE_DIR}/code ${Assimp_SOURCE_DIR}/code

View File

@ -1,5 +1,6 @@
FIND_PACKAGE(DirectX REQUIRED) cmake_minimum_required( VERSION 2.6 )
FIND_PACKAGE(DirectX REQUIRED)
INCLUDE_DIRECTORIES ( INCLUDE_DIRECTORIES (
${Assimp_SOURCE_DIR}/include ${Assimp_SOURCE_DIR}/include