fix irrreader leak.
parent
10ff2d94f7
commit
40d882af4f
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
|
|
@ -55,8 +55,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/anim.h>
|
||||
#include <stdio.h> //sprintf
|
||||
|
||||
namespace Assimp {
|
||||
namespace D3DS {
|
||||
namespace Assimp {
|
||||
namespace D3DS {
|
||||
|
||||
#include <assimp/Compiler/pushpack1.h>
|
||||
|
||||
|
|
|
@ -72,7 +72,6 @@ static const aiImporterDesc desc = {
|
|||
"3ds prj"
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Begins a new parsing block
|
||||
// - Reads the current chunk and validates it
|
||||
|
@ -141,23 +140,19 @@ bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandle
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Loader registry entry
|
||||
const aiImporterDesc* Discreet3DSImporter::GetInfo () const
|
||||
{
|
||||
const aiImporterDesc* Discreet3DSImporter::GetInfo () const {
|
||||
return &desc;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Setup configuration properties
|
||||
void Discreet3DSImporter::SetupProperties(const Importer* /*pImp*/)
|
||||
{
|
||||
void Discreet3DSImporter::SetupProperties(const Importer* /*pImp*/) {
|
||||
// nothing to be done for the moment
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
void Discreet3DSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
|
||||
StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
|
||||
|
||||
// We should have at least one chunk
|
||||
|
@ -200,7 +195,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
|||
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(mesh);
|
||||
}
|
||||
|
||||
// Replace all occurences of the default material with a
|
||||
// Replace all occurrences of the default material with a
|
||||
// valid material. Generate it if no material containing
|
||||
// DEFAULT in its name has been found in the file
|
||||
ReplaceDefaultMaterial();
|
||||
|
@ -227,8 +222,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Applies a master-scaling factor to the imported scene
|
||||
void Discreet3DSImporter::ApplyMasterScale(aiScene* pScene)
|
||||
{
|
||||
void Discreet3DSImporter::ApplyMasterScale(aiScene* pScene) {
|
||||
// There are some 3DS files with a zero scaling factor
|
||||
if (!mMasterScale)mMasterScale = 1.0f;
|
||||
else mMasterScale = 1.0f / mMasterScale;
|
||||
|
|
|
@ -65,15 +65,11 @@ using namespace D3DS;
|
|||
// ---------------------------------------------------------------------------------
|
||||
/** Importer class for 3D Studio r3 and r4 3DS files
|
||||
*/
|
||||
class Discreet3DSImporter : public BaseImporter
|
||||
{
|
||||
class Discreet3DSImporter : public BaseImporter {
|
||||
public:
|
||||
|
||||
Discreet3DSImporter();
|
||||
~Discreet3DSImporter();
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns whether the class can handle the format of the given file.
|
||||
* See BaseImporter::CanRead() for details.
|
||||
|
|
|
@ -9,6 +9,9 @@ For details, see http://sourceforge.net/projects/libb64
|
|||
|
||||
const int CHARS_PER_LINE = 72;
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4244)
|
||||
|
||||
void base64_init_encodestate(base64_encodestate* state_in)
|
||||
{
|
||||
state_in->step = step_A;
|
||||
|
@ -107,3 +110,4 @@ int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
|
|||
return codechar - code_out;
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
|
|
|
@ -178,7 +178,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
|
|||
*ot++ = *buffer++;
|
||||
|
||||
*ot = '\0';
|
||||
nda->mNodeName.length = (size_t)(ot-nda->mNodeName.data);
|
||||
nda->mNodeName.length = static_cast<ai_uint32>(ot-nda->mNodeName.data);
|
||||
}
|
||||
|
||||
anim->mNumChannels = static_cast<unsigned int>(anims_temp.size());
|
||||
|
|
|
@ -1564,8 +1564,10 @@ namespace Assimp {
|
|||
|
||||
bone_map.clear();
|
||||
}
|
||||
catch (std::exception&e) {
|
||||
catch (std::exception &e) {
|
||||
FBXImporter::LogError(e.what());
|
||||
std::for_each(bones.begin(), bones.end(), Util::delete_fun<aiBone>());
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
|
|
|
@ -1483,6 +1483,7 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
|||
*/
|
||||
|
||||
delete root;
|
||||
delete reader;
|
||||
}
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_IRR_IMPORTER
|
||||
|
|
|
@ -504,7 +504,7 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput,
|
|||
pcNew->mData = new char[pSizeInBytes];
|
||||
memcpy (pcNew->mData,pInput,pSizeInBytes);
|
||||
|
||||
pcNew->mKey.length = ::strlen(pKey);
|
||||
pcNew->mKey.length = static_cast<ai_uint32>( ::strlen(pKey) );
|
||||
ai_assert ( MAXLEN > pcNew->mKey.length);
|
||||
strcpy( pcNew->mKey.data, pKey );
|
||||
|
||||
|
|
|
@ -616,7 +616,7 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model
|
|||
// We'll leave it up to the user to figure out which extension the file has.
|
||||
aiString name;
|
||||
strncpy( name.data, pTexture->strName, sizeof name.data );
|
||||
name.length = strlen( name.data );
|
||||
name.length = static_cast<ai_uint32>(strlen( name.data ));
|
||||
pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -616,7 +616,7 @@ void SMDImporter::CreateOutputMaterials() {
|
|||
if (aszTextures[iMat].length())
|
||||
{
|
||||
::strncpy(szName.data, aszTextures[iMat].c_str(),MAXLEN-1);
|
||||
szName.length = aszTextures[iMat].length();
|
||||
szName.length = static_cast<ai_uint32>( aszTextures[iMat].length() );
|
||||
pcMat->AddProperty(&szName,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -48,8 +46,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* http://local.wasp.uwa.edu.au/~pbourke/dataformats/unreal/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_3D_IMPORTER
|
||||
|
||||
#include "Unreal/UnrealLoader.h"
|
||||
|
@ -65,9 +61,99 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/importerdesc.h>
|
||||
|
||||
#include <memory>
|
||||
#include <stdint.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
namespace Unreal {
|
||||
|
||||
/*
|
||||
0 = Normal one-sided
|
||||
1 = Normal two-sided
|
||||
2 = Translucent two-sided
|
||||
3 = Masked two-sided
|
||||
4 = Modulation blended two-sided
|
||||
8 = Placeholder triangle for weapon positioning (invisible)
|
||||
*/
|
||||
enum MeshFlags {
|
||||
MF_NORMAL_OS = 0,
|
||||
MF_NORMAL_TS = 1,
|
||||
MF_NORMAL_TRANS_TS = 2,
|
||||
MF_NORMAL_MASKED_TS = 3,
|
||||
MF_NORMAL_MOD_TS = 4,
|
||||
MF_WEAPON_PLACEHOLDER = 8
|
||||
};
|
||||
|
||||
// a single triangle
|
||||
struct Triangle {
|
||||
uint16_t mVertex[3]; // Vertex indices
|
||||
char mType; // James' Mesh Type
|
||||
char mColor; // Color for flat and Gourand Shaded
|
||||
unsigned char mTex[3][2]; // Texture UV coordinates
|
||||
unsigned char mTextureNum; // Source texture offset
|
||||
char mFlags; // Unreal Mesh Flags (unused)
|
||||
|
||||
unsigned int matIndex;
|
||||
};
|
||||
|
||||
// temporary representation for a material
|
||||
struct TempMat {
|
||||
TempMat() :
|
||||
type(), tex(), numFaces(0) {}
|
||||
|
||||
explicit TempMat(const Triangle &in) :
|
||||
type((Unreal::MeshFlags)in.mType), tex(in.mTextureNum), numFaces(0) {}
|
||||
|
||||
// type of mesh
|
||||
Unreal::MeshFlags type;
|
||||
|
||||
// index of texture
|
||||
unsigned int tex;
|
||||
|
||||
// number of faces using us
|
||||
unsigned int numFaces;
|
||||
|
||||
// for std::find
|
||||
bool operator==(const TempMat &o) {
|
||||
return (tex == o.tex && type == o.type);
|
||||
}
|
||||
};
|
||||
|
||||
struct Vertex {
|
||||
int32_t X : 11;
|
||||
int32_t Y : 11;
|
||||
int32_t Z : 10;
|
||||
};
|
||||
|
||||
// UNREAL vertex compression
|
||||
inline void CompressVertex(const aiVector3D &v, uint32_t &out) {
|
||||
union {
|
||||
Vertex n;
|
||||
int32_t t;
|
||||
};
|
||||
n.X = (int32_t)v.x;
|
||||
n.Y = (int32_t)v.y;
|
||||
n.Z = (int32_t)v.z;
|
||||
::memcpy(&out, &t, sizeof(int32_t));
|
||||
//out = t;
|
||||
}
|
||||
|
||||
// UNREAL vertex decompression
|
||||
inline void DecompressVertex(aiVector3D &v, int32_t in) {
|
||||
union {
|
||||
Vertex n;
|
||||
int32_t i;
|
||||
};
|
||||
i = in;
|
||||
|
||||
v.x = (float)n.X;
|
||||
v.y = (float)n.Y;
|
||||
v.z = (float)n.Z;
|
||||
}
|
||||
|
||||
} // end namespace Unreal
|
||||
|
||||
|
||||
static const aiImporterDesc desc = {
|
||||
"Unreal Mesh Importer",
|
||||
"",
|
||||
|
@ -403,7 +489,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
// set color and name
|
||||
mat->AddProperty(&color,1,AI_MATKEY_COLOR_DIFFUSE);
|
||||
s.length = ::strlen(s.data);
|
||||
s.length = static_cast<ai_uint32>(::strlen(s.data));
|
||||
mat->AddProperty(&s,AI_MATKEY_NAME);
|
||||
|
||||
// set texture, if any
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -47,118 +46,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#define INCLUDED_AI_3D_LOADER_H
|
||||
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Assimp {
|
||||
namespace Unreal {
|
||||
|
||||
/*
|
||||
0 = Normal one-sided
|
||||
1 = Normal two-sided
|
||||
2 = Translucent two-sided
|
||||
3 = Masked two-sided
|
||||
4 = Modulation blended two-sided
|
||||
8 = Placeholder triangle for weapon positioning (invisible)
|
||||
*/
|
||||
enum MeshFlags {
|
||||
MF_NORMAL_OS = 0,
|
||||
MF_NORMAL_TS = 1,
|
||||
MF_NORMAL_TRANS_TS = 2,
|
||||
MF_NORMAL_MASKED_TS = 3,
|
||||
MF_NORMAL_MOD_TS = 4,
|
||||
MF_WEAPON_PLACEHOLDER = 8
|
||||
};
|
||||
|
||||
// a single triangle
|
||||
struct Triangle {
|
||||
uint16_t mVertex[3]; // Vertex indices
|
||||
char mType; // James' Mesh Type
|
||||
char mColor; // Color for flat and Gourand Shaded
|
||||
unsigned char mTex[3][2]; // Texture UV coordinates
|
||||
unsigned char mTextureNum; // Source texture offset
|
||||
char mFlags; // Unreal Mesh Flags (unused)
|
||||
|
||||
unsigned int matIndex;
|
||||
};
|
||||
|
||||
// temporary representation for a material
|
||||
struct TempMat {
|
||||
TempMat()
|
||||
: type()
|
||||
, tex()
|
||||
, numFaces (0)
|
||||
{}
|
||||
|
||||
explicit TempMat(const Triangle& in)
|
||||
: type ((Unreal::MeshFlags)in.mType)
|
||||
, tex (in.mTextureNum)
|
||||
, numFaces (0)
|
||||
{}
|
||||
|
||||
// type of mesh
|
||||
Unreal::MeshFlags type;
|
||||
|
||||
// index of texture
|
||||
unsigned int tex;
|
||||
|
||||
// number of faces using us
|
||||
unsigned int numFaces;
|
||||
|
||||
// for std::find
|
||||
bool operator == (const TempMat& o ) {
|
||||
return (tex == o.tex && type == o.type);
|
||||
}
|
||||
};
|
||||
|
||||
struct Vertex
|
||||
{
|
||||
int32_t X : 11;
|
||||
int32_t Y : 11;
|
||||
int32_t Z : 10;
|
||||
};
|
||||
|
||||
// UNREAL vertex compression
|
||||
inline void CompressVertex(const aiVector3D& v, uint32_t& out)
|
||||
{
|
||||
union {
|
||||
Vertex n;
|
||||
int32_t t;
|
||||
};
|
||||
n.X = (int32_t)v.x;
|
||||
n.Y = (int32_t)v.y;
|
||||
n.Z = (int32_t)v.z;
|
||||
::memcpy( &out, &t, sizeof(int32_t));
|
||||
//out = t;
|
||||
}
|
||||
|
||||
// UNREAL vertex decompression
|
||||
inline void DecompressVertex(aiVector3D& v, int32_t in)
|
||||
{
|
||||
union {
|
||||
Vertex n;
|
||||
int32_t i;
|
||||
};
|
||||
i = in;
|
||||
|
||||
v.x = (float)n.X;
|
||||
v.y = (float)n.Y;
|
||||
v.z = (float)n.Z;
|
||||
}
|
||||
|
||||
} // end namespace Unreal
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Importer class to load UNREAL files (*.3d)
|
||||
*/
|
||||
class UnrealImporter : public BaseImporter
|
||||
{
|
||||
class UnrealImporter : public BaseImporter {
|
||||
public:
|
||||
UnrealImporter();
|
||||
~UnrealImporter();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Returns whether we can handle the format of the given file
|
||||
*
|
||||
|
@ -184,7 +82,6 @@ protected:
|
|||
*/
|
||||
void SetupProperties(const Importer* pImp);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Imports the given file into the given scene structure.
|
||||
*
|
||||
|
@ -204,4 +101,5 @@ private:
|
|||
}; // !class UnrealImporter
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_UNREALIMPORTER_H_INC
|
||||
|
|
|
@ -6085,7 +6085,7 @@ mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip) {
|
|||
if (!pZip->m_file_offset_alignment)
|
||||
return 0;
|
||||
n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1));
|
||||
return (pZip->m_file_offset_alignment - n) &
|
||||
return (mz_uint)(pZip->m_file_offset_alignment - n) &
|
||||
(pZip->m_file_offset_alignment - 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ int CDisplay::ReplaceCurrentTexture(const char* szPath)
|
|||
IDirect3DTexture9* piTexture = NULL;
|
||||
aiString szString;
|
||||
strcpy(szString.data,szPath);
|
||||
szString.length = strlen(szPath);
|
||||
szString.length = static_cast<ai_uint32>(strlen(szPath));
|
||||
CMaterialManager::Instance().LoadTexture(&piTexture,&szString);
|
||||
|
||||
if (!piTexture) {
|
||||
|
|
|
@ -287,7 +287,7 @@ bool CMaterialManager::TryLongerPath(char* szTemp,aiString* p_szString)
|
|||
size_t iLen2 = iLen+1;
|
||||
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
|
||||
memcpy(p_szString->data,szTempB,iLen2);
|
||||
p_szString->length = iLen;
|
||||
p_szString->length = static_cast<ai_uint32>(iLen);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ bool CMaterialManager::TryLongerPath(char* szTemp,aiString* p_szString)
|
|||
size_t iLen2 = iLen+1;
|
||||
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
|
||||
memcpy(p_szString->data,szTempB,iLen2);
|
||||
p_szString->length = iLen;
|
||||
p_szString->length = static_cast<ai_uint32>(iLen);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ int CMaterialManager::FindValidPath(aiString* p_szString)
|
|||
if((pFile=fopen( tmp2,"r" ))){
|
||||
fclose( pFile );
|
||||
strcpy(p_szString->data,tmp2);
|
||||
p_szString->length = strlen(tmp2);
|
||||
p_szString->length = static_cast<ai_uint32>(strlen(tmp2));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -403,11 +403,11 @@ int CMaterialManager::FindValidPath(aiString* p_szString)
|
|||
fclose(pFile);
|
||||
|
||||
// copy the result string back to the aiString
|
||||
const size_t iLen = strlen(szTemp);
|
||||
size_t iLen2 = iLen+1;
|
||||
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
|
||||
memcpy(p_szString->data,szTemp,iLen2);
|
||||
p_szString->length = iLen;
|
||||
const size_t len = strlen(szTemp);
|
||||
size_t len2 = len+1;
|
||||
len2 = len2 > MAXLEN ? MAXLEN : len2;
|
||||
memcpy(p_szString->data, szTemp, len2);
|
||||
p_szString->length = static_cast<ai_uint32>(len);
|
||||
|
||||
}
|
||||
return 1;
|
||||
|
|
Loading…
Reference in New Issue