RavEngine
Loading...
Searching...
No Matches
animation_keyframe.h
1//----------------------------------------------------------------------------//
2// //
3// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
4// and distributed under the MIT License (MIT). //
5// //
6// Copyright (c) Guillaume Blanc //
7// //
8// Permission is hereby granted, free of charge, to any person obtaining a //
9// copy of this software and associated documentation files (the "Software"), //
10// to deal in the Software without restriction, including without limitation //
11// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
12// and/or sell copies of the Software, and to permit persons to whom the //
13// Software is furnished to do so, subject to the following conditions: //
14// //
15// The above copyright notice and this permission notice shall be included in //
16// all copies or substantial portions of the Software. //
17// //
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
21// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
24// DEALINGS IN THE SOFTWARE. //
25// //
26//----------------------------------------------------------------------------//
27
28#ifndef OZZ_ANIMATION_RUNTIME_ANIMATION_KEYFRAME_H_
29#define OZZ_ANIMATION_RUNTIME_ANIMATION_KEYFRAME_H_
30
31#include "ozz/animation/runtime/export.h"
32#include "ozz/base/platform.h"
33
34#ifndef OZZ_INCLUDE_PRIVATE_HEADER
35#error "This header is private, it cannot be included from public headers."
36#endif // OZZ_INCLUDE_PRIVATE_HEADER
37
38namespace ozz {
39namespace animation {
40
41// Define animation key frame types (translation, rotation, scale). Every type
42// as the same base made of the key time ratio and it's track index. This is
43// required as key frames are not sorted per track, but sorted by ratio to favor
44// cache coherency. Key frame values are compressed, according on their type.
45// Decompression is efficient because it's done on SoA data and cached during
46// sampling.
47
48// Defines the float3 key frame type, used for translations and scales.
49// Translation values are stored as half precision floats with 16 bits per
50// component.
51struct OZZ_ANIMATION_DLL Float3Key {
52 float ratio;
53 uint16_t track;
54 uint16_t value[3];
55};
56
57// Defines the rotation key frame type.
58// Rotation value is a quaternion. Quaternion are normalized, which means each
59// component is in range [0:1]. This property allows to quantize the 3
60// components to 3 signed integer 16 bits values. The 4th component is restored
61// at runtime, using the knowledge that |w| = sqrt(1 - (a^2 + b^2 + c^2)).
62// The sign of this 4th component is stored using 1 bit taken from the track
63// member.
64//
65// In more details, compression algorithm stores the 3 smallest components of
66// the quaternion and restores the largest. The 3 smallest can be pre-multiplied
67// by sqrt(2) to gain some precision indeed.
68//
69// Quantization could be reduced to 11-11-10 bits as often used for animation
70// key frames, but in this case RotationKey structure would induce 16 bits of
71// padding.
72struct OZZ_ANIMATION_DLL QuaternionKey {
73 float ratio;
74 uint16_t track : 13; // The track this key frame belongs to.
75 uint16_t largest : 2; // The largest component of the quaternion.
76 uint16_t sign : 1; // The sign of the largest component. 1 for negative.
77 int16_t value[3]; // The quantized value of the 3 smallest components.
78};
79
80} // namespace animation
81} // namespace ozz
82#endif // OZZ_ANIMATION_RUNTIME_ANIMATION_KEYFRAME_H_
Definition animation_keyframe.h:51
Definition animation_keyframe.h:72