Compare commits

..

13 Commits

Author SHA1 Message Date
Kim Kulling
36c08a0a7d Merge branch 'master' of https://github.com/assimp/assimp 2014-05-12 20:00:59 +02:00
Kim Kulling
52f3cd0afb update: add static build to CI.
Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
2014-05-12 20:00:29 +02:00
Kim Kulling
c5ba04cabf Merge pull request #274 from JamesLupiani/BinaryXFileFix
Fixes #158 via anonymous user
2014-05-12 19:57:50 +02:00
James Lupiani
427eaad642 Fixes #158 via anonymous user 2014-05-12 12:04:19 -05:00
Alexander Gessler
04f0075b63 Change default extension for binary STL exports from stlb to stl 2014-05-12 12:50:21 +02:00
Kim Kulling
fb1c9ab86d bugfix: fix cexport API for c compilers. 2014-05-11 16:50:35 +02:00
Kim Kulling
9245469fb8 bugfix: fix invalid include path in find assimp macro for cmake. 2014-05-11 14:01:30 +02:00
Kim Kulling
22d026ac40 update: add asset importer lib cmake find macro. 2014-05-11 13:56:38 +02:00
Kim Kulling
f6925db3d8 update: add cmake_mimimum_required statement to each cmake file
for consistency
2014-05-10 10:31:42 +02:00
Kim Kulling
d5d9e59949 Merge pull request #270 from jonnenauha/redundant-material-fix
RemoveRedundantMaterials: Fix crash bug when unreferenced materials are removed.
2014-05-09 18:36:39 +02:00
Jonne Nauha
eea8099b05 RemoveRedundantMaterials: Fix crash bug when unreferenced materials were destroyed. The logic only rebuilt the material list if there were redundant materials being removed. This is a clear bug as it left freed aiMaterial ptrs into the list and did not fix the scene->numMaterials to be correct, even when deleting materials. This crashed later on in the ComputeUVMappingsProcess that accessed the freed ptr. 2014-05-09 01:33:30 +03:00
Kim Kulling
a5e179edf5 Merge pull request #267 from terziman/master
Fixed compilation errors on OgreImporter with Visual Studio 2012
2014-05-05 13:49:36 +02:00
Léo Terziman
f8b79acb36 Fixed compilation errors on OgreImporter with Visual Studio 2012 2014-05-05 10:25:04 +02:00
14 changed files with 78 additions and 34 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

@@ -111,7 +111,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
// Read root node
NextNode(reader.get());
if (!CurrentNodeNameEquals(reader, "mesh")) {
if (!CurrentNodeNameEquals(reader.get(), "mesh")) {
throw DeadlyImportError("Root node is not <mesh> but <" + string(reader->getNodeName()) + "> in " + pFile);
}
@@ -127,20 +127,20 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
// This can be used to share geometry between submeshes
NextNode(reader.get());
if (CurrentNodeNameEquals(reader, nnSharedGeometry))
if (CurrentNodeNameEquals(reader.get(), nnSharedGeometry))
{
DefaultLogger::get()->debug("Reading shared geometry");
unsigned int NumVertices = GetAttribute<unsigned int>(reader.get(), "vertexcount");
NextNode(reader.get());
while(CurrentNodeNameEquals(reader, nnVertexBuffer)) {
while(CurrentNodeNameEquals(reader.get(), nnVertexBuffer)) {
ReadVertexBuffer(m_SharedGeometry, reader.get(), NumVertices);
}
}
// -------------------- Sub Meshes --------------------
if (!CurrentNodeNameEquals(reader, nnSubMeshes)) {
if (!CurrentNodeNameEquals(reader.get(), nnSubMeshes)) {
throw DeadlyImportError("Could not find <submeshes> node inside root <mesh> node");
}
@@ -148,7 +148,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
vector<aiMaterial*> materials;
NextNode(reader.get());
while(CurrentNodeNameEquals(reader, nnSubMesh))
while(CurrentNodeNameEquals(reader.get(), nnSubMesh))
{
SubMesh* submesh = new SubMesh();
ReadSubMesh(subMeshes.size(), *submesh, reader.get());
@@ -178,10 +178,10 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
// Skip submesh names.
/// @todo Should these be read to scene etc. metadata?
if (CurrentNodeNameEquals(reader, nnSubMeshNames))
if (CurrentNodeNameEquals(reader.get(), nnSubMeshNames))
{
NextNode(reader.get());
while(CurrentNodeNameEquals(reader, nnSubMesh)) {
while(CurrentNodeNameEquals(reader.get(), nnSubMesh)) {
NextNode(reader.get());
}
}
@@ -191,7 +191,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
vector<Bone> Bones;
vector<Animation> Animations;
if (CurrentNodeNameEquals(reader, nnSkeletonLink))
if (CurrentNodeNameEquals(reader.get(), nnSkeletonLink))
{
string skeletonFile = GetAttribute<string>(reader.get(), "name");
if (!skeletonFile.empty())
@@ -210,7 +210,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
}
// Now there might be <boneassignments> for the shared geometry
if (CurrentNodeNameEquals(reader, "boneassignments")) {
if (CurrentNodeNameEquals(reader.get(), "boneassignments")) {
ReadBoneWeights(m_SharedGeometry, reader.get());
}

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

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

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