Updated ozz-animation to version 0.14.1 @35b2efd4
This commit is contained in:
@@ -3,6 +3,7 @@ add_executable(test_animation_builder
|
||||
target_link_libraries(test_animation_builder
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_animation_builder)
|
||||
set_target_properties(test_animation_builder PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
add_test(NAME test_animation_builder COMMAND test_animation_builder)
|
||||
|
||||
@@ -11,6 +12,7 @@ add_executable(test_animation_optimizer
|
||||
target_link_libraries(test_animation_optimizer
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_animation_optimizer)
|
||||
set_target_properties(test_animation_optimizer PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
add_test(NAME test_animation_optimizer COMMAND test_animation_optimizer)
|
||||
|
||||
@@ -19,6 +21,7 @@ add_executable(test_raw_animation_utils
|
||||
target_link_libraries(test_raw_animation_utils
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_raw_animation_utils)
|
||||
set_target_properties(test_raw_animation_utils PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
add_test(NAME test_raw_animation_utils COMMAND test_raw_animation_utils)
|
||||
|
||||
@@ -27,6 +30,7 @@ add_executable(test_additive_animation_builder
|
||||
target_link_libraries(test_additive_animation_builder
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_additive_animation_builder)
|
||||
set_target_properties(test_additive_animation_builder PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
add_test(NAME test_additive_animation_builder COMMAND test_additive_animation_builder)
|
||||
|
||||
@@ -35,6 +39,7 @@ add_executable(test_skeleton_builder
|
||||
target_link_libraries(test_skeleton_builder
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_skeleton_builder)
|
||||
set_target_properties(test_skeleton_builder PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
add_test(NAME test_skeleton_builder COMMAND test_skeleton_builder)
|
||||
|
||||
@@ -43,6 +48,7 @@ add_executable(test_raw_skeleton_archive
|
||||
target_link_libraries(test_raw_skeleton_archive
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_raw_skeleton_archive)
|
||||
set_target_properties(test_raw_skeleton_archive PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
add_test(NAME test_raw_skeleton_archive COMMAND test_raw_skeleton_archive)
|
||||
|
||||
@@ -53,6 +59,7 @@ target_link_libraries(test_track_builder
|
||||
ozz_animation
|
||||
ozz_base
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_track_builder)
|
||||
set_target_properties(test_track_builder PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
add_test(NAME test_track_builder COMMAND test_track_builder)
|
||||
|
||||
@@ -63,16 +70,17 @@ target_link_libraries(test_track_optimizer
|
||||
ozz_animation
|
||||
ozz_base
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_track_optimizer)
|
||||
set_target_properties(test_track_optimizer PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
add_test(NAME test_track_optimizer COMMAND test_track_optimizer)
|
||||
|
||||
add_executable(test_raw_skeleton_archive_versioning
|
||||
raw_skeleton_archive_versioning_tests.cc)
|
||||
|
||||
target_link_libraries(test_raw_skeleton_archive_versioning
|
||||
ozz_animation_offline
|
||||
ozz_options
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_raw_skeleton_archive_versioning)
|
||||
set_target_properties(test_raw_skeleton_archive_versioning PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
|
||||
add_test(NAME test_raw_skeleton_archive_versioning_le COMMAND test_raw_skeleton_archive_versioning "--file=${ozz_media_directory}/bin/versioning/raw_skeleton_v1_le.ozz" "--joints=67" "--root_name=Hips")
|
||||
@@ -83,6 +91,7 @@ add_executable(test_raw_animation_archive
|
||||
target_link_libraries(test_raw_animation_archive
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_raw_animation_archive)
|
||||
set_target_properties(test_raw_animation_archive PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
add_test(NAME test_raw_animation_archive COMMAND test_raw_animation_archive)
|
||||
|
||||
@@ -92,6 +101,7 @@ target_link_libraries(test_raw_animation_archive_versioning
|
||||
ozz_animation_offline
|
||||
ozz_options
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_raw_animation_archive_versioning)
|
||||
set_target_properties(test_raw_animation_archive_versioning PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
|
||||
add_test(NAME test_raw_animation_archive_versioning_le COMMAND test_raw_animation_archive_versioning "--file=${ozz_media_directory}/bin/versioning/raw_animation_v3_le.ozz" "--tracks=67" "--duration=.66666667" "--name=run")
|
||||
@@ -107,6 +117,7 @@ add_executable(test_raw_track_archive
|
||||
target_link_libraries(test_raw_track_archive
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_raw_track_archive)
|
||||
set_target_properties(test_raw_track_archive PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
add_test(NAME test_raw_track_archive COMMAND test_raw_track_archive)
|
||||
|
||||
@@ -119,8 +130,10 @@ add_dependencies(test_fuse_animation_offline BUILD_FUSE_ozz_animation_offline)
|
||||
target_link_libraries(test_fuse_animation_offline
|
||||
ozz_animation
|
||||
gtest)
|
||||
#target_copy_shared_libraries(test_fuse_animation_offline)
|
||||
add_test(NAME test_fuse_animation_offline COMMAND test_fuse_animation_offline)
|
||||
set_target_properties(test_fuse_animation_offline PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
target_compile_definitions(test_fuse_animation_offline PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:OZZ_BUILD_ANIMOFFLINE_LIB>)
|
||||
|
||||
add_subdirectory(fbx)
|
||||
add_subdirectory(gltf)
|
||||
|
||||
+6
-5
@@ -25,16 +25,13 @@
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "ozz/animation/offline/additive_animation_builder.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "ozz/animation/offline/additive_animation_builder.h"
|
||||
#include "ozz/animation/offline/raw_animation.h"
|
||||
#include "ozz/base/maths/gtest_math_helper.h"
|
||||
#include "ozz/base/maths/math_constant.h"
|
||||
#include "ozz/base/maths/transform.h"
|
||||
|
||||
#include "ozz/animation/offline/raw_animation.h"
|
||||
|
||||
using ozz::animation::offline::AdditiveAnimationBuilder;
|
||||
using ozz::animation::offline::RawAnimation;
|
||||
|
||||
@@ -85,6 +82,7 @@ TEST(Build, AdditiveAnimationBuilder) {
|
||||
AdditiveAnimationBuilder builder;
|
||||
|
||||
RawAnimation input;
|
||||
input.name = "test";
|
||||
input.duration = 1.f;
|
||||
input.tracks.resize(3);
|
||||
|
||||
@@ -140,6 +138,7 @@ TEST(Build, AdditiveAnimationBuilder) {
|
||||
{
|
||||
RawAnimation output;
|
||||
ASSERT_TRUE(builder(input, &output));
|
||||
EXPECT_STREQ(output.name.c_str(), input.name.c_str());
|
||||
EXPECT_EQ(output.num_tracks(), 3);
|
||||
|
||||
// 1st track.
|
||||
@@ -199,6 +198,7 @@ TEST(BuildRefPose, AdditiveAnimationBuilder) {
|
||||
RawAnimation input;
|
||||
input.duration = 1.f;
|
||||
input.tracks.resize(3);
|
||||
input.name = "test";
|
||||
|
||||
// First track is empty
|
||||
{
|
||||
@@ -263,6 +263,7 @@ TEST(BuildRefPose, AdditiveAnimationBuilder) {
|
||||
RawAnimation output;
|
||||
ASSERT_TRUE(
|
||||
builder(input, ozz::span<ozz::math::Transform>(ref_pose), &output));
|
||||
EXPECT_STREQ(output.name.c_str(), input.name.c_str());
|
||||
EXPECT_EQ(output.num_tracks(), 3);
|
||||
|
||||
// 1st track.
|
||||
|
||||
@@ -25,19 +25,15 @@
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "ozz/animation/offline/animation_builder.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ozz/base/maths/gtest_math_helper.h"
|
||||
|
||||
#include "ozz/base/maths/soa_transform.h"
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
|
||||
#include "ozz/animation/offline/animation_builder.h"
|
||||
#include "ozz/animation/offline/raw_animation.h"
|
||||
|
||||
#include "ozz/animation/runtime/animation.h"
|
||||
#include "ozz/animation/runtime/sampling_job.h"
|
||||
#include "ozz/animation/runtime/skeleton.h"
|
||||
#include "ozz/base/maths/gtest_math_helper.h"
|
||||
#include "ozz/base/maths/soa_transform.h"
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
|
||||
using ozz::animation::Animation;
|
||||
using ozz::animation::offline::AnimationBuilder;
|
||||
@@ -220,6 +216,42 @@ TEST(Name, AnimationBuilder) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Move, AnimationBuilder) {
|
||||
AnimationBuilder builder;
|
||||
RawAnimation raw_animation;
|
||||
|
||||
{ // Move constructor
|
||||
raw_animation.name = "anim1";
|
||||
raw_animation.duration = 46.f;
|
||||
raw_animation.tracks.resize(46);
|
||||
ozz::unique_ptr<Animation> anim1(builder(raw_animation));
|
||||
const Animation canim(std::move(*anim1));
|
||||
EXPECT_FLOAT_EQ(canim.duration(), 46.f);
|
||||
EXPECT_STREQ(canim.name(), "anim1");
|
||||
}
|
||||
|
||||
{ // Move assignment
|
||||
raw_animation.name = "anim1";
|
||||
raw_animation.duration = 46.f;
|
||||
raw_animation.tracks.resize(46);
|
||||
ozz::unique_ptr<Animation> anim1(builder(raw_animation));
|
||||
EXPECT_STREQ(anim1->name(), "anim1");
|
||||
EXPECT_EQ(anim1->num_tracks(), 46);
|
||||
|
||||
raw_animation.name = "anim2";
|
||||
raw_animation.duration = 93.f;
|
||||
raw_animation.tracks.resize(93);
|
||||
ozz::unique_ptr<Animation> anim2(builder(raw_animation));
|
||||
EXPECT_STREQ(anim2->name(), "anim2");
|
||||
EXPECT_EQ(anim2->num_tracks(), 93);
|
||||
|
||||
*anim2 = std::move(*anim1);
|
||||
EXPECT_FLOAT_EQ(anim2->duration(), 46.f);
|
||||
EXPECT_EQ(anim2->num_tracks(), 46);
|
||||
EXPECT_STREQ(anim2->name(), "anim1");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Sort, AnimationBuilder) {
|
||||
// Instantiates a builder objects with default parameters.
|
||||
AnimationBuilder builder;
|
||||
@@ -300,10 +332,10 @@ TEST(Sort, AnimationBuilder) {
|
||||
|
||||
// Needs to sample to test the animation.
|
||||
ozz::animation::SamplingJob job;
|
||||
ozz::animation::SamplingCache cache(1);
|
||||
ozz::animation::SamplingJob::Context context(1);
|
||||
ozz::math::SoaTransform output[1];
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
|
||||
// Samples and compares the two animations
|
||||
|
||||
@@ -152,18 +152,14 @@ endif()
|
||||
# ozz_animation_fbx fuse tests
|
||||
set_source_files_properties(${PROJECT_BINARY_DIR}/src_fused/ozz_animation_fbx.cc PROPERTIES GENERATED 1)
|
||||
add_executable(test_fuse_ozz_animation_fbx
|
||||
fuse_ozz_animation_fbx_tests
|
||||
fuse_ozz_animation_fbx_tests.cc
|
||||
${PROJECT_BINARY_DIR}/src_fused/ozz_animation_fbx.cc)
|
||||
add_dependencies(test_fuse_ozz_animation_fbx BUILD_FUSE_ozz_animation_fbx)
|
||||
target_include_directories(test_fuse_ozz_animation_fbx
|
||||
PUBLIC ${FBX_INCLUDE_DIRS})
|
||||
target_compile_options(test_fuse_ozz_animation_fbx
|
||||
PUBLIC $<$<BOOL:${W_NULL_DEREFERENCE}>:-Wno-null-dereference>
|
||||
PUBLIC $<$<BOOL:${W_PRAGMA_PACK}>:-Wno-pragma-pack>)
|
||||
target_link_libraries(test_fuse_ozz_animation_fbx
|
||||
debug ${FBX_LIBRARIES_DEBUG}
|
||||
optimized ${FBX_LIBRARIES}
|
||||
ozz_animation_offline)
|
||||
ozz_animation_offline
|
||||
fbx::sdk)
|
||||
target_copy_shared_libraries(test_fuse_ozz_animation_fbx)
|
||||
set_target_properties(test_fuse_ozz_animation_fbx PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
target_compile_definitions(test_fuse_ozz_animation_fbx PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:OZZ_BUILD_ANIMATIONFBX_LIB>)
|
||||
|
||||
add_test(NAME test_fuse_ozz_animation_fbx COMMAND test_fuse_ozz_animation_fbx)
|
||||
|
||||
@@ -25,20 +25,17 @@
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "ozz/animation/offline/raw_skeleton.h"
|
||||
#include "ozz/animation/offline/skeleton_builder.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "ozz/animation/offline/raw_skeleton.h"
|
||||
#include "ozz/animation/offline/skeleton_builder.h"
|
||||
#include "ozz/animation/runtime/skeleton.h"
|
||||
#include "ozz/base/maths/gtest_math_helper.h"
|
||||
#include "ozz/base/maths/simd_math.h"
|
||||
#include "ozz/base/maths/soa_transform.h"
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
|
||||
#include "ozz/base/maths/gtest_math_helper.h"
|
||||
|
||||
using ozz::animation::Skeleton;
|
||||
using ozz::animation::offline::RawSkeleton;
|
||||
using ozz::animation::offline::SkeletonBuilder;
|
||||
@@ -606,7 +603,7 @@ TEST(MultiRoots, SkeletonBuilder) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(BindPose, SkeletonBuilder) {
|
||||
TEST(RestPose, SkeletonBuilder) {
|
||||
using ozz::math::Float3;
|
||||
using ozz::math::Float4;
|
||||
using ozz::math::Quaternion;
|
||||
@@ -649,14 +646,14 @@ TEST(BindPose, SkeletonBuilder) {
|
||||
ozz::unique_ptr<Skeleton> skeleton(builder(raw_skeleton));
|
||||
ASSERT_TRUE(skeleton);
|
||||
|
||||
// Convert bind pose back to aos.
|
||||
// Convert rest pose back to aos.
|
||||
ozz::math::SimdFloat4 translations[4];
|
||||
ozz::math::SimdFloat4 scales[4];
|
||||
ozz::math::SimdFloat4 rotations[4];
|
||||
const ozz::math::SoaTransform& bind_pose = skeleton->joint_bind_poses()[0];
|
||||
ozz::math::Transpose3x4(&bind_pose.translation.x, translations);
|
||||
ozz::math::Transpose4x4(&bind_pose.rotation.x, rotations);
|
||||
ozz::math::Transpose3x4(&bind_pose.scale.x, scales);
|
||||
const ozz::math::SoaTransform& rest_pose = skeleton->joint_rest_poses()[0];
|
||||
ozz::math::Transpose3x4(&rest_pose.translation.x, translations);
|
||||
ozz::math::Transpose4x4(&rest_pose.rotation.x, rotations);
|
||||
ozz::math::Transpose3x4(&rest_pose.scale.x, scales);
|
||||
|
||||
for (int i = 0; i < skeleton->num_joints(); ++i) {
|
||||
if (std::strcmp(skeleton->joint_names()[i], "j0") == 0) {
|
||||
@@ -707,3 +704,43 @@ TEST(MaxJoints, SkeletonBuilder) {
|
||||
EXPECT_TRUE(!builder(raw_skeleton));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Move, SkeletonBuilder) {
|
||||
SkeletonBuilder builder;
|
||||
RawSkeleton raw_skeleton;
|
||||
|
||||
raw_skeleton.roots.resize(1);
|
||||
RawSkeleton::Joint& root = raw_skeleton.roots[0];
|
||||
root.name = "j0";
|
||||
|
||||
root.children.resize(2);
|
||||
root.children[0].name = "j1";
|
||||
root.children[1].name = "j2";
|
||||
|
||||
ozz::unique_ptr<Skeleton> skeleton(builder(raw_skeleton));
|
||||
|
||||
{ // Move constructor
|
||||
root.name = "root1";
|
||||
ozz::unique_ptr<Skeleton> skeleton1(builder(raw_skeleton));
|
||||
const Skeleton cskeleton(std::move(*skeleton1));
|
||||
EXPECT_STREQ(cskeleton.joint_names()[0], "root1");
|
||||
}
|
||||
|
||||
{ // Move assignment
|
||||
root.name = "root1";
|
||||
root.children.resize(45);
|
||||
ozz::unique_ptr<Skeleton> skeleton1(builder(raw_skeleton));
|
||||
EXPECT_STREQ(skeleton1->joint_names()[0], "root1");
|
||||
EXPECT_EQ(skeleton1->num_joints(), 46);
|
||||
|
||||
root.name = "root2";
|
||||
root.children.resize(92);
|
||||
ozz::unique_ptr<Skeleton> skeleton2(builder(raw_skeleton));
|
||||
EXPECT_STREQ(skeleton2->joint_names()[0], "root2");
|
||||
EXPECT_EQ(skeleton2->num_joints(), 93);
|
||||
|
||||
*skeleton2 = std::move(*skeleton1);
|
||||
EXPECT_STREQ(skeleton2->joint_names()[0], "root1");
|
||||
EXPECT_EQ(skeleton2->num_joints(), 46);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ add_executable(test2ozz
|
||||
target_link_libraries(test2ozz
|
||||
ozz_animation_tools
|
||||
ozz_options)
|
||||
target_copy_shared_libraries(test2ozz)
|
||||
|
||||
set_target_properties(test2ozz
|
||||
PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
@@ -18,6 +19,7 @@ file(WRITE "${ozz_temp_directory}/good.content1" "good content 1")
|
||||
file(WRITE "${ozz_temp_directory}/good.content2" "good content 2")
|
||||
file(WRITE "${ozz_temp_directory}/good.content_renamed" "good content renamed")
|
||||
file(WRITE "${ozz_temp_directory}/non_unique_names.content" "good content but not unique joint names")
|
||||
file(WRITE "${ozz_temp_directory}/partial.good.content0" "partial good content")
|
||||
|
||||
# Creates config test files.
|
||||
file(WRITE "${ozz_temp_directory}/valid_config.json" "{\"skeleton\":{\"filename\":\"${ozz_temp_directory}/skeleton.ozz\",\"import\":{\"enable\":false}},\"animations\":[{\"filename\":\"${ozz_temp_directory}/animation_valid_config.ozz\"}]}")
|
||||
@@ -179,6 +181,9 @@ set_tests_properties(test2ozz_anim_no_match PROPERTIES PASS_REGULAR_EXPRESSION "
|
||||
add_test(NAME test2ozz_anim_additive_wrong_ref COMMAND test2ozz "--file=${ozz_temp_directory}/good.content1" "--config={\"skeleton\":{\"filename\":\"${ozz_temp_directory}/skeleton.ozz\",\"import\":{\"enable\":false}},\"animations\":[{\"filename\":\"${ozz_temp_directory}/animation_${CMAKE_CURRENT_LIST_LINE}.ozz\",\"additive\":true,\"additive_reference\":\"anim\"}]}")
|
||||
set_tests_properties(test2ozz_anim_additive_wrong_ref PROPERTIES PASS_REGULAR_EXPRESSION "Invalid additive reference pose \"anim\"." DEPENDS test2ozz_skel_simple)
|
||||
|
||||
add_test(NAME test2ozz_anim_partial_good_content COMMAND test2ozz "--file=${ozz_temp_directory}/partial.good.content0" "--config={\"skeleton\":{\"filename\":\"${ozz_temp_directory}/skeleton.ozz\",\"import\":{\"enable\":false}},\"animations\":[{\"filename\":\"${ozz_temp_directory}/anim_good_part_content.ozz\"}]}")
|
||||
set_tests_properties(test2ozz_anim_partial_good_content PROPERTIES PASS_REGULAR_EXPRESSION "One of animation failed when import" DEPENDS test2ozz_skel_simple)
|
||||
|
||||
# Run test2ozz track import failing tests
|
||||
#----------------------------
|
||||
|
||||
@@ -194,6 +199,9 @@ set_tests_properties(test2ozz_anim_track_bad_type PROPERTIES PASS_REGULAR_EXPRES
|
||||
add_test(NAME test2ozz_anim_track_invalid_type COMMAND test2ozz "--file=${ozz_temp_directory}/good.content1" "--config={\"skeleton\":{\"filename\":\"${ozz_temp_directory}/skeleton.ozz\",\"import\":{\"enable\":false}},\"animations\":[{\"filename\":\"${ozz_temp_directory}/animation_${CMAKE_CURRENT_LIST_LINE}.ozz\",\"tracks\":[{\"properties\":[{\"joint_name\":\"joint1\",\"property_name\":\"property2\",\"type\":\"1\",\"filename\":\"${ozz_temp_directory}/anim_should_not_exist.ozz\"}]}]}]}")
|
||||
set_tests_properties(test2ozz_anim_track_invalid_type PROPERTIES PASS_REGULAR_EXPRESSION "Invalid value \"1\" for import track type property." DEPENDS test2ozz_skel_simple)
|
||||
|
||||
add_test(NAME test2ozz_anim_track_import_failed COMMAND test2ozz "--file=${ozz_temp_directory}/partial.good.content0" "--config={\"skeleton\":{\"filename\":\"${ozz_temp_directory}/skeleton.ozz\",\"import\":{\"enable\":false}},\"animations\":[{\"filename\":\"${ozz_temp_directory}/anim_good_part_content.ozz\",\"tracks\":[{\"properties\":[{\"joint_name\":\"joint0\",\"property_name\":\"property0\",\"type\":\"float1\",\"filename\":\"${ozz_temp_directory}/anim_should_not_exist.ozz\"}]}]}]}")
|
||||
set_tests_properties(test2ozz_anim_track_import_failed PROPERTIES PASS_REGULAR_EXPRESSION "One of track failed when import" DEPENDS test2ozz_skel_simple)
|
||||
|
||||
# Ensures nothing was outputted.
|
||||
add_test(NAME test2ozz_anim_output COMMAND ${CMAKE_COMMAND} -E copy "${ozz_temp_directory}/anim_should_not_exist.ozz" "${ozz_temp_directory}/anim_should_not_exist_too.ozz")
|
||||
set_tests_properties(test2ozz_anim_output PROPERTIES WILL_FAIL true)
|
||||
@@ -208,7 +216,8 @@ set_tests_properties(test2ozz_anim_output PROPERTIES
|
||||
test2ozz_anim_track_bad_joint_name
|
||||
test2ozz_anim_track_bad_ppt_name
|
||||
test2ozz_anim_track_bad_type
|
||||
test2ozz_anim_track_invalid_type")
|
||||
test2ozz_anim_track_invalid_type
|
||||
test2ozz_anim_track_import_failed")
|
||||
|
||||
# Run test2ozz animation import passing tests
|
||||
#----------------------------
|
||||
@@ -391,8 +400,10 @@ target_link_libraries(test_fuse_ozz_animation_tools
|
||||
ozz_options
|
||||
json
|
||||
gtest)
|
||||
#target_copy_shared_libraries(test_fuse_ozz_animation_tools)
|
||||
|
||||
set_target_properties(test_fuse_ozz_animation_tools PROPERTIES FOLDER "ozz/tests/animation_offline")
|
||||
target_compile_definitions(test_fuse_ozz_animation_tools PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:OZZ_BUILD_ANIMATIONTOOLS_LIB>)
|
||||
|
||||
add_test(NAME test_fuse_ozz_animation_tools_no_arg COMMAND test_fuse_ozz_animation_tools)
|
||||
set_tests_properties(test_fuse_ozz_animation_tools_no_arg PROPERTIES PASS_REGULAR_EXPRESSION "Required option \"file\" is not specified.")
|
||||
|
||||
@@ -45,12 +45,22 @@ class TestConverter : public ozz::animation::offline::OzzImporter {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char good_content[] = "good content";
|
||||
|
||||
char buffer[256];
|
||||
bool valid =
|
||||
file_->Read(buffer, sizeof(buffer)) >= sizeof(good_content) - 1 &&
|
||||
memcmp(buffer, good_content, sizeof(good_content) - 1) == 0;
|
||||
file_->Seek(0, ozz::io::File::kSet);
|
||||
bool valid = true;
|
||||
{
|
||||
const char good_content[] = "good content";
|
||||
valid = file_->Read(buffer, sizeof(buffer)) >= sizeof(good_content) - 1 &&
|
||||
memcmp(buffer, good_content, sizeof(good_content) - 1) == 0;
|
||||
file_->Seek(0, ozz::io::File::kSet);
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
const char partial_good_content[] = "partial good content";
|
||||
valid = file_->Read(buffer, sizeof(buffer)) >= sizeof(partial_good_content) - 1 &&
|
||||
memcmp(buffer, partial_good_content, sizeof(partial_good_content) - 1) == 0;
|
||||
file_->Seek(0, ozz::io::File::kSet);
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
@@ -172,6 +182,18 @@ class TestConverter : public ozz::animation::offline::OzzImporter {
|
||||
return names;
|
||||
}
|
||||
}
|
||||
|
||||
// Handles one of animation is good
|
||||
{
|
||||
file_->Seek(0, ozz::io::File::kSet);
|
||||
const char content[] = "partial good content";
|
||||
if (file_->Read(buffer, sizeof(buffer)) >= sizeof(content) - 1 &&
|
||||
memcmp(buffer, content, sizeof(content) - 1) == 0) {
|
||||
names.push_back("bad");
|
||||
names.push_back("good");
|
||||
return names;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return names;
|
||||
@@ -223,6 +245,20 @@ class TestConverter : public ozz::animation::offline::OzzImporter {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{ // Handles one of animation is good
|
||||
file_->Seek(0, ozz::io::File::kSet);
|
||||
const char content[] = "partial good content";
|
||||
if (file_->Read(buffer, sizeof(buffer)) >= sizeof(content) - 1 &&
|
||||
memcmp(buffer, content, sizeof(content) - 1) == 0){
|
||||
|
||||
if (strcmp(_animation_name, "good") == 0){
|
||||
_animation->tracks.resize(_skeleton.num_joints());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -254,6 +290,21 @@ class TestConverter : public ozz::animation::offline::OzzImporter {
|
||||
(void)_sampling_rate;
|
||||
(void)_track;
|
||||
|
||||
{
|
||||
char buffer[256];
|
||||
const char content[] = "partial good content";
|
||||
if (strcmp(_animation_name, "good") == 0 ||
|
||||
strcmp(_animation_name, "bad") == 0) {
|
||||
file_->Seek(0, ozz::io::File::kSet);
|
||||
bool valid = file_->Read(buffer, sizeof(buffer)) >= sizeof(content) - 1;
|
||||
valid &= memcmp(buffer, content, sizeof(content) - 1) == 0;
|
||||
if (valid){
|
||||
return !((strcmp(_node_name, "joint0") == 0) &&
|
||||
(strcmp(_track_name, "property0") == 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// joint2 doesn't have the property
|
||||
bool found = (strcmp(_node_name, "joint0") == 0 ||
|
||||
strcmp(_node_name, "joint1") == 0) &&
|
||||
|
||||
@@ -25,25 +25,22 @@
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "ozz/animation/offline/track_builder.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ozz/base/maths/gtest_math_helper.h"
|
||||
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
|
||||
#include "ozz/animation/offline/raw_track.h"
|
||||
#include "ozz/animation/runtime/track.h"
|
||||
#include "ozz/animation/runtime/track_sampling_job.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
using ozz::animation::FloatTrack;
|
||||
#include "gtest/gtest.h"
|
||||
#include "ozz/animation/offline/raw_track.h"
|
||||
#include "ozz/animation/offline/track_builder.h"
|
||||
#include "ozz/animation/runtime/track.h"
|
||||
#include "ozz/animation/runtime/track_sampling_job.h"
|
||||
#include "ozz/base/maths/gtest_math_helper.h"
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
|
||||
using ozz::animation::Float2Track;
|
||||
using ozz::animation::Float3Track;
|
||||
using ozz::animation::Float4Track;
|
||||
using ozz::animation::QuaternionTrack;
|
||||
using ozz::animation::FloatTrack;
|
||||
using ozz::animation::FloatTrackSamplingJob;
|
||||
using ozz::animation::QuaternionTrack;
|
||||
using ozz::animation::offline::RawFloatTrack;
|
||||
using ozz::animation::offline::RawTrackInterpolation;
|
||||
using ozz::animation::offline::TrackBuilder;
|
||||
@@ -731,6 +728,40 @@ TEST(BuildMixed, TrackBuilder) {
|
||||
ASSERT_TRUE(sampling.Run());
|
||||
EXPECT_FLOAT_EQ(result, 0.f);
|
||||
}
|
||||
TEST(Move, TrackBuilder) {
|
||||
TrackBuilder builder;
|
||||
RawFloatTrack raw_float_track;
|
||||
|
||||
const RawFloatTrack::Keyframe key0 = {RawTrackInterpolation::kLinear, 0.f,
|
||||
0.f};
|
||||
raw_float_track.keyframes.push_back(key0);
|
||||
const RawFloatTrack::Keyframe key1 = {RawTrackInterpolation::kStep, .5f,
|
||||
46.f};
|
||||
raw_float_track.keyframes.push_back(key1);
|
||||
const RawFloatTrack::Keyframe key2 = {RawTrackInterpolation::kLinear, .7f,
|
||||
0.f};
|
||||
raw_float_track.keyframes.push_back(key2);
|
||||
|
||||
{ // Move constructor
|
||||
raw_float_track.name = "track1";
|
||||
ozz::unique_ptr<FloatTrack> track(builder(raw_float_track));
|
||||
const FloatTrack ctrack(std::move(*track));
|
||||
EXPECT_STREQ(ctrack.name(), "track1");
|
||||
}
|
||||
|
||||
{ // Move assignment
|
||||
raw_float_track.name = "track1";
|
||||
ozz::unique_ptr<FloatTrack> track1(builder(raw_float_track));
|
||||
EXPECT_STREQ(track1->name(), "track1");
|
||||
|
||||
raw_float_track.name = "track2";
|
||||
ozz::unique_ptr<FloatTrack> track2(builder(raw_float_track));
|
||||
EXPECT_STREQ(track2->name(), "track2");
|
||||
|
||||
*track2 = std::move(*track1);
|
||||
EXPECT_STREQ(track2->name(), "track1");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Float, TrackBuilder) {
|
||||
TrackBuilder builder;
|
||||
|
||||
@@ -4,6 +4,7 @@ add_executable(test_sampling_job
|
||||
target_link_libraries(test_sampling_job
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_sampling_job)
|
||||
set_target_properties(test_sampling_job PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_sampling_job COMMAND test_sampling_job)
|
||||
|
||||
@@ -13,6 +14,7 @@ add_executable(test_blending_job
|
||||
target_link_libraries(test_blending_job
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_blending_job)
|
||||
set_target_properties(test_blending_job PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_blending_job COMMAND test_blending_job)
|
||||
|
||||
@@ -22,6 +24,7 @@ add_executable(test_local_to_model_job
|
||||
target_link_libraries(test_local_to_model_job
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_local_to_model_job)
|
||||
set_target_properties(test_local_to_model_job PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_local_to_model_job COMMAND test_local_to_model_job)
|
||||
|
||||
@@ -30,6 +33,7 @@ add_executable(test_animation_archive
|
||||
target_link_libraries(test_animation_archive
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_animation_archive)
|
||||
set_target_properties(test_animation_archive PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_animation_archive COMMAND test_animation_archive)
|
||||
|
||||
@@ -39,6 +43,7 @@ target_link_libraries(test_animation_archive_versioning
|
||||
ozz_animation
|
||||
ozz_options
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_animation_archive_versioning)
|
||||
set_target_properties(test_animation_archive_versioning PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_animation_archive_versioning_le COMMAND test_animation_archive_versioning "--file=${ozz_media_directory}/bin/versioning/animation_v6_le.ozz" "--tracks=67" "--duration=.66666667" "--name=run")
|
||||
add_test(NAME test_animation_archive_versioning_be COMMAND test_animation_archive_versioning "--file=${ozz_media_directory}/bin/versioning/animation_v6_be.ozz" "--tracks=67" "--duration=.66666667" "--name=run")
|
||||
@@ -60,6 +65,7 @@ add_executable(test_skeleton_archive
|
||||
target_link_libraries(test_skeleton_archive
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_skeleton_archive)
|
||||
set_target_properties(test_skeleton_archive PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_skeleton_archive COMMAND test_skeleton_archive)
|
||||
|
||||
@@ -69,6 +75,7 @@ target_link_libraries(test_skeleton_archive_versioning
|
||||
ozz_animation
|
||||
ozz_options
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_skeleton_archive_versioning)
|
||||
set_target_properties(test_skeleton_archive_versioning PROPERTIES FOLDER "ozz/tests/animation")
|
||||
|
||||
# Previous skeleton versions.
|
||||
@@ -84,6 +91,7 @@ add_executable(test_skeleton_utils
|
||||
target_link_libraries(test_skeleton_utils
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_skeleton_utils)
|
||||
set_target_properties(test_skeleton_utils PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_skeleton_utils COMMAND test_skeleton_utils)
|
||||
|
||||
@@ -92,6 +100,7 @@ add_executable(test_animation_utils
|
||||
target_link_libraries(test_animation_utils
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_animation_utils)
|
||||
set_target_properties(test_animation_utils PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_animation_utils COMMAND test_skeleton_utils)
|
||||
|
||||
@@ -103,6 +112,7 @@ target_link_libraries(test_track_sampling_job
|
||||
ozz_animation
|
||||
ozz_base
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_track_sampling_job)
|
||||
set_target_properties(test_track_sampling_job PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_track_sampling_job COMMAND test_track_sampling_job)
|
||||
|
||||
@@ -115,6 +125,7 @@ target_link_libraries(test_track_triggering_job
|
||||
ozz_animation
|
||||
ozz_base
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_track_triggering_job)
|
||||
set_target_properties(test_track_triggering_job PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_track_triggering_job COMMAND test_track_triggering_job)
|
||||
|
||||
@@ -123,6 +134,7 @@ add_executable(test_track_archive
|
||||
target_link_libraries(test_track_archive
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_track_archive)
|
||||
set_target_properties(test_track_archive PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_track_archive COMMAND test_track_archive)
|
||||
|
||||
@@ -131,6 +143,7 @@ add_executable(test_ik_aim_job
|
||||
target_link_libraries(test_ik_aim_job
|
||||
ozz_animation
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_ik_aim_job)
|
||||
set_target_properties(test_ik_aim_job PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_ik_aim_job COMMAND test_ik_aim_job)
|
||||
|
||||
@@ -139,6 +152,7 @@ add_executable(test_ik_two_bone_job
|
||||
target_link_libraries(test_ik_two_bone_job
|
||||
ozz_animation
|
||||
gtest)
|
||||
target_copy_shared_libraries(test_ik_two_bone_job)
|
||||
set_target_properties(test_ik_two_bone_job PROPERTIES FOLDER "ozz/tests/animation")
|
||||
add_test(NAME test_ik_two_bone_job COMMAND test_ik_two_bone_job)
|
||||
|
||||
@@ -148,8 +162,10 @@ add_executable(test_fuse_animation
|
||||
sampling_job_tests.cc
|
||||
${PROJECT_BINARY_DIR}/src_fused/ozz_animation.cc)
|
||||
add_dependencies(test_fuse_animation BUILD_FUSE_ozz_animation)
|
||||
target_compile_definitions(test_fuse_animation PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:OZZ_BUILD_ANIMATION_LIB>)
|
||||
target_link_libraries(test_fuse_animation
|
||||
ozz_animation_offline
|
||||
gtest)
|
||||
#target_copy_shared_libraries(test_fuse_animation)
|
||||
add_test(NAME test_fuse_animation COMMAND test_fuse_animation)
|
||||
set_target_properties(test_fuse_animation PROPERTIES FOLDER "ozz/tests/animation")
|
||||
|
||||
@@ -25,25 +25,20 @@
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "ozz/animation/runtime/animation.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ozz/base/maths/gtest_math_helper.h"
|
||||
|
||||
#include "ozz/base/io/archive.h"
|
||||
#include "ozz/base/io/stream.h"
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
|
||||
#include "ozz/base/maths/soa_transform.h"
|
||||
|
||||
#include "ozz/animation/runtime/sampling_job.h"
|
||||
|
||||
#include "ozz/animation/offline/animation_builder.h"
|
||||
#include "ozz/animation/offline/raw_animation.h"
|
||||
#include "ozz/animation/runtime/animation.h"
|
||||
#include "ozz/animation/runtime/sampling_job.h"
|
||||
#include "ozz/base/io/archive.h"
|
||||
#include "ozz/base/io/stream.h"
|
||||
#include "ozz/base/maths/gtest_math_helper.h"
|
||||
#include "ozz/base/maths/soa_transform.h"
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
|
||||
using ozz::animation::Animation;
|
||||
using ozz::animation::offline::RawAnimation;
|
||||
using ozz::animation::offline::AnimationBuilder;
|
||||
using ozz::animation::offline::RawAnimation;
|
||||
|
||||
TEST(Empty, AnimationSerialize) {
|
||||
ozz::io::MemoryStream stream;
|
||||
@@ -112,10 +107,10 @@ TEST(Filled, AnimationSerialize) {
|
||||
|
||||
// Needs to sample to test the animation.
|
||||
ozz::animation::SamplingJob job;
|
||||
ozz::animation::SamplingCache cache(1);
|
||||
ozz::animation::SamplingJob::Context context(1);
|
||||
ozz::math::SoaTransform output[1];
|
||||
job.animation = o_animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
|
||||
// Samples and compares the two animations
|
||||
|
||||
@@ -36,7 +36,7 @@ TEST(JobValidity, BlendingJob) {
|
||||
const ozz::math::SoaTransform identity = ozz::math::SoaTransform::identity();
|
||||
const ozz::math::SimdFloat4 zero = ozz::math::simd_float4::zero();
|
||||
BlendingJob::Layer layers[2];
|
||||
const ozz::math::SoaTransform bind_poses[3] = {identity, identity, identity};
|
||||
const ozz::math::SoaTransform rest_poses[3] = {identity, identity, identity};
|
||||
const ozz::math::SoaTransform input_transforms[3] = {identity, identity,
|
||||
identity};
|
||||
ozz::math::SoaTransform output_transforms[3] = {identity, identity, identity};
|
||||
@@ -54,18 +54,18 @@ TEST(JobValidity, BlendingJob) {
|
||||
{ // Invalid output.
|
||||
BlendingJob job;
|
||||
job.layers = {layers, layers + 2};
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
EXPECT_FALSE(job.Validate());
|
||||
EXPECT_FALSE(job.Run());
|
||||
}
|
||||
{ // Layers are optional.
|
||||
BlendingJob job;
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
job.output = {output_transforms, output_transforms + 2};
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
}
|
||||
{ // Invalid bind pose.
|
||||
{ // Invalid rest pose.
|
||||
BlendingJob job;
|
||||
job.layers = {layers, layers + 2};
|
||||
job.output = {output_transforms, output_transforms + 2};
|
||||
@@ -79,7 +79,7 @@ TEST(JobValidity, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.layers = invalid_layers;
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
job.output = {output_transforms, output_transforms + 2};
|
||||
EXPECT_FALSE(job.Validate());
|
||||
EXPECT_FALSE(job.Run());
|
||||
@@ -87,7 +87,7 @@ TEST(JobValidity, BlendingJob) {
|
||||
{ // Invalid output range, smaller output.
|
||||
BlendingJob job;
|
||||
job.layers = {layers, layers + 2};
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
job.output = {output_transforms, output_transforms + 1};
|
||||
EXPECT_FALSE(job.Validate());
|
||||
EXPECT_FALSE(job.Run());
|
||||
@@ -96,7 +96,7 @@ TEST(JobValidity, BlendingJob) {
|
||||
{ // Invalid smaller input.
|
||||
BlendingJob job;
|
||||
job.layers = {layers, layers + 2};
|
||||
job.bind_pose = {bind_poses, bind_poses + 3};
|
||||
job.rest_pose = {rest_poses, rest_poses + 3};
|
||||
job.output = {output_transforms, output_transforms + 3};
|
||||
EXPECT_FALSE(job.Validate());
|
||||
EXPECT_FALSE(job.Run());
|
||||
@@ -106,7 +106,7 @@ TEST(JobValidity, BlendingJob) {
|
||||
BlendingJob job;
|
||||
job.threshold = 0.f;
|
||||
job.layers = {layers, layers + 2};
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
job.output = {output_transforms, output_transforms + 2};
|
||||
EXPECT_FALSE(job.Validate());
|
||||
EXPECT_FALSE(job.Run());
|
||||
@@ -117,7 +117,7 @@ TEST(JobValidity, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.layers = {layers, layers + 2};
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
job.output = {output_transforms, output_transforms + 2};
|
||||
EXPECT_FALSE(job.Validate());
|
||||
EXPECT_FALSE(job.Run());
|
||||
@@ -128,7 +128,7 @@ TEST(JobValidity, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.layers = {layers, layers + 2};
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
job.output = {output_transforms, output_transforms + 2};
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -139,7 +139,7 @@ TEST(JobValidity, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.layers = {layers, layers + 2};
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
job.output = {output_transforms, output_transforms + 2};
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -150,7 +150,7 @@ TEST(JobValidity, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.layers = {layers, layers + 2};
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
job.output = {output_transforms, output_transforms + 3};
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -158,7 +158,7 @@ TEST(JobValidity, BlendingJob) {
|
||||
|
||||
{ // Valid no layers.
|
||||
BlendingJob job;
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
job.output = {output_transforms, output_transforms + 2};
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -171,7 +171,7 @@ TEST(JobValidityAdditive, BlendingJob) {
|
||||
BlendingJob::Layer layers[2];
|
||||
BlendingJob::Layer additive_layers[2];
|
||||
|
||||
const ozz::math::SoaTransform bind_poses[3] = {identity, identity, identity};
|
||||
const ozz::math::SoaTransform rest_poses[3] = {identity, identity, identity};
|
||||
const ozz::math::SoaTransform input_transforms[3] = {identity, identity,
|
||||
identity};
|
||||
ozz::math::SoaTransform output_transforms[3] = {identity, identity, identity};
|
||||
@@ -186,7 +186,7 @@ TEST(JobValidityAdditive, BlendingJob) {
|
||||
{ // Valid additive job, no normal blending.
|
||||
BlendingJob job;
|
||||
job.additive_layers = additive_layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -197,7 +197,7 @@ TEST(JobValidityAdditive, BlendingJob) {
|
||||
BlendingJob job;
|
||||
job.layers = layers;
|
||||
job.additive_layers = additive_layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -211,7 +211,7 @@ TEST(JobValidityAdditive, BlendingJob) {
|
||||
BlendingJob job;
|
||||
job.layers = layers;
|
||||
job.additive_layers = invalid_layers;
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
job.output = {output_transforms, output_transforms + 2};
|
||||
EXPECT_FALSE(job.Validate());
|
||||
EXPECT_FALSE(job.Run());
|
||||
@@ -222,7 +222,7 @@ TEST(JobValidityAdditive, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.additive_layers = additive_layers;
|
||||
job.bind_pose = {bind_poses, bind_poses + 2};
|
||||
job.rest_pose = {rest_poses, rest_poses + 2};
|
||||
job.output = {output_transforms, output_transforms + 2};
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -232,23 +232,23 @@ TEST(JobValidityAdditive, BlendingJob) {
|
||||
TEST(Empty, BlendingJob) {
|
||||
const ozz::math::SoaTransform identity = ozz::math::SoaTransform::identity();
|
||||
|
||||
// Initialize bind pose.
|
||||
ozz::math::SoaTransform bind_poses[2] = {identity, identity};
|
||||
bind_poses[0].translation = ozz::math::SoaFloat3::Load(
|
||||
// Initialize rest pose.
|
||||
ozz::math::SoaTransform rest_poses[2] = {identity, identity};
|
||||
rest_poses[0].translation = ozz::math::SoaFloat3::Load(
|
||||
ozz::math::simd_float4::Load(0.f, 1.f, 2.f, 3.f),
|
||||
ozz::math::simd_float4::Load(4.f, 5.f, 6.f, 7.f),
|
||||
ozz::math::simd_float4::Load(8.f, 9.f, 10.f, 11.f));
|
||||
bind_poses[0].scale = ozz::math::SoaFloat3::Load(
|
||||
rest_poses[0].scale = ozz::math::SoaFloat3::Load(
|
||||
ozz::math::simd_float4::Load(0.f, 10.f, 20.f, 30.f),
|
||||
ozz::math::simd_float4::Load(40.f, 50.f, 60.f, 70.f),
|
||||
ozz::math::simd_float4::Load(80.f, 90.f, 100.f, 110.f));
|
||||
bind_poses[1].translation = bind_poses[0].translation *
|
||||
rest_poses[1].translation = rest_poses[0].translation *
|
||||
ozz::math::simd_float4::Load(2.f, 2.f, 2.f, 2.f);
|
||||
bind_poses[1].scale =
|
||||
bind_poses[0].scale * ozz::math::simd_float4::Load(2.f, 2.f, 2.f, 2.f);
|
||||
rest_poses[1].scale =
|
||||
rest_poses[0].scale * ozz::math::simd_float4::Load(2.f, 2.f, 2.f, 2.f);
|
||||
|
||||
BlendingJob job;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
ozz::math::SoaTransform output_transforms[2];
|
||||
job.output = output_transforms;
|
||||
|
||||
@@ -282,14 +282,14 @@ TEST(Weight, BlendingJob) {
|
||||
input_transforms[1][0].translation = -input_transforms[0][0].translation;
|
||||
input_transforms[1][1].translation = -input_transforms[0][1].translation;
|
||||
|
||||
// Initialize bind pose.
|
||||
ozz::math::SoaTransform bind_poses[2] = {identity, identity};
|
||||
bind_poses[0].scale = ozz::math::SoaFloat3::Load(
|
||||
// Initialize rest pose.
|
||||
ozz::math::SoaTransform rest_poses[2] = {identity, identity};
|
||||
rest_poses[0].scale = ozz::math::SoaFloat3::Load(
|
||||
ozz::math::simd_float4::Load(0.f, 1.f, 2.f, 3.f),
|
||||
ozz::math::simd_float4::Load(4.f, 5.f, 6.f, 7.f),
|
||||
ozz::math::simd_float4::Load(8.f, 9.f, 10.f, 11.f));
|
||||
bind_poses[1].scale =
|
||||
bind_poses[0].scale * ozz::math::simd_float4::Load(2.f, 2.f, 2.f, 2.f);
|
||||
rest_poses[1].scale =
|
||||
rest_poses[0].scale * ozz::math::simd_float4::Load(2.f, 2.f, 2.f, 2.f);
|
||||
|
||||
{
|
||||
BlendingJob::Layer layers[2];
|
||||
@@ -300,7 +300,7 @@ TEST(Weight, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.layers = layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
|
||||
// Weight 0 (a bit less must give the same result) for the first layer,
|
||||
@@ -373,18 +373,18 @@ TEST(JointWeights, BlendingJob) {
|
||||
ozz::math::simd_float4::Load(1.f, 0.f, 1.f, 1.f)},
|
||||
{ozz::math::simd_float4::Load(1.f, 1.f, 1.f, 0.f),
|
||||
ozz::math::simd_float4::Load(0.f, 1.f, 1.f, 1.f)}};
|
||||
// Initialize bind pose.
|
||||
ozz::math::SoaTransform bind_poses[2] = {identity, identity};
|
||||
bind_poses[0].translation = ozz::math::SoaFloat3::Load(
|
||||
// Initialize rest pose.
|
||||
ozz::math::SoaTransform rest_poses[2] = {identity, identity};
|
||||
rest_poses[0].translation = ozz::math::SoaFloat3::Load(
|
||||
ozz::math::simd_float4::Load(10.f, 11.f, 12.f, 13.f),
|
||||
ozz::math::simd_float4::Load(14.f, 15.f, 16.f, 17.f),
|
||||
ozz::math::simd_float4::Load(18.f, 19.f, 20.f, 21.f));
|
||||
bind_poses[0].scale = ozz::math::SoaFloat3::Load(
|
||||
rest_poses[0].scale = ozz::math::SoaFloat3::Load(
|
||||
ozz::math::simd_float4::Load(0.f, 1.f, 2.f, 3.f),
|
||||
ozz::math::simd_float4::Load(4.f, 5.f, 6.f, 7.f),
|
||||
ozz::math::simd_float4::Load(8.f, 9.f, 10.f, 11.f));
|
||||
bind_poses[1].scale =
|
||||
bind_poses[0].scale * ozz::math::simd_float4::Load(2.f, 2.f, 2.f, 2.f);
|
||||
rest_poses[1].scale =
|
||||
rest_poses[0].scale * ozz::math::simd_float4::Load(2.f, 2.f, 2.f, 2.f);
|
||||
|
||||
BlendingJob::Layer layers[2];
|
||||
layers[0].transform = input_transforms[0];
|
||||
@@ -397,7 +397,7 @@ TEST(JointWeights, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.layers = layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
|
||||
layers[0].weight = .5f;
|
||||
@@ -419,7 +419,7 @@ TEST(JointWeights, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.layers = layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
|
||||
layers[0].weight = 0.f;
|
||||
@@ -445,9 +445,9 @@ TEST(Normalize, BlendingJob) {
|
||||
// Initialize inputs.
|
||||
ozz::math::SoaTransform input_transforms[2][1] = {{identity}, {identity}};
|
||||
|
||||
// Initialize bind pose.
|
||||
ozz::math::SoaTransform bind_poses[1] = {identity};
|
||||
bind_poses[0].scale = ozz::math::SoaFloat3::Load(
|
||||
// Initialize rest pose.
|
||||
ozz::math::SoaTransform rest_poses[1] = {identity};
|
||||
rest_poses[0].scale = ozz::math::SoaFloat3::Load(
|
||||
ozz::math::simd_float4::Load(0.f, 1.f, 2.f, 3.f),
|
||||
ozz::math::simd_float4::Load(4.f, 5.f, 6.f, 7.f),
|
||||
ozz::math::simd_float4::Load(8.f, 9.f, 10.f, 11.f));
|
||||
@@ -483,7 +483,7 @@ TEST(Normalize, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.layers = layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -520,7 +520,7 @@ TEST(Normalize, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.layers = layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -559,7 +559,7 @@ TEST(Normalize, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.layers = layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -578,9 +578,9 @@ TEST(Threshold, BlendingJob) {
|
||||
// Initialize inputs.
|
||||
ozz::math::SoaTransform input_transforms[2][1] = {{identity}, {identity}};
|
||||
|
||||
// Initialize bind pose.
|
||||
ozz::math::SoaTransform bind_poses[1] = {identity};
|
||||
bind_poses[0].scale = ozz::math::SoaFloat3::Load(
|
||||
// Initialize rest pose.
|
||||
ozz::math::SoaTransform rest_poses[1] = {identity};
|
||||
rest_poses[0].scale = ozz::math::SoaFloat3::Load(
|
||||
ozz::math::simd_float4::Load(0.f, 1.f, 2.f, 3.f),
|
||||
ozz::math::simd_float4::Load(4.f, 5.f, 6.f, 7.f),
|
||||
ozz::math::simd_float4::Load(8.f, 9.f, 10.f, 11.f));
|
||||
@@ -606,7 +606,7 @@ TEST(Threshold, BlendingJob) {
|
||||
BlendingJob job;
|
||||
job.threshold = .1f;
|
||||
job.layers = layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -632,7 +632,7 @@ TEST(Threshold, BlendingJob) {
|
||||
BlendingJob job;
|
||||
job.threshold = .1f;
|
||||
job.layers = layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -669,8 +669,8 @@ TEST(AdditiveWeight, BlendingJob) {
|
||||
input_transforms[1][0].rotation = Conjugate(input_transforms[0][0].rotation);
|
||||
input_transforms[1][0].scale = -input_transforms[0][0].scale;
|
||||
|
||||
// Initialize bind pose.
|
||||
ozz::math::SoaTransform bind_poses[1] = {identity};
|
||||
// Initialize rest pose.
|
||||
ozz::math::SoaTransform rest_poses[1] = {identity};
|
||||
|
||||
{
|
||||
BlendingJob::Layer layers[1];
|
||||
@@ -680,7 +680,7 @@ TEST(AdditiveWeight, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.additive_layers = layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
|
||||
// No weight for the 1st layer.
|
||||
@@ -731,7 +731,7 @@ TEST(AdditiveWeight, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.additive_layers = layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
|
||||
// No weight for the 1st layer.
|
||||
@@ -803,8 +803,8 @@ TEST(AdditiveJointWeight, BlendingJob) {
|
||||
ozz::math::SimdFloat4 joint_weights[1] = {
|
||||
ozz::math::simd_float4::Load(1.f, .5f, 0.f, -1.f)};
|
||||
|
||||
// Initialize bind pose.
|
||||
ozz::math::SoaTransform bind_poses[1] = {identity};
|
||||
// Initialize rest pose.
|
||||
ozz::math::SoaTransform rest_poses[1] = {identity};
|
||||
|
||||
{
|
||||
BlendingJob::Layer layers[1];
|
||||
@@ -815,7 +815,7 @@ TEST(AdditiveJointWeight, BlendingJob) {
|
||||
|
||||
BlendingJob job;
|
||||
job.additive_layers = layers;
|
||||
job.bind_pose = bind_poses;
|
||||
job.rest_pose = rest_poses;
|
||||
job.output = output_transforms;
|
||||
|
||||
// No weight for the 1st layer.
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
|
||||
using ozz::animation::Animation;
|
||||
using ozz::animation::SamplingCache;
|
||||
using ozz::animation::SamplingJob;
|
||||
using ozz::animation::offline::AnimationBuilder;
|
||||
using ozz::animation::offline::RawAnimation;
|
||||
@@ -49,8 +48,8 @@ TEST(JobValidity, SamplingJob) {
|
||||
ozz::unique_ptr<Animation> animation(builder(raw_animation));
|
||||
ASSERT_TRUE(animation);
|
||||
|
||||
// Allocates cache.
|
||||
SamplingCache cache(1);
|
||||
// Allocates context.
|
||||
SamplingJob::Context context(1);
|
||||
|
||||
{ // Empty/default job
|
||||
SamplingJob job;
|
||||
@@ -61,7 +60,7 @@ TEST(JobValidity, SamplingJob) {
|
||||
{ // Invalid output
|
||||
SamplingJob job;
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
EXPECT_FALSE(job.Validate());
|
||||
EXPECT_FALSE(job.Run());
|
||||
}
|
||||
@@ -70,13 +69,13 @@ TEST(JobValidity, SamplingJob) {
|
||||
ozz::math::SoaTransform output[1];
|
||||
|
||||
SamplingJob job;
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
EXPECT_FALSE(job.Validate());
|
||||
EXPECT_FALSE(job.Run());
|
||||
}
|
||||
|
||||
{ // Invalid cache.
|
||||
{ // Invalid context.
|
||||
ozz::math::SoaTransform output[1];
|
||||
|
||||
SamplingJob job;
|
||||
@@ -86,48 +85,66 @@ TEST(JobValidity, SamplingJob) {
|
||||
EXPECT_FALSE(job.Run());
|
||||
}
|
||||
|
||||
{ // Invalid cache size.
|
||||
SamplingCache zero_cache(0);
|
||||
{ // Invalid context size.
|
||||
SamplingJob::Context zero_cache(0);
|
||||
ozz::math::SoaTransform output[1];
|
||||
|
||||
SamplingJob job;
|
||||
job.animation = animation.get();
|
||||
job.cache = &zero_cache;
|
||||
job.context = &zero_cache;
|
||||
job.output = output;
|
||||
EXPECT_FALSE(job.Validate());
|
||||
EXPECT_FALSE(job.Run());
|
||||
}
|
||||
|
||||
{ // Invalid job with smaller output.
|
||||
{ // Invalid job with empty output.
|
||||
ozz::math::SoaTransform* output = nullptr;
|
||||
SamplingJob job;
|
||||
job.ratio =
|
||||
2155.f; // Any time ratio can be set, it's clamped in unit interval.
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = ozz::span<ozz::math::SoaTransform>(output, size_t(0));
|
||||
EXPECT_FALSE(job.Validate());
|
||||
EXPECT_FALSE(job.Run());
|
||||
}
|
||||
|
||||
{ // valid job with output smaller than animation, but not empty.
|
||||
RawAnimation big_raw_animation;
|
||||
big_raw_animation.duration = 1.f;
|
||||
big_raw_animation.tracks.resize(2);
|
||||
ozz::unique_ptr<Animation> big_animation(builder(big_raw_animation));
|
||||
ASSERT_TRUE(big_animation);
|
||||
|
||||
ozz::math::SoaTransform output[1];
|
||||
SamplingJob job;
|
||||
job.ratio =
|
||||
2155.f; // Any time ratio can be set, it's clamped in unit interval.
|
||||
job.animation = big_animation.get();
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
}
|
||||
|
||||
{ // Valid job.
|
||||
ozz::math::SoaTransform output[1];
|
||||
SamplingJob job;
|
||||
job.ratio = 2155.f; // Any time can be set.
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
}
|
||||
|
||||
{ // Valid job with bigger cache.
|
||||
SamplingCache big_cache(2);
|
||||
{ // Valid job with bigger context.
|
||||
SamplingJob::Context big_cache(2);
|
||||
ozz::math::SoaTransform output[1];
|
||||
SamplingJob job;
|
||||
job.ratio = 2155.f; // Any time can be set.
|
||||
job.animation = animation.get();
|
||||
job.cache = &big_cache;
|
||||
job.context = &big_cache;
|
||||
job.output = output;
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -138,7 +155,7 @@ TEST(JobValidity, SamplingJob) {
|
||||
SamplingJob job;
|
||||
job.ratio = 2155.f; // Any time can be set.
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -149,7 +166,7 @@ TEST(JobValidity, SamplingJob) {
|
||||
Animation default_animation;
|
||||
SamplingJob job;
|
||||
job.animation = &default_animation;
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -165,7 +182,7 @@ TEST(Sampling, SamplingJob) {
|
||||
raw_animation.duration = 1.f;
|
||||
raw_animation.tracks.resize(4);
|
||||
|
||||
SamplingCache cache(4);
|
||||
SamplingJob::Context context(4);
|
||||
|
||||
// Raw animation inputs.
|
||||
// 0 1
|
||||
@@ -239,7 +256,7 @@ TEST(Sampling, SamplingJob) {
|
||||
|
||||
SamplingJob job;
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
|
||||
for (size_t i = 0; i < OZZ_ARRAY_SIZE(result); ++i) {
|
||||
@@ -266,7 +283,7 @@ TEST(SamplingNoTrack, SamplingJob) {
|
||||
RawAnimation raw_animation;
|
||||
raw_animation.duration = 46.f;
|
||||
|
||||
SamplingCache cache(1);
|
||||
SamplingJob::Context context(1);
|
||||
|
||||
AnimationBuilder builder;
|
||||
ozz::unique_ptr<Animation> animation(builder(raw_animation));
|
||||
@@ -280,7 +297,7 @@ TEST(SamplingNoTrack, SamplingJob) {
|
||||
SamplingJob job;
|
||||
job.ratio = 0.f;
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -294,7 +311,7 @@ TEST(Sampling1Track0Key, SamplingJob) {
|
||||
raw_animation.duration = 46.f;
|
||||
raw_animation.tracks.resize(1); // Adds a joint.
|
||||
|
||||
SamplingCache cache(1);
|
||||
SamplingJob::Context context(1);
|
||||
|
||||
AnimationBuilder builder;
|
||||
ozz::unique_ptr<Animation> animation(builder(raw_animation));
|
||||
@@ -304,7 +321,7 @@ TEST(Sampling1Track0Key, SamplingJob) {
|
||||
|
||||
SamplingJob job;
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
|
||||
for (float t = -.2f; t < 1.2f; t += .1f) {
|
||||
@@ -327,7 +344,7 @@ TEST(Sampling1Track1Key, SamplingJob) {
|
||||
raw_animation.duration = 46.f;
|
||||
raw_animation.tracks.resize(1); // Adds a joint.
|
||||
|
||||
SamplingCache cache(1);
|
||||
SamplingJob::Context context(1);
|
||||
|
||||
const RawAnimation::TranslationKey tkey = {.3f,
|
||||
ozz::math::Float3(1.f, -1.f, 5.f)};
|
||||
@@ -341,7 +358,7 @@ TEST(Sampling1Track1Key, SamplingJob) {
|
||||
|
||||
SamplingJob job;
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
|
||||
for (float t = -.2f; t < 1.2f; t += .1f) {
|
||||
@@ -364,7 +381,7 @@ TEST(Sampling1Track2Keys, SamplingJob) {
|
||||
raw_animation.duration = 46.f;
|
||||
raw_animation.tracks.resize(1); // Adds a joint.
|
||||
|
||||
SamplingCache cache(1);
|
||||
SamplingJob::Context context(1);
|
||||
|
||||
const RawAnimation::TranslationKey tkey0 = {.5f,
|
||||
ozz::math::Float3(1.f, 2.f, 4.f)};
|
||||
@@ -382,7 +399,7 @@ TEST(Sampling1Track2Keys, SamplingJob) {
|
||||
|
||||
SamplingJob job;
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
|
||||
// Samples at t = 0.
|
||||
@@ -448,7 +465,7 @@ TEST(Sampling4Track2Keys, SamplingJob) {
|
||||
raw_animation.duration = 1.f;
|
||||
raw_animation.tracks.resize(4); // Adds a joint.
|
||||
|
||||
SamplingCache cache(1);
|
||||
SamplingJob::Context context(1);
|
||||
|
||||
const RawAnimation::TranslationKey tkey00 = {
|
||||
.5f, ozz::math::Float3(1.f, 2.f, 4.f)};
|
||||
@@ -488,7 +505,7 @@ TEST(Sampling4Track2Keys, SamplingJob) {
|
||||
|
||||
SamplingJob job;
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.output = output;
|
||||
|
||||
// Samples at t = 0.
|
||||
@@ -534,7 +551,7 @@ TEST(Cache, SamplingJob) {
|
||||
0.f, RawAnimation::TranslationKey::identity()};
|
||||
raw_animation.tracks[0].translations.push_back(empty_key);
|
||||
|
||||
SamplingCache cache(1);
|
||||
SamplingJob::Context context(1);
|
||||
ozz::unique_ptr<Animation> animations[2];
|
||||
|
||||
{
|
||||
@@ -560,7 +577,7 @@ TEST(Cache, SamplingJob) {
|
||||
|
||||
SamplingJob job;
|
||||
job.animation = animations[0].get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.ratio = 0.f;
|
||||
job.output = output;
|
||||
|
||||
@@ -573,14 +590,14 @@ TEST(Cache, SamplingJob) {
|
||||
EXPECT_SOAFLOAT3_EQ_EST(output[0].scale, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f,
|
||||
1.f, 1.f, 1.f, 1.f, 1.f);
|
||||
|
||||
// Re-uses cache.
|
||||
// Re-uses context.
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
EXPECT_SOAFLOAT3_EQ_EST(output[0].translation, 1.f, 0.f, 0.f, 0.f, -1.f, 0.f,
|
||||
0.f, 0.f, 5.f, 0.f, 0.f, 0.f);
|
||||
|
||||
// Invalidates cache.
|
||||
cache.Invalidate();
|
||||
// Invalidates context.
|
||||
context.Invalidate();
|
||||
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
@@ -615,14 +632,14 @@ TEST(CacheResize, SamplingJob) {
|
||||
ozz::unique_ptr<Animation> animation(builder(raw_animation));
|
||||
ASSERT_TRUE(animation);
|
||||
|
||||
// Empty cache by default
|
||||
SamplingCache cache;
|
||||
// Empty context by default
|
||||
SamplingJob::Context context;
|
||||
|
||||
ozz::math::SoaTransform output[7];
|
||||
|
||||
SamplingJob job;
|
||||
job.animation = animation.get();
|
||||
job.cache = &cache;
|
||||
job.context = &context;
|
||||
job.ratio = 0.f;
|
||||
job.output = output;
|
||||
|
||||
@@ -630,11 +647,11 @@ TEST(CacheResize, SamplingJob) {
|
||||
EXPECT_FALSE(job.Validate());
|
||||
|
||||
// Cache is ok.
|
||||
cache.Resize(7);
|
||||
context.Resize(7);
|
||||
EXPECT_TRUE(job.Validate());
|
||||
EXPECT_TRUE(job.Run());
|
||||
|
||||
// Cache is too small
|
||||
cache.Resize(1);
|
||||
context.Resize(1);
|
||||
EXPECT_FALSE(job.Validate());
|
||||
}
|
||||
|
||||
@@ -25,18 +25,13 @@
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "ozz/animation/runtime/skeleton.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "ozz/animation/offline/raw_skeleton.h"
|
||||
#include "ozz/animation/offline/skeleton_builder.h"
|
||||
|
||||
#include "ozz/animation/runtime/skeleton.h"
|
||||
#include "ozz/base/io/archive.h"
|
||||
#include "ozz/base/io/stream.h"
|
||||
|
||||
#include "ozz/base/maths/soa_transform.h"
|
||||
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
|
||||
using ozz::animation::Skeleton;
|
||||
@@ -109,20 +104,19 @@ TEST(Filled, SkeletonSerialize) {
|
||||
// Compares skeletons.
|
||||
EXPECT_EQ(o_skeleton->num_joints(), i_skeleton.num_joints());
|
||||
for (int i = 0; i < i_skeleton.num_joints(); ++i) {
|
||||
EXPECT_EQ(i_skeleton.joint_parents()[i],
|
||||
o_skeleton->joint_parents()[i]);
|
||||
EXPECT_EQ(i_skeleton.joint_parents()[i], o_skeleton->joint_parents()[i]);
|
||||
EXPECT_STREQ(i_skeleton.joint_names()[i], o_skeleton->joint_names()[i]);
|
||||
}
|
||||
for (int i = 0; i < (i_skeleton.num_joints() + 3) / 4; ++i) {
|
||||
EXPECT_TRUE(ozz::math::AreAllTrue(
|
||||
i_skeleton.joint_bind_poses()[i].translation ==
|
||||
o_skeleton->joint_bind_poses()[i].translation));
|
||||
EXPECT_TRUE(ozz::math::AreAllTrue(
|
||||
i_skeleton.joint_bind_poses()[i].rotation ==
|
||||
o_skeleton->joint_bind_poses()[i].rotation));
|
||||
EXPECT_TRUE(
|
||||
ozz::math::AreAllTrue(i_skeleton.joint_bind_poses()[i].scale ==
|
||||
o_skeleton->joint_bind_poses()[i].scale));
|
||||
ozz::math::AreAllTrue(i_skeleton.joint_rest_poses()[i].translation ==
|
||||
o_skeleton->joint_rest_poses()[i].translation));
|
||||
EXPECT_TRUE(
|
||||
ozz::math::AreAllTrue(i_skeleton.joint_rest_poses()[i].rotation ==
|
||||
o_skeleton->joint_rest_poses()[i].rotation));
|
||||
EXPECT_TRUE(
|
||||
ozz::math::AreAllTrue(i_skeleton.joint_rest_poses()[i].scale ==
|
||||
o_skeleton->joint_rest_poses()[i].scale));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,25 +25,23 @@
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "ozz/animation/offline/raw_skeleton.h"
|
||||
#include "ozz/animation/offline/skeleton_builder.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ozz/base/gtest_helper.h"
|
||||
#include "ozz/base/maths/gtest_math_helper.h"
|
||||
|
||||
#include "ozz/animation/offline/raw_skeleton.h"
|
||||
#include "ozz/animation/offline/skeleton_builder.h"
|
||||
#include "ozz/animation/runtime/skeleton.h"
|
||||
#include "ozz/animation/runtime/skeleton_utils.h"
|
||||
#include "ozz/base/gtest_helper.h"
|
||||
#include "ozz/base/maths/gtest_math_helper.h"
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
|
||||
using ozz::animation::Skeleton;
|
||||
using ozz::animation::offline::RawSkeleton;
|
||||
using ozz::animation::offline::SkeletonBuilder;
|
||||
|
||||
TEST(JointBindPose, SkeletonUtils) {
|
||||
TEST(JointRestPose, SkeletonUtils) {
|
||||
// Instantiates a builder objects with default parameters.
|
||||
SkeletonBuilder builder;
|
||||
|
||||
@@ -76,23 +74,23 @@ TEST(JointBindPose, SkeletonUtils) {
|
||||
EXPECT_EQ(skeleton->num_joints(), 3);
|
||||
|
||||
// Out of range.
|
||||
EXPECT_ASSERTION(GetJointLocalBindPose(*skeleton, 3),
|
||||
EXPECT_ASSERTION(GetJointLocalRestPose(*skeleton, 3),
|
||||
"Joint index out of range.");
|
||||
|
||||
const ozz::math::Transform bind_pose0 = GetJointLocalBindPose(*skeleton, 0);
|
||||
EXPECT_FLOAT3_EQ(bind_pose0.translation, 1.f, 0.f, 0.f);
|
||||
EXPECT_QUATERNION_EQ(bind_pose0.rotation, 0.f, 0.f, 0.f, 1.f);
|
||||
EXPECT_FLOAT3_EQ(bind_pose0.scale, 0.f, 0.f, 0.f);
|
||||
const ozz::math::Transform rest_pose0 = GetJointLocalRestPose(*skeleton, 0);
|
||||
EXPECT_FLOAT3_EQ(rest_pose0.translation, 1.f, 0.f, 0.f);
|
||||
EXPECT_QUATERNION_EQ(rest_pose0.rotation, 0.f, 0.f, 0.f, 1.f);
|
||||
EXPECT_FLOAT3_EQ(rest_pose0.scale, 0.f, 0.f, 0.f);
|
||||
|
||||
const ozz::math::Transform bind_pose1 = GetJointLocalBindPose(*skeleton, 1);
|
||||
EXPECT_FLOAT3_EQ(bind_pose1.translation, 0.f, 1.f, 0.f);
|
||||
EXPECT_QUATERNION_EQ(bind_pose1.rotation, 0.f, 0.f, 0.f, -1.f);
|
||||
EXPECT_FLOAT3_EQ(bind_pose1.scale, -1.f, -1.f, -1.f);
|
||||
const ozz::math::Transform rest_pose1 = GetJointLocalRestPose(*skeleton, 1);
|
||||
EXPECT_FLOAT3_EQ(rest_pose1.translation, 0.f, 1.f, 0.f);
|
||||
EXPECT_QUATERNION_EQ(rest_pose1.rotation, 0.f, 0.f, 0.f, -1.f);
|
||||
EXPECT_FLOAT3_EQ(rest_pose1.scale, -1.f, -1.f, -1.f);
|
||||
|
||||
const ozz::math::Transform bind_pose2 = GetJointLocalBindPose(*skeleton, 2);
|
||||
EXPECT_FLOAT3_EQ(bind_pose2.translation, 0.f, 0.f, 1.f);
|
||||
EXPECT_QUATERNION_EQ(bind_pose2.rotation, -0.f, -0.f, -0.f, 1.f);
|
||||
EXPECT_FLOAT3_EQ(bind_pose2.scale, 1.f, 1.f, 1.f);
|
||||
const ozz::math::Transform rest_pose2 = GetJointLocalRestPose(*skeleton, 2);
|
||||
EXPECT_FLOAT3_EQ(rest_pose2.translation, 0.f, 0.f, 1.f);
|
||||
EXPECT_QUATERNION_EQ(rest_pose2.rotation, -0.f, -0.f, -0.f, 1.f);
|
||||
EXPECT_FLOAT3_EQ(rest_pose2.scale, 1.f, 1.f, 1.f);
|
||||
}
|
||||
|
||||
/* Definition of the skeleton used by the tests.
|
||||
@@ -415,3 +413,26 @@ TEST(IsLeaf, SkeletonUtils) {
|
||||
EXPECT_FALSE(IsLeaf(*skeleton, 8));
|
||||
EXPECT_TRUE(IsLeaf(*skeleton, 9));
|
||||
}
|
||||
|
||||
TEST(Name, SkeletonUtils) {
|
||||
// Instantiates a builder objects with default parameters.
|
||||
SkeletonBuilder builder;
|
||||
|
||||
RawSkeleton raw_skeleton;
|
||||
raw_skeleton.roots.resize(4);
|
||||
raw_skeleton.roots[0].name = "j0";
|
||||
raw_skeleton.roots[1].name = "j10";
|
||||
raw_skeleton.roots[2].name = "j1";
|
||||
raw_skeleton.roots[3].name = "J0";
|
||||
|
||||
ozz::unique_ptr<Skeleton> skeleton(builder(raw_skeleton));
|
||||
ASSERT_TRUE(skeleton);
|
||||
|
||||
EXPECT_EQ(FindJoint(*skeleton, "j0"), 0);
|
||||
EXPECT_EQ(FindJoint(*skeleton, "j10"), 1);
|
||||
EXPECT_EQ(FindJoint(*skeleton, "j1"), 2);
|
||||
EXPECT_EQ(FindJoint(*skeleton, "J0"), 3);
|
||||
|
||||
EXPECT_TRUE(FindJoint(*skeleton, "aj0") < 0);
|
||||
EXPECT_TRUE(FindJoint(*skeleton, "j0a") < 0);
|
||||
}
|
||||
+6
-3
@@ -852,8 +852,10 @@ void TestEdgesExpectation(
|
||||
const size_t kMaxIterations = 1000;
|
||||
for (size_t i = 0; i < kMaxIterations; ++i) {
|
||||
job.from =
|
||||
kMaxRange * (1.f - 2.f * static_cast<float>(rand()) / RAND_MAX);
|
||||
job.to = kMaxRange * (1.f - 2.f * static_cast<float>(rand()) / RAND_MAX);
|
||||
kMaxRange * (1.f - 2.f * static_cast<float>(rand()) /
|
||||
static_cast<float>(RAND_MAX));
|
||||
job.to = kMaxRange * (1.f - 2.f * static_cast<float>(rand()) /
|
||||
static_cast<float>(RAND_MAX));
|
||||
TrackTriggeringJob::Iterator iterator;
|
||||
job.iterator = &iterator;
|
||||
ASSERT_TRUE(job.Run());
|
||||
@@ -870,7 +872,8 @@ void TestEdgesExpectation(
|
||||
// Finds new evaluation range
|
||||
float new_time =
|
||||
ratio +
|
||||
kMaxRange * (1.f - 2.f * static_cast<float>(rand()) / RAND_MAX);
|
||||
kMaxRange * (1.f - 2.f * static_cast<float>(rand()) /
|
||||
static_cast<float>(RAND_MAX));
|
||||
|
||||
switch (rand() % 20) {
|
||||
case 0: {
|
||||
|
||||
Reference in New Issue
Block a user