Updated ozz-animation to version 0.14.1 @35b2efd4

This commit is contained in:
Martin Felis
2023-03-26 13:28:12 +02:00
parent bf3189ff49
commit 15871f349c
194 changed files with 3495 additions and 1957 deletions
@@ -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)
@@ -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;