Updated ozz-animation to version 0.14.1 @35b2efd4
This commit is contained in:
+1
-1
@@ -17,10 +17,10 @@ add_executable(sample_optimize
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/README.md"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/media/skeleton.ozz"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/media/animation_raw.ozz")
|
||||
|
||||
target_link_libraries(sample_optimize
|
||||
ozz_animation_offline
|
||||
sample_framework)
|
||||
target_copy_shared_libraries(sample_optimize)
|
||||
|
||||
set_target_properties(sample_optimize
|
||||
PROPERTIES FOLDER "samples")
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ Some other parameters can be tuned from sample UI to affect animation playback.
|
||||
|
||||
1. Import the runtime skeleton and the unoptimized raw animation objects. These are imported from files as described in the "how to load an object from a file" section. Note that the animation is still in an offline format at this stage.
|
||||
2. Optimizes animation by removing interpolable keyframes using `ozz::animation::offline::AnimationOptimizer` utility. It processes the source raw animation and outputs a new one. Optimization tolerance values like translation (meter), rotation (radian) and scale (percentage) are exposed to sample UI.
|
||||
3. Convert the offline animation to the runtime format, using `ozz::animation::offline::AnimationBuilder`. This utility takes as input the optimized RawAnimation and outputs the runtime `ozz::animation::Animation`. The runtime format is the one used for sampling. In opposition with the offline one, it cannot be edited/modified. It is optimized for runtime usage in term of memory layout (cache coherence for sampling) and footprint (compression scheme).
|
||||
3. Convert the offline animation to the runtime format, using `ozz::animation::offline::AnimationBuilder`. This utility takes as input the optimized RawAnimation and outputs the runtime `ozz::animation::Animation`. The runtime format is the one used for sampling. In opposition with the offline one, it cannot be edited/modified. It is optimized for runtime usage in term of memory layout (context coherence for sampling) and footprint (compression scheme).
|
||||
4. Local-space transformations (in SoA format as required by the runtime pipeline) are computed from the runtime and the source raw animations according the selected rendering mode:
|
||||
- "Raw animation": Every track of the source raw animation is traversed in order to extract each relevant keyframes. Keyframes are interpolated to match the exact expected time. This implementation isn't part of the API but done by the sample, as raw animations aren't intended to be used this way in runtime. Even though it works, performance are quite low compared with sampling a runtime animation. On the other end the result is the closest to the input file, kind of lossless.
|
||||
- "Run time" (default): Samples optimized runtime animation as usual.
|
||||
|
||||
+39
-45
@@ -25,36 +25,30 @@
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "ozz/animation/runtime/animation.h"
|
||||
#include "ozz/animation/runtime/local_to_model_job.h"
|
||||
#include "ozz/animation/runtime/sampling_job.h"
|
||||
#include "ozz/animation/runtime/skeleton.h"
|
||||
|
||||
#include "ozz/animation/offline/animation_builder.h"
|
||||
#include "ozz/animation/offline/animation_optimizer.h"
|
||||
#include "ozz/animation/offline/raw_animation.h"
|
||||
#include "ozz/animation/offline/raw_animation_utils.h"
|
||||
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
|
||||
#include "ozz/base/io/archive.h"
|
||||
#include "ozz/base/io/stream.h"
|
||||
#include "ozz/base/log.h"
|
||||
|
||||
#include "ozz/base/maths/math_ex.h"
|
||||
#include "ozz/base/maths/simd_math.h"
|
||||
#include "ozz/base/maths/soa_transform.h"
|
||||
#include "ozz/base/maths/vec_float.h"
|
||||
|
||||
#include "ozz/options/options.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "framework/application.h"
|
||||
#include "framework/imgui.h"
|
||||
#include "framework/profile.h"
|
||||
#include "framework/renderer.h"
|
||||
#include "framework/utils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "ozz/animation/offline/animation_builder.h"
|
||||
#include "ozz/animation/offline/animation_optimizer.h"
|
||||
#include "ozz/animation/offline/raw_animation.h"
|
||||
#include "ozz/animation/offline/raw_animation_utils.h"
|
||||
#include "ozz/animation/runtime/animation.h"
|
||||
#include "ozz/animation/runtime/local_to_model_job.h"
|
||||
#include "ozz/animation/runtime/sampling_job.h"
|
||||
#include "ozz/animation/runtime/skeleton.h"
|
||||
#include "ozz/base/io/archive.h"
|
||||
#include "ozz/base/io/stream.h"
|
||||
#include "ozz/base/log.h"
|
||||
#include "ozz/base/maths/math_ex.h"
|
||||
#include "ozz/base/maths/simd_math.h"
|
||||
#include "ozz/base/maths/soa_transform.h"
|
||||
#include "ozz/base/maths/vec_float.h"
|
||||
#include "ozz/base/memory/unique_ptr.h"
|
||||
#include "ozz/options/options.h"
|
||||
|
||||
// Skeleton and animation file can be specified as an option.
|
||||
OZZ_OPTIONS_DECLARE_STRING(skeleton, "Path to the runtime skeleton file.",
|
||||
@@ -111,7 +105,7 @@ class OptimizeSampleApplication : public ozz::sample::Application {
|
||||
|
||||
// Prepares sampling job.
|
||||
ozz::animation::SamplingJob sampling_job;
|
||||
sampling_job.cache = &cache_;
|
||||
sampling_job.context = &context_;
|
||||
sampling_job.ratio = controller_.time_ratio();
|
||||
|
||||
// Samples optimized animation (_according to the display mode).
|
||||
@@ -129,20 +123,20 @@ class OptimizeSampleApplication : public ozz::sample::Application {
|
||||
}
|
||||
|
||||
// Computes difference between the optimized and non-optimized animations
|
||||
// in local space, and rebinds it to the bind pose.
|
||||
// in local space, and rebinds it to the rest pose.
|
||||
{
|
||||
const ozz::span<const ozz::math::SoaTransform>& bind_poses =
|
||||
skeleton_.joint_bind_poses();
|
||||
const ozz::math::SoaTransform* bind_pose = bind_poses.begin();
|
||||
const ozz::span<const ozz::math::SoaTransform>& rest_poses =
|
||||
skeleton_.joint_rest_poses();
|
||||
const ozz::math::SoaTransform* rest_pose = rest_poses.begin();
|
||||
const ozz::math::SoaTransform* locals_raw = locals_raw_.data();
|
||||
const ozz::math::SoaTransform* locals_rt = locals_rt_.data();
|
||||
ozz::math::SoaTransform* locals_diff = locals_diff_.data();
|
||||
for (; bind_pose < bind_poses.end();
|
||||
++locals_raw, ++locals_rt, ++locals_diff, ++bind_pose) {
|
||||
for (; rest_pose < rest_poses.end();
|
||||
++locals_raw, ++locals_rt, ++locals_diff, ++rest_pose) {
|
||||
assert(locals_raw < array_end(locals_raw_) &&
|
||||
locals_rt < array_end(locals_rt_) &&
|
||||
locals_diff < array_end(locals_diff_) &&
|
||||
bind_pose < bind_poses.end());
|
||||
rest_pose < rest_poses.end());
|
||||
|
||||
// Computes difference.
|
||||
const ozz::math::SoaTransform diff = {
|
||||
@@ -150,10 +144,10 @@ class OptimizeSampleApplication : public ozz::sample::Application {
|
||||
locals_rt->rotation * Conjugate(locals_raw->rotation),
|
||||
locals_rt->scale / locals_raw->scale};
|
||||
|
||||
// Rebinds to the bind pose in the diff buffer.
|
||||
locals_diff->translation = bind_pose->translation + diff.translation;
|
||||
locals_diff->rotation = bind_pose->rotation * diff.rotation;
|
||||
locals_diff->scale = bind_pose->scale * diff.scale;
|
||||
// Rebinds to the rest pose in the diff buffer.
|
||||
locals_diff->translation = rest_pose->translation + diff.translation;
|
||||
locals_diff->rotation = rest_pose->rotation * diff.rotation;
|
||||
locals_diff->scale = rest_pose->scale * diff.scale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,8 +314,8 @@ class OptimizeSampleApplication : public ozz::sample::Application {
|
||||
locals_diff_.resize(num_soa_joints);
|
||||
models_diff_.resize(num_joints);
|
||||
|
||||
// Allocates a cache that matches animation requirements.
|
||||
cache_.Resize(num_joints);
|
||||
// Allocates a context that matches animation requirements.
|
||||
context_.Resize(num_joints);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -374,11 +368,11 @@ class OptimizeSampleApplication : public ozz::sample::Application {
|
||||
.5f, joint_setting_enable_ && optimize_);
|
||||
|
||||
if (rebuild) {
|
||||
// Invalidates the cache in case the new animation has the same
|
||||
// Invalidates the context in case the new animation has the same
|
||||
// address as the previous one. Other cases (like changing animation)
|
||||
// are automatic handled by the cache. See SamplingCache::Invalidate
|
||||
// for more details.
|
||||
cache_.Invalidate();
|
||||
// are automatic handled by the context. See
|
||||
// SamplingJob::Context::Invalidate for more details.
|
||||
context_.Invalidate();
|
||||
|
||||
// Rebuilds a new runtime animation.
|
||||
if (!BuildAnimations()) {
|
||||
@@ -540,9 +534,9 @@ class OptimizeSampleApplication : public ozz::sample::Application {
|
||||
// Runtime skeleton.
|
||||
ozz::animation::Skeleton skeleton_;
|
||||
|
||||
// Sampling cache, shared across optimized and non-optimized animations. This
|
||||
// is not optimal, but it's not an issue either.
|
||||
ozz::animation::SamplingCache cache_;
|
||||
// Sampling context, shared across optimized and non-optimized animations.
|
||||
// This is not optimal, but it's not an issue either.
|
||||
ozz::animation::SamplingJob::Context context_;
|
||||
|
||||
// Runtime optimized animation.
|
||||
ozz::unique_ptr<ozz::animation::Animation> animation_rt_;
|
||||
|
||||
Reference in New Issue
Block a user