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:
- TRAVIS_NO_EXPORT=YES
- TRAVIS_NO_EXPORT=NO
- TRAVIS_STATIC_BUILD=ON
- TRAVIS_STATIC_BUILD=OFF
language: cpp
@ -11,7 +13,7 @@ compiler:
- gcc
- 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
# source groups and library command)
#
cmake_minimum_required( VERSION 2.6 )
SET( HEADER_PATH ../include/assimp )
SET( COMPILER_HEADERS

View File

@ -95,7 +95,7 @@ Exporter::ExportFormatEntry gExporters[] =
Exporter::ExportFormatEntry( "stl", "Stereolithography", "stl" , &ExportSceneSTL,
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
),
#endif

View File

@ -86,7 +86,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
{
DefaultLogger::get()->debug("RemoveRedundantMatsProcess begin");
unsigned int iCnt = 0, unreferenced = 0;
unsigned int redundantRemoved = 0, unreferencedRemoved = 0;
if (pScene->mNumMaterials)
{
// 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
unsigned int* aiMappingTable = new unsigned int[pScene->mNumMaterials];
unsigned int iNewNum = 0;
@ -139,37 +137,42 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
aiHashes = new uint32_t[pScene->mNumMaterials];
for (unsigned int i = 0; i < pScene->mNumMaterials;++i)
{
// if the material is not referenced ... remove it
if (!abReferenced[i]) {
++unreferenced;
// No mesh is referencing this material, remove it.
if (!abReferenced[i]) {
++unreferencedRemoved;
delete pScene->mMaterials[i];
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]);
for (unsigned int a = 0; a < i;++a)
{
if (abReferenced[a] && me == aiHashes[a]) {
++iCnt;
++redundantRemoved;
me = 0;
aiMappingTable[i] = aiMappingTable[a];
delete pScene->mMaterials[i];
break;
}
}
// This is a new material that is referenced, add to the map.
if (me) {
aiMappingTable[i] = iNewNum++;
}
}
if (iCnt) {
// build an output material list
// If the new material count differs from the original,
// we need to rebuild the material list and remap mesh material indexes.
if (iNewNum != pScene->mNumMaterials) {
aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];
::memset(ppcMaterials,0,sizeof(void*)*iNewNum);
for (unsigned int p = 0; p < pScene->mNumMaterials;++p)
{
// if the material is not referenced ... remove it
if (!abReferenced[p])
if (!abReferenced[p]) {
continue;
}
// generate new names for all modified materials
const unsigned int idx = aiMappingTable[p];
@ -179,10 +182,11 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
sz.length = ::sprintf(sz.data,"JoinedMaterial_#%i",p);
((aiMaterial*)ppcMaterials[idx])->AddProperty(&sz,AI_MATKEY_NAME);
}
else ppcMaterials[idx] = pScene->mMaterials[p];
else
ppcMaterials[idx] = pScene->mMaterials[p];
}
// 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];
mesh->mMaterialIndex = aiMappingTable[mesh->mMaterialIndex];
}
@ -195,12 +199,15 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
delete[] aiHashes;
delete[] aiMappingTable;
}
if (!iCnt)DefaultLogger::get()->debug("RemoveRedundantMatsProcess finished ");
if (redundantRemoved == 0 && unreferencedRemoved == 0)
{
DefaultLogger::get()->debug("RemoveRedundantMatsProcess finished ");
}
else
{
char szBuffer[128]; // should be sufficiently large
::sprintf(szBuffer,"RemoveRedundantMatsProcess finished. %i redundant and %i unused materials",
iCnt,unreferenced);
::sprintf(szBuffer,"RemoveRedundantMatsProcess finished. Removed %i redundant and %i unused materials.",
redundantRemoved,unreferencedRemoved);
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.")
% mBinaryFloatSize));
// The x format specifies size in bits, but we work in bytes
mBinaryFloatSize /= 8;
P += 16;
// If this is a compressed X file, apply the inflate algorithm to it

View File

@ -144,7 +144,7 @@ protected:
protected:
unsigned int mMajorVersion, mMinorVersion; ///< version numbers
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
unsigned int mBinaryNumCount;

View File

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

View File

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

View File

@ -88,6 +88,7 @@ public:
// comparison
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;

View File

@ -159,6 +159,11 @@ AI_FORCE_INLINE bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TR
}
// ------------------------------------------------------------------------------------------------
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) {
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(
${Assimp_SOURCE_DIR}/include
${Assimp_SOURCE_DIR}/code

Binary file not shown.

View File

@ -5,4 +5,5 @@
#include <assimp/scene.h>
#include <assimp/version.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(
${Assimp_SOURCE_DIR}/include
${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 (
${Assimp_SOURCE_DIR}/include