Fix ASEParser data handling.

pull/5656/head
Kim Kulling 2024-07-06 10:35:29 +02:00
parent 76fb4fa6fc
commit 772d8065ed
4 changed files with 286 additions and 288 deletions

View File

@ -124,7 +124,7 @@ void ASEImporter::InternReadFile(const std::string &pFile,
// Allocate storage and copy the contents of the file to a memory buffer // Allocate storage and copy the contents of the file to a memory buffer
std::vector<char> mBuffer2; std::vector<char> mBuffer2;
TextFileToBuffer(file.get(), mBuffer2); TextFileToBuffer(file.get(), mBuffer2);
const size_t fileSize = mBuffer2.size();
this->mBuffer = &mBuffer2[0]; this->mBuffer = &mBuffer2[0];
this->pcScene = pScene; this->pcScene = pScene;
@ -146,7 +146,7 @@ void ASEImporter::InternReadFile(const std::string &pFile,
}; };
// Construct an ASE parser and parse the file // Construct an ASE parser and parse the file
ASE::Parser parser(mBuffer, defaultFormat); ASE::Parser parser(mBuffer, fileSize, defaultFormat);
mParser = &parser; mParser = &parser;
mParser->Parse(); mParser->Parse();
@ -446,8 +446,7 @@ void ASEImporter::BuildLights() {
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void ASEImporter::AddNodes(const std::vector<BaseNode *> &nodes, void ASEImporter::AddNodes(const std::vector<BaseNode *> &nodes, aiNode *pcParent, const std::string &name) {
aiNode *pcParent, const std::string &name) {
aiMatrix4x4 m; aiMatrix4x4 m;
AddNodes(nodes, pcParent, name, m); AddNodes(nodes, pcParent, name, m);
} }
@ -620,7 +619,8 @@ void ASEImporter::BuildNodes(std::vector<BaseNode *> &nodes) {
} }
// add all nodes // add all nodes
AddNodes(nodes, ch, nullptr); static const std::string none = "";
AddNodes(nodes, ch, none);
// now iterate through al nodes and find those that have not yet // now iterate through al nodes and find those that have not yet
// been added to the nodegraph (= their parent could not be recognized) // been added to the nodegraph (= their parent could not be recognized)

File diff suppressed because it is too large Load Diff

View File

@ -395,7 +395,7 @@ public:
//! @param fileFormatDefault Assumed file format version. If the //! @param fileFormatDefault Assumed file format version. If the
//! file format is specified in the file the new value replaces //! file format is specified in the file the new value replaces
//! the default value. //! the default value.
Parser(const std::string &file, unsigned int fileFormatDefault); Parser(const char *file, size_t fileLen, unsigned int fileFormatDefault);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
//! Parses the file into the parsers internal representation //! Parses the file into the parsers internal representation
@ -617,11 +617,8 @@ private:
bool ParseString(std::string &out, const char *szName); bool ParseString(std::string &out, const char *szName);
public: public:
//! Pointer to current data const char *mFilePtr; ////< Pointer to current data
const char *filePtr; const char *mEnd; ///< The end pointer of the file data
/// The end pointer of the file data
const char *mEnd;
//! background color to be passed to the viewer //! background color to be passed to the viewer
//! QNAN if none was found //! QNAN if none was found

View File

@ -56,6 +56,6 @@ public:
} }
}; };
TEST_F(utB3DImportExport, importACFromFileTest) { TEST_F(utB3DImportExport, importB3DFromFileTest) {
EXPECT_TRUE(importerTest()); EXPECT_TRUE(importerTest());
} }