RavEngine
Loading...
Searching...
No Matches
animation_optimizer.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_OZZ_ANIMATION_OFFLINE_ANIMATION_OPTIMIZER_H_
29
#define OZZ_OZZ_ANIMATION_OFFLINE_ANIMATION_OPTIMIZER_H_
30
31
#include "ozz/animation/offline/export.h"
32
#include "ozz/base/containers/map.h"
33
34
namespace
ozz {
35
namespace
animation {
36
37
// Forward declare runtime skeleton type.
38
class
Skeleton;
39
namespace
offline {
40
41
// Forward declare offline animation type.
42
struct
RawAnimation;
43
44
// Defines the class responsible of optimizing an offline raw animation
45
// instance. Optimization is performed using a key frame reduction technique. It
46
// deciamtes redundant / interpolable key frames, within error tolerances given
47
// as input. The optimizer takes into account for each joint the error
48
// generated on its whole child hierarchy. This allows for example to take into
49
// consideration the error generated on a finger when optimizing the shoulder. A
50
// small error on the shoulder can be magnified when propagated to the finger
51
// indeed.
52
// It's possible to override optimization settings for a joint. This implicitely
53
// have an effect on the whole chain, up to that joint. This allows for example
54
// to have aggressive optimization for a whole skeleton, except for the chain
55
// that leads to the hand if user wants it to be precise. Default optimization
56
// tolerances are set in order to favor quality over runtime performances and
57
// memory footprint.
58
class
OZZ_ANIMOFFLINE_DLL
AnimationOptimizer
{
59
public
:
60
// Initializes the optimizer with default tolerances (favoring quality).
61
AnimationOptimizer
();
62
63
// Optimizes _input using *this parameters. _skeleton is required to evaluate
64
// optimization error along joint hierarchy (see hierarchical_tolerance).
65
// Returns true on success and fills _output animation with the optimized
66
// version of _input animation.
67
// *_output must be a valid RawAnimation instance.
68
// Returns false on failure and resets _output to an empty animation.
69
// See RawAnimation::Validate() for more details about failure reasons.
70
bool
operator()(
const
RawAnimation
& _input,
const
Skeleton
& _skeleton,
71
RawAnimation
* _output)
const
;
72
73
// Optimization settings.
74
struct
Setting
{
75
// Default settings
76
Setting
()
77
: tolerance(1e-3f),
// 1mm
78
distance(1e-1f)
// 10cm
79
{}
80
81
Setting
(
float
_tolerance,
float
_distance)
82
: tolerance(_tolerance), distance(_distance) {}
83
84
// The maximum error that an optimization is allowed to generate on a whole
85
// joint hierarchy.
86
float
tolerance;
87
88
// The distance (from the joint) at which error is measured (if bigger that
89
// joint hierarchy). This allows to emulate effect on skinning.
90
float
distance;
91
};
92
93
// Global optimization settings. These settings apply to all joints of the
94
// hierarchy, unless overriden by joint specific settings.
95
Setting
setting;
96
97
// Per joint override of optimization settings.
98
typedef
ozz::map<int, Setting> JointsSetting;
99
JointsSetting joints_setting_override;
100
};
101
}
// namespace offline
102
}
// namespace animation
103
}
// namespace ozz
104
#endif
// OZZ_OZZ_ANIMATION_OFFLINE_ANIMATION_OPTIMIZER_H_
ozz::animation::Skeleton
Definition
skeleton.h:61
ozz::animation::offline::AnimationOptimizer
Definition
animation_optimizer.h:58
ozz::animation::offline::AnimationOptimizer::Setting
Definition
animation_optimizer.h:74
ozz::animation::offline::RawAnimation
Definition
raw_animation.h:59
RavEngine
deps
ozz-animation
include
ozz
animation
offline
animation_optimizer.h
Generated by
1.9.8