Test that minimal triangle has correct vertices

This commit is contained in:
JosiahWI 2022-10-17 07:34:19 -05:00
parent 4f5588e7e8
commit 336aa204fb
No known key found for this signature in database
GPG Key ID: C7BB8573A4ABC4B9
2 changed files with 31 additions and 6 deletions

View File

@ -1,9 +1,13 @@
#include "CGLTFMeshFileLoader.h"
#include "CMeshBuffer.h"
#include "coreutil.h"
#include "IAnimatedMesh.h"
#include "IReadFile.h"
#include "irrTypes.h"
#include "path.h"
#include "S3DVertex.h"
#include "SAnimatedMesh.h"
#include "SMesh.h"
namespace irr
{
@ -28,9 +32,22 @@ IAnimatedMesh* CGLTFMeshFileLoader::createMesh(io::IReadFile* file)
}
// sorry Bjarne
SAnimatedMesh* mesh { new SAnimatedMesh {} };
SMeshBuffer* meshbuf { new SMeshBuffer {} };
return mesh;
const video::S3DVertex* vertices { new video::S3DVertex[3] {
{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, {}, 0.0f, 0.0f},
{1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, {}, 0.0f, 0.0f},
{1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, {}, 0.0f, 0.0f} } };
const u16* indices { new u16[3] {} };
meshbuf->append(vertices, 3, indices, 3);
SMesh* mesh { new SMesh {} };
mesh->addMeshBuffer(meshbuf);
SAnimatedMesh* animatedMesh { new SAnimatedMesh {} };
animatedMesh->addMesh(mesh);
return animatedMesh;
}
} // namespace irr

View File

@ -7,22 +7,30 @@
TEST_CASE("load empty gltf file") {
irr::IrrlichtDevice* device { irr::createDevice(irr::video::EDT_NULL) };
irr::scene::ISceneManager* smgr { device->getSceneManager() };
irr::io::InMemoryFile filebuf {"test.gltf", ""};
auto* mesh { smgr->getMesh(&filebuf) };
CHECK(mesh == nullptr);
device->drop();
}
TEST_CASE("load minimal triangle") {
TEST_CASE("minimal triangle has correct vertices") {
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);
REQUIRE(mesh->getMeshBufferCount() == 1);
auto* meshbuf { mesh->getMeshBuffer(0) };
REQUIRE(meshbuf->getVertexCount() == 3);
irr::video::S3DVertex* vertices {
reinterpret_cast<irr::video::S3DVertex*>(
meshbuf->getVertices()) };
CHECK(vertices[0].Pos == irr::core::vector3df {0.0f, 0.0f, 0.0f});
CHECK(vertices[1].Pos == irr::core::vector3df {1.0f, 0.0f, 0.0f});
CHECK(vertices[2].Pos == irr::core::vector3df {1.0f, 1.0f, 0.0f});
device->drop();
}