mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-16 23:40:25 +01:00
spaces->tabs
This commit is contained in:
parent
2a027f755e
commit
32906fc867
|
@ -59,7 +59,7 @@ bool dummyImageLoader(tinygltf::Image *a, const int b, std::string *c,
|
||||||
std::string *d, int e, int f, const unsigned char * g,
|
std::string *d, int e, int f, const unsigned char * g,
|
||||||
int h, void *user_pointer)
|
int h, void *user_pointer)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
|
@ -260,17 +260,17 @@ IAnimatedMesh* CGLTFMeshFileLoader::createMesh(io::IReadFile* file)
|
||||||
// This is used to copy data into the vertexBuffer
|
// This is used to copy data into the vertexBuffer
|
||||||
Span<video::S3DVertex> verticesBuffer{vertexBuffer,vertices_count};
|
Span<video::S3DVertex> verticesBuffer{vertexBuffer,vertices_count};
|
||||||
// Create dynamic indices buffer so it's easier to work with.
|
// Create dynamic indices buffer so it's easier to work with.
|
||||||
// Preallocate needed resources to boost game startup speed
|
// Preallocate needed resources to boost game startup speed
|
||||||
std::vector<u16> indicesBuffer(model.accessors[
|
std::vector<u16> indicesBuffer(model.accessors[
|
||||||
indicesAccessorId].count);
|
indicesAccessorId].count);
|
||||||
|
|
||||||
getIndices(model, indicesAccessorId, indicesBuffer);
|
getIndices(model, indicesAccessorId, indicesBuffer);
|
||||||
getVertices(model, positionAccessorId, verticesBuffer,
|
getVertices(model, positionAccessorId, verticesBuffer,
|
||||||
mesh_index, primitive_index);
|
mesh_index, primitive_index);
|
||||||
|
|
||||||
// Inverse the order of indices due to the axis of the model being
|
// Inverse the order of indices due to the axis of the model being
|
||||||
// inverted when going from left handed to right handed coordinates
|
// inverted when going from left handed to right handed coordinates
|
||||||
std::reverse(indicesBuffer.begin(),indicesBuffer.end());
|
std::reverse(indicesBuffer.begin(),indicesBuffer.end());
|
||||||
|
|
||||||
// Create the mesh buffer
|
// Create the mesh buffer
|
||||||
SMeshBuffer* meshbuf { new SMeshBuffer {} };
|
SMeshBuffer* meshbuf { new SMeshBuffer {} };
|
||||||
|
|
|
@ -141,7 +141,7 @@ TEST_CASE("snow man") {
|
||||||
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getVertexCount() == 24);
|
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getVertexCount() == 24);
|
||||||
const auto* vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
const auto* vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||||
sm.getMesh()->getMeshBuffer(0)->getVertices());
|
sm.getMesh()->getMeshBuffer(0)->getVertices());
|
||||||
|
|
||||||
CHECK(vertices[0].Pos == irr::core::vector3df{3.0f, 24.0f, -3.0f});
|
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[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[6].Pos == irr::core::vector3df{-3.0f, 18.0f, -3.0f});
|
||||||
|
@ -150,11 +150,11 @@ TEST_CASE("snow man") {
|
||||||
CHECK(vertices[15].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[18].Pos == irr::core::vector3df{3.0f, 18.0f, -3.0f});
|
||||||
CHECK(vertices[21].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*>(
|
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||||
sm.getMesh()->getMeshBuffer(1)->getVertices());
|
sm.getMesh()->getMeshBuffer(1)->getVertices());
|
||||||
|
|
||||||
CHECK(vertices[2].Pos == irr::core::vector3df{5.0f, 10.0f, 5.0f});
|
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[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[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[8].Pos == irr::core::vector3df{5.0f, 10.0f, -5.0f});
|
||||||
|
@ -163,17 +163,17 @@ TEST_CASE("snow man") {
|
||||||
CHECK(vertices[22].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});
|
CHECK(vertices[23].Pos == irr::core::vector3df{-5.0f, 0.0f, 5.0f});
|
||||||
|
|
||||||
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||||
sm.getMesh()->getMeshBuffer(2)->getVertices());
|
sm.getMesh()->getMeshBuffer(2)->getVertices());
|
||||||
|
|
||||||
CHECK(vertices[1].Pos == irr::core::vector3df{4.0f, 10.0f, -4.0f});
|
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[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[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[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[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[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[17].Pos == irr::core::vector3df{-4.0f, 18.0f, -4.0f});
|
||||||
CHECK(vertices[18].Pos == irr::core::vector3df{4.0f, 10.0f, -4.0f});
|
CHECK(vertices[18].Pos == irr::core::vector3df{4.0f, 10.0f, -4.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("vertex indices are correct for all buffers") {
|
SECTION("vertex indices are correct for all buffers") {
|
||||||
|
@ -185,7 +185,7 @@ TEST_CASE("snow man") {
|
||||||
CHECK(indices[2] == 22);
|
CHECK(indices[2] == 22);
|
||||||
CHECK(indices[35] == 2);
|
CHECK(indices[35] == 2);
|
||||||
|
|
||||||
REQUIRE(sm.getMesh()->getMeshBuffer(1)->getIndexCount() == 36);
|
REQUIRE(sm.getMesh()->getMeshBuffer(1)->getIndexCount() == 36);
|
||||||
indices = reinterpret_cast<irr::u16*>(
|
indices = reinterpret_cast<irr::u16*>(
|
||||||
sm.getMesh()->getMeshBuffer(1)->getIndices());
|
sm.getMesh()->getMeshBuffer(1)->getIndices());
|
||||||
CHECK(indices[10] == 16);
|
CHECK(indices[10] == 16);
|
||||||
|
@ -193,7 +193,7 @@ TEST_CASE("snow man") {
|
||||||
CHECK(indices[15] == 13);
|
CHECK(indices[15] == 13);
|
||||||
CHECK(indices[27] == 5);
|
CHECK(indices[27] == 5);
|
||||||
|
|
||||||
REQUIRE(sm.getMesh()->getMeshBuffer(1)->getIndexCount() == 36);
|
REQUIRE(sm.getMesh()->getMeshBuffer(1)->getIndexCount() == 36);
|
||||||
indices = reinterpret_cast<irr::u16*>(
|
indices = reinterpret_cast<irr::u16*>(
|
||||||
sm.getMesh()->getMeshBuffer(2)->getIndices());
|
sm.getMesh()->getMeshBuffer(2)->getIndices());
|
||||||
CHECK(indices[26] == 6);
|
CHECK(indices[26] == 6);
|
||||||
|
@ -202,72 +202,72 @@ TEST_CASE("snow man") {
|
||||||
CHECK(indices[32] == 2);
|
CHECK(indices[32] == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SECTION("vertex normals are correct for all buffers") {
|
SECTION("vertex normals are correct for all buffers") {
|
||||||
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getVertexCount() == 24);
|
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getVertexCount() == 24);
|
||||||
const auto* vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
const auto* vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||||
sm.getMesh()->getMeshBuffer(0)->getVertices());
|
sm.getMesh()->getMeshBuffer(0)->getVertices());
|
||||||
CHECK(vertices[0].Normal == irr::core::vector3df{1.0f, 0.0f, -0.0f});
|
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[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[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[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[6].Normal == irr::core::vector3df{-1.0f, 0.0f, -0.0f});
|
||||||
CHECK(vertices[23].Normal == irr::core::vector3df{0.0f, 0.0f, 1.0f});
|
CHECK(vertices[23].Normal == irr::core::vector3df{0.0f, 0.0f, 1.0f});
|
||||||
|
|
||||||
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||||
sm.getMesh()->getMeshBuffer(1)->getVertices());
|
sm.getMesh()->getMeshBuffer(1)->getVertices());
|
||||||
|
|
||||||
CHECK(vertices[0].Normal == irr::core::vector3df{1.0f, 0.0f, -0.0f});
|
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[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[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[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[7].Normal == irr::core::vector3df{-1.0f, 0.0f, -0.0f});
|
||||||
CHECK(vertices[22].Normal == irr::core::vector3df{0.0f, 0.0f, 1.0f});
|
CHECK(vertices[22].Normal == irr::core::vector3df{0.0f, 0.0f, 1.0f});
|
||||||
|
|
||||||
|
|
||||||
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||||
sm.getMesh()->getMeshBuffer(2)->getVertices());
|
sm.getMesh()->getMeshBuffer(2)->getVertices());
|
||||||
|
|
||||||
CHECK(vertices[3].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[4].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[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[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[11].Normal == irr::core::vector3df{0.0f, 1.0f, -0.0f});
|
||||||
CHECK(vertices[19].Normal == irr::core::vector3df{0.0f, 0.0f, -1.0f});
|
CHECK(vertices[19].Normal == irr::core::vector3df{0.0f, 0.0f, -1.0f});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SECTION("texture coords are correct for all buffers") {
|
SECTION("texture coords are correct for all buffers") {
|
||||||
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getVertexCount() == 24);
|
REQUIRE(sm.getMesh()->getMeshBuffer(0)->getVertexCount() == 24);
|
||||||
const auto* vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
const auto* vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||||
sm.getMesh()->getMeshBuffer(0)->getVertices());
|
sm.getMesh()->getMeshBuffer(0)->getVertices());
|
||||||
|
|
||||||
CHECK(vertices[0].TCoords == irr::core::vector2df{0.583333, 0.791667});
|
CHECK(vertices[0].TCoords == irr::core::vector2df{0.583333, 0.791667});
|
||||||
CHECK(vertices[1].TCoords == irr::core::vector2df{0.583333, 0.666667});
|
CHECK(vertices[1].TCoords == irr::core::vector2df{0.583333, 0.666667});
|
||||||
CHECK(vertices[2].TCoords == irr::core::vector2df{0.708333, 0.791667});
|
CHECK(vertices[2].TCoords == irr::core::vector2df{0.708333, 0.791667});
|
||||||
CHECK(vertices[5].TCoords == irr::core::vector2df{0.375, 0.416667});
|
CHECK(vertices[5].TCoords == irr::core::vector2df{0.375, 0.416667});
|
||||||
CHECK(vertices[6].TCoords == irr::core::vector2df{0.5, 0.291667});
|
CHECK(vertices[6].TCoords == irr::core::vector2df{0.5, 0.291667});
|
||||||
CHECK(vertices[19].TCoords == irr::core::vector2df{0.708333, 0.75});
|
CHECK(vertices[19].TCoords == irr::core::vector2df{0.708333, 0.75});
|
||||||
|
|
||||||
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
vertices = reinterpret_cast<irr::video::S3DVertex*>(
|
||||||
sm.getMesh()->getMeshBuffer(1)->getVertices());
|
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*>(
|
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());
|
sm.getMesh()->getMeshBuffer(2)->getVertices());
|
||||||
|
|
||||||
CHECK(vertices[10].TCoords == irr::core::vector2df{0.375, 0.416667});
|
CHECK(vertices[10].TCoords == irr::core::vector2df{0.375, 0.416667});
|
||||||
CHECK(vertices[11].TCoords == irr::core::vector2df{0.375, 0.583333});
|
CHECK(vertices[11].TCoords == irr::core::vector2df{0.375, 0.583333});
|
||||||
CHECK(vertices[12].TCoords == irr::core::vector2df{0.708333, 0.625});
|
CHECK(vertices[12].TCoords == irr::core::vector2df{0.708333, 0.625});
|
||||||
CHECK(vertices[17].TCoords == irr::core::vector2df{0.541667, 0.458333});
|
CHECK(vertices[17].TCoords == irr::core::vector2df{0.541667, 0.458333});
|
||||||
CHECK(vertices[20].TCoords == irr::core::vector2df{0.208333, 0.416667});
|
CHECK(vertices[20].TCoords == irr::core::vector2df{0.208333, 0.416667});
|
||||||
CHECK(vertices[22].TCoords == irr::core::vector2df{0.375, 0.416667});
|
CHECK(vertices[22].TCoords == irr::core::vector2df{0.375, 0.416667});
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user