@@ -82,6 +82,20 @@ static const aiImporterDesc desc = {
|
||||
|
||||
//#define DEBUG_B3D
|
||||
|
||||
template<typename T>
|
||||
void DeleteAllBarePointers(std::vector<T>& x)
|
||||
{
|
||||
for(auto p : x)
|
||||
{
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
B3DImporter::~B3DImporter()
|
||||
{
|
||||
DeleteAllBarePointers(_animations);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool B3DImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const{
|
||||
|
||||
@@ -558,13 +572,19 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
|
||||
void B3DImporter::ReadBB3D( aiScene *scene ){
|
||||
|
||||
_textures.clear();
|
||||
|
||||
_materials.clear();
|
||||
|
||||
_vertices.clear();
|
||||
|
||||
_meshes.clear();
|
||||
|
||||
DeleteAllBarePointers(_nodes);
|
||||
_nodes.clear();
|
||||
|
||||
_nodeAnims.clear();
|
||||
|
||||
DeleteAllBarePointers(_animations);
|
||||
_animations.clear();
|
||||
|
||||
string t=ReadChunk();
|
||||
|
||||
@@ -59,6 +59,8 @@ namespace Assimp{
|
||||
|
||||
class B3DImporter : public BaseImporter{
|
||||
public:
|
||||
B3DImporter() = default;
|
||||
virtual ~B3DImporter();
|
||||
|
||||
virtual bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const;
|
||||
|
||||
|
||||
@@ -193,14 +193,14 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh)
|
||||
p = 0;
|
||||
while (pcMesh->HasTextureCoords(p))
|
||||
{
|
||||
delete pcMesh->mTextureCoords[p];
|
||||
delete[] pcMesh->mTextureCoords[p];
|
||||
pcMesh->mTextureCoords[p] = apvTextureCoords[p];
|
||||
++p;
|
||||
}
|
||||
p = 0;
|
||||
while (pcMesh->HasVertexColors(p))
|
||||
{
|
||||
delete pcMesh->mColors[p];
|
||||
delete[] pcMesh->mColors[p];
|
||||
pcMesh->mColors[p] = apvColorSets[p];
|
||||
++p;
|
||||
}
|
||||
|
||||
@@ -634,7 +634,7 @@ void PretransformVertices::Execute( aiScene* pScene)
|
||||
aiNode* newRoot = new aiNode();
|
||||
newRoot->mName = pScene->mRootNode->mName;
|
||||
delete pScene->mRootNode;
|
||||
pScene->mRootNode = new aiNode();
|
||||
pScene->mRootNode = newRoot;
|
||||
|
||||
if (1 == pScene->mNumMeshes && !pScene->mNumLights && !pScene->mNumCameras)
|
||||
{
|
||||
|
||||
@@ -511,7 +511,7 @@ namespace glTF2
|
||||
|
||||
/// \fn ~SEncodedRegion()
|
||||
/// Destructor.
|
||||
~SEncodedRegion() { delete [] DecodedData; }
|
||||
~SEncodedRegion() { delete[] DecodedData; }
|
||||
};
|
||||
|
||||
/******************* Variables *******************/
|
||||
|
||||
@@ -313,7 +313,7 @@ inline void Buffer::Read(Value& obj, Asset& r)
|
||||
if (dataURI.base64) {
|
||||
uint8_t* data = 0;
|
||||
this->byteLength = Util::DecodeBase64(dataURI.data, dataURI.dataLength, data);
|
||||
this->mData.reset(data);
|
||||
this->mData.reset(data, std::default_delete<uint8_t[]>());
|
||||
|
||||
if (statedLength > 0 && this->byteLength != statedLength) {
|
||||
throw DeadlyImportError("GLTF: buffer \"" + id + "\", expected " + to_string(statedLength) +
|
||||
@@ -326,7 +326,7 @@ inline void Buffer::Read(Value& obj, Asset& r)
|
||||
" bytes, but found " + to_string(dataURI.dataLength));
|
||||
}
|
||||
|
||||
this->mData.reset(new uint8_t[dataURI.dataLength]);
|
||||
this->mData.reset(new uint8_t[dataURI.dataLength], std::default_delete<uint8_t[]>());
|
||||
memcpy( this->mData.get(), dataURI.data, dataURI.dataLength );
|
||||
}
|
||||
}
|
||||
@@ -357,7 +357,7 @@ inline bool Buffer::LoadFromStream(IOStream& stream, size_t length, size_t baseO
|
||||
stream.Seek(baseOffset, aiOrigin_SET);
|
||||
}
|
||||
|
||||
mData.reset(new uint8_t[byteLength]);
|
||||
mData.reset(new uint8_t[byteLength], std::default_delete<uint8_t[]>());
|
||||
|
||||
if (stream.Read(mData.get(), byteLength, 1) != 1) {
|
||||
return false;
|
||||
@@ -432,7 +432,7 @@ uint8_t* new_data;
|
||||
// Copy data which place after replacing part.
|
||||
memcpy(&new_data[pBufferData_Offset + pReplace_Count], &mData.get()[pBufferData_Offset + pBufferData_Count], pBufferData_Offset);
|
||||
// Apply new data
|
||||
mData.reset(new_data);
|
||||
mData.reset(new_data, std::default_delete<uint8_t[]>());
|
||||
byteLength = new_data_size;
|
||||
|
||||
return true;
|
||||
@@ -451,7 +451,7 @@ inline void Buffer::Grow(size_t amount)
|
||||
if (amount <= 0) return;
|
||||
uint8_t* b = new uint8_t[byteLength + amount];
|
||||
if (mData) memcpy(b, mData.get(), byteLength);
|
||||
mData.reset(b);
|
||||
mData.reset(b, std::default_delete<uint8_t[]>());
|
||||
byteLength += amount;
|
||||
}
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ inline bool Buffer::LoadFromStream(IOStream& stream, size_t length, size_t baseO
|
||||
stream.Seek(baseOffset, aiOrigin_SET);
|
||||
}
|
||||
|
||||
mData.reset(new uint8_t[byteLength]);
|
||||
mData.reset(new uint8_t[byteLength], std::default_delete<uint8_t[]>());
|
||||
|
||||
if (stream.Read(mData.get(), byteLength, 1) != 1) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user