Merge branch 'master' into patch-7
commit
92c7419a28
|
@ -560,7 +560,11 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
|||
SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Cineware/includes")
|
||||
|
||||
# pick the correct prebuilt library
|
||||
IF(MSVC15)
|
||||
IF(MSVC143)
|
||||
SET(C4D_LIB_POSTFIX "_2022")
|
||||
ELSEIF(MSV142)
|
||||
SET(C4D_LIB_POSTFIX "_2019")
|
||||
ELSEIF(MSVC15)
|
||||
SET(C4D_LIB_POSTFIX "_2017")
|
||||
ELSEIF(MSVC14)
|
||||
SET(C4D_LIB_POSTFIX "_2015")
|
||||
|
@ -572,7 +576,7 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
|||
SET(C4D_LIB_POSTFIX "_2010")
|
||||
ELSE()
|
||||
MESSAGE( FATAL_ERROR
|
||||
"C4D is currently only supported with MSVC 10, 11, 12, 14"
|
||||
"C4D is currently only supported with MSVC 10, 11, 12, 14, 14.2, 14.3"
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
|
@ -804,6 +808,10 @@ if(WIN32)
|
|||
SET(ASSIMP_MSVC_VERSION "vc140")
|
||||
ELSEIF(MSVC15)
|
||||
SET(ASSIMP_MSVC_VERSION "vc141")
|
||||
ELSEIF(MSV142)
|
||||
SET(ASSIMP_MSVC_VERSION "vc142")
|
||||
ELSEIF(MSVC143)
|
||||
SET(ASSIMP_MSVC_VERSION "vc143")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
|
|
|
@ -60,14 +60,11 @@ using namespace Assimp::MD5;
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Parse the segment structure for an MD5 file
|
||||
MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) {
|
||||
MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) : buffer(_buffer), bufferEnd(nullptr), fileSize(_fileSize), lineNumber(0) {
|
||||
ai_assert(nullptr != _buffer);
|
||||
ai_assert(0 != _fileSize);
|
||||
|
||||
buffer = _buffer;
|
||||
fileSize = _fileSize;
|
||||
lineNumber = 0;
|
||||
|
||||
bufferEnd = buffer + fileSize;
|
||||
ASSIMP_LOG_DEBUG("MD5Parser begin");
|
||||
|
||||
// parse the file header
|
||||
|
|
|
@ -39,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/** @file MD5Parser.h
|
||||
* @brief Definition of the .MD5 parser class.
|
||||
|
@ -51,20 +51,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/types.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
struct aiFace;
|
||||
|
||||
namespace Assimp {
|
||||
namespace MD5 {
|
||||
namespace Assimp {
|
||||
namespace MD5 {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a single element in a MD5 file
|
||||
*
|
||||
* Elements are always contained in sections.
|
||||
*/
|
||||
struct Element
|
||||
{
|
||||
struct Element {
|
||||
//! Points to the starting point of the element
|
||||
//! Whitespace at the beginning and at the end have been removed,
|
||||
//! Elements are terminated with \0
|
||||
|
@ -75,15 +74,14 @@ struct Element
|
|||
unsigned int iLineNumber;
|
||||
};
|
||||
|
||||
typedef std::vector< Element > ElementList;
|
||||
using ElementList = std::vector<Element>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a section of a MD5 file (such as the mesh or the joints section)
|
||||
*
|
||||
* A section is always enclosed in { and } brackets.
|
||||
*/
|
||||
struct Section
|
||||
{
|
||||
struct Section {
|
||||
//! Original line number (can be used in error messages
|
||||
//! if a parsing error occurs)
|
||||
unsigned int iLineNumber;
|
||||
|
@ -99,13 +97,12 @@ struct Section
|
|||
std::string mGlobalValue;
|
||||
};
|
||||
|
||||
typedef std::vector< Section> SectionList;
|
||||
using SectionList = std::vector<Section>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Basic information about a joint
|
||||
*/
|
||||
struct BaseJointDescription
|
||||
{
|
||||
struct BaseJointDescription {
|
||||
//! Name of the bone
|
||||
aiString mName;
|
||||
|
||||
|
@ -116,8 +113,7 @@ struct BaseJointDescription
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Represents a bone (joint) descriptor in a MD5Mesh file
|
||||
*/
|
||||
struct BoneDesc : BaseJointDescription
|
||||
{
|
||||
struct BoneDesc : BaseJointDescription {
|
||||
//! Absolute position of the bone
|
||||
aiVector3D mPositionXYZ;
|
||||
|
||||
|
@ -137,13 +133,12 @@ struct BoneDesc : BaseJointDescription
|
|||
unsigned int mMap;
|
||||
};
|
||||
|
||||
typedef std::vector< BoneDesc > BoneList;
|
||||
using BoneList = std::vector<BoneDesc>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a bone (joint) descriptor in a MD5Anim file
|
||||
*/
|
||||
struct AnimBoneDesc : BaseJointDescription
|
||||
{
|
||||
struct AnimBoneDesc : BaseJointDescription {
|
||||
//! Flags (AI_MD5_ANIMATION_FLAG_xxx)
|
||||
unsigned int iFlags;
|
||||
|
||||
|
@ -151,35 +146,31 @@ struct AnimBoneDesc : BaseJointDescription
|
|||
unsigned int iFirstKeyIndex;
|
||||
};
|
||||
|
||||
typedef std::vector< AnimBoneDesc > AnimBoneList;
|
||||
|
||||
using AnimBoneList = std::vector< AnimBoneDesc >;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a base frame descriptor in a MD5Anim file
|
||||
*/
|
||||
struct BaseFrameDesc
|
||||
{
|
||||
struct BaseFrameDesc {
|
||||
aiVector3D vPositionXYZ;
|
||||
aiVector3D vRotationQuat;
|
||||
};
|
||||
|
||||
typedef std::vector< BaseFrameDesc > BaseFrameList;
|
||||
using BaseFrameList = std::vector<BaseFrameDesc>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a camera animation frame in a MDCamera file
|
||||
*/
|
||||
struct CameraAnimFrameDesc : BaseFrameDesc
|
||||
{
|
||||
struct CameraAnimFrameDesc : BaseFrameDesc {
|
||||
float fFOV;
|
||||
};
|
||||
|
||||
typedef std::vector< CameraAnimFrameDesc > CameraFrameList;
|
||||
using CameraFrameList = std::vector<CameraAnimFrameDesc>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a frame descriptor in a MD5Anim file
|
||||
*/
|
||||
struct FrameDesc
|
||||
{
|
||||
struct FrameDesc {
|
||||
//! Index of the frame
|
||||
unsigned int iIndex;
|
||||
|
||||
|
@ -187,15 +178,14 @@ struct FrameDesc
|
|||
std::vector< float > mValues;
|
||||
};
|
||||
|
||||
typedef std::vector< FrameDesc > FrameList;
|
||||
using FrameList = std::vector<FrameDesc>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a vertex descriptor in a MD5 file
|
||||
*/
|
||||
struct VertexDesc {
|
||||
VertexDesc() AI_NO_EXCEPT
|
||||
: mFirstWeight(0)
|
||||
, mNumWeights(0) {
|
||||
: mFirstWeight(0), mNumWeights(0) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -210,13 +200,12 @@ struct VertexDesc {
|
|||
unsigned int mNumWeights;
|
||||
};
|
||||
|
||||
typedef std::vector< VertexDesc > VertexList;
|
||||
using VertexList = std::vector<VertexDesc>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a vertex weight descriptor in a MD5 file
|
||||
*/
|
||||
struct WeightDesc
|
||||
{
|
||||
struct WeightDesc {
|
||||
//! Index of the bone to which this weight refers
|
||||
unsigned int mBone;
|
||||
|
||||
|
@ -228,14 +217,13 @@ struct WeightDesc
|
|||
aiVector3D vOffsetPosition;
|
||||
};
|
||||
|
||||
typedef std::vector< WeightDesc > WeightList;
|
||||
typedef std::vector< aiFace > FaceList;
|
||||
using WeightList = std::vector<WeightDesc>;
|
||||
using FaceList = std::vector<aiFace>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a mesh in a MD5 file
|
||||
*/
|
||||
struct MeshDesc
|
||||
{
|
||||
struct MeshDesc {
|
||||
//! Weights of the mesh
|
||||
WeightList mWeights;
|
||||
|
||||
|
@ -249,7 +237,7 @@ struct MeshDesc
|
|||
aiString mShader;
|
||||
};
|
||||
|
||||
typedef std::vector< MeshDesc > MeshList;
|
||||
using MeshList = std::vector<MeshDesc>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Convert a quaternion to its usual representation
|
||||
|
@ -261,9 +249,11 @@ inline void ConvertQuaternion (const aiVector3D& in, aiQuaternion& out) {
|
|||
|
||||
const float t = 1.0f - (in.x*in.x) - (in.y*in.y) - (in.z*in.z);
|
||||
|
||||
if (t < 0.0f)
|
||||
if (t < 0.0f) {
|
||||
out.w = 0.0f;
|
||||
else out.w = std::sqrt (t);
|
||||
} else {
|
||||
out.w = std::sqrt (t);
|
||||
}
|
||||
|
||||
// Assimp convention.
|
||||
out.w *= -1.f;
|
||||
|
@ -272,10 +262,8 @@ inline void ConvertQuaternion (const aiVector3D& in, aiQuaternion& out) {
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Parses the data sections of a MD5 mesh file
|
||||
*/
|
||||
class MD5MeshParser
|
||||
{
|
||||
class MD5MeshParser {
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5MeshParser instance from an existing
|
||||
* preparsed list of file sections.
|
||||
|
@ -297,10 +285,8 @@ public:
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Parses the data sections of a MD5 animation file
|
||||
*/
|
||||
class MD5AnimParser
|
||||
{
|
||||
class MD5AnimParser {
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5AnimParser instance from an existing
|
||||
* preparsed list of file sections.
|
||||
|
@ -329,10 +315,8 @@ public:
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Parses the data sections of a MD5 camera animation file
|
||||
*/
|
||||
class MD5CameraParser
|
||||
{
|
||||
class MD5CameraParser {
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5CameraParser instance from an existing
|
||||
* preparsed list of file sections.
|
||||
|
@ -341,7 +325,6 @@ public:
|
|||
*/
|
||||
explicit MD5CameraParser(SectionList& mSections);
|
||||
|
||||
|
||||
//! Output frame rate
|
||||
float fFrameRate;
|
||||
|
||||
|
@ -356,10 +339,8 @@ public:
|
|||
/** Parses the block structure of MD5MESH and MD5ANIM files (but does no
|
||||
* further processing)
|
||||
*/
|
||||
class MD5Parser
|
||||
{
|
||||
class MD5Parser {
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5Parser instance from an existing buffer.
|
||||
*
|
||||
|
@ -392,13 +373,10 @@ public:
|
|||
return ReportWarning(warn, lineNumber);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! List of all sections which have been read
|
||||
SectionList mSections;
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Parses a file section. The current file pointer must be outside
|
||||
* of a section.
|
||||
|
@ -414,54 +392,63 @@ private:
|
|||
*/
|
||||
void ParseHeader();
|
||||
|
||||
|
||||
// override these functions to make sure the line counter gets incremented
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipLine( const char* in, const char** out)
|
||||
{
|
||||
++lineNumber;
|
||||
return Assimp::SkipLine(in,out);
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipLine( )
|
||||
{
|
||||
return SkipLine(buffer,(const char**)&buffer);
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipSpacesAndLineEnd( const char* in, const char** out)
|
||||
{
|
||||
bool bHad = false;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
if( *in == '\r' || *in == '\n') {
|
||||
// we open files in binary mode, so there could be \r\n sequences ...
|
||||
if (!bHad) {
|
||||
bHad = true;
|
||||
++lineNumber;
|
||||
}
|
||||
}
|
||||
else if (*in == '\t' || *in == ' ')bHad = false;
|
||||
else break;
|
||||
in++;
|
||||
}
|
||||
*out = in;
|
||||
return *in != '\0';
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipSpacesAndLineEnd( )
|
||||
{
|
||||
return SkipSpacesAndLineEnd(buffer,(const char**)&buffer);
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipSpaces( )
|
||||
{
|
||||
return Assimp::SkipSpaces((const char**)&buffer);
|
||||
}
|
||||
bool SkipLine(const char* in, const char** out);
|
||||
bool SkipLine( );
|
||||
bool SkipSpacesAndLineEnd( const char* in, const char** out);
|
||||
bool SkipSpacesAndLineEnd();
|
||||
bool SkipSpaces();
|
||||
|
||||
char* buffer;
|
||||
char* bufferEnd;
|
||||
unsigned int fileSize;
|
||||
unsigned int lineNumber;
|
||||
};
|
||||
}}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipLine(const char* in, const char** out) {
|
||||
++lineNumber;
|
||||
return Assimp::SkipLine(in ,out);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipLine( ) {
|
||||
return SkipLine(buffer,(const char**)&buffer);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipSpacesAndLineEnd( const char* in, const char** out) {
|
||||
bool bHad = false;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
if( *in == '\r' || *in == '\n') {
|
||||
// we open files in binary mode, so there could be \r\n sequences ...
|
||||
if (!bHad) {
|
||||
bHad = true;
|
||||
++lineNumber;
|
||||
}
|
||||
}
|
||||
else if (*in == '\t' || *in == ' ')bHad = false;
|
||||
else break;
|
||||
++in;
|
||||
if (in == bufferEnd) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*out = in;
|
||||
return *in != '\0';
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipSpacesAndLineEnd() {
|
||||
return SkipSpacesAndLineEnd(buffer,(const char**)&buffer);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipSpaces() {
|
||||
return Assimp::SkipSpaces((const char**)&buffer);
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
} // namespace MD5
|
||||
|
||||
#endif // AI_MD5PARSER_H_INCLUDED
|
||||
|
|
|
@ -1273,11 +1273,13 @@ ASSIMP_API void aiQuaternionInterpolate(
|
|||
#define ASSIMP_HAS_PBRT_EXPORT (!ASSIMP_BUILD_NO_EXPORT && !ASSIMP_BUILD_NO_PBRT_EXPORTER)
|
||||
#define ASSIMP_HAS_M3D ((!ASSIMP_BUILD_NO_EXPORT && !ASSIMP_BUILD_NO_M3D_EXPORTER) || !ASSIMP_BUILD_NO_M3D_IMPORTER)
|
||||
|
||||
#if ASSIMP_HAS_PBRT_EXPORT
|
||||
# define ASSIMP_NEEDS_STB_IMAGE 1
|
||||
#elif ASSIMP_HAS_M3D
|
||||
# define ASSIMP_NEEDS_STB_IMAGE 1
|
||||
# define STBI_ONLY_PNG
|
||||
#ifndef STB_USE_HUNTER
|
||||
# if ASSIMP_HAS_PBRT_EXPORT
|
||||
# define ASSIMP_NEEDS_STB_IMAGE 1
|
||||
# elif ASSIMP_HAS_M3D
|
||||
# define ASSIMP_NEEDS_STB_IMAGE 1
|
||||
# define STBI_ONLY_PNG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Ensure all symbols are linked correctly
|
||||
|
|
|
@ -48,6 +48,64 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
#ifndef STB_USE_HUNTER
|
||||
/* Use prefixed names for the symbols from stb_image as it is a very commonly embedded library.
|
||||
Including vanilla stb_image symbols causes duplicate symbol problems if assimp is linked
|
||||
statically together with another library or executable that also embeds stb_image.
|
||||
|
||||
Symbols are not prefixed if using Hunter because in such case there exists a single true
|
||||
stb_image library on the system that is used by assimp and can be used by all the other
|
||||
libraries and executables.
|
||||
|
||||
The list can be regenerated using the following:
|
||||
|
||||
cat <path/to/stb/stb_image.h> | fgrep STBIDEF | fgrep '(' | sed -E 's/\*|\(.+//g' | \
|
||||
awk '{print "#define " $(NF) " assimp_" $(NF) }' | sort | uniq"
|
||||
*/
|
||||
#define stbi_convert_iphone_png_to_rgb assimp_stbi_convert_iphone_png_to_rgb
|
||||
#define stbi_convert_wchar_to_utf8 assimp_stbi_convert_wchar_to_utf8
|
||||
#define stbi_failure_reason assimp_stbi_failure_reason
|
||||
#define stbi_hdr_to_ldr_gamma assimp_stbi_hdr_to_ldr_gamma
|
||||
#define stbi_hdr_to_ldr_scale assimp_stbi_hdr_to_ldr_scale
|
||||
#define stbi_image_free assimp_stbi_image_free
|
||||
#define stbi_info assimp_stbi_info
|
||||
#define stbi_info_from_callbacks assimp_stbi_info_from_callbacks
|
||||
#define stbi_info_from_file assimp_stbi_info_from_file
|
||||
#define stbi_info_from_memory assimp_stbi_info_from_memory
|
||||
#define stbi_is_16_bit assimp_stbi_is_16_bit
|
||||
#define stbi_is_16_bit_from_callbacks assimp_stbi_is_16_bit_from_callbacks
|
||||
#define stbi_is_16_bit_from_file assimp_stbi_is_16_bit_from_file
|
||||
#define stbi_is_16_bit_from_memory assimp_stbi_is_16_bit_from_memory
|
||||
#define stbi_is_hdr assimp_stbi_is_hdr
|
||||
#define stbi_is_hdr_from_callbacks assimp_stbi_is_hdr_from_callbacks
|
||||
#define stbi_is_hdr_from_file assimp_stbi_is_hdr_from_file
|
||||
#define stbi_is_hdr_from_memory assimp_stbi_is_hdr_from_memory
|
||||
#define stbi_ldr_to_hdr_gamma assimp_stbi_ldr_to_hdr_gamma
|
||||
#define stbi_ldr_to_hdr_scale assimp_stbi_ldr_to_hdr_scale
|
||||
#define stbi_load_16 assimp_stbi_load_16
|
||||
#define stbi_load_16_from_callbacks assimp_stbi_load_16_from_callbacks
|
||||
#define stbi_load_16_from_memory assimp_stbi_load_16_from_memory
|
||||
#define stbi_load assimp_stbi_load
|
||||
#define stbi_loadf assimp_stbi_loadf
|
||||
#define stbi_loadf_from_callbacks assimp_stbi_loadf_from_callbacks
|
||||
#define stbi_loadf_from_file assimp_stbi_loadf_from_file
|
||||
#define stbi_loadf_from_memory assimp_stbi_loadf_from_memory
|
||||
#define stbi_load_from_callbacks assimp_stbi_load_from_callbacks
|
||||
#define stbi_load_from_file_16 assimp_stbi_load_from_file_16
|
||||
#define stbi_load_from_file assimp_stbi_load_from_file
|
||||
#define stbi_load_from_memory assimp_stbi_load_from_memory
|
||||
#define stbi_load_gif_from_memory assimp_stbi_load_gif_from_memory
|
||||
#define stbi_set_flip_vertically_on_load assimp_stbi_set_flip_vertically_on_load
|
||||
#define stbi_set_flip_vertically_on_load_thread assimp_stbi_set_flip_vertically_on_load_thread
|
||||
#define stbi_set_unpremultiply_on_load assimp_stbi_set_unpremultiply_on_load
|
||||
#define stbi_zlib_decode_buffer assimp_stbi_zlib_decode_buffer
|
||||
#define stbi_zlib_decode_malloc assimp_stbi_zlib_decode_malloc
|
||||
#define stbi_zlib_decode_malloc_guesssize assimp_stbi_zlib_decode_malloc_guesssize
|
||||
#define stbi_zlib_decode_malloc_guesssize_headerflag assimp_stbi_zlib_decode_malloc_guesssize_headerflag
|
||||
#define stbi_zlib_decode_noheader_buffer assimp_stbi_zlib_decode_noheader_buffer
|
||||
#define stbi_zlib_decode_noheader_malloc assimp_stbi_zlib_decode_noheader_malloc
|
||||
#endif
|
||||
|
||||
#include "stb/stb_image.h"
|
||||
|
||||
#if _MSC_VER
|
||||
|
|
Loading…
Reference in New Issue