Skip to content

Commit

Permalink
Fix test_gltfio cmake duplicate libs and failed UT. (google#7199)
Browse files Browse the repository at this point in the history
* fix test-gltfio cmake duplicated libs links.

* fix test_gltfio failed UT.
  • Loading branch information
suzp1984 authored and plepers committed Dec 9, 2023
1 parent 42a17d6 commit fc60e01
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
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

0 comments on commit fc60e01

Please sign in to comment.