mirror of
https://github.com/minetest/irrlicht.git
synced 2025-06-28 14:26:06 +02:00
Update code with requested changes
Fix mistake on github Comply with changes 1 Comply with requested changes 2 Comply with requested changed 3 Comply with requested changed 4 Requested changed 5 Requested changed 6 Requested changed 7 Requested changed 8 Requested changed 9 Requested changed 10 Requested changes 11 Requested changes 12 This one wasn't even requested I just turned on my vertical ruler and I'm going to go nuts Line 81 doesn't exist anymore Requested changes 13 Requested changes 14 Begin snow man test Write a lot of tests for snow man Add to git ignore Now unignore it Alphabetical order Pass by reference Pass by reference vertexBuffer is now handled on stack Preallocate indicesBuffer then reverse it when complete Undo vertexBuffer stack change causing mac builds to fail Use direct initialization on the vertexBuffer
This commit is contained in:
1
source/Irrlicht/tests/assets/snow_man.gltf
Normal file
1
source/Irrlicht/tests/assets/snow_man.gltf
Normal file
File diff suppressed because one or more lines are too long
@ -1,6 +1,9 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch.hpp>
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class ScopedMesh
|
||||
{
|
||||
@ -60,9 +63,9 @@ TEST_CASE("minimal triangle") {
|
||||
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getIndexCount() == 3);
|
||||
const auto* indices = reinterpret_cast<irr::u16*>(
|
||||
sm.getMesh()->getMeshBuffer(0)->getIndices());
|
||||
CHECK(indices[0] == 0);
|
||||
CHECK(indices[0] == 2);
|
||||
CHECK(indices[1] == 1);
|
||||
CHECK(indices[2] == 2);
|
||||
CHECK(indices[2] == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,10 +91,10 @@ TEST_CASE("blender cube") {
|
||||
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getIndexCount() == 36);
|
||||
const auto* indices = reinterpret_cast<irr::u16*>(
|
||||
sm.getMesh()->getMeshBuffer(0)->getIndices());
|
||||
CHECK(indices[0] == 0);
|
||||
CHECK(indices[1] == 3);
|
||||
CHECK(indices[2] == 9);
|
||||
CHECK(indices[35] == 16);
|
||||
CHECK(indices[0] == 16);
|
||||
CHECK(indices[1] == 5);
|
||||
CHECK(indices[2] == 22);
|
||||
CHECK(indices[35] == 0);
|
||||
}
|
||||
|
||||
SECTION("vertex normals are correct") {
|
||||
@ -129,3 +132,142 @@ TEST_CASE("invalid JSON returns nullptr") {
|
||||
CHECK(sm.getMesh() == nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("snow man") {
|
||||
ScopedMesh sm("source/Irrlicht/tests/assets/snow_man.gltf");
|
||||
REQUIRE(sm.getMesh() != nullptr);
|
||||
REQUIRE(sm.getMesh()->getMeshBufferCount() == 3);
|
||||
|
||||
SECTION("vertex coordinates are correct for all buffers") {
|
||||
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getVertexCount() == 24);
|
||||
const auto* vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||
sm.getMesh()->getMeshBuffer(0)->getVertices());
|
||||
|
||||
CHECK(vertices[0].Pos == irr::core::vector3df{3.0f, 24.0f, -3.0f});
|
||||
CHECK(vertices[3].Pos == irr::core::vector3df{3.0f, 18.0f, 3.0f});
|
||||
CHECK(vertices[6].Pos == irr::core::vector3df{-3.0f, 18.0f, -3.0f});
|
||||
CHECK(vertices[9].Pos == irr::core::vector3df{3.0f, 24.0f, 3.0f});
|
||||
CHECK(vertices[12].Pos == irr::core::vector3df{3.0f, 18.0f, -3.0f});
|
||||
CHECK(vertices[15].Pos == irr::core::vector3df{-3.0f, 18.0f, 3.0f});
|
||||
CHECK(vertices[18].Pos == irr::core::vector3df{3.0f, 18.0f, -3.0f});
|
||||
CHECK(vertices[21].Pos == irr::core::vector3df{3.0f, 18.0f, 3.0f});
|
||||
|
||||
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||
sm.getMesh()->getMeshBuffer(1)->getVertices());
|
||||
|
||||
CHECK(vertices[2].Pos == irr::core::vector3df{5.0f, 10.0f, 5.0f});
|
||||
CHECK(vertices[3].Pos == irr::core::vector3df{5.0f, 0.0f, 5.0f});
|
||||
CHECK(vertices[7].Pos == irr::core::vector3df{-5.0f, 0.0f, 5.0f});
|
||||
CHECK(vertices[8].Pos == irr::core::vector3df{5.0f, 10.0f, -5.0f});
|
||||
CHECK(vertices[14].Pos == irr::core::vector3df{5.0f, 0.0f, 5.0f});
|
||||
CHECK(vertices[16].Pos == irr::core::vector3df{5.0f, 10.0f, -5.0f});
|
||||
CHECK(vertices[22].Pos == irr::core::vector3df{-5.0f, 10.0f, 5.0f});
|
||||
CHECK(vertices[23].Pos == irr::core::vector3df{-5.0f, 0.0f, 5.0f});
|
||||
|
||||
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||
sm.getMesh()->getMeshBuffer(2)->getVertices());
|
||||
|
||||
CHECK(vertices[1].Pos == irr::core::vector3df{4.0f, 10.0f, -4.0f});
|
||||
CHECK(vertices[2].Pos == irr::core::vector3df{4.0f, 18.0f, 4.0f});
|
||||
CHECK(vertices[3].Pos == irr::core::vector3df{4.0f, 10.0f, 4.0f});
|
||||
CHECK(vertices[10].Pos == irr::core::vector3df{-4.0f, 18.0f, -4.0f});
|
||||
CHECK(vertices[11].Pos == irr::core::vector3df{-4.0f, 18.0f, 4.0f});
|
||||
CHECK(vertices[12].Pos == irr::core::vector3df{4.0f, 10.0f, -4.0f});
|
||||
CHECK(vertices[17].Pos == irr::core::vector3df{-4.0f, 18.0f, -4.0f});
|
||||
CHECK(vertices[18].Pos == irr::core::vector3df{4.0f, 10.0f, -4.0f});
|
||||
}
|
||||
|
||||
SECTION("vertex indices are correct for all buffers") {
|
||||
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getIndexCount() == 36);
|
||||
const auto* indices = reinterpret_cast<irr::u16*>(
|
||||
sm.getMesh()->getMeshBuffer(0)->getIndices());
|
||||
CHECK(indices[0] == 23);
|
||||
CHECK(indices[1] == 21);
|
||||
CHECK(indices[2] == 22);
|
||||
CHECK(indices[35] == 2);
|
||||
|
||||
REQUIRE(sm.getMesh()->getMeshBuffer(1)->getIndexCount() == 36);
|
||||
indices = reinterpret_cast<irr::u16*>(
|
||||
sm.getMesh()->getMeshBuffer(1)->getIndices());
|
||||
CHECK(indices[10] == 16);
|
||||
CHECK(indices[11] == 18);
|
||||
CHECK(indices[15] == 13);
|
||||
CHECK(indices[27] == 5);
|
||||
|
||||
REQUIRE(sm.getMesh()->getMeshBuffer(1)->getIndexCount() == 36);
|
||||
indices = reinterpret_cast<irr::u16*>(
|
||||
sm.getMesh()->getMeshBuffer(2)->getIndices());
|
||||
CHECK(indices[26] == 6);
|
||||
CHECK(indices[27] == 5);
|
||||
CHECK(indices[29] == 6);
|
||||
CHECK(indices[32] == 2);
|
||||
}
|
||||
|
||||
|
||||
SECTION("vertex normals are correct for all buffers") {
|
||||
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getVertexCount() == 24);
|
||||
const auto* vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||
sm.getMesh()->getMeshBuffer(0)->getVertices());
|
||||
CHECK(vertices[0].Normal == irr::core::vector3df{1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[1].Normal == irr::core::vector3df{1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[2].Normal == irr::core::vector3df{1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[3].Normal == irr::core::vector3df{1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[6].Normal == irr::core::vector3df{-1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[23].Normal == irr::core::vector3df{0.0f, 0.0f, 1.0f});
|
||||
|
||||
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||
sm.getMesh()->getMeshBuffer(1)->getVertices());
|
||||
|
||||
CHECK(vertices[0].Normal == irr::core::vector3df{1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[1].Normal == irr::core::vector3df{1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[3].Normal == irr::core::vector3df{1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[6].Normal == irr::core::vector3df{-1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[7].Normal == irr::core::vector3df{-1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[22].Normal == irr::core::vector3df{0.0f, 0.0f, 1.0f});
|
||||
|
||||
|
||||
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||
sm.getMesh()->getMeshBuffer(2)->getVertices());
|
||||
|
||||
CHECK(vertices[3].Normal == irr::core::vector3df{1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[4].Normal == irr::core::vector3df{-1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[5].Normal == irr::core::vector3df{-1.0f, 0.0f, -0.0f});
|
||||
CHECK(vertices[10].Normal == irr::core::vector3df{0.0f, 1.0f, -0.0f});
|
||||
CHECK(vertices[11].Normal == irr::core::vector3df{0.0f, 1.0f, -0.0f});
|
||||
CHECK(vertices[19].Normal == irr::core::vector3df{0.0f, 0.0f, -1.0f});
|
||||
|
||||
}
|
||||
|
||||
|
||||
SECTION("texture coords are correct for all buffers") {
|
||||
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getVertexCount() == 24);
|
||||
const auto* vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||
sm.getMesh()->getMeshBuffer(0)->getVertices());
|
||||
|
||||
CHECK(vertices[0].TCoords == irr::core::vector2df{0.583333, 0.791667});
|
||||
CHECK(vertices[1].TCoords == irr::core::vector2df{0.583333, 0.666667});
|
||||
CHECK(vertices[2].TCoords == irr::core::vector2df{0.708333, 0.791667});
|
||||
CHECK(vertices[5].TCoords == irr::core::vector2df{0.375, 0.416667});
|
||||
CHECK(vertices[6].TCoords == irr::core::vector2df{0.5, 0.291667});
|
||||
CHECK(vertices[19].TCoords == irr::core::vector2df{0.708333, 0.75});
|
||||
|
||||
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||
sm.getMesh()->getMeshBuffer(1)->getVertices());
|
||||
|
||||
CHECK(vertices[1].TCoords == irr::core::vector2df{0, 0.791667});
|
||||
CHECK(vertices[4].TCoords == irr::core::vector2df{0.208333, 0.791667});
|
||||
CHECK(vertices[5].TCoords == irr::core::vector2df{0, 0.791667});
|
||||
CHECK(vertices[6].TCoords == irr::core::vector2df{0.208333, 0.583333});
|
||||
CHECK(vertices[12].TCoords == irr::core::vector2df{0.416667, 0.791667});
|
||||
CHECK(vertices[15].TCoords == irr::core::vector2df{0.208333, 0.583333});
|
||||
|
||||
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||
sm.getMesh()->getMeshBuffer(2)->getVertices());
|
||||
|
||||
CHECK(vertices[10].TCoords == irr::core::vector2df{0.375, 0.416667});
|
||||
CHECK(vertices[11].TCoords == irr::core::vector2df{0.375, 0.583333});
|
||||
CHECK(vertices[12].TCoords == irr::core::vector2df{0.708333, 0.625});
|
||||
CHECK(vertices[17].TCoords == irr::core::vector2df{0.541667, 0.458333});
|
||||
CHECK(vertices[20].TCoords == irr::core::vector2df{0.208333, 0.416667});
|
||||
CHECK(vertices[22].TCoords == irr::core::vector2df{0.375, 0.416667});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user