Now we can use C++ tricks to make this easier

This commit is contained in:
jordan4ibanez 2023-11-28 05:02:31 -05:00
parent 80e5da381d
commit 132f1ae5d6
2 changed files with 20 additions and 6 deletions

View File

@ -191,13 +191,16 @@ void CB3DJSONMeshFileLoader::cleanUp(std::string failure) {
AnimatedMesh = 0; AnimatedMesh = 0;
} }
IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) { bool CB3DJSONMeshFileLoader::parseJSONFile() {
}
IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
// Less than zero? What is this file a black hole? // Less than zero? What is this file a black hole?
if (file->getSize() <= 0) { if (file->getSize() <= 0) {
this->cleanUp("B3D JSON severe error! File size is 0!"); this->cleanUp("B3D JSON severe error! File size is 0!");
return nullptr; return AnimatedMesh;
} }
// So here we turn this mangled disaster into a C string. // So here we turn this mangled disaster into a C string.
@ -214,7 +217,6 @@ IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
output[file->getSize()] = '\0'; output[file->getSize()] = '\0';
// We have to catch a JSON parse error or else the game will segfault. // We have to catch a JSON parse error or else the game will segfault.
json data;
try { try {
data = json::parse(output); data = json::parse(output);
} catch (const json::parse_error& e) { } catch (const json::parse_error& e) {
@ -236,10 +238,10 @@ IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
} }
// Now we can start doing a full parse of the data in the model JSON. // Now we can start doing a full parse of the data in the model JSON.
IAnimatedMesh* finalizedModel = parseModel(data); const bool placeholder = parseModel(data);
println("We got to the end.");
return finalizedModel; return nullptr;
} }
} // namespace scene } // namespace scene

View File

@ -15,8 +15,20 @@ namespace scene
class CB3DJSONMeshFileLoader : public IMeshLoader class CB3DJSONMeshFileLoader : public IMeshLoader
{ {
private: private:
// Fields.
CSkinnedMesh* AnimatedMesh; CSkinnedMesh* AnimatedMesh;
/*
Quick note about JSON.
This is static memory, it's a static memory address so I do not think
that this needs to be freed.
So once this model goes out of scope, I'm pretty sure that this will
be pointing to the next model. Or maybe the last model loaded.
*/
json data;
// Methods.
void cleanUp(std::string); void cleanUp(std::string);
bool parseJSONFile();
public: public: