Skip to content

Commit

Permalink
Merge branch 'release/0.15.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeblanc committed Apr 13, 2024
2 parents 92c392b + af3abba commit c40a726
Show file tree
Hide file tree
Showing 108 changed files with 2,388 additions and 948 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: guillaumeblanc
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
compiler_cxx: clang++-15

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install OpenGL dependency
run: |
Expand All @@ -80,7 +80,7 @@ jobs:
run: |
mkdir fbx
cd fbx
sudo wget --user-agent='Mozilla/5.0' 'https://damassets.autodesk.net/content/dam/autodesk/www/adn/fbx/2020-2/fbx20202_fbxsdk_linux.tar.gz' -O 'fbx.tar.gz'
sudo wget --user-agent='Mozilla/5.0' 'https://damassets.autodesk.net/content/dam/autodesk/www/adn/fbx/2020-3-4/fbx202034_fbxsdk_linux.tar.gz' -O 'fbx.tar.gz'
sudo tar -xf 'fbx.tar.gz'
(yes yes | sudo ./*_fbxsdk_linux /usr/local) || true
sudo chmod -R 755 /usr/local/lib
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@ name: macOS
on: [push, pull_request]
jobs:
build:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
build_type: [Debug]
os: [macos-latest, macos-14]
build_type: [Debug, Release]
option: [default, ref, shared, no_fbx]
include:
- build_type: Release
option: default
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install fbx sdk
if: matrix.option != 'no_fbx'
run: |
mkdir fbx
cd fbx
sudo wget --user-agent='Mozilla/5.0' 'https://damassets.autodesk.net/content/dam/autodesk/www/adn/fbx/2020-0-1/fbx202001_fbxsdk_clang_mac.pkg.tgz' -O 'fbx.tgz'
sudo wget --user-agent='Mozilla/5.0' 'https://damassets.autodesk.net/content/dam/autodesk/www/adn/fbx/2020-3-4/fbx202034_fbxsdk_clang_mac.pkg.tgz' -O 'fbx.tgz'
sudo tar -xf 'fbx.tgz'
sudo installer -pkg *_fbxsdk_clang_macos.pkg -target /
cd ..
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: wasm
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build_type: [Debug, Release]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: emscripten-core/emsdk
path: extern/emsdk
- name: Build
run: |
./build-utils/em-build.sh ${{matrix.build_type}}
- name: Uploads artifacts
uses: actions/upload-artifact@v4
with:
name: samples${{matrix.build_type}}
path: |
build-wasm/samples/**/*.html
build-wasm/samples/**/*.js
build-wasm/samples/**/*.wasm
12 changes: 10 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ jobs:
fail-fast: false
matrix:
build_type: [Debug]
platform: [x64]
option: [default, ref, shared, no_fbx]
include:
- build_type: Debug
platform: Win32
option: default
- build_type: Release
platform: Win32
option: default
- build_type: Release
platform: x64
option: default
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install fbx sdk
if: matrix.option != 'no_fbx'
Expand All @@ -27,7 +35,7 @@ jobs:
# Configure CMake in a 'build' subdirectory.
run: |
cmake --version
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.option == 'shared'}} -Dozz_build_tests=${{matrix.option != 'no_tests'}} -Dozz_build_simd_ref=${{matrix.option == 'ref'}} -Dozz_build_samples=${{matrix.option != 'no_sample'}} -Dozz_build_data=${{matrix.option != 'no_data'}} -Dozz_build_gltf=${{matrix.option != 'no_gltf'}}
cmake -A ${{matrix.platform}} -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.option == 'shared'}} -Dozz_build_tests=${{matrix.option != 'no_tests'}} -Dozz_build_simd_ref=${{matrix.option == 'ref'}} -Dozz_build_samples=${{matrix.option != 'no_sample'}} -Dozz_build_data=${{matrix.option != 'no_data'}} -Dozz_build_gltf=${{matrix.option != 'no_gltf'}}
- name: Build
# Build your program with the given configuration
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ The following authors have all licensed their contributions to ozz-animation und
- Mikołaj Siedlarek <mikolaj@siedlarek.net>
- Paul Gruenbacher <pgruenbacher@gmail.com>
- Christophe Meyer <christophe.meyer.pro@gmail.com>
- Lukas Friembichler <lukas.friembichler@gmail.com>
- Blaž Tomažič <blaz.tomazic@gmail.com>
- Jan Krassnigg <jan@krassnigg.de>
86 changes: 53 additions & 33 deletions CHANGES.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ get_directory_property(is_sub_project PARENT_DIRECTORY)

