mirror of
https://github.com/minetest/irrlicht.git
synced 2025-06-28 14:26:06 +02:00
Test for correct vertex indices
This commit is contained in:
committed by
JosiahWI
parent
f2a3e990f3
commit
1b9d3ca502
@ -45,19 +45,30 @@ TEST_CASE("load empty gltf file") {
|
||||
CHECK(sm.getMesh() == nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("minimal triangle has correct vertices") {
|
||||
TEST_CASE("minimal triangle") {
|
||||
ScopedMesh sm { "source/Irrlicht/tests/assets/minimal_triangle.gltf" };
|
||||
|
||||
auto* mesh = sm.getMesh();
|
||||
REQUIRE(mesh != nullptr);
|
||||
REQUIRE(mesh->getMeshBufferCount() == 1);
|
||||
auto* meshbuf = mesh->getMeshBuffer(0);
|
||||
REQUIRE(meshbuf->getVertexCount() == 3);
|
||||
auto* 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 {0.0f, 1.0f, 0.0f});
|
||||
|
||||
SECTION("vertex coordinates are correct") {
|
||||
REQUIRE(meshbuf->getVertexCount() == 3);
|
||||
auto* 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 {0.0f, 1.0f, 0.0f});
|
||||
}
|
||||
|
||||
SECTION("vertex indices are correct") {
|
||||
REQUIRE(meshbuf->getIndexCount() == 3);
|
||||
auto* indices = reinterpret_cast<irr::u16*>(meshbuf->getIndices());
|
||||
CHECK(indices[0] == 0);
|
||||
CHECK(indices[1] == 1);
|
||||
CHECK(indices[2] == 2);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("mesh loader returns nullptr when given null file pointer") {
|
||||
|
Reference in New Issue
Block a user