Merge branch 'master' into fix_1623
commit
3d743151ce
|
@ -33,9 +33,10 @@ env:
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: linux
|
# disabled until clang 5.0 analyzer issues are fixed
|
||||||
compiler: clang
|
# - os: linux
|
||||||
env: ANALYZE=ON
|
# compiler: clang
|
||||||
|
# env: ANALYZE=ON
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: ASAN=ON
|
env: ASAN=ON
|
||||||
|
|
|
@ -93,7 +93,6 @@ void DeleteAllBarePointers(std::vector<T>& x)
|
||||||
|
|
||||||
B3DImporter::~B3DImporter()
|
B3DImporter::~B3DImporter()
|
||||||
{
|
{
|
||||||
DeleteAllBarePointers(_animations);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -267,6 +266,21 @@ T *B3DImporter::to_array( const vector<T> &v ){
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
template<class T>
|
||||||
|
T **unique_to_array( vector<std::unique_ptr<T> > &v ){
|
||||||
|
if( v.empty() ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
T **p = new T*[ v.size() ];
|
||||||
|
for( size_t i = 0; i < v.size(); ++i ){
|
||||||
|
p[i] = v[i].release();
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void B3DImporter::ReadTEXS(){
|
void B3DImporter::ReadTEXS(){
|
||||||
while( ChunkSize() ){
|
while( ChunkSize() ){
|
||||||
|
@ -295,8 +309,7 @@ void B3DImporter::ReadBRUS(){
|
||||||
/*int blend=**/ReadInt();
|
/*int blend=**/ReadInt();
|
||||||
int fx=ReadInt();
|
int fx=ReadInt();
|
||||||
|
|
||||||
aiMaterial *mat=new aiMaterial;
|
std::unique_ptr<aiMaterial> mat(new aiMaterial);
|
||||||
_materials.push_back( mat );
|
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
aiString ainame( name );
|
aiString ainame( name );
|
||||||
|
@ -333,6 +346,7 @@ void B3DImporter::ReadBRUS(){
|
||||||
mat->AddProperty( &texname,AI_MATKEY_TEXTURE_DIFFUSE(0) );
|
mat->AddProperty( &texname,AI_MATKEY_TEXTURE_DIFFUSE(0) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_materials.emplace_back( std::move(mat) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,8 +400,7 @@ void B3DImporter::ReadTRIS( int v0 ){
|
||||||
Fail( "Bad material id" );
|
Fail( "Bad material id" );
|
||||||
}
|
}
|
||||||
|
|
||||||
aiMesh *mesh=new aiMesh;
|
std::unique_ptr<aiMesh> mesh(new aiMesh);
|
||||||
_meshes.push_back( mesh );
|
|
||||||
|
|
||||||
mesh->mMaterialIndex=matid;
|
mesh->mMaterialIndex=matid;
|
||||||
mesh->mNumFaces=0;
|
mesh->mNumFaces=0;
|
||||||
|
@ -415,6 +428,8 @@ void B3DImporter::ReadTRIS( int v0 ){
|
||||||
++mesh->mNumFaces;
|
++mesh->mNumFaces;
|
||||||
++face;
|
++face;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_meshes.emplace_back( std::move(mesh) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -500,11 +515,11 @@ void B3DImporter::ReadANIM(){
|
||||||
int frames=ReadInt();
|
int frames=ReadInt();
|
||||||
float fps=ReadFloat();
|
float fps=ReadFloat();
|
||||||
|
|
||||||
aiAnimation *anim=new aiAnimation;
|
std::unique_ptr<aiAnimation> anim(new aiAnimation);
|
||||||
_animations.push_back( anim );
|
|
||||||
|
|
||||||
anim->mDuration=frames;
|
anim->mDuration=frames;
|
||||||
anim->mTicksPerSecond=fps;
|
anim->mTicksPerSecond=fps;
|
||||||
|
_animations.emplace_back( std::move(anim) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -531,7 +546,7 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
|
||||||
node->mParent=parent;
|
node->mParent=parent;
|
||||||
node->mTransformation=tform;
|
node->mTransformation=tform;
|
||||||
|
|
||||||
aiNodeAnim *nodeAnim=0;
|
std::unique_ptr<aiNodeAnim> nodeAnim;
|
||||||
vector<unsigned> meshes;
|
vector<unsigned> meshes;
|
||||||
vector<aiNode*> children;
|
vector<aiNode*> children;
|
||||||
|
|
||||||
|
@ -549,11 +564,10 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
|
||||||
ReadANIM();
|
ReadANIM();
|
||||||
}else if( t=="KEYS" ){
|
}else if( t=="KEYS" ){
|
||||||
if( !nodeAnim ){
|
if( !nodeAnim ){
|
||||||
nodeAnim=new aiNodeAnim;
|
nodeAnim.reset(new aiNodeAnim);
|
||||||
_nodeAnims.push_back( nodeAnim );
|
|
||||||
nodeAnim->mNodeName=node->mName;
|
nodeAnim->mNodeName=node->mName;
|
||||||
}
|
}
|
||||||
ReadKEYS( nodeAnim );
|
ReadKEYS( nodeAnim.get() );
|
||||||
}else if( t=="NODE" ){
|
}else if( t=="NODE" ){
|
||||||
aiNode *child=ReadNODE( node );
|
aiNode *child=ReadNODE( node );
|
||||||
children.push_back( child );
|
children.push_back( child );
|
||||||
|
@ -561,6 +575,10 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
|
||||||
ExitChunk();
|
ExitChunk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nodeAnim) {
|
||||||
|
_nodeAnims.emplace_back( std::move(nodeAnim) );
|
||||||
|
}
|
||||||
|
|
||||||
node->mNumMeshes= static_cast<unsigned int>(meshes.size());
|
node->mNumMeshes= static_cast<unsigned int>(meshes.size());
|
||||||
node->mMeshes=to_array( meshes );
|
node->mMeshes=to_array( meshes );
|
||||||
|
|
||||||
|
@ -586,7 +604,6 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
|
||||||
|
|
||||||
_nodeAnims.clear();
|
_nodeAnims.clear();
|
||||||
|
|
||||||
DeleteAllBarePointers(_animations);
|
|
||||||
_animations.clear();
|
_animations.clear();
|
||||||
|
|
||||||
string t=ReadChunk();
|
string t=ReadChunk();
|
||||||
|
@ -622,7 +639,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
|
||||||
aiNode *node=_nodes[i];
|
aiNode *node=_nodes[i];
|
||||||
|
|
||||||
for( size_t j=0;j<node->mNumMeshes;++j ){
|
for( size_t j=0;j<node->mNumMeshes;++j ){
|
||||||
aiMesh *mesh=_meshes[node->mMeshes[j]];
|
aiMesh *mesh = _meshes[node->mMeshes[j]].get();
|
||||||
|
|
||||||
int n_tris=mesh->mNumFaces;
|
int n_tris=mesh->mNumFaces;
|
||||||
int n_verts=mesh->mNumVertices=n_tris * 3;
|
int n_verts=mesh->mNumVertices=n_tris * 3;
|
||||||
|
@ -685,27 +702,28 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
|
||||||
|
|
||||||
//nodes
|
//nodes
|
||||||
scene->mRootNode=_nodes[0];
|
scene->mRootNode=_nodes[0];
|
||||||
|
_nodes.clear(); // node ownership now belongs to scene
|
||||||
|
|
||||||
//material
|
//material
|
||||||
if( !_materials.size() ){
|
if( !_materials.size() ){
|
||||||
_materials.push_back( new aiMaterial );
|
_materials.emplace_back( std::unique_ptr<aiMaterial>(new aiMaterial) );
|
||||||
}
|
}
|
||||||
scene->mNumMaterials= static_cast<unsigned int>(_materials.size());
|
scene->mNumMaterials= static_cast<unsigned int>(_materials.size());
|
||||||
scene->mMaterials=to_array( _materials );
|
scene->mMaterials = unique_to_array( _materials );
|
||||||
|
|
||||||
//meshes
|
//meshes
|
||||||
scene->mNumMeshes= static_cast<unsigned int>(_meshes.size());
|
scene->mNumMeshes= static_cast<unsigned int>(_meshes.size());
|
||||||
scene->mMeshes=to_array( _meshes );
|
scene->mMeshes = unique_to_array( _meshes );
|
||||||
|
|
||||||
//animations
|
//animations
|
||||||
if( _animations.size()==1 && _nodeAnims.size() ){
|
if( _animations.size()==1 && _nodeAnims.size() ){
|
||||||
|
|
||||||
aiAnimation *anim=_animations.back();
|
aiAnimation *anim = _animations.back().get();
|
||||||
anim->mNumChannels=static_cast<unsigned int>(_nodeAnims.size());
|
anim->mNumChannels=static_cast<unsigned int>(_nodeAnims.size());
|
||||||
anim->mChannels=to_array( _nodeAnims );
|
anim->mChannels = unique_to_array( _nodeAnims );
|
||||||
|
|
||||||
scene->mNumAnimations=static_cast<unsigned int>(_animations.size());
|
scene->mNumAnimations=static_cast<unsigned int>(_animations.size());
|
||||||
scene->mAnimations=to_array( _animations );
|
scene->mAnimations=unique_to_array( _animations );
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert to RH
|
// convert to RH
|
||||||
|
|
|
@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/material.h>
|
#include <assimp/material.h>
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct aiNodeAnim;
|
struct aiNodeAnim;
|
||||||
|
@ -116,15 +117,15 @@ private:
|
||||||
std::vector<unsigned> _stack;
|
std::vector<unsigned> _stack;
|
||||||
|
|
||||||
std::vector<std::string> _textures;
|
std::vector<std::string> _textures;
|
||||||
std::vector<aiMaterial*> _materials;
|
std::vector<std::unique_ptr<aiMaterial> > _materials;
|
||||||
|
|
||||||
int _vflags,_tcsets,_tcsize;
|
int _vflags,_tcsets,_tcsize;
|
||||||
std::vector<Vertex> _vertices;
|
std::vector<Vertex> _vertices;
|
||||||
|
|
||||||
std::vector<aiNode*> _nodes;
|
std::vector<aiNode*> _nodes;
|
||||||
std::vector<aiMesh*> _meshes;
|
std::vector<std::unique_ptr<aiMesh> > _meshes;
|
||||||
std::vector<aiNodeAnim*> _nodeAnims;
|
std::vector<std::unique_ptr<aiNodeAnim> > _nodeAnims;
|
||||||
std::vector<aiAnimation*> _animations;
|
std::vector<std::unique_ptr<aiAnimation> > _animations;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -434,6 +434,14 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int le
|
||||||
TokenizeError("file is too short",0);
|
TokenizeError("file is too short",0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//uint32_t offset = 0x15;
|
||||||
|
/* const char* cursor = input + 0x15;
|
||||||
|
|
||||||
|
const uint32_t flags = ReadWord(input, cursor, input + length);
|
||||||
|
|
||||||
|
const uint8_t padding_0 = ReadByte(input, cursor, input + length); // unused
|
||||||
|
const uint8_t padding_1 = ReadByte(input, cursor, input + length); // unused*/
|
||||||
|
|
||||||
if (strncmp(input,"Kaydara FBX Binary",18)) {
|
if (strncmp(input,"Kaydara FBX Binary",18)) {
|
||||||
TokenizeError("magic bytes not found",0);
|
TokenizeError("magic bytes not found",0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ protected:
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Load the contents of a specific file into memory and
|
/** Load the contents of a specific file into memory and
|
||||||
* alocates a buffer to keep it.
|
* allocates a buffer to keep it.
|
||||||
*
|
*
|
||||||
* mBuffer is modified to point to this buffer.
|
* mBuffer is modified to point to this buffer.
|
||||||
* @param pFile File stream to be read
|
* @param pFile File stream to be read
|
||||||
|
|
|
@ -415,8 +415,14 @@ void MDLImporter::InternReadFile_Quake1( )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// get the first frame in the group
|
// get the first frame in the group
|
||||||
|
#if 1
|
||||||
|
// FIXME: the cast is wrong and causea a warning on clang 5.0
|
||||||
|
// disable thi code for now, fix it later
|
||||||
|
ai_assert(false && "Bad pointer cast");
|
||||||
|
#else
|
||||||
BE_NCONST MDL::GroupFrame* pcFrames2 = (BE_NCONST MDL::GroupFrame*)pcFrames;
|
BE_NCONST MDL::GroupFrame* pcFrames2 = (BE_NCONST MDL::GroupFrame*)pcFrames;
|
||||||
pcFirstFrame = (BE_NCONST MDL::SimpleFrame*)(&pcFrames2->time + pcFrames->type);
|
pcFirstFrame = (BE_NCONST MDL::SimpleFrame*)(&pcFrames2->time + pcFrames->type);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
BE_NCONST MDL::Vertex* pcVertices = (BE_NCONST MDL::Vertex*) ((pcFirstFrame->name) + sizeof(pcFirstFrame->name));
|
BE_NCONST MDL::Vertex* pcVertices = (BE_NCONST MDL::Vertex*) ((pcFirstFrame->name) + sizeof(pcFirstFrame->name));
|
||||||
VALIDATE_FILE_SIZE((const unsigned char*)(pcVertices + pcHeader->num_verts));
|
VALIDATE_FILE_SIZE((const unsigned char*)(pcVertices + pcHeader->num_verts));
|
||||||
|
|
|
@ -192,7 +192,7 @@ public:
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Increase the file pointer (relative seeking) */
|
/** Increase the file pointer (relative seeking) */
|
||||||
void IncPtr(size_t plus) {
|
void IncPtr(intptr_t plus) {
|
||||||
current += plus;
|
current += plus;
|
||||||
if (current > limit) {
|
if (current > limit) {
|
||||||
throw DeadlyImportError("End of file or read limit was reached");
|
throw DeadlyImportError("End of file or read limit was reached");
|
||||||
|
|
|
@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef AI_GLTFEXPORTER_H_INC
|
#ifndef AI_GLTFEXPORTER_H_INC
|
||||||
#define AI_GLTFEXPORTER_H_INC
|
#define AI_GLTFEXPORTER_H_INC
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
|
||||||
|
|
||||||
#include <assimp/types.h>
|
#include <assimp/types.h>
|
||||||
#include <assimp/material.h>
|
#include <assimp/material.h>
|
||||||
|
@ -113,6 +113,6 @@ namespace Assimp
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
|
#endif // ASSIMP_BUILD_NO_GLTF_EXPORTER
|
||||||
|
|
||||||
#endif // AI_GLTFEXPORTER_H_INC
|
#endif // AI_GLTFEXPORTER_H_INC
|
||||||
|
|
|
@ -41,6 +41,10 @@ woven in by Terry Thorsen 1/2003.
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
|
|
||||||
|
#if ZLIB_VERNUM < 0x1270
|
||||||
|
typedef unsigned long z_crc_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef STDC
|
#ifdef STDC
|
||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
|
|
@ -491,7 +491,7 @@ struct aiUVTransform
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} PACK_STRUCT;
|
};
|
||||||
|
|
||||||
#include "./Compiler/poppack1.h"
|
#include "./Compiler/poppack1.h"
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ public:
|
||||||
operator aiVector2t<TOther> () const;
|
operator aiVector2t<TOther> () const;
|
||||||
|
|
||||||
TReal x, y;
|
TReal x, y;
|
||||||
} PACK_STRUCT;
|
};
|
||||||
|
|
||||||
typedef aiVector2t<ai_real> aiVector2D;
|
typedef aiVector2t<ai_real> aiVector2D;
|
||||||
|
|
||||||
|
|
|
@ -114,13 +114,29 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator /= (TReal f) {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
template <typename TReal>
|
template <typename TReal>
|
||||||
TReal aiVector2t<TReal>::operator[](unsigned int i) const {
|
TReal aiVector2t<TReal>::operator[](unsigned int i) const {
|
||||||
return *(&x + i);
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
return x;
|
||||||
|
case 1:
|
||||||
|
return y;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
template <typename TReal>
|
template <typename TReal>
|
||||||
TReal& aiVector2t<TReal>::operator[](unsigned int i) {
|
TReal& aiVector2t<TReal>::operator[](unsigned int i) {
|
||||||
return *(&x + i);
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
return x;
|
||||||
|
case 1:
|
||||||
|
return y;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue