Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_gltfio cmake duplicate libs and failed UT. #7199

Merged
merged 4 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libs/gltfio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,9 @@ if (TNT_DEV AND NOT WEBGL AND NOT ANDROID AND NOT IOS)

add_executable(${TEST_TARGET} test/gltfio_test.cpp)
add_dependencies(${TEST_TARGET} test_gltfio_files)
set_property(TARGET test_gltfio PROPERTY LINK_LIBRARIES)

target_link_libraries(${TEST_TARGET} PRIVATE ${TARGET} filament filabridge gtest uberarchive)
target_link_libraries(${TEST_TARGET} PRIVATE ${TARGET} gtest uberarchive)
if (NOT MSVC)
target_compile_options(${TEST_TARGET} PRIVATE -Wno-deprecated-register)
endif()
Expand Down
19 changes: 18 additions & 1 deletion libs/gltfio/test/gltfio_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ TEST_F(glTFIOTest, AnimatedMorphCubeMaterials) {
EXPECT_EQ(name, "Material");
}

// A macro to help with mat comparisons within a range.
#define EXPECT_MAT_NEAR(MAT1, MAT2, eps) \
do { \
const decltype(MAT1) v1 = MAT1; \
const decltype(MAT2) v2 = MAT2; \
EXPECT_EQ(v1.NUM_ROWS, v2.NUM_ROWS); \
EXPECT_EQ(v1.NUM_COLS, v2.NUM_COLS); \
for (int i = 0; i < v1.NUM_ROWS; ++i) { \
for (int j = 0; j < v1.NUM_COLS; ++j) \
EXPECT_NEAR(v1[i][j], v2[i][j], eps) << \
"v[" << i << "][" << j << "]"; \
} \
} while(0)


TEST_F(glTFIOTest, AnimatedMorphCubeTransforms) {
FilamentAsset const& morphCubeAsset = *mData[ANIMATED_MORPH_CUBE_GLB]->getAsset();
auto const& transformManager = mEngine->getTransformManager();
Expand All @@ -177,8 +192,10 @@ TEST_F(glTFIOTest, AnimatedMorphCubeTransforms) {

auto const result = inverse(transform) * expectedTransform;

float const value_eps = float(0.00001) * std::numeric_limits<float>::epsilon();

// We expect the result to be identity
EXPECT_EQ(result, math::mat4f{});
EXPECT_MAT_NEAR(result, math::mat4f{}, value_eps);
}

TEST_F(glTFIOTest, AnimatedMorphCubeRenderables) {
Expand Down
Loading