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
@@ -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);
}
@@ -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: {