Test that minimal triangle returns some mesh

This commit is contained in:
JosiahWI 2022-10-17 07:17:07 -05:00
parent 880cbbbb5e
commit 4f5588e7e8
No known key found for this signature in database
GPG Key ID: C7BB8573A4ABC4B9
3 changed files with 92 additions and 3 deletions

View File

@ -3,6 +3,7 @@
#include "IAnimatedMesh.h" #include "IAnimatedMesh.h"
#include "IReadFile.h" #include "IReadFile.h"
#include "path.h" #include "path.h"
#include "SAnimatedMesh.h"
namespace irr namespace irr
{ {
@ -22,9 +23,16 @@ bool CGLTFMeshFileLoader::isALoadableFileExtension(
IAnimatedMesh* CGLTFMeshFileLoader::createMesh(io::IReadFile* file) IAnimatedMesh* CGLTFMeshFileLoader::createMesh(io::IReadFile* file)
{ {
if (file->getSize() == 0) {
return nullptr; return nullptr;
} }
// sorry Bjarne
SAnimatedMesh* mesh { new SAnimatedMesh {} };
return mesh;
}
} // namespace irr } // namespace irr
} // namespace scene } // namespace scene

View File

@ -0,0 +1,70 @@
{
"scene": 0,
"scenes" : [
{
"nodes" : [ 0 ]
}
],
"nodes" : [
{
"mesh" : 0
}
],
"meshes" : [
{
"primitives" : [ {
"attributes" : {
"POSITION" : 1
},
"indices" : 0
} ]
}
],
"buffers" : [
{
"uri" : "data:application/octet-stream;base64,AAABAAIAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAA=",
"byteLength" : 44
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 6,
"target" : 34963
},
{
"buffer" : 0,
"byteOffset" : 8,
"byteLength" : 36,
"target" : 34962
}
],
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 3,
"type" : "SCALAR",
"max" : [ 2 ],
"min" : [ 0 ]
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 3,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
}
],
"asset" : {
"version" : "2.0"
}
}

View File

@ -11,7 +11,18 @@ TEST_CASE("load empty gltf file") {
irr::io::InMemoryFile filebuf {"test.gltf", ""}; irr::io::InMemoryFile filebuf {"test.gltf", ""};
auto* mesh { smgr->getMesh(&filebuf) }; auto* mesh { smgr->getMesh(&filebuf) };
REQUIRE(mesh == nullptr); CHECK(mesh == nullptr);
device->drop();
}
TEST_CASE("load minimal triangle") {
irr::IrrlichtDevice* device { irr::createDevice(irr::video::EDT_NULL) };
irr::scene::ISceneManager* smgr { device->getSceneManager() };
auto* mesh { smgr->getMesh(
"source/Irrlicht/tests/assets/minimal_triangle.gltf", "") };
REQUIRE(mesh != nullptr);
device->drop(); device->drop();
} }