replace NULL and avoid ai_assert with more than 2 tests.
This commit is contained in:
@@ -46,22 +46,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define INCLUDED_AI_BASEIMPORTER_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include "Exceptional.h"
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/ProgressHandler.hpp>
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
struct aiScene;
|
||||
struct aiImporterDesc;
|
||||
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
|
||||
class Importer;
|
||||
class IOSystem;
|
||||
@@ -71,8 +71,7 @@ class IOStream;
|
||||
|
||||
// utility to do char4 to uint32 in a portable manner
|
||||
#define AI_MAKE_MAGIC(string) ((uint32_t)((string[0] << 24) + \
|
||||
(string[1] << 16) + (string[2] << 8) + string[3]))
|
||||
|
||||
(string[1] << 16) + (string[2] << 8) + string[3]))
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** FOR IMPORTER PLUGINS ONLY: The BaseImporter defines a common interface
|
||||
@@ -89,10 +88,9 @@ class ASSIMP_API BaseImporter {
|
||||
|
||||
private:
|
||||
/* Pushes state into importer for the importer scale */
|
||||
virtual void UpdateImporterScale( Importer* pImp );
|
||||
virtual void UpdateImporterScale(Importer *pImp);
|
||||
|
||||
public:
|
||||
|
||||
/** Constructor to be privately used by #Importer */
|
||||
BaseImporter() AI_NO_EXCEPT;
|
||||
|
||||
@@ -118,22 +116,21 @@ public:
|
||||
* @return true if the class can read this file, false if not.
|
||||
*/
|
||||
virtual bool CanRead(
|
||||
const std::string& pFile,
|
||||
IOSystem* pIOHandler,
|
||||
bool checkSig
|
||||
) const = 0;
|
||||
const std::string &pFile,
|
||||
IOSystem *pIOHandler,
|
||||
bool checkSig) const = 0;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Imports the given file and returns the imported data.
|
||||
* If the import succeeds, ownership of the data is transferred to
|
||||
* the caller. If the import fails, NULL is returned. The function
|
||||
* the caller. If the import fails, nullptr is returned. The function
|
||||
* takes care that any partially constructed data is destroyed
|
||||
* beforehand.
|
||||
*
|
||||
* @param pImp #Importer object hosting this loader.
|
||||
* @param pFile Path of the file to be imported.
|
||||
* @param pIOHandler IO-Handler used to open this and possible other files.
|
||||
* @return The imported data or NULL if failed. If it failed a
|
||||
* @return The imported data or nullptr if failed. If it failed a
|
||||
* human-readable error description can be retrieved by calling
|
||||
* GetErrorText()
|
||||
*
|
||||
@@ -142,18 +139,17 @@ public:
|
||||
* in InternReadFile(), this function will catch it and transform it into
|
||||
* a suitable response to the caller.
|
||||
*/
|
||||
aiScene* ReadFile(
|
||||
Importer* pImp,
|
||||
const std::string& pFile,
|
||||
IOSystem* pIOHandler
|
||||
);
|
||||
aiScene *ReadFile(
|
||||
Importer *pImp,
|
||||
const std::string &pFile,
|
||||
IOSystem *pIOHandler);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns the error description of the last error that occurred.
|
||||
* @return A description of the last error that occurred. An empty
|
||||
* string if there was no error.
|
||||
*/
|
||||
const std::string& GetErrorText() const {
|
||||
const std::string &GetErrorText() const {
|
||||
return m_ErrorText;
|
||||
}
|
||||
|
||||
@@ -164,24 +160,21 @@ public:
|
||||
* @param pImp Importer instance
|
||||
*/
|
||||
virtual void SetupProperties(
|
||||
const Importer* pImp
|
||||
);
|
||||
const Importer *pImp);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Called by #Importer::GetImporterInfo to get a description of
|
||||
* some loader features. Importers must provide this information. */
|
||||
virtual const aiImporterDesc* GetInfo() const = 0;
|
||||
virtual const aiImporterDesc *GetInfo() const = 0;
|
||||
|
||||
/**
|
||||
* Will be called only by scale process when scaling is requested.
|
||||
*/
|
||||
virtual void SetFileScale(double scale)
|
||||
{
|
||||
virtual void SetFileScale(double scale) {
|
||||
fileScale = scale;
|
||||
}
|
||||
|
||||
virtual double GetFileScale() const
|
||||
{
|
||||
virtual double GetFileScale() const {
|
||||
return fileScale;
|
||||
}
|
||||
|
||||
@@ -204,14 +197,12 @@ public:
|
||||
* */
|
||||
std::map<ImporterUnits, double> importerUnits;
|
||||
|
||||
virtual void SetApplicationUnits( const ImporterUnits& unit )
|
||||
{
|
||||
virtual void SetApplicationUnits(const ImporterUnits &unit) {
|
||||
importerScale = importerUnits[unit];
|
||||
applicationUnits = unit;
|
||||
}
|
||||
|
||||
virtual const ImporterUnits& GetApplicationUnits()
|
||||
{
|
||||
virtual const ImporterUnits &GetApplicationUnits() {
|
||||
return applicationUnits;
|
||||
}
|
||||
|
||||
@@ -220,15 +211,13 @@ public:
|
||||
* Take the extension list contained in the structure returned by
|
||||
* #GetInfo and insert all file extensions into the given set.
|
||||
* @param extension set to collect file extensions in*/
|
||||
void GetExtensionList(std::set<std::string>& extensions);
|
||||
|
||||
protected:
|
||||
void GetExtensionList(std::set<std::string> &extensions);
|
||||
|
||||
protected:
|
||||
ImporterUnits applicationUnits = ImporterUnits::M;
|
||||
double importerScale = 1.0;
|
||||
double fileScale = 1.0;
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Imports the given file into the given scene structure. The
|
||||
* function is expected to throw an ImportErrorException if there is
|
||||
@@ -249,7 +238,7 @@ protected:
|
||||
* <li>aiAnimation::mDuration may be -1. Assimp determines the length
|
||||
* of the animation automatically in this case as the length of
|
||||
* the longest animation channel.</li>
|
||||
* <li>aiMesh::mBitangents may be NULL if tangents and normals are
|
||||
* <li>aiMesh::mBitangents may be nullptr if tangents and normals are
|
||||
* given. In this case bitangents are computed as the cross product
|
||||
* between normal and tangent.</li>
|
||||
* <li>There needn't be a material. If none is there a default material
|
||||
@@ -270,17 +259,15 @@ protected:
|
||||
*
|
||||
* @param pFile Path of the file to be imported.
|
||||
* @param pScene The scene object to hold the imported data.
|
||||
* NULL is not a valid parameter.
|
||||
* nullptr is not a valid parameter.
|
||||
* @param pIOHandler The IO handler to use for any file access.
|
||||
* NULL is not a valid parameter. */
|
||||
* nullptr is not a valid parameter. */
|
||||
virtual void InternReadFile(
|
||||
const std::string& pFile,
|
||||
aiScene* pScene,
|
||||
IOSystem* pIOHandler
|
||||
) = 0;
|
||||
const std::string &pFile,
|
||||
aiScene *pScene,
|
||||
IOSystem *pIOHandler) = 0;
|
||||
|
||||
public: // static utilities
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** A utility for CanRead().
|
||||
*
|
||||
@@ -296,13 +283,13 @@ public: // static utilities
|
||||
* @param searchBytes Number of bytes to be searched for the tokens.
|
||||
*/
|
||||
static bool SearchFileHeaderForToken(
|
||||
IOSystem* pIOSystem,
|
||||
const std::string& file,
|
||||
const char** tokens,
|
||||
unsigned int numTokens,
|
||||
unsigned int searchBytes = 200,
|
||||
bool tokensSol = false,
|
||||
bool noAlphaBeforeTokens = false);
|
||||
IOSystem *pIOSystem,
|
||||
const std::string &file,
|
||||
const char **tokens,
|
||||
unsigned int numTokens,
|
||||
unsigned int searchBytes = 200,
|
||||
bool tokensSol = false,
|
||||
bool noAlphaBeforeTokens = false);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Check whether a file has a specific file extension
|
||||
@@ -312,19 +299,19 @@ public: // static utilities
|
||||
* @param ext2 Optional third extension
|
||||
* @note Case-insensitive
|
||||
*/
|
||||
static bool SimpleExtensionCheck (
|
||||
const std::string& pFile,
|
||||
const char* ext0,
|
||||
const char* ext1 = NULL,
|
||||
const char* ext2 = NULL);
|
||||
static bool SimpleExtensionCheck(
|
||||
const std::string &pFile,
|
||||
const char *ext0,
|
||||
const char *ext1 = nullptr,
|
||||
const char *ext2 = nullptr);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Extract file extension from a string
|
||||
* @param pFile Input file
|
||||
* @return Extension without trailing dot, all lowercase
|
||||
*/
|
||||
static std::string GetExtension (
|
||||
const std::string& pFile);
|
||||
static std::string GetExtension(
|
||||
const std::string &pFile);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Check whether a file starts with one or more magic tokens
|
||||
@@ -341,12 +328,12 @@ public: // static utilities
|
||||
* tokens of size 2,4.
|
||||
*/
|
||||
static bool CheckMagicToken(
|
||||
IOSystem* pIOHandler,
|
||||
const std::string& pFile,
|
||||
const void* magic,
|
||||
unsigned int num,
|
||||
unsigned int offset = 0,
|
||||
unsigned int size = 4);
|
||||
IOSystem *pIOHandler,
|
||||
const std::string &pFile,
|
||||
const void *magic,
|
||||
unsigned int num,
|
||||
unsigned int offset = 0,
|
||||
unsigned int size = 4);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** An utility for all text file loaders. It converts a file to our
|
||||
@@ -355,7 +342,7 @@ public: // static utilities
|
||||
* @param data File buffer to be converted to UTF8 data. The buffer
|
||||
* is resized as appropriate. */
|
||||
static void ConvertToUTF8(
|
||||
std::vector<char>& data);
|
||||
std::vector<char> &data);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** An utility for all text file loaders. It converts a file from our
|
||||
@@ -364,13 +351,13 @@ public: // static utilities
|
||||
* @param data File buffer to be converted from UTF8 to ISO-8859-1. The buffer
|
||||
* is resized as appropriate. */
|
||||
static void ConvertUTF8toISO8859_1(
|
||||
std::string& data);
|
||||
std::string &data);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/// @brief Enum to define, if empty files are ok or not.
|
||||
enum TextFileMode {
|
||||
enum TextFileMode {
|
||||
ALLOW_EMPTY,
|
||||
FORBID_EMPTY
|
||||
FORBID_EMPTY
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@@ -383,22 +370,20 @@ public: // static utilities
|
||||
* a binary 0.
|
||||
* @param mode Whether it is OK to load empty text files. */
|
||||
static void TextFileToBuffer(
|
||||
IOStream* stream,
|
||||
std::vector<char>& data,
|
||||
TextFileMode mode = FORBID_EMPTY);
|
||||
IOStream *stream,
|
||||
std::vector<char> &data,
|
||||
TextFileMode mode = FORBID_EMPTY);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Utility function to move a std::vector into a aiScene array
|
||||
* @param vec The vector to be moved
|
||||
* @param out The output pointer to the allocated array.
|
||||
* @param numOut The output count of elements copied. */
|
||||
template<typename T>
|
||||
AI_FORCE_INLINE
|
||||
static void CopyVector(
|
||||
std::vector<T>& vec,
|
||||
T*& out,
|
||||
unsigned int& outLength)
|
||||
{
|
||||
template <typename T>
|
||||
AI_FORCE_INLINE static void CopyVector(
|
||||
std::vector<T> &vec,
|
||||
T *&out,
|
||||
unsigned int &outLength) {
|
||||
outLength = unsigned(vec.size());
|
||||
if (outLength) {
|
||||
out = new T[outLength];
|
||||
@@ -410,11 +395,9 @@ protected:
|
||||
/// Error description in case there was one.
|
||||
std::string m_ErrorText;
|
||||
/// Currently set progress handler.
|
||||
ProgressHandler* m_progress;
|
||||
ProgressHandler *m_progress;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_BASEIMPORTER_H_INC
|
||||
|
||||
@@ -47,87 +47,74 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef AI_BLOBIOSYSTEM_H_INCLUDED
|
||||
#define AI_BLOBIOSYSTEM_H_INCLUDED
|
||||
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/cexport.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <stdint.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace Assimp {
|
||||
class BlobIOSystem;
|
||||
namespace Assimp {
|
||||
class BlobIOSystem;
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
/** Redirect IOStream to a blob */
|
||||
// --------------------------------------------------------------------------------------------
|
||||
class BlobIOStream : public IOStream
|
||||
{
|
||||
class BlobIOStream : public IOStream {
|
||||
public:
|
||||
|
||||
BlobIOStream(BlobIOSystem* creator, const std::string& file, size_t initial = 4096)
|
||||
: buffer()
|
||||
, cur_size()
|
||||
, file_size()
|
||||
, cursor()
|
||||
, initial(initial)
|
||||
, file(file)
|
||||
, creator(creator)
|
||||
{
|
||||
BlobIOStream(BlobIOSystem *creator, const std::string &file, size_t initial = 4096) :
|
||||
buffer(),
|
||||
cur_size(),
|
||||
file_size(),
|
||||
cursor(),
|
||||
initial(initial),
|
||||
file(file),
|
||||
creator(creator) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
virtual ~BlobIOStream();
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
aiExportDataBlob* GetBlob()
|
||||
{
|
||||
aiExportDataBlob* blob = new aiExportDataBlob();
|
||||
aiExportDataBlob *GetBlob() {
|
||||
aiExportDataBlob *blob = new aiExportDataBlob();
|
||||
blob->size = file_size;
|
||||
blob->data = buffer;
|
||||
|
||||
buffer = NULL;
|
||||
buffer = nullptr;
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Read( void *,
|
||||
size_t,
|
||||
size_t )
|
||||
{
|
||||
virtual size_t Read(void *,
|
||||
size_t,
|
||||
size_t) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Write(const void* pvBuffer,
|
||||
size_t pSize,
|
||||
size_t pCount)
|
||||
{
|
||||
virtual size_t Write(const void *pvBuffer,
|
||||
size_t pSize,
|
||||
size_t pCount) {
|
||||
pSize *= pCount;
|
||||
if (cursor + pSize > cur_size) {
|
||||
Grow(cursor + pSize);
|
||||
}
|
||||
|
||||
memcpy(buffer+cursor, pvBuffer, pSize);
|
||||
memcpy(buffer + cursor, pvBuffer, pSize);
|
||||
cursor += pSize;
|
||||
|
||||
file_size = std::max(file_size,cursor);
|
||||
file_size = std::max(file_size, cursor);
|
||||
return pCount;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual aiReturn Seek(size_t pOffset,
|
||||
aiOrigin pOrigin)
|
||||
{
|
||||
switch(pOrigin)
|
||||
{
|
||||
aiOrigin pOrigin) {
|
||||
switch (pOrigin) {
|
||||
case aiOrigin_CUR:
|
||||
cursor += pOffset;
|
||||
break;
|
||||
@@ -148,48 +135,41 @@ public:
|
||||
Grow(cursor);
|
||||
}
|
||||
|
||||
file_size = std::max(cursor,file_size);
|
||||
file_size = std::max(cursor, file_size);
|
||||
return AI_SUCCESS;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Tell() const
|
||||
{
|
||||
virtual size_t Tell() const {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t FileSize() const
|
||||
{
|
||||
virtual size_t FileSize() const {
|
||||
return file_size;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual void Flush()
|
||||
{
|
||||
virtual void Flush() {
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
void Grow(size_t need = 0)
|
||||
{
|
||||
void Grow(size_t need = 0) {
|
||||
// 1.5 and phi are very heap-friendly growth factors (the first
|
||||
// allows for frequent re-use of heap blocks, the second
|
||||
// forms a fibonacci sequence with similar characteristics -
|
||||
// since this heavily depends on the heap implementation
|
||||
// and other factors as well, i'll just go with 1.5 since
|
||||
// it is quicker to compute).
|
||||
size_t new_size = std::max(initial, std::max( need, cur_size+(cur_size>>1) ));
|
||||
size_t new_size = std::max(initial, std::max(need, cur_size + (cur_size >> 1)));
|
||||
|
||||
const uint8_t* const old = buffer;
|
||||
const uint8_t *const old = buffer;
|
||||
buffer = new uint8_t[new_size];
|
||||
|
||||
if (old) {
|
||||
memcpy(buffer,old,cur_size);
|
||||
memcpy(buffer, old, cur_size);
|
||||
delete[] old;
|
||||
}
|
||||
|
||||
@@ -197,54 +177,44 @@ private:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
uint8_t* buffer;
|
||||
size_t cur_size,file_size, cursor, initial;
|
||||
uint8_t *buffer;
|
||||
size_t cur_size, file_size, cursor, initial;
|
||||
|
||||
const std::string file;
|
||||
BlobIOSystem* const creator;
|
||||
BlobIOSystem *const creator;
|
||||
};
|
||||
|
||||
|
||||
#define AI_BLOBIO_MAGIC "$blobfile"
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
/** Redirect IOSystem to a blob */
|
||||
// --------------------------------------------------------------------------------------------
|
||||
class BlobIOSystem : public IOSystem
|
||||
{
|
||||
class BlobIOSystem : public IOSystem {
|
||||
|
||||
friend class BlobIOStream;
|
||||
typedef std::pair<std::string, aiExportDataBlob*> BlobEntry;
|
||||
typedef std::pair<std::string, aiExportDataBlob *> BlobEntry;
|
||||
|
||||
public:
|
||||
|
||||
BlobIOSystem()
|
||||
{
|
||||
BlobIOSystem() {
|
||||
}
|
||||
|
||||
virtual ~BlobIOSystem()
|
||||
{
|
||||
for(BlobEntry& blobby : blobs) {
|
||||
virtual ~BlobIOSystem() {
|
||||
for (BlobEntry &blobby : blobs) {
|
||||
delete blobby.second;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
const char* GetMagicFileName() const
|
||||
{
|
||||
const char *GetMagicFileName() const {
|
||||
return AI_BLOBIO_MAGIC;
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
aiExportDataBlob* GetBlobChain()
|
||||
{
|
||||
aiExportDataBlob *GetBlobChain() {
|
||||
// one must be the master
|
||||
aiExportDataBlob* master = NULL, *cur;
|
||||
for(const BlobEntry& blobby : blobs) {
|
||||
aiExportDataBlob *master = nullptr, *cur;
|
||||
for (const BlobEntry &blobby : blobs) {
|
||||
if (blobby.first == AI_BLOBIO_MAGIC) {
|
||||
master = blobby.second;
|
||||
break;
|
||||
@@ -252,13 +222,13 @@ public:
|
||||
}
|
||||
if (!master) {
|
||||
ASSIMP_LOG_ERROR("BlobIOSystem: no data written or master file was not closed properly.");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
master->name.Set("");
|
||||
|
||||
cur = master;
|
||||
for(const BlobEntry& blobby : blobs) {
|
||||
for (const BlobEntry &blobby : blobs) {
|
||||
if (blobby.second == master) {
|
||||
continue;
|
||||
}
|
||||
@@ -268,7 +238,7 @@ public:
|
||||
|
||||
// extract the file extension from the file written
|
||||
const std::string::size_type s = blobby.first.find_first_of('.');
|
||||
cur->name.Set(s == std::string::npos ? blobby.first : blobby.first.substr(s+1));
|
||||
cur->name.Set(s == std::string::npos ? blobby.first : blobby.first.substr(s + 1));
|
||||
}
|
||||
|
||||
// give up blob ownership
|
||||
@@ -277,62 +247,52 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual bool Exists( const char* pFile) const {
|
||||
virtual bool Exists(const char *pFile) const {
|
||||
return created.find(std::string(pFile)) != created.end();
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual char getOsSeparator() const {
|
||||
return '/';
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual IOStream* Open(const char* pFile,
|
||||
const char* pMode)
|
||||
{
|
||||
virtual IOStream *Open(const char *pFile,
|
||||
const char *pMode) {
|
||||
if (pMode[0] != 'w') {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
created.insert(std::string(pFile));
|
||||
return new BlobIOStream(this,std::string(pFile));
|
||||
return new BlobIOStream(this, std::string(pFile));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual void Close( IOStream* pFile)
|
||||
{
|
||||
virtual void Close(IOStream *pFile) {
|
||||
delete pFile;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
void OnDestruct(const std::string& filename, BlobIOStream* child)
|
||||
{
|
||||
void OnDestruct(const std::string &filename, BlobIOStream *child) {
|
||||
// we don't know in which the files are closed, so we
|
||||
// can't reliably say that the first must be the master
|
||||
// file ...
|
||||
blobs.push_back( BlobEntry(filename,child->GetBlob()) );
|
||||
blobs.push_back(BlobEntry(filename, child->GetBlob()));
|
||||
}
|
||||
|
||||
private:
|
||||
std::set<std::string> created;
|
||||
std::vector< BlobEntry > blobs;
|
||||
std::vector<BlobEntry> blobs;
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
BlobIOStream :: ~BlobIOStream()
|
||||
{
|
||||
creator->OnDestruct(file,this);
|
||||
BlobIOStream ::~BlobIOStream() {
|
||||
creator->OnDestruct(file, this);
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
|
||||
} // end Assimp
|
||||
} // namespace Assimp
|
||||
|
||||
#endif
|
||||
|
||||
53
include/assimp/ColladaMetaData.h
Normal file
53
include/assimp/ColladaMetaData.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
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,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file ColladaMetaData.h
|
||||
* Declares common metadata constants used by Collada files
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef AI_COLLADAMETADATA_H_INC
|
||||
#define AI_COLLADAMETADATA_H_INC
|
||||
|
||||
#define AI_METADATA_COLLADA_ID "Collada_id"
|
||||
#define AI_METADATA_COLLADA_SID "Collada_sid"
|
||||
|
||||
#endif
|
||||
@@ -45,12 +45,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef INCLUDED_AI_DEFAULTLOGGER
|
||||
#define INCLUDED_AI_DEFAULTLOGGER
|
||||
|
||||
#include "Logger.hpp"
|
||||
#include "LogStream.hpp"
|
||||
#include "Logger.hpp"
|
||||
#include "NullLogger.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
// ------------------------------------------------------------------------------------
|
||||
class IOStream;
|
||||
struct LogStreamInfo;
|
||||
@@ -71,27 +71,25 @@ struct LogStreamInfo;
|
||||
* If you wish to customize the logging at an even deeper level supply your own
|
||||
* implementation of #Logger to #set().
|
||||
* @note The whole logging stuff causes a small extra overhead for all imports. */
|
||||
class ASSIMP_API DefaultLogger :
|
||||
public Logger {
|
||||
class ASSIMP_API DefaultLogger : public Logger {
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Creates a logging instance.
|
||||
* @param name Name for log file. Only valid in combination
|
||||
* with the aiDefaultLogStream_FILE flag.
|
||||
* @param severity Log severity, VERBOSE turns on debug messages
|
||||
* @param severity Log severity, DEBUG turns on debug messages and VERBOSE turns on all messages.
|
||||
* @param defStreams Default log streams to be attached. Any bitwise
|
||||
* combination of the aiDefaultLogStream enumerated values.
|
||||
* If #aiDefaultLogStream_FILE is specified but an empty string is
|
||||
* passed for 'name', no log file is created at all.
|
||||
* @param io IOSystem to be used to open external files (such as the
|
||||
* log file). Pass NULL to rely on the default implementation.
|
||||
* log file). Pass nullptr to rely on the default implementation.
|
||||
* This replaces the default #NullLogger with a #DefaultLogger instance. */
|
||||
static Logger *create(const char* name = ASSIMP_DEFAULT_LOG_NAME,
|
||||
LogSeverity severity = NORMAL,
|
||||
unsigned int defStreams = aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE,
|
||||
IOSystem* io = NULL);
|
||||
static Logger *create(const char *name = ASSIMP_DEFAULT_LOG_NAME,
|
||||
LogSeverity severity = NORMAL,
|
||||
unsigned int defStreams = aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE,
|
||||
IOSystem *io = nullptr);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Setup a custom #Logger implementation.
|
||||
@@ -101,7 +99,7 @@ public:
|
||||
* it's much easier to use #create() and to attach your own custom
|
||||
* output streams to it.
|
||||
* @param logger Pass NULL to setup a default NullLogger*/
|
||||
static void set (Logger *logger);
|
||||
static void set(Logger *logger);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Getter for singleton instance
|
||||
@@ -124,12 +122,12 @@ public:
|
||||
// ----------------------------------------------------------------------
|
||||
/** @copydoc Logger::attachStream */
|
||||
bool attachStream(LogStream *pStream,
|
||||
unsigned int severity);
|
||||
unsigned int severity);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @copydoc Logger::detatchStream */
|
||||
bool detatchStream(LogStream *pStream,
|
||||
unsigned int severity);
|
||||
/** @copydoc Logger::detachStream */
|
||||
bool detachStream(LogStream *pStream,
|
||||
unsigned int severity);
|
||||
|
||||
private:
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -141,21 +139,24 @@ private:
|
||||
/** @briefDestructor */
|
||||
~DefaultLogger();
|
||||
|
||||
/** @brief Logs debug infos, only been written when severity level DEBUG or higher is set */
|
||||
void OnDebug(const char *message);
|
||||
|
||||
/** @brief Logs debug infos, only been written when severity level VERBOSE is set */
|
||||
void OnDebug(const char* message);
|
||||
void OnVerboseDebug(const char *message);
|
||||
|
||||
/** @brief Logs an info message */
|
||||
void OnInfo(const char* message);
|
||||
void OnInfo(const char *message);
|
||||
|
||||
/** @brief Logs a warning message */
|
||||
void OnWarn(const char* message);
|
||||
void OnWarn(const char *message);
|
||||
|
||||
/** @brief Logs an error message */
|
||||
void OnError(const char* message);
|
||||
void OnError(const char *message);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Writes a message to all streams */
|
||||
void WriteToStreams(const char* message, ErrorSeverity ErrorSev );
|
||||
void WriteToStreams(const char *message, ErrorSeverity ErrorSev);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Returns the thread id.
|
||||
@@ -166,9 +167,9 @@ private:
|
||||
|
||||
private:
|
||||
// Aliases for stream container
|
||||
typedef std::vector<LogStreamInfo*> StreamArray;
|
||||
typedef std::vector<LogStreamInfo*>::iterator StreamIt;
|
||||
typedef std::vector<LogStreamInfo*>::const_iterator ConstStreamIt;
|
||||
typedef std::vector<LogStreamInfo *> StreamArray;
|
||||
typedef std::vector<LogStreamInfo *>::iterator StreamIt;
|
||||
typedef std::vector<LogStreamInfo *>::const_iterator ConstStreamIt;
|
||||
|
||||
//! only logging instance
|
||||
static Logger *m_pLogger;
|
||||
@@ -178,7 +179,7 @@ private:
|
||||
StreamArray m_StreamArray;
|
||||
|
||||
bool noRepeatMsg;
|
||||
char lastMsg[MAX_LOG_MESSAGE_LENGTH*2];
|
||||
char lastMsg[MAX_LOG_MESSAGE_LENGTH * 2];
|
||||
size_t lastLen;
|
||||
};
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
@@ -43,50 +43,56 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define AI_INCLUDED_EXCEPTIONAL_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <assimp/DefaultIOStream.h>
|
||||
#include <stdexcept>
|
||||
|
||||
using std::runtime_error;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable : 4275)
|
||||
#pragma warning(disable : 4275)
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** FOR IMPORTER PLUGINS ONLY: Simple exception class to be thrown if an
|
||||
* unrecoverable error occurs while importing. Loading APIs return
|
||||
* NULL instead of a valid aiScene then. */
|
||||
* nullptr instead of a valid aiScene then. */
|
||||
class DeadlyImportError : public runtime_error {
|
||||
public:
|
||||
/** Constructor with arguments */
|
||||
explicit DeadlyImportError( const std::string& errorText)
|
||||
: runtime_error(errorText) {
|
||||
explicit DeadlyImportError(const std::string &errorText) :
|
||||
runtime_error(errorText) {
|
||||
// empty
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef DeadlyImportError DeadlyExportError;
|
||||
class DeadlyExportError : public runtime_error {
|
||||
public:
|
||||
/** Constructor with arguments */
|
||||
explicit DeadlyExportError(const std::string &errorText) :
|
||||
runtime_error(errorText) {
|
||||
// empty
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(default : 4275)
|
||||
#pragma warning(default : 4275)
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
struct ExceptionSwallower {
|
||||
T operator ()() const {
|
||||
struct ExceptionSwallower {
|
||||
T operator()() const {
|
||||
return T();
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
struct ExceptionSwallower<T*> {
|
||||
T* operator ()() const {
|
||||
struct ExceptionSwallower<T *> {
|
||||
T *operator()() const {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
@@ -94,14 +100,12 @@ struct ExceptionSwallower<T*> {
|
||||
// ---------------------------------------------------------------------------
|
||||
template <>
|
||||
struct ExceptionSwallower<aiReturn> {
|
||||
aiReturn operator ()() const {
|
||||
aiReturn operator()() const {
|
||||
try {
|
||||
throw;
|
||||
}
|
||||
catch (std::bad_alloc&) {
|
||||
} catch (std::bad_alloc &) {
|
||||
return aiReturn_OUTOFMEMORY;
|
||||
}
|
||||
catch (...) {
|
||||
} catch (...) {
|
||||
return aiReturn_FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -110,29 +114,32 @@ struct ExceptionSwallower<aiReturn> {
|
||||
// ---------------------------------------------------------------------------
|
||||
template <>
|
||||
struct ExceptionSwallower<void> {
|
||||
void operator ()() const {
|
||||
void operator()() const {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
#define ASSIMP_BEGIN_EXCEPTION_REGION()\
|
||||
{\
|
||||
try {
|
||||
#define ASSIMP_BEGIN_EXCEPTION_REGION() \
|
||||
{ \
|
||||
try {
|
||||
|
||||
#define ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(type, ASSIMP_END_EXCEPTION_REGION_errorString)\
|
||||
} catch(const DeadlyImportError& e) {\
|
||||
ASSIMP_END_EXCEPTION_REGION_errorString = e.what();\
|
||||
return ExceptionSwallower<type>()();\
|
||||
} catch(...) {\
|
||||
ASSIMP_END_EXCEPTION_REGION_errorString = "Unknown exception";\
|
||||
return ExceptionSwallower<type>()();\
|
||||
}\
|
||||
}
|
||||
#define ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(type, ASSIMP_END_EXCEPTION_REGION_errorString) \
|
||||
} \
|
||||
catch (const DeadlyImportError &e) { \
|
||||
ASSIMP_END_EXCEPTION_REGION_errorString = e.what(); \
|
||||
return ExceptionSwallower<type>()(); \
|
||||
} \
|
||||
catch (...) { \
|
||||
ASSIMP_END_EXCEPTION_REGION_errorString = "Unknown exception"; \
|
||||
return ExceptionSwallower<type>()(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define ASSIMP_END_EXCEPTION_REGION(type)\
|
||||
} catch(...) {\
|
||||
return ExceptionSwallower<type>()();\
|
||||
}\
|
||||
}
|
||||
#define ASSIMP_END_EXCEPTION_REGION(type) \
|
||||
} \
|
||||
catch (...) { \
|
||||
return ExceptionSwallower<type>()(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif // AI_INCLUDED_EXCEPTIONAL_H
|
||||
|
||||
@@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define AI_EXPORT_HPP_INC
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
@@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <map>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
||||
class ExporterPimpl;
|
||||
class IOSystem;
|
||||
class ProgressHandler;
|
||||
@@ -84,7 +84,7 @@ class ASSIMP_API ExportProperties;
|
||||
class ASSIMP_API Exporter {
|
||||
public:
|
||||
/** Function pointer type of a Export worker function */
|
||||
typedef void (*fpExportFunc)(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
typedef void (*fpExportFunc)(const char *, IOSystem *, const aiScene *, const ExportProperties *);
|
||||
|
||||
/** Internal description of an Assimp export format option */
|
||||
struct ExportFormatEntry {
|
||||
@@ -98,8 +98,7 @@ public:
|
||||
unsigned int mEnforcePP;
|
||||
|
||||
// Constructor to fill all entries
|
||||
ExportFormatEntry( const char* pId, const char* pDesc, const char* pExtension, fpExportFunc pFunction, unsigned int pEnforcePP = 0u)
|
||||
{
|
||||
ExportFormatEntry(const char *pId, const char *pDesc, const char *pExtension, fpExportFunc pFunction, unsigned int pEnforcePP = 0u) {
|
||||
mDescription.id = pId;
|
||||
mDescription.description = pDesc;
|
||||
mDescription.fileExtension = pExtension;
|
||||
@@ -108,12 +107,10 @@ public:
|
||||
}
|
||||
|
||||
ExportFormatEntry() :
|
||||
mExportFunction()
|
||||
, mEnforcePP()
|
||||
{
|
||||
mDescription.id = NULL;
|
||||
mDescription.description = NULL;
|
||||
mDescription.fileExtension = NULL;
|
||||
mExportFunction(), mEnforcePP() {
|
||||
mDescription.id = nullptr;
|
||||
mDescription.description = nullptr;
|
||||
mDescription.fileExtension = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -142,7 +139,7 @@ public:
|
||||
*
|
||||
* @param pIOHandler The IO handler to be used in all file accesses
|
||||
* of the Importer. */
|
||||
void SetIOHandler( IOSystem* pIOHandler);
|
||||
void SetIOHandler(IOSystem *pIOHandler);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Retrieves the IO handler that is currently set.
|
||||
@@ -150,8 +147,8 @@ public:
|
||||
* interface is the default IO handler provided by ASSIMP. The default
|
||||
* handler is active as long the application doesn't supply its own
|
||||
* custom IO handler via #SetIOHandler().
|
||||
* @return A valid IOSystem interface, never NULL. */
|
||||
IOSystem* GetIOHandler() const;
|
||||
* @return A valid IOSystem interface, never nullptr. */
|
||||
IOSystem *GetIOHandler() const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Checks whether a default IO handler is active
|
||||
@@ -171,7 +168,7 @@ public:
|
||||
* disable progress reporting.
|
||||
* @note Progress handlers can be used to abort the loading
|
||||
* at almost any time.*/
|
||||
void SetProgressHandler(ProgressHandler* pHandler);
|
||||
void SetProgressHandler(ProgressHandler *pHandler);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Exports the given scene to a chosen file format. Returns the exported
|
||||
@@ -185,22 +182,22 @@ public:
|
||||
* #GetExportFormatCount / #GetExportFormatDescription to learn which
|
||||
* export formats are available.
|
||||
* @param pPreprocessing See the documentation for #Export
|
||||
* @return the exported data or NULL in case of error.
|
||||
* @return the exported data or nullptr in case of error.
|
||||
* @note If the Exporter instance did already hold a blob from
|
||||
* a previous call to #ExportToBlob, it will be disposed.
|
||||
* Any IO handlers set via #SetIOHandler are ignored here.
|
||||
* @note Use aiCopyScene() to get a modifiable copy of a previously
|
||||
* imported scene. */
|
||||
const aiExportDataBlob* ExportToBlob(const aiScene* pScene, const char* pFormatId,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = nullptr);
|
||||
const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = nullptr);
|
||||
const aiExportDataBlob *ExportToBlob(const aiScene *pScene, const char *pFormatId,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties *pProperties = nullptr);
|
||||
const aiExportDataBlob *ExportToBlob(const aiScene *pScene, const std::string &pFormatId,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties *pProperties = nullptr);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Convenience function to export directly to a file. Use
|
||||
* #SetIOSystem to supply a custom IOSystem to gain fine-grained control
|
||||
* about the output data flow of the export process.
|
||||
* @param pBlob A data blob obtained from a previous call to #aiExportScene. Must not be NULL.
|
||||
* @param pBlob A data blob obtained from a previous call to #aiExportScene. Must not be nullptr.
|
||||
* @param pPath Full target file name. Target must be accessible.
|
||||
* @param pPreprocessing Accepts any choice of the #aiPostProcessSteps enumerated
|
||||
* flags, but in reality only a subset of them makes sense here. Specifying
|
||||
@@ -229,10 +226,10 @@ public:
|
||||
* @return AI_SUCCESS if everything was fine.
|
||||
* @note Use aiCopyScene() to get a modifiable copy of a previously
|
||||
* imported scene.*/
|
||||
aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = nullptr);
|
||||
aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = nullptr);
|
||||
aiReturn Export(const aiScene *pScene, const char *pFormatId, const char *pPath,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties *pProperties = nullptr);
|
||||
aiReturn Export(const aiScene *pScene, const std::string &pFormatId, const std::string &pPath,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties *pProperties = nullptr);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns an error description of an error that occurred in #Export
|
||||
@@ -240,21 +237,21 @@ public:
|
||||
*
|
||||
* Returns an empty string if no error occurred.
|
||||
* @return A description of the last error, an empty string if no
|
||||
* error occurred. The string is never NULL.
|
||||
* error occurred. The string is never nullptr.
|
||||
*
|
||||
* @note The returned function remains valid until one of the
|
||||
* following methods is called: #Export, #ExportToBlob, #FreeBlob */
|
||||
const char* GetErrorString() const;
|
||||
const char *GetErrorString() const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Return the blob obtained from the last call to #ExportToBlob */
|
||||
const aiExportDataBlob* GetBlob() const;
|
||||
const aiExportDataBlob *GetBlob() const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Orphan the blob from the last call to #ExportToBlob. This means
|
||||
* the caller takes ownership and is thus responsible for calling
|
||||
* the C API function #aiReleaseExportBlob to release it. */
|
||||
const aiExportDataBlob* GetOrphanedBlob() const;
|
||||
const aiExportDataBlob *GetOrphanedBlob() const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Frees the current blob.
|
||||
@@ -264,7 +261,7 @@ public:
|
||||
* automatically by the destructor. The only reason to call
|
||||
* it manually would be to reclaim as much storage as possible
|
||||
* without giving up the #Exporter instance yet. */
|
||||
void FreeBlob( );
|
||||
void FreeBlob();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns the number of export file formats available in the current
|
||||
@@ -289,8 +286,8 @@ public:
|
||||
* @param pIndex Index of the export format to retrieve information
|
||||
* for. Valid range is 0 to #Exporter::GetExportFormatCount
|
||||
* @return A description of that specific export format.
|
||||
* NULL if pIndex is out of range. */
|
||||
const aiExportFormatDesc* GetExportFormatDescription( size_t pIndex ) const;
|
||||
* nullptr if pIndex is out of range. */
|
||||
const aiExportFormatDesc *GetExportFormatDescription(size_t pIndex) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Register a custom exporter. Custom export formats are limited to
|
||||
@@ -303,7 +300,7 @@ public:
|
||||
* registered. A common cause that would prevent an exporter
|
||||
* from being registered is that its format id is already
|
||||
* occupied by another format. */
|
||||
aiReturn RegisterExporter(const ExportFormatEntry& desc);
|
||||
aiReturn RegisterExporter(const ExportFormatEntry &desc);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Remove an export format previously registered with #RegisterExporter
|
||||
@@ -314,11 +311,11 @@ public:
|
||||
* 'id' field of #aiExportFormatDesc.
|
||||
* @note Calling this method on a format description not yet registered
|
||||
* has no effect.*/
|
||||
void UnregisterExporter(const char* id);
|
||||
void UnregisterExporter(const char *id);
|
||||
|
||||
protected:
|
||||
// Just because we don't want you to know how we're hacking around.
|
||||
ExporterPimpl* pimpl;
|
||||
ExporterPimpl *pimpl;
|
||||
};
|
||||
|
||||
class ASSIMP_API ExportProperties {
|
||||
@@ -345,7 +342,7 @@ public:
|
||||
* This copies the configuration properties of another ExportProperties.
|
||||
* @see ExportProperties(const ExportProperties& other)
|
||||
*/
|
||||
ExportProperties(const ExportProperties& other);
|
||||
ExportProperties(const ExportProperties &other);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Set an integer configuration property.
|
||||
@@ -360,7 +357,7 @@ public:
|
||||
* floating-point property has no effect - the loader will call
|
||||
* GetPropertyFloat() to read the property, but it won't be there.
|
||||
*/
|
||||
bool SetPropertyInteger(const char* szName, int iValue);
|
||||
bool SetPropertyInteger(const char *szName, int iValue);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Set a boolean configuration property. Boolean properties
|
||||
@@ -369,27 +366,27 @@ public:
|
||||
* #GetPropertyBool and vice versa.
|
||||
* @see SetPropertyInteger()
|
||||
*/
|
||||
bool SetPropertyBool(const char* szName, bool value) {
|
||||
return SetPropertyInteger(szName,value);
|
||||
bool SetPropertyBool(const char *szName, bool value) {
|
||||
return SetPropertyInteger(szName, value);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Set a floating-point configuration property.
|
||||
* @see SetPropertyInteger()
|
||||
*/
|
||||
bool SetPropertyFloat(const char* szName, ai_real fValue);
|
||||
bool SetPropertyFloat(const char *szName, ai_real fValue);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Set a string configuration property.
|
||||
* @see SetPropertyInteger()
|
||||
*/
|
||||
bool SetPropertyString(const char* szName, const std::string& sValue);
|
||||
bool SetPropertyString(const char *szName, const std::string &sValue);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Set a matrix configuration property.
|
||||
* @see SetPropertyInteger()
|
||||
*/
|
||||
bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue);
|
||||
bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a configuration property.
|
||||
@@ -404,8 +401,8 @@ public:
|
||||
* floating-point property has no effect - the loader will call
|
||||
* GetPropertyFloat() to read the property, but it won't be there.
|
||||
*/
|
||||
int GetPropertyInteger(const char* szName,
|
||||
int iErrorReturn = 0xffffffff) const;
|
||||
int GetPropertyInteger(const char *szName,
|
||||
int iErrorReturn = 0xffffffff) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a boolean configuration property. Boolean properties
|
||||
@@ -414,16 +411,16 @@ public:
|
||||
* #GetPropertyBool and vice versa.
|
||||
* @see GetPropertyInteger()
|
||||
*/
|
||||
bool GetPropertyBool(const char* szName, bool bErrorReturn = false) const {
|
||||
return GetPropertyInteger(szName,bErrorReturn)!=0;
|
||||
bool GetPropertyBool(const char *szName, bool bErrorReturn = false) const {
|
||||
return GetPropertyInteger(szName, bErrorReturn) != 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a floating-point configuration property
|
||||
* @see GetPropertyInteger()
|
||||
*/
|
||||
ai_real GetPropertyFloat(const char* szName,
|
||||
ai_real fErrorReturn = 10e10f) const;
|
||||
ai_real GetPropertyFloat(const char *szName,
|
||||
ai_real fErrorReturn = 10e10f) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a string configuration property
|
||||
@@ -431,8 +428,8 @@ public:
|
||||
* The return value remains valid until the property is modified.
|
||||
* @see GetPropertyInteger()
|
||||
*/
|
||||
const std::string GetPropertyString(const char* szName,
|
||||
const std::string& sErrorReturn = "") const;
|
||||
const std::string GetPropertyString(const char *szName,
|
||||
const std::string &sErrorReturn = "") const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a matrix configuration property
|
||||
@@ -440,37 +437,36 @@ public:
|
||||
* The return value remains valid until the property is modified.
|
||||
* @see GetPropertyInteger()
|
||||
*/
|
||||
const aiMatrix4x4 GetPropertyMatrix(const char* szName,
|
||||
const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const;
|
||||
const aiMatrix4x4 GetPropertyMatrix(const char *szName,
|
||||
const aiMatrix4x4 &sErrorReturn = aiMatrix4x4()) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Determine a integer configuration property has been set.
|
||||
* @see HasPropertyInteger()
|
||||
*/
|
||||
bool HasPropertyInteger(const char* szName) const;
|
||||
bool HasPropertyInteger(const char *szName) const;
|
||||
|
||||
/** Determine a boolean configuration property has been set.
|
||||
* @see HasPropertyBool()
|
||||
*/
|
||||
bool HasPropertyBool(const char* szName) const;
|
||||
bool HasPropertyBool(const char *szName) const;
|
||||
|
||||
/** Determine a boolean configuration property has been set.
|
||||
* @see HasPropertyFloat()
|
||||
*/
|
||||
bool HasPropertyFloat(const char* szName) const;
|
||||
bool HasPropertyFloat(const char *szName) const;
|
||||
|
||||
/** Determine a String configuration property has been set.
|
||||
* @see HasPropertyString()
|
||||
*/
|
||||
bool HasPropertyString(const char* szName) const;
|
||||
bool HasPropertyString(const char *szName) const;
|
||||
|
||||
/** Determine a Matrix configuration property has been set.
|
||||
* @see HasPropertyMatrix()
|
||||
*/
|
||||
bool HasPropertyMatrix(const char* szName) const;
|
||||
bool HasPropertyMatrix(const char *szName) const;
|
||||
|
||||
protected:
|
||||
|
||||
/** List of integer properties */
|
||||
IntPropertyMap mIntProperties;
|
||||
|
||||
@@ -485,20 +481,16 @@ protected:
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const std::string& pFormatId,
|
||||
unsigned int pPreprocessing, const ExportProperties* pProperties)
|
||||
{
|
||||
return ExportToBlob(pScene,pFormatId.c_str(),pPreprocessing, pProperties);
|
||||
inline const aiExportDataBlob *Exporter::ExportToBlob(const aiScene *pScene, const std::string &pFormatId,
|
||||
unsigned int pPreprocessing, const ExportProperties *pProperties) {
|
||||
return ExportToBlob(pScene, pFormatId.c_str(), pPreprocessing, pProperties);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
aiReturn Exporter :: Export( const aiScene* pScene, const std::string& pFormatId,
|
||||
const std::string& pPath, unsigned int pPreprocessing,
|
||||
const ExportProperties* pProperties)
|
||||
{
|
||||
return Export(pScene,pFormatId.c_str(),pPath.c_str(),pPreprocessing, pProperties);
|
||||
inline aiReturn Exporter ::Export(const aiScene *pScene, const std::string &pFormatId,
|
||||
const std::string &pPath, unsigned int pPreprocessing,
|
||||
const ExportProperties *pProperties) {
|
||||
return Export(pScene, pFormatId.c_str(), pPath.c_str(), pPreprocessing, pProperties);
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
@@ -87,7 +87,7 @@ inline const T &GetGenericProperty(const std::map<unsigned int, T> &list,
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Special version for pointer types - they will be deleted when replaced with another value
|
||||
// passing NULL removes the whole property
|
||||
// passing nullptr removes the whole property
|
||||
template <class T>
|
||||
inline void SetGenericPropertyPtr(std::map<unsigned int, T *> &list,
|
||||
const char *szName, T *value, bool *bWasExisting = nullptr) {
|
||||
|
||||
@@ -49,39 +49,39 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define AI_ASSIMP_HPP_INC
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This header requires C++ to be used. Use assimp.h for plain C.
|
||||
#error This header requires C++ to be used. Use assimp.h for plain C.
|
||||
#endif // __cplusplus
|
||||
|
||||
// Public ASSIMP data structures
|
||||
#include <assimp/types.h>
|
||||
|
||||
namespace Assimp {
|
||||
// =======================================================================
|
||||
// Public interface to Assimp
|
||||
class Importer;
|
||||
class IOStream;
|
||||
class IOSystem;
|
||||
class ProgressHandler;
|
||||
// =======================================================================
|
||||
// Public interface to Assimp
|
||||
class Importer;
|
||||
class IOStream;
|
||||
class IOSystem;
|
||||
class ProgressHandler;
|
||||
|
||||
// =======================================================================
|
||||
// Plugin development
|
||||
//
|
||||
// Include the following headers for the declarations:
|
||||
// BaseImporter.h
|
||||
// BaseProcess.h
|
||||
class BaseImporter;
|
||||
class BaseProcess;
|
||||
class SharedPostProcessInfo;
|
||||
class BatchLoader;
|
||||
// =======================================================================
|
||||
// Plugin development
|
||||
//
|
||||
// Include the following headers for the declarations:
|
||||
// BaseImporter.h
|
||||
// BaseProcess.h
|
||||
class BaseImporter;
|
||||
class BaseProcess;
|
||||
class SharedPostProcessInfo;
|
||||
class BatchLoader;
|
||||
|
||||
// =======================================================================
|
||||
// Holy stuff, only for members of the high council of the Jedi.
|
||||
class ImporterPimpl;
|
||||
} //! namespace Assimp
|
||||
// =======================================================================
|
||||
// Holy stuff, only for members of the high council of the Jedi.
|
||||
class ImporterPimpl;
|
||||
} // namespace Assimp
|
||||
|
||||
#define AI_PROPERTY_WAS_NOT_EXISTING 0xffffffff
|
||||
|
||||
@@ -91,7 +91,7 @@ struct aiScene;
|
||||
struct aiImporterDesc;
|
||||
|
||||
/** @namespace Assimp Assimp's CPP-API and all internal APIs */
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
/** CPP-API: The Importer class forms an C++ interface to the functionality of the
|
||||
@@ -101,7 +101,7 @@ namespace Assimp {
|
||||
* If the import succeeds, the function returns a pointer to the imported data.
|
||||
* The data remains property of the object, it is intended to be accessed
|
||||
* read-only. The imported data will be destroyed along with the Importer
|
||||
* object. If the import fails, ReadFile() returns a NULL pointer. In this
|
||||
* object. If the import fails, ReadFile() returns a nullptr pointer. In this
|
||||
* case you can retrieve a human-readable error description be calling
|
||||
* GetErrorString(). You can call ReadFile() multiple times with a single Importer
|
||||
* instance. Actually, constructing Importer objects involves quite many
|
||||
@@ -117,7 +117,7 @@ namespace Assimp {
|
||||
* @note One Importer instance is not thread-safe. If you use multiple
|
||||
* threads for loading, each thread should maintain its own Importer instance.
|
||||
*/
|
||||
class ASSIMP_API Importer {
|
||||
class ASSIMP_API Importer {
|
||||
public:
|
||||
/**
|
||||
* @brief The upper limit for hints.
|
||||
@@ -125,7 +125,6 @@ public:
|
||||
static const unsigned int MaxLenHint = 200;
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructor. Creates an empty importer object.
|
||||
*
|
||||
@@ -141,7 +140,7 @@ public:
|
||||
* If this Importer owns a scene it won't be copied.
|
||||
* Call ReadFile() to start the import process.
|
||||
*/
|
||||
Importer(const Importer& other)=delete;
|
||||
Importer(const Importer &other) = delete;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Assignment operator has been deleted
|
||||
@@ -154,7 +153,6 @@ public:
|
||||
*/
|
||||
~Importer();
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Registers a new loader.
|
||||
*
|
||||
@@ -164,7 +162,7 @@ public:
|
||||
* @return AI_SUCCESS if the loader has been added. The registration
|
||||
* fails if there is already a loader for a specific file extension.
|
||||
*/
|
||||
aiReturn RegisterLoader(BaseImporter* pImp);
|
||||
aiReturn RegisterLoader(BaseImporter *pImp);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Unregisters a loader.
|
||||
@@ -175,7 +173,7 @@ public:
|
||||
* if the #Importer instance is used by more than one thread) or
|
||||
* if it has not yet been registered.
|
||||
*/
|
||||
aiReturn UnregisterLoader(BaseImporter* pImp);
|
||||
aiReturn UnregisterLoader(BaseImporter *pImp);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Registers a new post-process step.
|
||||
@@ -188,7 +186,7 @@ public:
|
||||
* deleted with the Importer instance.
|
||||
* @return AI_SUCCESS if the step has been added correctly.
|
||||
*/
|
||||
aiReturn RegisterPPStep(BaseProcess* pImp);
|
||||
aiReturn RegisterPPStep(BaseProcess *pImp);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Unregisters a post-process step.
|
||||
@@ -199,7 +197,7 @@ public:
|
||||
* if the #Importer instance is used by more than one thread) or
|
||||
* if it has not yet been registered.
|
||||
*/
|
||||
aiReturn UnregisterPPStep(BaseProcess* pImp);
|
||||
aiReturn UnregisterPPStep(BaseProcess *pImp);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Set an integer configuration property.
|
||||
@@ -214,7 +212,7 @@ public:
|
||||
* floating-point property has no effect - the loader will call
|
||||
* GetPropertyFloat() to read the property, but it won't be there.
|
||||
*/
|
||||
bool SetPropertyInteger(const char* szName, int iValue);
|
||||
bool SetPropertyInteger(const char *szName, int iValue);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Set a boolean configuration property. Boolean properties
|
||||
@@ -223,27 +221,27 @@ public:
|
||||
* #GetPropertyBool and vice versa.
|
||||
* @see SetPropertyInteger()
|
||||
*/
|
||||
bool SetPropertyBool(const char* szName, bool value) {
|
||||
return SetPropertyInteger(szName,value);
|
||||
bool SetPropertyBool(const char *szName, bool value) {
|
||||
return SetPropertyInteger(szName, value);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Set a floating-point configuration property.
|
||||
* @see SetPropertyInteger()
|
||||
*/
|
||||
bool SetPropertyFloat(const char* szName, ai_real fValue);
|
||||
bool SetPropertyFloat(const char *szName, ai_real fValue);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Set a string configuration property.
|
||||
* @see SetPropertyInteger()
|
||||
*/
|
||||
bool SetPropertyString(const char* szName, const std::string& sValue);
|
||||
bool SetPropertyString(const char *szName, const std::string &sValue);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Set a matrix configuration property.
|
||||
* @see SetPropertyInteger()
|
||||
*/
|
||||
bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue);
|
||||
bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a configuration property.
|
||||
@@ -258,8 +256,8 @@ public:
|
||||
* floating-point property has no effect - the loader will call
|
||||
* GetPropertyFloat() to read the property, but it won't be there.
|
||||
*/
|
||||
int GetPropertyInteger(const char* szName,
|
||||
int iErrorReturn = 0xffffffff) const;
|
||||
int GetPropertyInteger(const char *szName,
|
||||
int iErrorReturn = 0xffffffff) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a boolean configuration property. Boolean properties
|
||||
@@ -268,16 +266,16 @@ public:
|
||||
* #GetPropertyBool and vice versa.
|
||||
* @see GetPropertyInteger()
|
||||
*/
|
||||
bool GetPropertyBool(const char* szName, bool bErrorReturn = false) const {
|
||||
return GetPropertyInteger(szName,bErrorReturn)!=0;
|
||||
bool GetPropertyBool(const char *szName, bool bErrorReturn = false) const {
|
||||
return GetPropertyInteger(szName, bErrorReturn) != 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a floating-point configuration property
|
||||
* @see GetPropertyInteger()
|
||||
*/
|
||||
ai_real GetPropertyFloat(const char* szName,
|
||||
ai_real fErrorReturn = 10e10) const;
|
||||
ai_real GetPropertyFloat(const char *szName,
|
||||
ai_real fErrorReturn = 10e10) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a string configuration property
|
||||
@@ -285,8 +283,8 @@ public:
|
||||
* The return value remains valid until the property is modified.
|
||||
* @see GetPropertyInteger()
|
||||
*/
|
||||
std::string GetPropertyString(const char* szName,
|
||||
const std::string& sErrorReturn = "") const;
|
||||
std::string GetPropertyString(const char *szName,
|
||||
const std::string &sErrorReturn = "") const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a matrix configuration property
|
||||
@@ -294,8 +292,8 @@ public:
|
||||
* The return value remains valid until the property is modified.
|
||||
* @see GetPropertyInteger()
|
||||
*/
|
||||
aiMatrix4x4 GetPropertyMatrix(const char* szName,
|
||||
const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const;
|
||||
aiMatrix4x4 GetPropertyMatrix(const char *szName,
|
||||
const aiMatrix4x4 &sErrorReturn = aiMatrix4x4()) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Supplies a custom IO handler to the importer to use to open and
|
||||
@@ -306,13 +304,13 @@ public:
|
||||
*
|
||||
* The Importer takes ownership of the object and will destroy it
|
||||
* afterwards. The previously assigned handler will be deleted.
|
||||
* Pass NULL to take again ownership of your IOSystem and reset Assimp
|
||||
* Pass nullptr to take again ownership of your IOSystem and reset Assimp
|
||||
* to use its default implementation.
|
||||
*
|
||||
* @param pIOHandler The IO handler to be used in all file accesses
|
||||
* of the Importer.
|
||||
*/
|
||||
void SetIOHandler( IOSystem* pIOHandler);
|
||||
void SetIOHandler(IOSystem *pIOHandler);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Retrieves the IO handler that is currently set.
|
||||
@@ -320,9 +318,9 @@ public:
|
||||
* interface is the default IO handler provided by ASSIMP. The default
|
||||
* handler is active as long the application doesn't supply its own
|
||||
* custom IO handler via #SetIOHandler().
|
||||
* @return A valid IOSystem interface, never NULL.
|
||||
* @return A valid IOSystem interface, never nullptr.
|
||||
*/
|
||||
IOSystem* GetIOHandler() const;
|
||||
IOSystem *GetIOHandler() const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Checks whether a default IO handler is active
|
||||
@@ -339,11 +337,11 @@ public:
|
||||
* isn't as periodically as you'd like it to have ...).
|
||||
* This can be used to implement progress bars and loading
|
||||
* timeouts.
|
||||
* @param pHandler Progress callback interface. Pass NULL to
|
||||
* @param pHandler Progress callback interface. Pass nullptr to
|
||||
* disable progress reporting.
|
||||
* @note Progress handlers can be used to abort the loading
|
||||
* at almost any time.*/
|
||||
void SetProgressHandler ( ProgressHandler* pHandler );
|
||||
void SetProgressHandler(ProgressHandler *pHandler);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Retrieves the progress handler that is currently set.
|
||||
@@ -351,9 +349,9 @@ public:
|
||||
* interface is the default handler provided by ASSIMP. The default
|
||||
* handler is active as long the application doesn't supply its own
|
||||
* custom handler via #SetProgressHandler().
|
||||
* @return A valid ProgressHandler interface, never NULL.
|
||||
* @return A valid ProgressHandler interface, never nullptr.
|
||||
*/
|
||||
ProgressHandler* GetProgressHandler() const;
|
||||
ProgressHandler *GetProgressHandler() const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Checks whether a default progress handler is active
|
||||
@@ -383,7 +381,7 @@ public:
|
||||
* If the call succeeds, the contents of the file are returned as a
|
||||
* pointer to an aiScene object. The returned data is intended to be
|
||||
* read-only, the importer object keeps ownership of the data and will
|
||||
* destroy it upon destruction. If the import fails, NULL is returned.
|
||||
* destroy it upon destruction. If the import fails, nullptr is returned.
|
||||
* A human-readable error description can be retrieved by calling
|
||||
* GetErrorString(). The previous scene will be deleted during this call.
|
||||
* @param pFile Path and filename to the file to be imported.
|
||||
@@ -392,16 +390,16 @@ public:
|
||||
* #aiPostProcessSteps flags. If you wish to inspect the imported
|
||||
* scene first in order to fine-tune your post-processing setup,
|
||||
* consider to use #ApplyPostProcessing().
|
||||
* @return A pointer to the imported data, NULL if the import failed.
|
||||
* @return A pointer to the imported data, nullptr if the import failed.
|
||||
* The pointer to the scene remains in possession of the Importer
|
||||
* instance. Use GetOrphanedScene() to take ownership of it.
|
||||
*
|
||||
* @note Assimp is able to determine the file format of a file
|
||||
* automatically.
|
||||
*/
|
||||
const aiScene* ReadFile(
|
||||
const char* pFile,
|
||||
unsigned int pFlags);
|
||||
const aiScene *ReadFile(
|
||||
const char *pFile,
|
||||
unsigned int pFlags);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Reads the given file from a memory buffer and returns its
|
||||
@@ -410,7 +408,7 @@ public:
|
||||
* If the call succeeds, the contents of the file are returned as a
|
||||
* pointer to an aiScene object. The returned data is intended to be
|
||||
* read-only, the importer object keeps ownership of the data and will
|
||||
* destroy it upon destruction. If the import fails, NULL is returned.
|
||||
* destroy it upon destruction. If the import fails, nullptr is returned.
|
||||
* A human-readable error description can be retrieved by calling
|
||||
* GetErrorString(). The previous scene will be deleted during this call.
|
||||
* Calling this method doesn't affect the active IOSystem.
|
||||
@@ -428,7 +426,7 @@ public:
|
||||
* the request, the library continues and tries to determine the
|
||||
* file format on its own, a task that may or may not be successful.
|
||||
* Check the return value, and you'll know ...
|
||||
* @return A pointer to the imported data, NULL if the import failed.
|
||||
* @return A pointer to the imported data, nullptr if the import failed.
|
||||
* The pointer to the scene remains in possession of the Importer
|
||||
* instance. Use GetOrphanedScene() to take ownership of it.
|
||||
*
|
||||
@@ -440,11 +438,11 @@ public:
|
||||
* a custom IOSystem to make Assimp find these files and use
|
||||
* the regular ReadFile() API.
|
||||
*/
|
||||
const aiScene* ReadFileFromMemory(
|
||||
const void* pBuffer,
|
||||
size_t pLength,
|
||||
unsigned int pFlags,
|
||||
const char* pHint = "");
|
||||
const aiScene *ReadFileFromMemory(
|
||||
const void *pBuffer,
|
||||
size_t pLength,
|
||||
unsigned int pFlags,
|
||||
const char *pHint = "");
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Apply post-processing to an already-imported scene.
|
||||
@@ -456,17 +454,17 @@ public:
|
||||
* #aiPostProcessSteps flags.
|
||||
* @return A pointer to the post-processed data. This is still the
|
||||
* same as the pointer returned by #ReadFile(). However, if
|
||||
* post-processing fails, the scene could now be NULL.
|
||||
* post-processing fails, the scene could now be nullptr.
|
||||
* That's quite a rare case, post processing steps are not really
|
||||
* designed to 'fail'. To be exact, the #aiProcess_ValidateDS
|
||||
* flag is currently the only post processing step which can actually
|
||||
* cause the scene to be reset to NULL.
|
||||
* cause the scene to be reset to nullptr.
|
||||
*
|
||||
* @note The method does nothing if no scene is currently bound
|
||||
* to the #Importer instance. */
|
||||
const aiScene* ApplyPostProcessing(unsigned int pFlags);
|
||||
const aiScene *ApplyPostProcessing(unsigned int pFlags);
|
||||
|
||||
const aiScene* ApplyCustomizedPostProcessing( BaseProcess *rootProcess, bool requestValidation );
|
||||
const aiScene *ApplyCustomizedPostProcessing(BaseProcess *rootProcess, bool requestValidation);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Reads the given file and returns its contents if successful.
|
||||
@@ -474,9 +472,9 @@ public:
|
||||
* This function is provided for backward compatibility.
|
||||
* See the const char* version for detailed docs.
|
||||
* @see ReadFile(const char*, pFlags) */
|
||||
const aiScene* ReadFile(
|
||||
const std::string& pFile,
|
||||
unsigned int pFlags);
|
||||
const aiScene *ReadFile(
|
||||
const std::string &pFile,
|
||||
unsigned int pFlags);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Frees the current scene.
|
||||
@@ -484,33 +482,33 @@ public:
|
||||
* The function does nothing if no scene has previously been
|
||||
* read via ReadFile(). FreeScene() is called automatically by the
|
||||
* destructor and ReadFile() itself. */
|
||||
void FreeScene( );
|
||||
void FreeScene();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns an error description of an error that occurred in ReadFile().
|
||||
*
|
||||
* Returns an empty string if no error occurred.
|
||||
* @return A description of the last error, an empty string if no
|
||||
* error occurred. The string is never NULL.
|
||||
* error occurred. The string is never nullptr.
|
||||
*
|
||||
* @note The returned function remains valid until one of the
|
||||
* following methods is called: #ReadFile(), #FreeScene(). */
|
||||
const char* GetErrorString() const;
|
||||
const char *GetErrorString() const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns the scene loaded by the last successful call to ReadFile()
|
||||
*
|
||||
* @return Current scene or NULL if there is currently no scene loaded */
|
||||
const aiScene* GetScene() const;
|
||||
* @return Current scene or nullptr if there is currently no scene loaded */
|
||||
const aiScene *GetScene() const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns the scene loaded by the last successful call to ReadFile()
|
||||
* and releases the scene from the ownership of the Importer
|
||||
* instance. The application is now responsible for deleting the
|
||||
* scene. Any further calls to GetScene() or GetOrphanedScene()
|
||||
* will return NULL - until a new scene has been loaded via ReadFile().
|
||||
* will return nullptr - until a new scene has been loaded via ReadFile().
|
||||
*
|
||||
* @return Current scene or NULL if there is currently no scene loaded
|
||||
* @return Current scene or nullptr if there is currently no scene loaded
|
||||
* @note Use this method with maximal caution, and only if you have to.
|
||||
* By design, aiScene's are exclusively maintained, allocated and
|
||||
* deallocated by Assimp and no one else. The reasoning behind this
|
||||
@@ -522,7 +520,7 @@ public:
|
||||
* On Windows, it's typically fine provided everything is linked
|
||||
* against the multithreaded-dll version of the runtime library.
|
||||
* It will work as well for static linkage with Assimp.*/
|
||||
aiScene* GetOrphanedScene();
|
||||
aiScene *GetOrphanedScene();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns whether a given file extension is supported by ASSIMP.
|
||||
@@ -531,7 +529,7 @@ public:
|
||||
* Must include a trailing dot '.'. Example: ".3ds", ".md3".
|
||||
* Cases-insensitive.
|
||||
* @return true if the extension is supported, false otherwise */
|
||||
bool IsExtensionSupported(const char* szExtension) const;
|
||||
bool IsExtensionSupported(const char *szExtension) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Returns whether a given file extension is supported by ASSIMP.
|
||||
@@ -539,7 +537,7 @@ public:
|
||||
* This function is provided for backward compatibility.
|
||||
* See the const char* version for detailed and up-to-date docs.
|
||||
* @see IsExtensionSupported(const char*) */
|
||||
inline bool IsExtensionSupported(const std::string& szExtension) const;
|
||||
inline bool IsExtensionSupported(const std::string &szExtension) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a full list of all file extensions supported by ASSIMP.
|
||||
@@ -551,7 +549,7 @@ public:
|
||||
* @param szOut String to receive the extension list.
|
||||
* Format of the list: "*.3ds;*.obj;*.dae". This is useful for
|
||||
* use with the WinAPI call GetOpenFileName(Ex). */
|
||||
void GetExtensionList(aiString& szOut) const;
|
||||
void GetExtensionList(aiString &szOut) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Get a full list of all file extensions supported by ASSIMP.
|
||||
@@ -559,7 +557,7 @@ public:
|
||||
* This function is provided for backward compatibility.
|
||||
* See the aiString version for detailed and up-to-date docs.
|
||||
* @see GetExtensionList(aiString&)*/
|
||||
inline void GetExtensionList(std::string& szOut) const;
|
||||
inline void GetExtensionList(std::string &szOut) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get the number of importers currently registered with Assimp. */
|
||||
@@ -570,18 +568,18 @@ public:
|
||||
*
|
||||
* For the declaration of #aiImporterDesc, include <assimp/importerdesc.h>.
|
||||
* @param index Index to query, must be within [0,GetImporterCount())
|
||||
* @return Importer meta data structure, NULL if the index does not
|
||||
* @return Importer meta data structure, nullptr if the index does not
|
||||
* exist or if the importer doesn't offer meta information (
|
||||
* importers may do this at the cost of being hated by their peers).*/
|
||||
const aiImporterDesc* GetImporterInfo(size_t index) const;
|
||||
const aiImporterDesc *GetImporterInfo(size_t index) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Find the importer corresponding to a specific index.
|
||||
*
|
||||
* @param index Index to query, must be within [0,GetImporterCount())
|
||||
* @return Importer instance. NULL if the index does not
|
||||
* @return Importer instance. nullptr if the index does not
|
||||
* exist. */
|
||||
BaseImporter* GetImporter(size_t index) const;
|
||||
BaseImporter *GetImporter(size_t index) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Find the importer corresponding to a specific file extension.
|
||||
@@ -592,8 +590,8 @@ public:
|
||||
* are recognized (BAH being the file extension): "BAH" (comparison
|
||||
* is case-insensitive), ".bah", "*.bah" (wild card and dot
|
||||
* characters at the beginning of the extension are skipped).
|
||||
* @return NULL if no importer is found*/
|
||||
BaseImporter* GetImporter (const char* szExtension) const;
|
||||
* @return nullptr if no importer is found*/
|
||||
BaseImporter *GetImporter(const char *szExtension) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Find the importer index corresponding to a specific file extension.
|
||||
@@ -603,7 +601,7 @@ public:
|
||||
* is case-insensitive), ".bah", "*.bah" (wild card and dot
|
||||
* characters at the beginning of the extension are skipped).
|
||||
* @return (size_t)-1 if no importer is found */
|
||||
size_t GetImporterIndex (const char* szExtension) const;
|
||||
size_t GetImporterIndex(const char *szExtension) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns the storage allocated by ASSIMP to hold the scene data
|
||||
@@ -614,7 +612,7 @@ public:
|
||||
* @note The returned memory statistics refer to the actual
|
||||
* size of the use data of the aiScene. Heap-related overhead
|
||||
* is (naturally) not included.*/
|
||||
void GetMemoryRequirements(aiMemoryInfo& in) const;
|
||||
void GetMemoryRequirements(aiMemoryInfo &in) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Enables "extra verbose" mode.
|
||||
@@ -627,16 +625,14 @@ public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Private, do not use. */
|
||||
ImporterPimpl* Pimpl() { return pimpl; }
|
||||
const ImporterPimpl* Pimpl() const { return pimpl; }
|
||||
ImporterPimpl *Pimpl() { return pimpl; }
|
||||
const ImporterPimpl *Pimpl() const { return pimpl; }
|
||||
|
||||
protected:
|
||||
|
||||
// Just because we don't want you to know how we're hacking around.
|
||||
ImporterPimpl* pimpl;
|
||||
ImporterPimpl *pimpl;
|
||||
}; //! class Importer
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// For compatibility, the interface of some functions taking a std::string was
|
||||
// changed to const char* to avoid crashes between binary incompatible STL
|
||||
@@ -644,20 +640,20 @@ protected:
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE const aiScene* Importer::ReadFile( const std::string& pFile,unsigned int pFlags){
|
||||
return ReadFile(pFile.c_str(),pFlags);
|
||||
AI_FORCE_INLINE const aiScene *Importer::ReadFile(const std::string &pFile, unsigned int pFlags) {
|
||||
return ReadFile(pFile.c_str(), pFlags);
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE void Importer::GetExtensionList(std::string& szOut) const {
|
||||
AI_FORCE_INLINE void Importer::GetExtensionList(std::string &szOut) const {
|
||||
aiString s;
|
||||
GetExtensionList(s);
|
||||
szOut = s.data;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE bool Importer::IsExtensionSupported(const std::string& szExtension) const {
|
||||
AI_FORCE_INLINE bool Importer::IsExtensionSupported(const std::string &szExtension) const {
|
||||
return IsExtensionSupported(szExtension.c_str());
|
||||
}
|
||||
|
||||
} // !namespace Assimp
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // AI_ASSIMP_HPP_INC
|
||||
|
||||
@@ -72,7 +72,7 @@ for(LineSplitter splitter(stream);splitter;++splitter) {
|
||||
if (strtol(splitter[2]) > 5) { .. }
|
||||
}
|
||||
|
||||
ASSIMP_LOG_DEBUG_F("Current line is: ", splitter.get_index());
|
||||
ASSIMP_LOG_VERBOSE_DEBUG_F("Current line is: ", splitter.get_index());
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
|
||||
@@ -94,6 +94,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static void LogVerboseDebug(const Formatter::format& message) {
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
ASSIMP_LOG_VERBOSE_DEBUG(Prefix()+(std::string)message);
|
||||
}
|
||||
}
|
||||
|
||||
// https://sourceforge.net/tracker/?func=detail&atid=1067632&aid=3358562&group_id=226462
|
||||
#if !defined(__GNUC__) || !defined(__APPLE__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
|
||||
@@ -125,6 +131,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void LogVerboseDebug (const char* message) {
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
LogVerboseDebug(Formatter::format(message));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "types.h"
|
||||
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
|
||||
class IOSystem;
|
||||
|
||||
@@ -60,7 +60,7 @@ class IOSystem;
|
||||
* are not enough for your purpose. */
|
||||
class ASSIMP_API LogStream
|
||||
#ifndef SWIG
|
||||
: public Intern::AllocateFromAssimpHeap
|
||||
: public Intern::AllocateFromAssimpHeap
|
||||
#endif
|
||||
{
|
||||
protected:
|
||||
@@ -80,28 +80,26 @@ public:
|
||||
* #DefaultLogger:set(). Usually you can *expect* that a log message
|
||||
* is exactly one line and terminated with a single \n character.
|
||||
* @param message Message to be written */
|
||||
virtual void write(const char* message) = 0;
|
||||
virtual void write(const char *message) = 0;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Creates a default log stream
|
||||
* @param streams Type of the default stream
|
||||
* @param name For aiDefaultLogStream_FILE: name of the output file
|
||||
* @param io For aiDefaultLogStream_FILE: IOSystem to be used to open the output
|
||||
* file. Pass NULL for the default implementation.
|
||||
* file. Pass nullptr for the default implementation.
|
||||
* @return New LogStream instance. */
|
||||
static LogStream* createDefaultStream(aiDefaultLogStream stream,
|
||||
const char* name = "AssimpLog.txt",
|
||||
IOSystem* io = nullptr );
|
||||
static LogStream *createDefaultStream(aiDefaultLogStream stream,
|
||||
const char *name = "AssimpLog.txt",
|
||||
IOSystem *io = nullptr);
|
||||
|
||||
}; // !class LogStream
|
||||
|
||||
inline
|
||||
LogStream::LogStream() AI_NO_EXCEPT {
|
||||
inline LogStream::LogStream() AI_NO_EXCEPT {
|
||||
// empty
|
||||
}
|
||||
|
||||
inline
|
||||
LogStream::~LogStream() {
|
||||
inline LogStream::~LogStream() {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,8 @@ public:
|
||||
*/
|
||||
enum LogSeverity {
|
||||
NORMAL, //!< Normal granularity of logging
|
||||
VERBOSE //!< Debug infos will be logged, too
|
||||
DEBUG, //!< Debug messages will be logged, but not verbose debug messages.
|
||||
VERBOSE //!< All messages will be logged
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -103,6 +104,12 @@ public:
|
||||
void debug(const char* message);
|
||||
void debug(const std::string &message);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Writes a debug message
|
||||
* @param message Debug message*/
|
||||
void verboseDebug(const char *message);
|
||||
void verboseDebug(const std::string &message);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Writes a info message
|
||||
* @param message Info message*/
|
||||
@@ -154,7 +161,7 @@ public:
|
||||
* if the result is 0 the stream is detached from the Logger and
|
||||
* the caller retakes the possession of the stream.
|
||||
* @return true if the stream has been detached, false otherwise.*/
|
||||
virtual bool detatchStream(LogStream *pStream,
|
||||
virtual bool detachStream(LogStream *pStream,
|
||||
unsigned int severity = Debugging | Err | Warn | Info) = 0;
|
||||
|
||||
protected:
|
||||
@@ -178,6 +185,16 @@ protected:
|
||||
*/
|
||||
virtual void OnDebug(const char* message)= 0;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Called as a request to write a specific verbose debug message
|
||||
* @param message Debug message. Never longer than
|
||||
* MAX_LOG_MESSAGE_LENGTH characters (excluding the '0').
|
||||
* @note The message string is only valid until the scope of
|
||||
* the function is left.
|
||||
*/
|
||||
virtual void OnVerboseDebug(const char *message) = 0;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Called as a request to write a specific info message
|
||||
@@ -255,6 +272,11 @@ void Logger::debug(const std::string &message) {
|
||||
return debug(message.c_str());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline void Logger::verboseDebug(const std::string &message) {
|
||||
return verboseDebug(message.c_str());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
void Logger::error(const std::string &message) {
|
||||
@@ -273,33 +295,37 @@ void Logger::info(const std::string &message) {
|
||||
return info(message.c_str());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define ASSIMP_LOG_WARN_F(string,...)\
|
||||
DefaultLogger::get()->warn((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_ERROR_F(string,...)\
|
||||
DefaultLogger::get()->error((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_DEBUG_F(string,...)\
|
||||
DefaultLogger::get()->debug((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_INFO_F(string,...)\
|
||||
DefaultLogger::get()->info((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
|
||||
#define ASSIMP_LOG_WARN(string)\
|
||||
DefaultLogger::get()->warn(string)
|
||||
|
||||
#define ASSIMP_LOG_ERROR(string)\
|
||||
DefaultLogger::get()->error(string)
|
||||
|
||||
#define ASSIMP_LOG_DEBUG(string)\
|
||||
DefaultLogger::get()->debug(string)
|
||||
|
||||
#define ASSIMP_LOG_INFO(string)\
|
||||
DefaultLogger::get()->info(string)
|
||||
|
||||
|
||||
} // Namespace Assimp
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define ASSIMP_LOG_WARN_F(string, ...) \
|
||||
Assimp::DefaultLogger::get()->warn((Assimp::Formatter::format(string), __VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_ERROR_F(string, ...) \
|
||||
Assimp::DefaultLogger::get()->error((Assimp::Formatter::format(string), __VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_DEBUG_F(string, ...) \
|
||||
Assimp::DefaultLogger::get()->debug((Assimp::Formatter::format(string), __VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_VERBOSE_DEBUG_F(string, ...) \
|
||||
Assimp::DefaultLogger::get()->verboseDebug((Assimp::Formatter::format(string), __VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_INFO_F(string, ...) \
|
||||
Assimp::DefaultLogger::get()->info((Assimp::Formatter::format(string), __VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_WARN(string) \
|
||||
Assimp::DefaultLogger::get()->warn(string)
|
||||
|
||||
#define ASSIMP_LOG_ERROR(string) \
|
||||
Assimp::DefaultLogger::get()->error(string)
|
||||
|
||||
#define ASSIMP_LOG_DEBUG(string) \
|
||||
Assimp::DefaultLogger::get()->debug(string)
|
||||
|
||||
#define ASSIMP_LOG_VERBOSE_DEBUG(string) \
|
||||
Assimp::DefaultLogger::get()->verboseDebug(string)
|
||||
|
||||
#define ASSIMP_LOG_INFO(string) \
|
||||
Assimp::DefaultLogger::get()->info(string)
|
||||
|
||||
#endif // !! INCLUDED_AI_LOGGER_H
|
||||
|
||||
@@ -55,36 +55,51 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
namespace Assimp {
|
||||
namespace Math {
|
||||
|
||||
// TODO: use binary GCD for unsigned integers ....
|
||||
template < typename IntegerType >
|
||||
inline
|
||||
IntegerType gcd( IntegerType a, IntegerType b ) {
|
||||
/// @brief Will return the greatest common divisor.
|
||||
/// @param a [in] Value a.
|
||||
/// @param b [in] Value b.
|
||||
/// @return The greatest common divisor.
|
||||
template <typename IntegerType>
|
||||
inline IntegerType gcd( IntegerType a, IntegerType b ) {
|
||||
const IntegerType zero = (IntegerType)0;
|
||||
while ( true ) {
|
||||
if ( a == zero )
|
||||
if ( a == zero ) {
|
||||
return b;
|
||||
}
|
||||
b %= a;
|
||||
|
||||
if ( b == zero )
|
||||
if ( b == zero ) {
|
||||
return a;
|
||||
}
|
||||
a %= b;
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Will return the greatest common divisor.
|
||||
/// @param a [in] Value a.
|
||||
/// @param b [in] Value b.
|
||||
/// @return The greatest common divisor.
|
||||
template < typename IntegerType >
|
||||
inline
|
||||
IntegerType lcm( IntegerType a, IntegerType b ) {
|
||||
inline IntegerType lcm( IntegerType a, IntegerType b ) {
|
||||
const IntegerType t = gcd (a,b);
|
||||
if (!t)
|
||||
if (!t) {
|
||||
return t;
|
||||
}
|
||||
return a / t * b;
|
||||
}
|
||||
|
||||
/// @brief Will return the smallest epsilon-value for the requested type.
|
||||
/// @return The numercical limit epsilon depending on its type.
|
||||
template<class T>
|
||||
inline
|
||||
T getEpsilon() {
|
||||
inline T getEpsilon() {
|
||||
return std::numeric_limits<T>::epsilon();
|
||||
}
|
||||
|
||||
/// @brief Will return the constant PI for the requested type.
|
||||
/// @return Pi
|
||||
template<class T>
|
||||
inline T PI() {
|
||||
return static_cast<T>(3.14159265358979323846);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Math
|
||||
} // namespace Assimp
|
||||
|
||||
@@ -66,6 +66,11 @@ public:
|
||||
(void)message; //this avoids compiler warnings
|
||||
}
|
||||
|
||||
/** @brief Logs a verbose debug message */
|
||||
void OnVerboseDebug(const char *message) {
|
||||
(void)message; //this avoids compiler warnings
|
||||
}
|
||||
|
||||
/** @brief Logs an info message */
|
||||
void OnInfo(const char* message) {
|
||||
(void)message; //this avoids compiler warnings
|
||||
@@ -88,7 +93,7 @@ public:
|
||||
}
|
||||
|
||||
/** @brief Detach a still attached stream from logger */
|
||||
bool detatchStream(LogStream *pStream, unsigned int severity) {
|
||||
bool detachStream(LogStream *pStream, unsigned int severity) {
|
||||
(void)pStream; (void)severity; //this avoids compiler warnings
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
* occasion (loaders and Assimp are generally allowed to perform
|
||||
* all needed cleanup tasks prior to returning control to the
|
||||
* caller). If the loading is aborted, #Importer::ReadFile()
|
||||
* returns always NULL.
|
||||
* returns always nullptr.
|
||||
* */
|
||||
virtual bool Update(float percentage = -1.f) = 0;
|
||||
|
||||
|
||||
@@ -48,17 +48,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define AI_SCENE_COMBINER_H_INC
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <assimp/Defines.h>
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/Defines.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <set>
|
||||
#include <list>
|
||||
#include <stdint.h>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
struct aiScene;
|
||||
@@ -75,68 +75,58 @@ struct aiAnimation;
|
||||
struct aiNodeAnim;
|
||||
struct aiMeshMorphAnim;
|
||||
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** \brief Helper data structure for SceneCombiner.
|
||||
*
|
||||
* Describes to which node a scene must be attached to.
|
||||
*/
|
||||
struct AttachmentInfo
|
||||
{
|
||||
AttachmentInfo()
|
||||
: scene (NULL)
|
||||
, attachToNode (NULL)
|
||||
{}
|
||||
struct AttachmentInfo {
|
||||
AttachmentInfo() :
|
||||
scene(nullptr),
|
||||
attachToNode(nullptr) {}
|
||||
|
||||
AttachmentInfo(aiScene* _scene, aiNode* _attachToNode)
|
||||
: scene (_scene)
|
||||
, attachToNode (_attachToNode)
|
||||
{}
|
||||
AttachmentInfo(aiScene *_scene, aiNode *_attachToNode) :
|
||||
scene(_scene), attachToNode(_attachToNode) {}
|
||||
|
||||
aiScene* scene;
|
||||
aiNode* attachToNode;
|
||||
aiScene *scene;
|
||||
aiNode *attachToNode;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
struct NodeAttachmentInfo
|
||||
{
|
||||
NodeAttachmentInfo()
|
||||
: node (NULL)
|
||||
, attachToNode (NULL)
|
||||
, resolved (false)
|
||||
, src_idx (SIZE_MAX)
|
||||
{}
|
||||
struct NodeAttachmentInfo {
|
||||
NodeAttachmentInfo() :
|
||||
node(nullptr),
|
||||
attachToNode(nullptr),
|
||||
resolved(false),
|
||||
src_idx(SIZE_MAX) {}
|
||||
|
||||
NodeAttachmentInfo(aiNode* _scene, aiNode* _attachToNode,size_t idx)
|
||||
: node (_scene)
|
||||
, attachToNode (_attachToNode)
|
||||
, resolved (false)
|
||||
, src_idx (idx)
|
||||
{}
|
||||
NodeAttachmentInfo(aiNode *_scene, aiNode *_attachToNode, size_t idx) :
|
||||
node(_scene), attachToNode(_attachToNode), resolved(false), src_idx(idx) {}
|
||||
|
||||
aiNode* node;
|
||||
aiNode* attachToNode;
|
||||
bool resolved;
|
||||
size_t src_idx;
|
||||
aiNode *node;
|
||||
aiNode *attachToNode;
|
||||
bool resolved;
|
||||
size_t src_idx;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @def AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES
|
||||
* Generate unique names for all named scene items
|
||||
*/
|
||||
#define AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES 0x1
|
||||
#define AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES 0x1
|
||||
|
||||
/** @def AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES
|
||||
* Generate unique names for materials, too.
|
||||
* This is not absolutely required to pass the validation.
|
||||
*/
|
||||
#define AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES 0x2
|
||||
#define AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES 0x2
|
||||
|
||||
/** @def AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY
|
||||
* Use deep copies of duplicate scenes
|
||||
*/
|
||||
#define AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY 0x4
|
||||
#define AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY 0x4
|
||||
|
||||
/** @def AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS
|
||||
* If attachment nodes are not found in the given master scene,
|
||||
@@ -151,44 +141,39 @@ struct NodeAttachmentInfo
|
||||
*/
|
||||
#define AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY 0x10
|
||||
|
||||
typedef std::pair<aiBone*,unsigned int> BoneSrcIndex;
|
||||
typedef std::pair<aiBone *, unsigned int> BoneSrcIndex;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Helper data structure for SceneCombiner::MergeBones.
|
||||
*/
|
||||
struct BoneWithHash : public std::pair<uint32_t,aiString*> {
|
||||
struct BoneWithHash : public std::pair<uint32_t, aiString *> {
|
||||
std::vector<BoneSrcIndex> pSrcBones;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Utility for SceneCombiner
|
||||
*/
|
||||
struct SceneHelper
|
||||
{
|
||||
SceneHelper ()
|
||||
: scene (NULL)
|
||||
, idlen (0)
|
||||
{
|
||||
struct SceneHelper {
|
||||
SceneHelper() :
|
||||
scene(nullptr),
|
||||
idlen(0) {
|
||||
id[0] = 0;
|
||||
}
|
||||
|
||||
explicit SceneHelper (aiScene* _scene)
|
||||
: scene (_scene)
|
||||
, idlen (0)
|
||||
{
|
||||
explicit SceneHelper(aiScene *_scene) :
|
||||
scene(_scene), idlen(0) {
|
||||
id[0] = 0;
|
||||
}
|
||||
|
||||
AI_FORCE_INLINE aiScene* operator-> () const
|
||||
{
|
||||
AI_FORCE_INLINE aiScene *operator->() const {
|
||||
return scene;
|
||||
}
|
||||
|
||||
// scene we're working on
|
||||
aiScene* scene;
|
||||
aiScene *scene;
|
||||
|
||||
// prefix to be added to all identifiers in the scene ...
|
||||
char id [32];
|
||||
char id[32];
|
||||
|
||||
// and its strlen()
|
||||
unsigned int idlen;
|
||||
@@ -220,21 +205,21 @@ public:
|
||||
/** Merges two or more scenes.
|
||||
*
|
||||
* @param dest Receives a pointer to the destination scene. If the
|
||||
* pointer doesn't point to NULL when the function is called, the
|
||||
* pointer doesn't point to nullptr when the function is called, the
|
||||
* existing scene is cleared and refilled.
|
||||
* @param src Non-empty list of scenes to be merged. The function
|
||||
* deletes the input scenes afterwards. There may be duplicate scenes.
|
||||
* @param flags Combination of the AI_INT_MERGE_SCENE flags defined above
|
||||
*/
|
||||
static void MergeScenes(aiScene** dest,std::vector<aiScene*>& src,
|
||||
unsigned int flags = 0);
|
||||
static void MergeScenes(aiScene **dest, std::vector<aiScene *> &src,
|
||||
unsigned int flags = 0);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Merges two or more scenes and attaches all scenes to a specific
|
||||
* position in the node graph of the master scene.
|
||||
*
|
||||
* @param dest Receives a pointer to the destination scene. If the
|
||||
* pointer doesn't point to NULL when the function is called, the
|
||||
* pointer doesn't point to nullptr when the function is called, the
|
||||
* existing scene is cleared and refilled.
|
||||
* @param master Master scene. It will be deleted afterwards. All
|
||||
* other scenes will be inserted in its node graph.
|
||||
@@ -243,9 +228,9 @@ public:
|
||||
* deletes the input scenes afterwards. There may be duplicate scenes.
|
||||
* @param flags Combination of the AI_INT_MERGE_SCENE flags defined above
|
||||
*/
|
||||
static void MergeScenes(aiScene** dest, aiScene* master,
|
||||
std::vector<AttachmentInfo>& src,
|
||||
unsigned int flags = 0);
|
||||
static void MergeScenes(aiScene **dest, aiScene *master,
|
||||
std::vector<AttachmentInfo> &src,
|
||||
unsigned int flags = 0);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Merges two or more meshes
|
||||
@@ -261,9 +246,9 @@ public:
|
||||
* @param begin First mesh to be processed
|
||||
* @param end Points to the mesh after the last mesh to be processed
|
||||
*/
|
||||
static void MergeMeshes(aiMesh** dest,unsigned int flags,
|
||||
std::vector<aiMesh*>::const_iterator begin,
|
||||
std::vector<aiMesh*>::const_iterator end);
|
||||
static void MergeMeshes(aiMesh **dest, unsigned int flags,
|
||||
std::vector<aiMesh *>::const_iterator begin,
|
||||
std::vector<aiMesh *>::const_iterator end);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Merges two or more bones
|
||||
@@ -273,8 +258,8 @@ public:
|
||||
* @param begin First mesh to be processed
|
||||
* @param end Points to the mesh after the last mesh to be processed
|
||||
*/
|
||||
static void MergeBones(aiMesh* out,std::vector<aiMesh*>::const_iterator it,
|
||||
std::vector<aiMesh*>::const_iterator end);
|
||||
static void MergeBones(aiMesh *out, std::vector<aiMesh *>::const_iterator it,
|
||||
std::vector<aiMesh *>::const_iterator end);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Merges two or more materials
|
||||
@@ -287,9 +272,9 @@ public:
|
||||
* @param begin First material to be processed
|
||||
* @param end Points to the material after the last material to be processed
|
||||
*/
|
||||
static void MergeMaterials(aiMaterial** dest,
|
||||
std::vector<aiMaterial*>::const_iterator begin,
|
||||
std::vector<aiMaterial*>::const_iterator end);
|
||||
static void MergeMaterials(aiMaterial **dest,
|
||||
std::vector<aiMaterial *>::const_iterator begin,
|
||||
std::vector<aiMaterial *>::const_iterator end);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Builds a list of uniquely named bones in a mesh list
|
||||
@@ -298,9 +283,9 @@ public:
|
||||
* @param it First mesh to be processed
|
||||
* @param end Last mesh to be processed
|
||||
*/
|
||||
static void BuildUniqueBoneList(std::list<BoneWithHash>& asBones,
|
||||
std::vector<aiMesh*>::const_iterator it,
|
||||
std::vector<aiMesh*>::const_iterator end);
|
||||
static void BuildUniqueBoneList(std::list<BoneWithHash> &asBones,
|
||||
std::vector<aiMesh *>::const_iterator it,
|
||||
std::vector<aiMesh *>::const_iterator end);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Add a name prefix to all nodes in a scene.
|
||||
@@ -309,8 +294,8 @@ public:
|
||||
* @param prefix Prefix to be added to all nodes
|
||||
* @param len STring length
|
||||
*/
|
||||
static void AddNodePrefixes(aiNode* node, const char* prefix,
|
||||
unsigned int len);
|
||||
static void AddNodePrefixes(aiNode *node, const char *prefix,
|
||||
unsigned int len);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Add an offset to all mesh indices in a node graph
|
||||
@@ -318,7 +303,7 @@ public:
|
||||
* @param Current node. This function is called recursively.
|
||||
* @param offset Offset to be added to all mesh indices
|
||||
*/
|
||||
static void OffsetNodeMeshIndices (aiNode* node, unsigned int offset);
|
||||
static void OffsetNodeMeshIndices(aiNode *node, unsigned int offset);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Attach a list of node graphs to well-defined nodes in a master
|
||||
@@ -326,18 +311,17 @@ public:
|
||||
*
|
||||
* @param master Master scene
|
||||
* @param srcList List of source scenes along with their attachment
|
||||
* points. If an attachment point is NULL (or does not exist in
|
||||
* points. If an attachment point is nullptr (or does not exist in
|
||||
* the master graph), a scene is attached to the root of the master
|
||||
* graph (as an additional child node)
|
||||
* @duplicates List of duplicates. If elem[n] == n the scene is not
|
||||
* a duplicate. Otherwise elem[n] links scene n to its first occurrence.
|
||||
*/
|
||||
static void AttachToGraph ( aiScene* master,
|
||||
std::vector<NodeAttachmentInfo>& srcList);
|
||||
|
||||
static void AttachToGraph (aiNode* attach,
|
||||
std::vector<NodeAttachmentInfo>& srcList);
|
||||
static void AttachToGraph(aiScene *master,
|
||||
std::vector<NodeAttachmentInfo> &srcList);
|
||||
|
||||
static void AttachToGraph(aiNode *attach,
|
||||
std::vector<NodeAttachmentInfo> &srcList);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a deep copy of a scene
|
||||
@@ -345,21 +329,19 @@ public:
|
||||
* @param dest Receives a pointer to the destination scene
|
||||
* @param src Source scene - remains unmodified.
|
||||
*/
|
||||
static void CopyScene(aiScene** dest,const aiScene* source,bool allocate = true);
|
||||
|
||||
static void CopyScene(aiScene **dest, const aiScene *source, bool allocate = true);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a flat copy of a scene
|
||||
*
|
||||
* Only the first hierarchy layer is copied. All pointer members of
|
||||
* aiScene are shared by source and destination scene. If the
|
||||
* pointer doesn't point to NULL when the function is called, the
|
||||
* pointer doesn't point to nullptr when the function is called, the
|
||||
* existing scene is cleared and refilled.
|
||||
* @param dest Receives a pointer to the destination scene
|
||||
* @param src Source scene - remains unmodified.
|
||||
*/
|
||||
static void CopySceneFlat(aiScene** dest,const aiScene* source);
|
||||
|
||||
static void CopySceneFlat(aiScene **dest, const aiScene *source);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a deep copy of a mesh
|
||||
@@ -367,44 +349,41 @@ public:
|
||||
* @param dest Receives a pointer to the destination mesh
|
||||
* @param src Source mesh - remains unmodified.
|
||||
*/
|
||||
static void Copy (aiMesh** dest, const aiMesh* src);
|
||||
static void Copy(aiMesh **dest, const aiMesh *src);
|
||||
|
||||
// similar to Copy():
|
||||
static void Copy (aiAnimMesh** dest, const aiAnimMesh* src);
|
||||
static void Copy (aiMaterial** dest, const aiMaterial* src);
|
||||
static void Copy (aiTexture** dest, const aiTexture* src);
|
||||
static void Copy (aiAnimation** dest, const aiAnimation* src);
|
||||
static void Copy (aiCamera** dest, const aiCamera* src);
|
||||
static void Copy (aiBone** dest, const aiBone* src);
|
||||
static void Copy (aiLight** dest, const aiLight* src);
|
||||
static void Copy (aiNodeAnim** dest, const aiNodeAnim* src);
|
||||
static void Copy (aiMeshMorphAnim** dest, const aiMeshMorphAnim* src);
|
||||
static void Copy (aiMetadata** dest, const aiMetadata* src);
|
||||
static void Copy(aiAnimMesh **dest, const aiAnimMesh *src);
|
||||
static void Copy(aiMaterial **dest, const aiMaterial *src);
|
||||
static void Copy(aiTexture **dest, const aiTexture *src);
|
||||
static void Copy(aiAnimation **dest, const aiAnimation *src);
|
||||
static void Copy(aiCamera **dest, const aiCamera *src);
|
||||
static void Copy(aiBone **dest, const aiBone *src);
|
||||
static void Copy(aiLight **dest, const aiLight *src);
|
||||
static void Copy(aiNodeAnim **dest, const aiNodeAnim *src);
|
||||
static void Copy(aiMeshMorphAnim **dest, const aiMeshMorphAnim *src);
|
||||
static void Copy(aiMetadata **dest, const aiMetadata *src);
|
||||
|
||||
// recursive, of course
|
||||
static void Copy (aiNode** dest, const aiNode* src);
|
||||
|
||||
static void Copy(aiNode **dest, const aiNode *src);
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Same as AddNodePrefixes, but with an additional check
|
||||
static void AddNodePrefixesChecked(aiNode* node, const char* prefix,
|
||||
unsigned int len,
|
||||
std::vector<SceneHelper>& input,
|
||||
unsigned int cur);
|
||||
static void AddNodePrefixesChecked(aiNode *node, const char *prefix,
|
||||
unsigned int len,
|
||||
std::vector<SceneHelper> &input,
|
||||
unsigned int cur);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Add node identifiers to a hashing set
|
||||
static void AddNodeHashes(aiNode* node, std::set<unsigned int>& hashes);
|
||||
|
||||
static void AddNodeHashes(aiNode *node, std::set<unsigned int> &hashes);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Search for duplicate names
|
||||
static bool FindNameMatch(const aiString& name,
|
||||
std::vector<SceneHelper>& input, unsigned int cur);
|
||||
static bool FindNameMatch(const aiString &name,
|
||||
std::vector<SceneHelper> &input, unsigned int cur);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // !! AI_SCENE_COMBINER_H_INC
|
||||
|
||||
@@ -52,17 +52,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define AI_SKELETONMESHBUILDER_H_INC
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <assimp/mesh.h>
|
||||
#include <vector>
|
||||
|
||||
struct aiMaterial;
|
||||
struct aiScene;
|
||||
struct aiNode;
|
||||
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -70,57 +70,56 @@ namespace Assimp {
|
||||
* the resembles the node hierarchy. This is useful for file formats
|
||||
* that don't carry any mesh data but only animation data.
|
||||
*/
|
||||
class ASSIMP_API SkeletonMeshBuilder
|
||||
{
|
||||
class ASSIMP_API SkeletonMeshBuilder {
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** The constructor processes the given scene and adds a mesh there.
|
||||
*
|
||||
* Does nothing if the scene already has mesh data.
|
||||
* @param pScene The scene for which a skeleton mesh should be constructed.
|
||||
* @param root The node to start with. NULL is the scene root
|
||||
* @param root The node to start with. nullptr is the scene root
|
||||
* @param bKnobsOnly Set this to true if you don't want the connectors
|
||||
* between the knobs representing the nodes.
|
||||
*/
|
||||
SkeletonMeshBuilder( aiScene* pScene, aiNode* root = NULL,
|
||||
bool bKnobsOnly = false);
|
||||
SkeletonMeshBuilder(aiScene *pScene, aiNode *root = nullptr,
|
||||
bool bKnobsOnly = false);
|
||||
|
||||
protected:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Recursively builds a simple mesh representation for the given node
|
||||
* and also creates a joint for the node that affects this part of
|
||||
* the mesh.
|
||||
* @param pNode The node to build geometry for.
|
||||
*/
|
||||
void CreateGeometry( const aiNode* pNode);
|
||||
void CreateGeometry(const aiNode *pNode);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Creates the mesh from the internally accumulated stuff and returns it.
|
||||
*/
|
||||
aiMesh* CreateMesh();
|
||||
aiMesh *CreateMesh();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Creates a dummy material and returns it. */
|
||||
aiMaterial* CreateMaterial();
|
||||
aiMaterial *CreateMaterial();
|
||||
|
||||
protected:
|
||||
/** space to assemble the mesh data: points */
|
||||
std::vector<aiVector3D> mVertices;
|
||||
|
||||
/** faces */
|
||||
struct Face
|
||||
{
|
||||
struct Face {
|
||||
unsigned int mIndices[3];
|
||||
Face();
|
||||
Face( unsigned int p0, unsigned int p1, unsigned int p2)
|
||||
{ mIndices[0] = p0; mIndices[1] = p1; mIndices[2] = p2; }
|
||||
Face(unsigned int p0, unsigned int p1, unsigned int p2) {
|
||||
mIndices[0] = p0;
|
||||
mIndices[1] = p1;
|
||||
mIndices[2] = p2;
|
||||
}
|
||||
};
|
||||
std::vector<Face> mFaces;
|
||||
|
||||
/** bones */
|
||||
std::vector<aiBone*> mBones;
|
||||
std::vector<aiBone *> mBones;
|
||||
|
||||
bool mKnobsOnly;
|
||||
};
|
||||
|
||||
164
include/assimp/SmallVector.h
Normal file
164
include/assimp/SmallVector.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
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,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Defines small vector with inplace storage.
|
||||
Based on CppCon 2016: Chandler Carruth "High Performance Code 201: Hybrid Data Structures" */
|
||||
|
||||
#pragma once
|
||||
#ifndef AI_SMALLVECTOR_H_INC
|
||||
#define AI_SMALLVECTOR_H_INC
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
/// @brief Small vector with inplace storage.
|
||||
///
|
||||
/// Reduces heap allocations when list is shorter. It uses a small array for a dedicated size.
|
||||
/// When the growing gets bigger than this small cache a dynamic growing algorithm will be
|
||||
/// used.
|
||||
// --------------------------------------------------------------------------------------------
|
||||
template<typename T, unsigned int Capacity>
|
||||
class SmallVector {
|
||||
public:
|
||||
/// @brief The default class constructor.
|
||||
SmallVector() :
|
||||
mStorage(mInplaceStorage),
|
||||
mSize(0),
|
||||
mCapacity(Capacity) {
|
||||
// empty
|
||||
}
|
||||
|
||||
/// @brief The class destructor.
|
||||
~SmallVector() {
|
||||
if (mStorage != mInplaceStorage) {
|
||||
delete [] mStorage;
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Will push a new item. The capacity will grow in case of a too small capacity.
|
||||
/// @param item [in] The item to push at the end of the vector.
|
||||
void push_back(const T& item) {
|
||||
if (mSize < mCapacity) {
|
||||
mStorage[mSize++] = item;
|
||||
return;
|
||||
}
|
||||
|
||||
push_back_and_grow(item);
|
||||
}
|
||||
|
||||
/// @brief Will resize the vector.
|
||||
/// @param newSize [in] The new size.
|
||||
void resize(size_t newSize) {
|
||||
if (newSize > mCapacity) {
|
||||
grow(newSize);
|
||||
}
|
||||
mSize = newSize;
|
||||
}
|
||||
|
||||
/// @brief Returns the current size of the vector.
|
||||
/// @return The current size.
|
||||
size_t size() const {
|
||||
return mSize;
|
||||
}
|
||||
|
||||
/// @brief Returns a pointer to the first item.
|
||||
/// @return The first item as a pointer.
|
||||
T* begin() {
|
||||
return mStorage;
|
||||
}
|
||||
|
||||
/// @brief Returns a pointer to the end.
|
||||
/// @return The end as a pointer.
|
||||
T* end() {
|
||||
return &mStorage[mSize];
|
||||
}
|
||||
|
||||
/// @brief Returns a const pointer to the first item.
|
||||
/// @return The first item as a const pointer.
|
||||
T* begin() const {
|
||||
return mStorage;
|
||||
}
|
||||
|
||||
/// @brief Returns a const pointer to the end.
|
||||
/// @return The end as a const pointer.
|
||||
T* end() const {
|
||||
return &mStorage[mSize];
|
||||
}
|
||||
|
||||
SmallVector(const SmallVector &) = delete;
|
||||
SmallVector(SmallVector &&) = delete;
|
||||
SmallVector &operator = (const SmallVector &) = delete;
|
||||
SmallVector &operator = (SmallVector &&) = delete;
|
||||
|
||||
private:
|
||||
void grow( size_t newCapacity) {
|
||||
T* oldStorage = mStorage;
|
||||
T* newStorage = new T[newCapacity];
|
||||
|
||||
std::memcpy(newStorage, oldStorage, mSize * sizeof(T));
|
||||
|
||||
mStorage = newStorage;
|
||||
mCapacity = newCapacity;
|
||||
|
||||
if (oldStorage != mInplaceStorage) {
|
||||
delete [] oldStorage;
|
||||
}
|
||||
}
|
||||
|
||||
void push_back_and_grow(const T& item) {
|
||||
grow(mCapacity + Capacity);
|
||||
|
||||
mStorage[mSize++] = item;
|
||||
}
|
||||
|
||||
T* mStorage;
|
||||
size_t mSize;
|
||||
size_t mCapacity;
|
||||
T mInplaceStorage[Capacity];
|
||||
};
|
||||
|
||||
} // end namespace Assimp
|
||||
|
||||
#endif // !! AI_SMALLVECTOR_H_INC
|
||||
@@ -46,11 +46,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define AI_SPATIALSORT_H_INC
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <assimp/types.h>
|
||||
#include <vector>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
@@ -62,10 +62,8 @@ namespace Assimp {
|
||||
* time, with O(n) worst case complexity when all vertices lay on the plane. The plane is chosen
|
||||
* so that it avoids common planes in usual data sets. */
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class ASSIMP_API SpatialSort
|
||||
{
|
||||
class ASSIMP_API SpatialSort {
|
||||
public:
|
||||
|
||||
SpatialSort();
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
@@ -76,14 +74,12 @@ public:
|
||||
* @param pNumPositions Number of vectors to expect in that array.
|
||||
* @param pElementOffset Offset in bytes from the beginning of one vector in memory
|
||||
* to the beginning of the next vector. */
|
||||
SpatialSort( const aiVector3D* pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset);
|
||||
SpatialSort(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset);
|
||||
|
||||
/** Destructor */
|
||||
~SpatialSort();
|
||||
|
||||
public:
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Sets the input data for the SpatialSort. This replaces existing data, if any.
|
||||
* The new data receives new indices in ascending order.
|
||||
@@ -97,17 +93,15 @@ public:
|
||||
* required in order to use #FindPosition() or #GenerateMappingTable().
|
||||
* If you don't finalize yet, you can use #Append() to add data from
|
||||
* other sources.*/
|
||||
void Fill( const aiVector3D* pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
bool pFinalize = true);
|
||||
|
||||
void Fill(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
bool pFinalize = true);
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Same as #Fill(), except the method appends to existing data in the #SpatialSort. */
|
||||
void Append( const aiVector3D* pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
bool pFinalize = true);
|
||||
|
||||
void Append(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
bool pFinalize = true);
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Finalize the spatial hash data structure. This can be useful after
|
||||
@@ -123,8 +117,8 @@ public:
|
||||
* @param poResults The container to store the indices of the found positions.
|
||||
* Will be emptied by the call so it may contain anything.
|
||||
* @return An iterator to iterate over all vertices in the given area.*/
|
||||
void FindPositions( const aiVector3D& pPosition, ai_real pRadius,
|
||||
std::vector<unsigned int>& poResults) const;
|
||||
void FindPositions(const aiVector3D &pPosition, ai_real pRadius,
|
||||
std::vector<unsigned int> &poResults) const;
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Fills an array with indices of all positions identical to the given position. In
|
||||
@@ -133,8 +127,8 @@ public:
|
||||
* @param pPosition The position to look for vertices.
|
||||
* @param poResults The container to store the indices of the found positions.
|
||||
* Will be emptied by the call so it may contain anything.*/
|
||||
void FindIdenticalPositions( const aiVector3D& pPosition,
|
||||
std::vector<unsigned int>& poResults) const;
|
||||
void FindIdenticalPositions(const aiVector3D &pPosition,
|
||||
std::vector<unsigned int> &poResults) const;
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Compute a table that maps each vertex ID referring to a spatially close
|
||||
@@ -144,8 +138,8 @@ public:
|
||||
* @param pRadius Maximal distance from the position a vertex may have to
|
||||
* be counted in.
|
||||
* @return Number of unique vertices (n). */
|
||||
unsigned int GenerateMappingTable(std::vector<unsigned int>& fill,
|
||||
ai_real pRadius) const;
|
||||
unsigned int GenerateMappingTable(std::vector<unsigned int> &fill,
|
||||
ai_real pRadius) const;
|
||||
|
||||
protected:
|
||||
/** Normal of the sorting plane, normalized. The center is always at (0, 0, 0) */
|
||||
@@ -159,15 +153,17 @@ protected:
|
||||
ai_real mDistance; ///< Distance of this vertex to the sorting plane
|
||||
|
||||
Entry() AI_NO_EXCEPT
|
||||
: mIndex( 999999999 ), mPosition(), mDistance( 99999. ) {
|
||||
// empty
|
||||
: mIndex(999999999),
|
||||
mPosition(),
|
||||
mDistance(99999.) {
|
||||
// empty
|
||||
}
|
||||
Entry( unsigned int pIndex, const aiVector3D& pPosition, ai_real pDistance)
|
||||
: mIndex( pIndex), mPosition( pPosition), mDistance( pDistance) {
|
||||
Entry(unsigned int pIndex, const aiVector3D &pPosition, ai_real pDistance) :
|
||||
mIndex(pIndex), mPosition(pPosition), mDistance(pDistance) {
|
||||
// empty
|
||||
}
|
||||
|
||||
bool operator < (const Entry& e) const { return mDistance < e.mDistance; }
|
||||
bool operator<(const Entry &e) const { return mDistance < e.mDistance; }
|
||||
};
|
||||
|
||||
// all positions, sorted by distance to the sorting plane
|
||||
|
||||
@@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#endif
|
||||
|
||||
#include <assimp/vector3.h>
|
||||
#include <stddef.h>
|
||||
#include <vector>
|
||||
|
||||
struct aiMesh;
|
||||
|
||||
@@ -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,13 +47,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define AI_STREAMREADER_H_INCLUDED
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/Defines.h>
|
||||
#include <assimp/ByteSwapper.h>
|
||||
#include <assimp/Defines.h>
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/IOStream.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -74,10 +72,8 @@ namespace Assimp {
|
||||
template <bool SwapEndianess = false, bool RuntimeSwitch = false>
|
||||
class StreamReader {
|
||||
public:
|
||||
// FIXME: use these data types throughout the whole library,
|
||||
// then change them to 64 bit values :-)
|
||||
using diff = int;
|
||||
using pos = unsigned int;
|
||||
using diff = size_t;
|
||||
using pos = size_t;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Construction from a given stream with a well-defined endianness.
|
||||
@@ -91,40 +87,45 @@ public:
|
||||
* stream is in little endian byte order. Otherwise the
|
||||
* endianness information is contained in the @c SwapEndianess
|
||||
* template parameter and this parameter is meaningless. */
|
||||
StreamReader(std::shared_ptr<IOStream> stream, bool le = false)
|
||||
: stream(stream)
|
||||
, le(le)
|
||||
{
|
||||
StreamReader(std::shared_ptr<IOStream> stream, bool le = false) :
|
||||
mStream(stream),
|
||||
mBuffer(nullptr),
|
||||
mCurrent(nullptr),
|
||||
mEnd(nullptr),
|
||||
mLimit(nullptr),
|
||||
mLe(le) {
|
||||
ai_assert(stream);
|
||||
InternBegin();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
StreamReader(IOStream* stream, bool le = false)
|
||||
: stream(std::shared_ptr<IOStream>(stream))
|
||||
, le(le)
|
||||
{
|
||||
ai_assert(stream);
|
||||
StreamReader(IOStream *stream, bool le = false) :
|
||||
mStream(std::shared_ptr<IOStream>(stream)),
|
||||
mBuffer(nullptr),
|
||||
mCurrent(nullptr),
|
||||
mEnd(nullptr),
|
||||
mLimit(nullptr),
|
||||
mLe(le) {
|
||||
ai_assert(nullptr != stream);
|
||||
InternBegin();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
~StreamReader() {
|
||||
delete[] buffer;
|
||||
delete[] mBuffer;
|
||||
}
|
||||
|
||||
// deprecated, use overloaded operator>> instead
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a float from the stream */
|
||||
float GetF4()
|
||||
{
|
||||
/// Read a float from the stream.
|
||||
float GetF4() {
|
||||
return Get<float>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a double from the stream */
|
||||
double GetF8() {
|
||||
/// Read a double from the stream.
|
||||
double GetF8() {
|
||||
return Get<double>();
|
||||
}
|
||||
|
||||
@@ -136,7 +137,7 @@ public:
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a signed 8 bit integer from the stream */
|
||||
int8_t GetI1() {
|
||||
int8_t GetI1() {
|
||||
return Get<int8_t>();
|
||||
}
|
||||
|
||||
@@ -154,55 +155,55 @@ public:
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a unsigned 16 bit integer from the stream */
|
||||
uint16_t GetU2() {
|
||||
uint16_t GetU2() {
|
||||
return Get<uint16_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a unsigned 8 bit integer from the stream */
|
||||
/// Read a unsigned 8 bit integer from the stream
|
||||
uint8_t GetU1() {
|
||||
return Get<uint8_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read an unsigned 32 bit integer from the stream */
|
||||
uint32_t GetU4() {
|
||||
/// Read an unsigned 32 bit integer from the stream
|
||||
uint32_t GetU4() {
|
||||
return Get<uint32_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a unsigned 64 bit integer from the stream */
|
||||
uint64_t GetU8() {
|
||||
/// Read a unsigned 64 bit integer from the stream
|
||||
uint64_t GetU8() {
|
||||
return Get<uint64_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the remaining stream size (to the end of the stream) */
|
||||
unsigned int GetRemainingSize() const {
|
||||
return (unsigned int)(end - current);
|
||||
/// Get the remaining stream size (to the end of the stream)
|
||||
size_t GetRemainingSize() const {
|
||||
return (unsigned int)(mEnd - mCurrent);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the remaining stream size (to the current read limit). The
|
||||
* return value is the remaining size of the stream if no custom
|
||||
* read limit has been set. */
|
||||
unsigned int GetRemainingSizeToLimit() const {
|
||||
return (unsigned int)(limit - current);
|
||||
size_t GetRemainingSizeToLimit() const {
|
||||
return (unsigned int)(mLimit - mCurrent);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Increase the file pointer (relative seeking) */
|
||||
void IncPtr(intptr_t plus) {
|
||||
current += plus;
|
||||
if (current > limit) {
|
||||
void IncPtr(intptr_t plus) {
|
||||
mCurrent += plus;
|
||||
if (mCurrent > mLimit) {
|
||||
throw DeadlyImportError("End of file or read limit was reached");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the current file pointer */
|
||||
int8_t* GetPtr() const {
|
||||
return current;
|
||||
int8_t *GetPtr() const {
|
||||
return mCurrent;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -211,9 +212,9 @@ public:
|
||||
* large chunks of data at once.
|
||||
* @param p The new pointer, which is validated against the size
|
||||
* limit and buffer boundaries. */
|
||||
void SetPtr(int8_t* p) {
|
||||
current = p;
|
||||
if (current > limit || current < buffer) {
|
||||
void SetPtr(int8_t *p) {
|
||||
mCurrent = p;
|
||||
if (mCurrent > mLimit || mCurrent < mBuffer) {
|
||||
throw DeadlyImportError("End of file or read limit was reached");
|
||||
}
|
||||
}
|
||||
@@ -222,21 +223,20 @@ public:
|
||||
/** Copy n bytes to an external buffer
|
||||
* @param out Destination for copying
|
||||
* @param bytes Number of bytes to copy */
|
||||
void CopyAndAdvance(void* out, size_t bytes) {
|
||||
int8_t* ur = GetPtr();
|
||||
SetPtr(ur+bytes); // fire exception if eof
|
||||
void CopyAndAdvance(void *out, size_t bytes) {
|
||||
int8_t *ur = GetPtr();
|
||||
SetPtr(ur + bytes); // fire exception if eof
|
||||
|
||||
::memcpy(out,ur,bytes);
|
||||
::memcpy(out, ur, bytes);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the current offset from the beginning of the file */
|
||||
int GetCurrentPos() const {
|
||||
return (unsigned int)(current - buffer);
|
||||
/// @brief Get the current offset from the beginning of the file
|
||||
int GetCurrentPos() const {
|
||||
return (unsigned int)(mCurrent - mBuffer);
|
||||
}
|
||||
|
||||
void SetCurrentPos(size_t pos) {
|
||||
SetPtr(buffer + pos);
|
||||
SetPtr(mBuffer + pos);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -246,15 +246,15 @@ public:
|
||||
* the beginning of the file. Specifying UINT_MAX
|
||||
* resets the limit to the original end of the stream.
|
||||
* Returns the previously set limit. */
|
||||
unsigned int SetReadLimit(unsigned int _limit) {
|
||||
unsigned int SetReadLimit(unsigned int _limit) {
|
||||
unsigned int prev = GetReadLimit();
|
||||
if (UINT_MAX == _limit) {
|
||||
limit = end;
|
||||
mLimit = mEnd;
|
||||
return prev;
|
||||
}
|
||||
|
||||
limit = buffer + _limit;
|
||||
if (limit > end) {
|
||||
mLimit = mBuffer + _limit;
|
||||
if (mLimit > mEnd) {
|
||||
throw DeadlyImportError("StreamReader: Invalid read limit");
|
||||
}
|
||||
return prev;
|
||||
@@ -263,21 +263,21 @@ public:
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the current read limit in bytes. Reading over this limit
|
||||
* accidentally raises an exception. */
|
||||
unsigned int GetReadLimit() const {
|
||||
return (unsigned int)(limit - buffer);
|
||||
unsigned int GetReadLimit() const {
|
||||
return (unsigned int)(mLimit - mBuffer);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Skip to the read limit in bytes. Reading over this limit
|
||||
* accidentally raises an exception. */
|
||||
void SkipToReadLimit() {
|
||||
current = limit;
|
||||
void SkipToReadLimit() {
|
||||
mCurrent = mLimit;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** overload operator>> and allow chaining of >> ops. */
|
||||
template <typename T>
|
||||
StreamReader& operator >> (T& f) {
|
||||
StreamReader &operator>>(T &f) {
|
||||
f = Get<T>();
|
||||
return *this;
|
||||
}
|
||||
@@ -286,14 +286,14 @@ public:
|
||||
/** Generic read method. ByteSwap::Swap(T*) *must* be defined */
|
||||
template <typename T>
|
||||
T Get() {
|
||||
if ( current + sizeof(T) > limit) {
|
||||
if (mCurrent + sizeof(T) > mLimit) {
|
||||
throw DeadlyImportError("End of file or stream limit was reached");
|
||||
}
|
||||
|
||||
T f;
|
||||
::memcpy (&f, current, sizeof(T));
|
||||
Intern::Getter<SwapEndianess,T,RuntimeSwitch>() (&f,le);
|
||||
current += sizeof(T);
|
||||
::memcpy(&f, mCurrent, sizeof(T));
|
||||
Intern::Getter<SwapEndianess, T, RuntimeSwitch>()(&f, mLe);
|
||||
mCurrent += sizeof(T);
|
||||
|
||||
return f;
|
||||
}
|
||||
@@ -301,46 +301,44 @@ public:
|
||||
private:
|
||||
// ---------------------------------------------------------------------
|
||||
void InternBegin() {
|
||||
if (!stream) {
|
||||
// in case someone wonders: StreamReader is frequently invoked with
|
||||
// no prior validation whether the input stream is valid. Since
|
||||
// no one bothers changing the error message, this message here
|
||||
// is passed down to the caller and 'unable to open file'
|
||||
// simply describes best what happened.
|
||||
if (nullptr == mStream) {
|
||||
throw DeadlyImportError("StreamReader: Unable to open file");
|
||||
}
|
||||
|
||||
const size_t s = stream->FileSize() - stream->Tell();
|
||||
if (!s) {
|
||||
const size_t filesize = mStream->FileSize() - mStream->Tell();
|
||||
if (0 == filesize) {
|
||||
throw DeadlyImportError("StreamReader: File is empty or EOF is already reached");
|
||||
}
|
||||
|
||||
current = buffer = new int8_t[s];
|
||||
const size_t read = stream->Read(current,1,s);
|
||||
mCurrent = mBuffer = new int8_t[filesize];
|
||||
const size_t read = mStream->Read(mCurrent, 1, filesize);
|
||||
// (read < s) can only happen if the stream was opened in text mode, in which case FileSize() is not reliable
|
||||
ai_assert(read <= s);
|
||||
end = limit = &buffer[read-1] + 1;
|
||||
ai_assert(read <= filesize);
|
||||
mEnd = mLimit = &mBuffer[read - 1] + 1;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<IOStream> stream;
|
||||
int8_t *buffer, *current, *end, *limit;
|
||||
bool le;
|
||||
std::shared_ptr<IOStream> mStream;
|
||||
int8_t *mBuffer;
|
||||
int8_t *mCurrent;
|
||||
int8_t *mEnd;
|
||||
int8_t *mLimit;
|
||||
bool mLe;
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// `static` StreamReaders. Their byte order is fixed and they might be a little bit faster.
|
||||
#ifdef AI_BUILD_BIG_ENDIAN
|
||||
typedef StreamReader<true> StreamReaderLE;
|
||||
typedef StreamReader<false> StreamReaderBE;
|
||||
typedef StreamReader<true> StreamReaderLE;
|
||||
typedef StreamReader<false> StreamReaderBE;
|
||||
#else
|
||||
typedef StreamReader<true> StreamReaderBE;
|
||||
typedef StreamReader<false> StreamReaderLE;
|
||||
typedef StreamReader<true> StreamReaderBE;
|
||||
typedef StreamReader<false> StreamReaderLE;
|
||||
#endif
|
||||
|
||||
// `dynamic` StreamReader. The byte order of the input data is specified in the
|
||||
// c'tor. This involves runtime branching and might be a little bit slower.
|
||||
typedef StreamReader<true,true> StreamReaderAny;
|
||||
typedef StreamReader<true, true> StreamReaderAny;
|
||||
|
||||
} // end namespace Assimp
|
||||
|
||||
|
||||
@@ -54,18 +54,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define INCLUDED_AI_STRING_WORKERS_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/defs.h>
|
||||
#include <assimp/StringComparison.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** @brief itoa with a fixed base 10
|
||||
@@ -79,12 +79,12 @@ namespace Assimp {
|
||||
* @return Length of the output string, excluding the '\0'
|
||||
*/
|
||||
AI_FORCE_INLINE
|
||||
unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number) {
|
||||
ai_assert(NULL != out);
|
||||
unsigned int ASSIMP_itoa10(char *out, unsigned int max, int32_t number) {
|
||||
ai_assert(nullptr != out);
|
||||
|
||||
// write the unary minus to indicate we have a negative number
|
||||
unsigned int written = 1u;
|
||||
if (number < 0 && written < max) {
|
||||
if (number < 0 && written < max) {
|
||||
*out++ = '-';
|
||||
++written;
|
||||
number = -number;
|
||||
@@ -93,17 +93,17 @@ unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number) {
|
||||
// We begin with the largest number that is not zero.
|
||||
int32_t cur = 1000000000; // 2147483648
|
||||
bool mustPrint = false;
|
||||
while (written < max) {
|
||||
while (written < max) {
|
||||
|
||||
const unsigned int digit = number / cur;
|
||||
if (mustPrint || digit > 0 || 1 == cur) {
|
||||
// print all future zeroe's from now
|
||||
mustPrint = true;
|
||||
|
||||
*out++ = '0'+static_cast<char>(digit);
|
||||
*out++ = '0' + static_cast<char>(digit);
|
||||
|
||||
++written;
|
||||
number -= digit*cur;
|
||||
number -= digit * cur;
|
||||
if (1 == cur) {
|
||||
break;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number) {
|
||||
|
||||
// append a terminal zero
|
||||
*out++ = '\0';
|
||||
return written-1;
|
||||
return written - 1;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
@@ -122,9 +122,8 @@ unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number) {
|
||||
* size of the array automatically.
|
||||
*/
|
||||
template <size_t length>
|
||||
AI_FORCE_INLINE
|
||||
unsigned int ASSIMP_itoa10( char(& out)[length], int32_t number) {
|
||||
return ASSIMP_itoa10(out,length,number);
|
||||
AI_FORCE_INLINE unsigned int ASSIMP_itoa10(char (&out)[length], int32_t number) {
|
||||
return ASSIMP_itoa10(out, length, number);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
@@ -140,23 +139,22 @@ unsigned int ASSIMP_itoa10( char(& out)[length], int32_t number) {
|
||||
*/
|
||||
AI_FORCE_INLINE
|
||||
int ASSIMP_stricmp(const char *s1, const char *s2) {
|
||||
ai_assert( NULL != s1 );
|
||||
ai_assert( NULL != s2 );
|
||||
ai_assert(nullptr != s1);
|
||||
ai_assert(nullptr != s2);
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
|
||||
return ::_stricmp(s1,s2);
|
||||
#elif defined( __GNUC__ )
|
||||
return ::_stricmp(s1, s2);
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
return ::strcasecmp(s1,s2);
|
||||
return ::strcasecmp(s1, s2);
|
||||
#else
|
||||
|
||||
char c1, c2;
|
||||
do {
|
||||
do {
|
||||
c1 = tolower(*s1++);
|
||||
c2 = tolower(*s2++);
|
||||
}
|
||||
while ( c1 && (c1 == c2) );
|
||||
} while (c1 && (c1 == c2));
|
||||
return c1 - c2;
|
||||
#endif
|
||||
}
|
||||
@@ -169,9 +167,9 @@ int ASSIMP_stricmp(const char *s1, const char *s2) {
|
||||
* @return 0 if a == b
|
||||
*/
|
||||
AI_FORCE_INLINE
|
||||
int ASSIMP_stricmp(const std::string& a, const std::string& b) {
|
||||
int i = (int)b.length()-(int)a.length();
|
||||
return (i ? i : ASSIMP_stricmp(a.c_str(),b.c_str()));
|
||||
int ASSIMP_stricmp(const std::string &a, const std::string &b) {
|
||||
int i = (int)b.length() - (int)a.length();
|
||||
return (i ? i : ASSIMP_stricmp(a.c_str(), b.c_str()));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
@@ -188,51 +186,48 @@ int ASSIMP_stricmp(const std::string& a, const std::string& b) {
|
||||
*/
|
||||
AI_FORCE_INLINE
|
||||
int ASSIMP_strincmp(const char *s1, const char *s2, unsigned int n) {
|
||||
ai_assert( NULL != s1 );
|
||||
ai_assert( NULL != s2 );
|
||||
if ( !n ) {
|
||||
ai_assert(nullptr != s1);
|
||||
ai_assert(nullptr != s2);
|
||||
if (!n) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
|
||||
return ::_strnicmp(s1,s2,n);
|
||||
return ::_strnicmp(s1, s2, n);
|
||||
|
||||
#elif defined( __GNUC__ )
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
return ::strncasecmp(s1,s2, n);
|
||||
return ::strncasecmp(s1, s2, n);
|
||||
|
||||
#else
|
||||
char c1, c2;
|
||||
unsigned int p = 0;
|
||||
do
|
||||
{
|
||||
if (p++ >= n)return 0;
|
||||
do {
|
||||
if (p++ >= n) return 0;
|
||||
c1 = tolower(*s1++);
|
||||
c2 = tolower(*s2++);
|
||||
}
|
||||
while ( c1 && (c1 == c2) );
|
||||
} while (c1 && (c1 == c2));
|
||||
|
||||
return c1 - c2;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** @brief Evaluates an integer power
|
||||
*
|
||||
* todo: move somewhere where it fits better in than here
|
||||
*/
|
||||
AI_FORCE_INLINE
|
||||
unsigned int integer_pow( unsigned int base, unsigned int power ) {
|
||||
unsigned int integer_pow(unsigned int base, unsigned int power) {
|
||||
unsigned int res = 1;
|
||||
for ( unsigned int i = 0; i < power; ++i ) {
|
||||
for (unsigned int i = 0; i < power; ++i) {
|
||||
res *= base;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // ! AI_STRINGCOMPARISON_H_INC
|
||||
|
||||
@@ -145,4 +145,21 @@ std::string DecimalToHexa( T toConvert ) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/// @brief translate RGBA to String
|
||||
/// @param r aiColor.r
|
||||
/// @param g aiColor.g
|
||||
/// @param b aiColor.b
|
||||
/// @param a aiColor.a
|
||||
/// @param with_head #
|
||||
/// @return The hexadecimal string, is empty in case of an error.
|
||||
AI_FORCE_INLINE std::string Rgba2Hex(int r, int g, int b, int a, bool with_head) {
|
||||
std::stringstream ss;
|
||||
if (with_head) {
|
||||
ss << "#";
|
||||
}
|
||||
ss << std::hex << (r << 24 | g << 16 | b << 8 | a);
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
#endif // INCLUDED_AI_STRINGUTILS_H
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
@@ -350,7 +348,7 @@ struct aiMeshAnim {
|
||||
/** Size of the #mKeys array. Must be 1, at least. */
|
||||
unsigned int mNumKeys;
|
||||
|
||||
/** Key frames of the animation. May not be NULL. */
|
||||
/** Key frames of the animation. May not be nullptr. */
|
||||
C_STRUCT aiMeshKey *mKeys;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -378,7 +376,7 @@ struct aiMeshMorphAnim {
|
||||
/** Size of the #mKeys array. Must be 1, at least. */
|
||||
unsigned int mNumKeys;
|
||||
|
||||
/** Key frames of the animation. May not be NULL. */
|
||||
/** Key frames of the animation. May not be nullptr. */
|
||||
C_STRUCT aiMeshMorphKey *mKeys;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -171,15 +171,26 @@ struct aiCamera
|
||||
*/
|
||||
float mAspect;
|
||||
|
||||
/** Half horizontal orthographic width, in scene units.
|
||||
*
|
||||
* The orthographic width specifies the half width of the
|
||||
* orthographic view box. If non-zero the camera is
|
||||
* orthographic and the mAspect should define to the
|
||||
* ratio between the orthographic width and height
|
||||
* and mHorizontalFOV should be set to 0.
|
||||
* The default value is 0 (not orthographic).
|
||||
*/
|
||||
float mOrthographicWidth;
|
||||
#ifdef __cplusplus
|
||||
|
||||
aiCamera() AI_NO_EXCEPT
|
||||
: mUp (0.f,1.f,0.f)
|
||||
, mLookAt (0.f,0.f,1.f)
|
||||
, mHorizontalFOV (0.25f * (float)AI_MATH_PI)
|
||||
, mClipPlaneNear (0.1f)
|
||||
, mClipPlaneFar (1000.f)
|
||||
, mAspect (0.f)
|
||||
: mUp (0.f,1.f,0.f)
|
||||
, mLookAt (0.f,0.f,1.f)
|
||||
, mHorizontalFOV (0.25f * (float)AI_MATH_PI)
|
||||
, mClipPlaneNear (0.1f)
|
||||
, mClipPlaneFar (1000.f)
|
||||
, mAspect (0.f)
|
||||
, mOrthographicWidth (0.f)
|
||||
{}
|
||||
|
||||
/** @brief Get a *right-handed* camera matrix from me
|
||||
|
||||
@@ -47,42 +47,42 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define AI_EXPORT_H_INC
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
|
||||
// Public ASSIMP data structures
|
||||
#include <assimp/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct aiScene; // aiScene.h
|
||||
struct aiFileIO; // aiFileIO.h
|
||||
struct aiScene;
|
||||
struct aiFileIO;
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Describes an file format which Assimp can export to. Use #aiGetExportFormatCount() to
|
||||
* learn how many export formats the current Assimp build supports and #aiGetExportFormatDescription()
|
||||
* to retrieve a description of an export format option.
|
||||
*/
|
||||
struct aiExportFormatDesc
|
||||
{
|
||||
/**
|
||||
* @brief Describes an file format which Assimp can export to.
|
||||
*
|
||||
* Use #aiGetExportFormatCount() to learn how many export-formats are supported by
|
||||
* the current Assimp-build and #aiGetExportFormatDescription() to retrieve the
|
||||
* description of the export format option.
|
||||
*/
|
||||
struct aiExportFormatDesc {
|
||||
/// a short string ID to uniquely identify the export format. Use this ID string to
|
||||
/// specify which file format you want to export to when calling #aiExportScene().
|
||||
/// Example: "dae" or "obj"
|
||||
const char* id;
|
||||
const char *id;
|
||||
|
||||
/// A short description of the file format to present to users. Useful if you want
|
||||
/// to allow the user to select an export format.
|
||||
const char* description;
|
||||
const char *description;
|
||||
|
||||
/// Recommended file extension for the exported file in lower case.
|
||||
const char* fileExtension;
|
||||
const char *fileExtension;
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Returns the number of export file formats available in the current Assimp build.
|
||||
* Use aiGetExportFormatDescription() to retrieve infos of a specific export format.
|
||||
@@ -97,14 +97,14 @@ ASSIMP_API size_t aiGetExportFormatCount(void);
|
||||
* 0 to #aiGetExportFormatCount()
|
||||
* @return A description of that specific export format. NULL if pIndex is out of range.
|
||||
*/
|
||||
ASSIMP_API const C_STRUCT aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex);
|
||||
ASSIMP_API const C_STRUCT aiExportFormatDesc *aiGetExportFormatDescription(size_t pIndex);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Release a description of the nth export file format. Must be returned by
|
||||
* aiGetExportFormatDescription
|
||||
* @param desc Pointer to the description
|
||||
*/
|
||||
ASSIMP_API void aiReleaseExportFormatDescription( const C_STRUCT aiExportFormatDesc *desc );
|
||||
ASSIMP_API void aiReleaseExportFormatDescription(const C_STRUCT aiExportFormatDesc *desc);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Create a modifiable copy of a scene.
|
||||
@@ -115,13 +115,12 @@ ASSIMP_API void aiReleaseExportFormatDescription( const C_STRUCT aiExportFormatD
|
||||
* @param pOut Receives a modifyable copy of the scene. Use aiFreeScene() to
|
||||
* delete it again.
|
||||
*/
|
||||
ASSIMP_API void aiCopyScene(const C_STRUCT aiScene* pIn,
|
||||
C_STRUCT aiScene** pOut);
|
||||
|
||||
ASSIMP_API void aiCopyScene(const C_STRUCT aiScene *pIn,
|
||||
C_STRUCT aiScene **pOut);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Frees a scene copy created using aiCopyScene() */
|
||||
ASSIMP_API void aiFreeScene(const C_STRUCT aiScene* pIn);
|
||||
ASSIMP_API void aiFreeScene(const C_STRUCT aiScene *pIn);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Exports the given scene to a chosen file format and writes the result file(s) to disk.
|
||||
@@ -154,19 +153,18 @@ ASSIMP_API void aiFreeScene(const C_STRUCT aiScene* pIn);
|
||||
* triangulate data so they would run the step anyway.
|
||||
*
|
||||
* If assimp detects that the input scene was directly taken from the importer side of
|
||||
* the library (i.e. not copied using aiCopyScene and potetially modified afterwards),
|
||||
* any postprocessing steps already applied to the scene will not be applied again, unless
|
||||
* they show non-idempotent behaviour (#aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and
|
||||
* the library (i.e. not copied using aiCopyScene and potentially modified afterwards),
|
||||
* any post-processing steps already applied to the scene will not be applied again, unless
|
||||
* they show non-idempotent behavior (#aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and
|
||||
* #aiProcess_FlipWindingOrder).
|
||||
* @return a status code indicating the result of the export
|
||||
* @note Use aiCopyScene() to get a modifiable copy of a previously
|
||||
* imported scene.
|
||||
*/
|
||||
ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene,
|
||||
const char* pFormatId,
|
||||
const char* pFileName,
|
||||
unsigned int pPreprocessing);
|
||||
|
||||
ASSIMP_API aiReturn aiExportScene(const C_STRUCT aiScene *pScene,
|
||||
const char *pFormatId,
|
||||
const char *pFileName,
|
||||
unsigned int pPreprocessing);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Exports the given scene to a chosen file format using custom IO logic supplied by you.
|
||||
@@ -183,11 +181,11 @@ ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene,
|
||||
* @note Use aiCopyScene() to get a modifiable copy of a previously
|
||||
* imported scene.
|
||||
*/
|
||||
ASSIMP_API aiReturn aiExportSceneEx( const C_STRUCT aiScene* pScene,
|
||||
const char* pFormatId,
|
||||
const char* pFileName,
|
||||
C_STRUCT aiFileIO* pIO,
|
||||
unsigned int pPreprocessing );
|
||||
ASSIMP_API aiReturn aiExportSceneEx(const C_STRUCT aiScene *pScene,
|
||||
const char *pFormatId,
|
||||
const char *pFileName,
|
||||
C_STRUCT aiFileIO *pIO,
|
||||
unsigned int pPreprocessing);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Describes a blob of exported scene data. Use #aiExportSceneToBlob() to create a blob containing an
|
||||
@@ -199,13 +197,12 @@ ASSIMP_API aiReturn aiExportSceneEx( const C_STRUCT aiScene* pScene,
|
||||
* This is used when exporters write more than one output file for a given #aiScene. See the remarks for
|
||||
* #aiExportDataBlob::name for more information.
|
||||
*/
|
||||
struct aiExportDataBlob
|
||||
{
|
||||
struct aiExportDataBlob {
|
||||
/// Size of the data in bytes
|
||||
size_t size;
|
||||
|
||||
/// The data.
|
||||
void* data;
|
||||
void *data;
|
||||
|
||||
/** Name of the blob. An empty string always
|
||||
indicates the first (and primary) blob,
|
||||
@@ -222,18 +219,23 @@ struct aiExportDataBlob
|
||||
C_STRUCT aiString name;
|
||||
|
||||
/** Pointer to the next blob in the chain or NULL if there is none. */
|
||||
C_STRUCT aiExportDataBlob * next;
|
||||
C_STRUCT aiExportDataBlob *next;
|
||||
|
||||
#ifdef __cplusplus
|
||||
/// Default constructor
|
||||
aiExportDataBlob() { size = 0; data = next = NULL; }
|
||||
aiExportDataBlob() {
|
||||
size = 0;
|
||||
data = next = nullptr;
|
||||
}
|
||||
/// Releases the data
|
||||
~aiExportDataBlob() { delete [] static_cast<unsigned char*>( data ); delete next; }
|
||||
~aiExportDataBlob() {
|
||||
delete[] static_cast<unsigned char *>(data);
|
||||
delete next;
|
||||
}
|
||||
|
||||
aiExportDataBlob(const aiExportDataBlob &) = delete;
|
||||
aiExportDataBlob &operator=(const aiExportDataBlob &) = delete;
|
||||
|
||||
private:
|
||||
// no copying
|
||||
aiExportDataBlob(const aiExportDataBlob& );
|
||||
aiExportDataBlob& operator= (const aiExportDataBlob& );
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
||||
@@ -247,15 +249,15 @@ private:
|
||||
* @param pPreprocessing Please see the documentation for #aiExportScene
|
||||
* @return the exported data or NULL in case of error
|
||||
*/
|
||||
ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const C_STRUCT aiScene* pScene, const char* pFormatId,
|
||||
unsigned int pPreprocessing );
|
||||
ASSIMP_API const C_STRUCT aiExportDataBlob *aiExportSceneToBlob(const C_STRUCT aiScene *pScene, const char *pFormatId,
|
||||
unsigned int pPreprocessing);
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Releases the memory associated with the given exported data. Use this function to free a data blob
|
||||
* returned by aiExportScene().
|
||||
* @param pData the data blob returned by #aiExportSceneToBlob
|
||||
*/
|
||||
ASSIMP_API void aiReleaseExportBlob( const C_STRUCT aiExportDataBlob* pData );
|
||||
ASSIMP_API void aiReleaseExportBlob(const C_STRUCT aiExportDataBlob *pData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1030,10 +1030,10 @@ enum aiComponent
|
||||
#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specifies whether the Collada loader should use Collada names as node names.
|
||||
/** @brief Specifies whether the Collada loader should use Collada names.
|
||||
*
|
||||
* If this property is set to true, the Collada names will be used as the
|
||||
* node name. The default is to use the id tag (resp. sid tag, if no id tag is present)
|
||||
* If this property is set to true, the Collada names will be used as the node and
|
||||
* mesh names. The default is to use the id tag (resp. sid tag, if no id tag is present)
|
||||
* instead.
|
||||
* Property type: Bool. Default value: false.
|
||||
*/
|
||||
|
||||
@@ -49,10 +49,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define AI_IMPORTER_DESC_H_INC
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
|
||||
/** Mixed set of flags for #aiImporterDesc, indicating some features
|
||||
* common to many importers*/
|
||||
enum aiImporterFlags {
|
||||
@@ -81,7 +80,6 @@ enum aiImporterFlags {
|
||||
aiImporterFlags_Experimental = 0x10
|
||||
};
|
||||
|
||||
|
||||
/** Meta information about a particular importer. Importers need to fill
|
||||
* this structure, but they can freely decide how talkative they are.
|
||||
* A common use case for loader meta info is a user interface
|
||||
@@ -92,16 +90,16 @@ enum aiImporterFlags {
|
||||
* characteristics. */
|
||||
struct aiImporterDesc {
|
||||
/** Full name of the importer (i.e. Blender3D importer)*/
|
||||
const char* mName;
|
||||
const char *mName;
|
||||
|
||||
/** Original author (left blank if unknown or whole assimp team) */
|
||||
const char* mAuthor;
|
||||
const char *mAuthor;
|
||||
|
||||
/** Current maintainer, left blank if the author maintains */
|
||||
const char* mMaintainer;
|
||||
const char *mMaintainer;
|
||||
|
||||
/** Implementation comments, i.e. unimplemented features*/
|
||||
const char* mComments;
|
||||
const char *mComments;
|
||||
|
||||
/** These flags indicate some characteristics common to many
|
||||
importers. */
|
||||
@@ -134,15 +132,15 @@ struct aiImporterDesc {
|
||||
other methods to quickly reject files (i.e. magic
|
||||
words) so this does not mean that common or generic
|
||||
file extensions such as XML would be tediously slow. */
|
||||
const char* mFileExtensions;
|
||||
const char *mFileExtensions;
|
||||
};
|
||||
|
||||
/** \brief Returns the Importer description for a given extension.
|
||||
|
||||
Will return a NULL-pointer if no assigned importer desc. was found for the given extension
|
||||
Will return a nullptr if no assigned importer desc. was found for the given extension
|
||||
\param extension [in] The extension to look for
|
||||
\return A pointer showing to the ImporterDesc, \see aiImporterDesc.
|
||||
*/
|
||||
ASSIMP_API const C_STRUCT aiImporterDesc* aiGetImporterDesc( const char *extension );
|
||||
ASSIMP_API const C_STRUCT aiImporterDesc *aiGetImporterDesc(const char *extension);
|
||||
|
||||
#endif // AI_IMPORTER_DESC_H_INC
|
||||
|
||||
@@ -308,7 +308,10 @@ struct aiBone {
|
||||
|
||||
//! Copy constructor
|
||||
aiBone(const aiBone &other) :
|
||||
mName(other.mName), mNumWeights(other.mNumWeights), mWeights(nullptr), mOffsetMatrix(other.mOffsetMatrix) {
|
||||
mName(other.mName),
|
||||
mNumWeights(other.mNumWeights),
|
||||
mWeights(nullptr),
|
||||
mOffsetMatrix(other.mOffsetMatrix) {
|
||||
if (other.mWeights && other.mNumWeights) {
|
||||
mWeights = new aiVertexWeight[mNumWeights];
|
||||
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
|
||||
|
||||
@@ -86,6 +86,14 @@ typedef enum aiMetadataType {
|
||||
struct aiMetadataEntry {
|
||||
aiMetadataType mType;
|
||||
void *mData;
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiMetadataEntry() :
|
||||
mType(AI_META_MAX),
|
||||
mData( nullptr ) {
|
||||
// empty
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -313,14 +321,19 @@ struct aiMetadata {
|
||||
|
||||
// Set metadata type
|
||||
mValues[index].mType = GetAiType(value);
|
||||
|
||||
// Copy the given value to the dynamic storage
|
||||
mValues[index].mData = new T(value);
|
||||
if (nullptr != mValues[index].mData) {
|
||||
::memcpy(mValues[index].mData, &value, sizeof(T));
|
||||
} else {
|
||||
mValues[index].mData = new T(value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool Set( const std::string &key, const T &value ) {
|
||||
inline bool Set(const std::string &key, const T &value) {
|
||||
if (key.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user