mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-18 08:10:32 +01:00
Fix coordinate system change
Old code was inverting the X axis, new code inverts the Z axis.
This commit is contained in:
parent
56c4a5a945
commit
373a33a246
@ -93,12 +93,12 @@ static core::vector2df readVec2DF(const BufferOffset& readFrom)
|
|||||||
static core::vector3df readVec3DF(const BufferOffset& readFrom,
|
static core::vector3df readVec3DF(const BufferOffset& readFrom,
|
||||||
const float scale = 1.0f)
|
const float scale = 1.0f)
|
||||||
{
|
{
|
||||||
// glTF coordinates are right-handed, minetest ones are left-handed
|
// glTF's coordinate system is right-handed, Irrlicht's is left-handed
|
||||||
// 1 glTF coordinate is equivalent to 10 Irrlicht coordinates
|
// glTF's +Z axis corresponds to Irrlicht's -Z axis
|
||||||
return core::vector3df(
|
return core::vector3df(
|
||||||
-scale * readPrimitive<float>(readFrom),
|
scale * readPrimitive<float>(readFrom),
|
||||||
scale * readPrimitive<float>(BufferOffset(readFrom, sizeof(float))),
|
scale * readPrimitive<float>(BufferOffset(readFrom, sizeof(float))),
|
||||||
scale * readPrimitive<float>(BufferOffset(readFrom, 2 * sizeof(float))));
|
-scale * readPrimitive<float>(BufferOffset(readFrom, 2 * sizeof(float))));
|
||||||
}
|
}
|
||||||
|
|
||||||
static u16* readIndices(const BufferOffset& readFrom, const std::size_t count)
|
static u16* readIndices(const BufferOffset& readFrom, const std::size_t count)
|
||||||
|
@ -52,7 +52,7 @@ TEST_CASE("minimal triangle") {
|
|||||||
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 {0.0f, 0.0f, 0.0f});
|
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[1].Pos == irr::core::vector3df {1.0f, 0.0f, 0.0f});
|
||||||
CHECK(vertices[2].Pos == irr::core::vector3df {0.0f, 1.0f, 0.0f});
|
CHECK(vertices[2].Pos == irr::core::vector3df {0.0f, 1.0f, 0.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,14 +74,14 @@ TEST_CASE("blender cube") {
|
|||||||
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{10.0f, -10.0f, 10.0f});
|
CHECK(vertices[0].Pos == irr::core::vector3df{-10.0f, -10.0f, -10.0f});
|
||||||
CHECK(vertices[3].Pos == irr::core::vector3df{10.0f, 10.0f, 10.0f});
|
CHECK(vertices[3].Pos == irr::core::vector3df{-10.0f, 10.0f, -10.0f});
|
||||||
CHECK(vertices[6].Pos == irr::core::vector3df{10.0f, -10.0f, -10.0f});
|
CHECK(vertices[6].Pos == irr::core::vector3df{-10.0f, -10.0f, 10.0f});
|
||||||
CHECK(vertices[9].Pos == irr::core::vector3df{10.0f, 10.0f, -10.0f});
|
CHECK(vertices[9].Pos == irr::core::vector3df{-10.0f, 10.0f, 10.0f});
|
||||||
CHECK(vertices[12].Pos == irr::core::vector3df{-10.0f, -10.0f, 10.0f});
|
CHECK(vertices[12].Pos == irr::core::vector3df{10.0f, -10.0f, -10.0f});
|
||||||
CHECK(vertices[15].Pos == irr::core::vector3df{-10.0f, 10.0f, 10.0f});
|
CHECK(vertices[15].Pos == irr::core::vector3df{10.0f, 10.0f, -10.0f});
|
||||||
CHECK(vertices[18].Pos == irr::core::vector3df{-10.0f, -10.0f, -10.0f});
|
CHECK(vertices[18].Pos == irr::core::vector3df{10.0f, -10.0f, 10.0f});
|
||||||
CHECK(vertices[21].Pos == irr::core::vector3df{-10.0f, 10.0f, -10.0f});
|
CHECK(vertices[21].Pos == irr::core::vector3df{10.0f, 10.0f, 10.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("vertex indices are correct") {
|
SECTION("vertex indices are correct") {
|
||||||
@ -97,12 +97,12 @@ TEST_CASE("blender cube") {
|
|||||||
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{0.0f, -1.0f, 0.0f});
|
CHECK(vertices[1].Normal == irr::core::vector3df{0.0f, -1.0f, 0.0f});
|
||||||
CHECK(vertices[2].Normal == irr::core::vector3df{0.0f, 0.0f, 1.0f});
|
CHECK(vertices[2].Normal == irr::core::vector3df{0.0f, 0.0f, -1.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{-1.0f, 0.0f, 0.0f});
|
CHECK(vertices[23].Normal == irr::core::vector3df{1.0f, 0.0f, 0.0f});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user