# Current version
set(OZZ_VERSION_MAJOR 0)
set(OZZ_VERSION_MINOR 14)
set(OZZ_VERSION_PATCH 3)
set(OZZ_VERSION_MINOR 15)
set(OZZ_VERSION_PATCH 0)
set(OZZ_VERSION ${OZZ_VERSION_MAJOR}.${OZZ_VERSION_MINOR}.${OZZ_VERSION_PATCH})

# Add project build options
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@ ozz-animation provides runtime character animation playback functionalities (loa

ozz-animation comes with the toolchain to convert from major Digital Content Creation formats (gltf, Fbx, Collada, Obj, 3ds, dxf) to ozz optimized runtime structures. Offline libraries are also provided to implement the conversion from any other animation and skeleton format.

Follow [this link](https://github.com/guillaumeblanc/ozz-animation/issues/175) for a list of projects using ozz-animation.

Documentation
-------------

Documentation and samples are available from [ozz-animation website](http://guillaumeblanc.github.io/ozz-animation/). Join [Gitter](https://gitter.im/ozz-animation/community) for further discussions.
Documentation and samples are available from [ozz-animation website](http://guillaumeblanc.github.io/ozz-animation/).

Supported platforms
-------------------

Ozz is tested on Linux, Mac OS and Windows, for x86, x86-64 and ARM architectures. The run-time code (ozz_base, ozz_animation, ozz_geometry) depends only on c++11, on the C and the C++ standard libraries, and has no OS specific code. Portability to any other platform shouldn't be an issue.
ozz-animation is tested on WebAssembly, Linux, macOS and Windows, for x86, x86-64 and ARM architectures. The run-time code (ozz_base, ozz_animation, ozz_geometry) depends only on c++11, on the C and the C++ standard libraries, and has no OS specific code. Portability to any other platform shouldn't be an issue.

Samples, tools and tests depend on external libraries (glfw, tinygltf, Fbx SDK, jsoncpp, gtest, ...), which could limit portability.
Samples, tools and tests depend on external libraries (glfw, tinygltf, Fbx SDK, jsoncpp, gtest, ...), which aren't need to ship with ozz-animation runtime.

Build status
------------

| | Linux | macOS | Windows |
| ------- | ------ | ------ | ------- |
| master | [![Linux](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml) | [![macOS](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml) | [![Windows](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml) |
| develop | [![Linux](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml) | [![macOS](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml) | [![Windows](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml) |
| | Linux | macOS | Windows | WebAssembly |
| ------- | ------ | ------ | ------- | ------- |
| master | [![Linux](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml) | [![macOS](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml) | [![Windows](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml) | [![WASM](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/wasm.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/wasm.yml) |
| develop | [![Linux](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml) | [![macOS](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml) | [![Windows](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml) | [![WASM](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/wasm.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/wasm.yml) |

The dashboard for all branches is available [here](http://guillaumeblanc.github.io/ozz-animation/documentation/dashboard/).

Expand Down
22 changes: 22 additions & 0 deletions build-utils/em-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Setup emscripten
cd extern/emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ../..


# Setup cmake
mkdir build-wasm
cd build-wasm

if [[ $# -eq 0 ]] ; then
emcmake cmake -DCMAKE_BUILD_TYPE=Release ..
else
emcmake cmake -DCMAKE_BUILD_TYPE=$1 ..
fi

# Build
cmake --build .
9 changes: 9 additions & 0 deletions include/ozz/animation/offline/animation_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ class OZZ_ANIMOFFLINE_DLL AnimationBuilder {
// The animation is returned as an unique_ptr as ownership is given back to
// the caller.
unique_ptr<Animation> operator()(const RawAnimation& _raw_animation) const;

// IFrames allow the sampler to instantly seek to a point in time in the
// animation. If no iframe is available, the sampler needs to read
// sequentially forward or backward to reach a point. So that's useful for
// long animations, if they are accessed randomly, or if sampling starts from
// the end. A 0 interval means no iframe is generated. Any positive number is
// the interval between iframes, with a guaranted one at the end of the
// animation if interval is bigger than animation duration.
float iframe_interval = 0.f;
};
} // namespace offline
} // namespace animation
Expand Down
17 changes: 11 additions & 6 deletions include/ozz/animation/offline/raw_animation_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "ozz/animation/offline/export.h"
#include "ozz/animation/offline/raw_animation.h"

#include "ozz/base/containers/vector.h"
#include "ozz/base/maths/transform.h"
#include "ozz/base/span.h"

Expand All @@ -41,24 +41,25 @@ namespace offline {
// Translation interpolation method.
OZZ_ANIMOFFLINE_DLL math::Float3 LerpTranslation(const math::Float3& _a,
const math::Float3& _b,
float _alpha);
float _alpha);

// Rotation interpolation method.
OZZ_ANIMOFFLINE_DLL math::Quaternion LerpRotation(const math::Quaternion& _a,
const math::Quaternion& _b, float _alpha);
const math::Quaternion& _b,
float _alpha);

// Scale interpolation method.
OZZ_ANIMOFFLINE_DLL math::Float3 LerpScale(const math::Float3& _a,
const math::Float3& _b,
float _alpha);
float _alpha);

// Samples a RawAnimation track. This function shall be used for offline
// purpose. Use ozz::animation::Animation and ozz::animation::SamplingJob for
// runtime purpose.
// Returns false if track is invalid.
OZZ_ANIMOFFLINE_DLL bool SampleTrack(const RawAnimation::JointTrack& _track,
float _time,
ozz::math::Transform* _transform);
ozz::math::Transform* _transform);

// Samples a RawAnimation. This function shall be used for offline
// purpose. Use ozz::animation::Animation and ozz::animation::SamplingJob for
Expand All @@ -67,7 +68,11 @@ OZZ_ANIMOFFLINE_DLL bool SampleTrack(const RawAnimation::JointTrack& _track,
// Returns false output range is too small or animation is invalid.
OZZ_ANIMOFFLINE_DLL bool SampleAnimation(
const RawAnimation& _animation, float _time,
const span<ozz::math::Transform>& _transforms);
const span<ozz::math::Transform>& _transforms);

// Get the union of all keyframe times from a valid RawAnimation.
OZZ_ANIMOFFLINE_DLL ozz::vector<float> ExtractTimePoints(
const RawAnimation& _animation);

// Implement fixed rate keyframe time iteration. This utility purpose is to
// ensure that sampling goes strictly from 0 to duration, and that period
Expand Down
103 changes: 92 additions & 11 deletions include/ozz/animation/runtime/animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ class AnimationBuilder;
}

// Forward declaration of key frame's type.
namespace internal {
struct Float3Key;
struct QuaternionKey;
} // namespace internal

// Defines a runtime skeletal animation clip.
// The runtime animation data structure stores animation keyframes, for all the
Expand Down Expand Up @@ -88,14 +90,69 @@ class OZZ_ANIMATION_DLL Animation {
// Gets animation name.
const char* name() const { return name_ ? name_ : ""; }

// Gets the buffer of time points.
span<const float> timepoints() const { return timepoints_; }

template <bool _Const>
struct TKeyframesCtrl {
size_t size_bytes() const {
return ratios.size_bytes() + previouses.size_bytes() +
iframe_entries.size_bytes() + iframe_desc.size_bytes();
}

// Implicit conversion to const.
operator TKeyframesCtrl<true>() const {
return {ratios, previouses, iframe_entries, iframe_desc, iframe_interval};
}

template <typename _Ty, bool>
struct ConstQualifier {
typedef const _Ty type;
};

template <typename _Ty>
struct ConstQualifier<_Ty, false> {
typedef _Ty type;
};

// Indices to timepoints. uint8_t or uint16_t depending on timepoints size.
span<typename ConstQualifier<byte, _Const>::type> ratios;

// Offsets from the previous keyframe of the same track.
span<typename ConstQualifier<uint16_t, _Const>::type> previouses;

// Cached iframe entries packed with GV4 encoding.
span<typename ConstQualifier<byte, _Const>::type> iframe_entries;

// 2 intergers per iframe:
// 1. Offset in compressed entries
// 2. Maximum key index (latest updated key).
span<typename ConstQualifier<uint32_t, _Const>::type> iframe_desc;

// Interval, used at runtime to index iframe_desc.
float iframe_interval;
};

typedef TKeyframesCtrl<true> KeyframesCtrlConst;
typedef TKeyframesCtrl<false> KeyframesCtrl;

// Gets the buffer of translations keys.
span<const Float3Key> translations() const { return translations_; }
KeyframesCtrlConst translations_ctrl() const { return translations_ctrl_; }
span<const internal::Float3Key> translations_values() const {
return translations_values_;
}

// Gets the buffer of rotation keys.
span<const QuaternionKey> rotations() const { return rotations_; }
KeyframesCtrlConst rotations_ctrl() const { return rotations_ctrl_; }
span<const internal::QuaternionKey> rotations_values() const {
return rotations_values_;
}

// Gets the buffer of scale keys.
span<const Float3Key> scales() const { return scales_; }
KeyframesCtrlConst scales_ctrl() const { return scales_ctrl_; }
span<const internal::Float3Key> scales_values() const {
return scales_values_;
}

// Get the estimated animation's size in bytes.
size_t size() const;
Expand All @@ -109,9 +166,25 @@ class OZZ_ANIMATION_DLL Animation {
// AnimationBuilder class is allowed to instantiate an Animation.
friend class offline::AnimationBuilder;

// Internal destruction function.
void Allocate(size_t _name_len, size_t _translation_count,
size_t _rotation_count, size_t _scale_count);
// Internal memory management functions.
struct AllocateParams {
size_t name_len;
size_t timepoints;

size_t translations;
size_t rotations;
size_t scales;

struct IFrames {
size_t entries;
size_t offsets;
};

IFrames translation_iframes;
IFrames rotation_iframes;
IFrames scale_iframes;
};
void Allocate(const AllocateParams& _params);
void Deallocate();

// Duration of the animation clip.
Expand All @@ -124,15 +197,23 @@ class OZZ_ANIMATION_DLL Animation {
// Animation name.
char* name_;

// Stores all translation/rotation/scale keys begin and end of buffers.
span<Float3Key> translations_;
span<QuaternionKey> rotations_;
span<Float3Key> scales_;
// Stores all translation/rotation/scale keys.
span<float> timepoints_;

// Keyframes series controllers.
KeyframesCtrl translations_ctrl_;
KeyframesCtrl rotations_ctrl_;
KeyframesCtrl scales_ctrl_;

// Keyframes series values.
span<internal::Float3Key> translations_values_;
span<internal::QuaternionKey> rotations_values_;
span<internal::Float3Key> scales_values_;
};
} // namespace animation

namespace io {
OZZ_IO_TYPE_VERSION(6, animation::Animation)
OZZ_IO_TYPE_VERSION(7, animation::Animation)
OZZ_IO_TYPE_TAG("ozz-animation", animation::Animation)
} // namespace io
} // namespace ozz
Expand Down
Loading

0 comments on commit c40a726

Please sign in to comment.