Skip to content

Commit 0e03643

Browse files
committedOct 30, 2020
#110 Renames skeleton bind pose to rest pose, to avoid confusion with skinning bind pose
1 parent 1014cb5 commit 0e03643

33 files changed

+229
-253
lines changed
 

‎CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Next release
44
* Library
55
- [animation] #103 Allows move constructor and assignment for ozz::animation::Skeleton, ozz::animation::Animation and ozz::animation::Track.
66
- [animation] Renames SamplingCache to SamplingJob::Context.
7+
- [animation] #110 Renames skeleton bind pose to rest pose, to avoid confusion with skinning bind pose.
78

89
* Build pipeline
910
- #59 Adds support for shared libraries on Windows (dll), Linux and MacOS platforms.

‎howtos/custom_skeleton_importer.cc

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525
// //
2626
//----------------------------------------------------------------------------//
2727

28+
#include <cstdlib>
29+
2830
#include "ozz/animation/offline/raw_skeleton.h"
2931
#include "ozz/animation/offline/skeleton_builder.h"
30-
3132
#include "ozz/animation/runtime/skeleton.h"
3233

33-
#include <cstdlib>
34-
3534
// Code for ozz-animation HowTo: "How to write a custon skeleton importer?"
3635

3736
int main(int argc, char const* argv[]) {
@@ -52,7 +51,7 @@ int main(int argc, char const* argv[]) {
5251
// Setup root joints name.
5352
root.name = "root";
5453

55-
// Setup root joints bind-pose/rest transformation, in joint local-space.
54+
// Setup root joints rest pose transformation, in joint local-space.
5655
// This is the default skeleton posture (most of the time a T-pose). It's
5756
// used as a fallback when there's no animation for a joint.
5857
root.transform.translation = ozz::math::Float3(0.f, 1.f, 0.f);

‎include/ozz/animation/offline/raw_skeleton.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ namespace offline {
4242
// This skeleton type is not intended to be used in run time. It is used to
4343
// define the offline skeleton object that can be converted to the runtime
4444
// skeleton using the SkeletonBuilder. This skeleton structure exposes joints'
45-
// hierarchy. A joint is defined with a name, a transformation (its bind pose),
46-
// and its children. Children are exposed as a public std::vector of joints.
47-
// This same type is used for skeleton roots, also exposed from the public API.
48-
// The public API exposed through std:vector's of joints can be used freely with
49-
// the only restriction that the total number of joints does not exceed
50-
// Skeleton::kMaxJoints.
45+
// hierarchy. A joint is defined with a name, a transformation (its rest_pose
46+
// pose), and its children. Children are exposed as a public std::vector of
47+
// joints. This same type is used for skeleton roots, also exposed from the
48+
// public API. The public API exposed through std:vector's of joints can be used
49+
// freely with the only restriction that the total number of joints does not
50+
// exceed Skeleton::kMaxJoints.
5151
struct OZZ_ANIMOFFLINE_DLL RawSkeleton {
5252
// Construct an empty skeleton.
5353
RawSkeleton();
@@ -66,7 +66,7 @@ struct OZZ_ANIMOFFLINE_DLL RawSkeleton {
6666
// The name of the joint.
6767
ozz::string name;
6868

69-
// Joint bind pose transformation in local space.
69+
// Joint rest pose transformation in local space.
7070
math::Transform transform;
7171
};
7272

‎include/ozz/animation/runtime/blending_job.h

+12-12
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ namespace animation {
4545
// (the result of a sampled animation) according to their respective weight,
4646
// into one output pose.
4747
// The number of transforms/joints blended by the job is defined by the number
48-
// of transforms of the bind pose (note that this is a SoA format). This means
49-
// that all buffers must be at least as big as the bind pose buffer.
48+
// of transforms of the rest pose (note that this is a SoA format). This means
49+
// that all buffers must be at least as big as the rest pose buffer.
5050
// Partial animation blending is supported through optional joint weights that
5151
// can be specified with layers joint_weights buffer. Unspecified joint weights
5252
// are considered as a unit weight of 1.f, allowing to mix full and partial
@@ -64,7 +64,7 @@ struct OZZ_ANIMATION_DLL BlendingJob {
6464
// -if any layer is not valid.
6565
// -if output range is not valid.
6666
// -if any buffer (including layers' content : transform, joint weights...) is
67-
// smaller than the bind pose buffer.
67+
// smaller than the rest pose buffer.
6868
// -if the threshold value is less than or equal to 0.f.
6969
bool Validate() const;
7070

@@ -87,17 +87,17 @@ struct OZZ_ANIMATION_DLL BlendingJob {
8787

8888
// The range [begin,end[ of input layer posture. This buffer expect to store
8989
// local space transforms, that are usually outputted from a sampling job.
90-
// This range must be at least as big as the bind pose buffer, even though
91-
// only the number of transforms defined by the bind pose buffer will be
90+
// This range must be at least as big as the rest pose buffer, even though
91+
// only the number of transforms defined by the rest pose buffer will be
9292
// processed.
9393
span<const math::SoaTransform> transform;
9494

9595
// Optional range [begin,end[ of blending weight for each joint in this
9696
// layer.
9797
// If both pointers are nullptr (default case) then per joint weight
9898
// blending is disabled. A valid range is defined as being at least as big
99-
// as the bind pose buffer, even though only the number of transforms
100-
// defined by the bind pose buffer will be processed. When a layer doesn't
99+
// as the rest pose buffer, even though only the number of transforms
100+
// defined by the rest pose buffer will be processed. When a layer doesn't
101101
// specifies per joint weights, then it is implicitly considered as
102102
// being 1.f. This default value is a reference value for the normalization
103103
// process, which implies that the range of values for joint weights should
@@ -107,7 +107,7 @@ struct OZZ_ANIMATION_DLL BlendingJob {
107107
span<const math::SimdFloat4> joint_weights;
108108
};
109109

110-
// The job blends the bind pose to the output when the accumulated weight of
110+
// The job blends the rest pose to the output when the accumulated weight of
111111
// all layers is less than this threshold value.
112112
// Must be greater than 0.f.
113113
float threshold;
@@ -120,18 +120,18 @@ struct OZZ_ANIMATION_DLL BlendingJob {
120120
// The range of layers that must be added to the output.
121121
span<const Layer> additive_layers;
122122

123-
// The skeleton bind pose. The size of this buffer defines the number of
123+
// The skeleton rest pose. The size of this buffer defines the number of
124124
// transforms to blend. This is the reference because this buffer is defined
125125
// by the skeleton that all the animations belongs to.
126126
// It is used when the accumulated weight for a bone on all layers is
127127
// less than the threshold value, in order to fall back on valid transforms.
128-
span<const ozz::math::SoaTransform> bind_pose;
128+
span<const ozz::math::SoaTransform> rest_pose;
129129

130130
// Job output.
131131
// The range of output transforms to be filled with blended layer
132132
// transforms during job execution.
133-
// Must be at least as big as the bind pose buffer, but only the number of
134-
// transforms defined by the bind pose buffer size will be processed.
133+
// Must be at least as big as the rest pose buffer, but only the number of
134+
// transforms defined by the rest pose buffer size will be processed.
135135
span<ozz::math::SoaTransform> output;
136136
};
137137
} // namespace animation

‎include/ozz/animation/runtime/skeleton.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class SkeletonBuilder;
4949
}
5050

5151
// This runtime skeleton data structure provides a const-only access to joint
52-
// hierarchy, joint names and bind-pose. This structure is filled by the
52+
// hierarchy, joint names and rest-pose. This structure is filled by the
5353
// SkeletonBuilder and can be serialize/deserialized.
54-
// Joint names, bind-poses and hierarchy information are all stored in separate
54+
// Joint names, rest-poses and hierarchy information are all stored in separate
5555
// arrays of data (as opposed to joint structures for the RawSkeleton), in order
5656
// to closely match with the way runtime algorithms use them. Joint hierarchy is
5757
// packed as an array of parent jont indices (16 bits), stored in depth-first
@@ -100,9 +100,9 @@ class OZZ_ANIMATION_DLL Skeleton {
100100
// skeleton. This value is useful to allocate SoA runtime data structures.
101101
int num_soa_joints() const { return (num_joints() + 3) / 4; }
102102

103-
// Returns joint's bind poses. Bind poses are stored in soa format.
104-
span<const math::SoaTransform> joint_bind_poses() const {
105-
return joint_bind_poses_;
103+
// Returns joint's rest poses. Rest poses are stored in soa format.
104+
span<const math::SoaTransform> joint_rest_poses() const {
105+
return joint_rest_poses_;
106106
}
107107

108108
// Returns joint's parent indices range.
@@ -130,8 +130,8 @@ class OZZ_ANIMATION_DLL Skeleton {
130130
// Buffers below store joint informations in joing depth first order. Their
131131
// size is equal to the number of joints of the skeleton.
132132

133-
// Bind pose of every joint in local space.
134-
span<math::SoaTransform> joint_bind_poses_;
133+
// Rest pose of every joint in local space.
134+
span<math::SoaTransform> joint_rest_poses_;
135135

136136
// Array of joint parent indexes.
137137
span<int16_t> joint_parents_;

‎include/ozz/animation/runtime/skeleton_utils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
namespace ozz {
3838
namespace animation {
3939

40-
// Get bind-pose of a skeleton joint.
41-
OZZ_ANIMATION_DLL ozz::math::Transform GetJointLocalBindPose(
40+
// Get rest-pose of a skeleton joint.
41+
OZZ_ANIMATION_DLL ozz::math::Transform GetJointLocalRestPose(
4242
const Skeleton& _skeleton, int _joint);
4343

4444
// Test if a joint is a leaf. _joint number must be in range [0, num joints].

‎samples/additive/sample_additive.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {
115115
ozz::animation::BlendingJob blend_job;
116116
blend_job.layers = layers;
117117
blend_job.additive_layers = additive_layers;
118-
blend_job.bind_pose = skeleton_.joint_bind_poses();
118+
blend_job.rest_pose = skeleton_.joint_rest_poses();
119119
blend_job.output = make_span(blended_locals_);
120120

121121
// Blends.

‎samples/blend/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ There are two ways to use the sample:
2323

2424
1. Load animations and skeleton. See "playback" sample for more details.
2525
2. Compute each animation time (in order to sync their duration) and samples each of them to get local-space transformations.
26-
3. Compute each animation (layer) blend weight and fills ozz::animation::BlendingJob object. BlendingJob object takes as input an array of BlendingJob::Layer representing each layer to blend: weight and local-space transformations (as outputed from the sampling stage). It also takes as input the skeleton bind-pose, which represents the default transformation of each joint. It is used by the blending algorithm as a fall-back when the accumulated layer weight is too small (under a threshold value which is also an input) to be used. The output of the blending job is a set of local-space transformations.
26+
3. Compute each animation (layer) blend weight and fills ozz::animation::BlendingJob object. BlendingJob object takes as input an array of BlendingJob::Layer representing each layer to blend: weight and local-space transformations (as outputed from the sampling stage). It also takes as input the skeleton rest-pose, which represents the default transformation of each joint. It is used by the blending algorithm as a fall-back when the accumulated layer weight is too small (under a threshold value which is also an input) to be used. The output of the blending job is a set of local-space transformations.
2727
4. Convert local-space transformations to model-space matrices using ozz::animation::LocalToModelJob. It takes as input the skeleton (to know about joint's hierarchy) and local-space transforms. Output is model-space matrices array.
2828
5. Model-space matrices array can then be used for rendering (to skin a mesh) or updating the scene graph.

‎samples/blend/sample_blend.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class BlendSampleApplication : public ozz::sample::Application {
119119
ozz::animation::BlendingJob blend_job;
120120
blend_job.threshold = threshold_;
121121
blend_job.layers = layers;
122-
blend_job.bind_pose = skeleton_.joint_bind_poses();
122+
blend_job.rest_pose = skeleton_.joint_rest_poses();
123123
blend_job.output = make_span(blended_locals_);
124124

125125
// Blends.
@@ -322,7 +322,7 @@ class BlendSampleApplication : public ozz::sample::Application {
322322
ozz::vector<ozz::math::SoaTransform> locals;
323323
} samplers_[kNumLayers]; // kNumLayers animations to blend.
324324

325-
// Blending job bind pose threshold.
325+
// Blending job rest pose threshold.
326326
float threshold_;
327327

328328
// Buffer of local transforms which stores the blending result.

‎samples/foot_ik/sample_foot_ik.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ class FootIKSampleApplication : public ozz::sample::Application {
746746
ozz::vector<ozz::math::Float4x4> models_;
747747

748748
// Buffer of skinning matrices, result of the joint multiplication of the
749-
// inverse bind pose with the model space matrix.
749+
// inverse rest pose with the model space matrix.
750750
ozz::vector<ozz::math::Float4x4> skinning_matrices_;
751751

752752
// The mesh used by the sample.

‎samples/framework/internal/renderer_impl.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ bool RendererImpl::DrawGrid(int _cell_count, float _cell_size) {
239239
return true;
240240
}
241241

242-
// Computes the model space bind pose and renders it.
242+
// Computes the model space rest pose and renders it.
243243
bool RendererImpl::DrawSkeleton(const ozz::animation::Skeleton& _skeleton,
244244
const ozz::math::Float4x4& _transform,
245245
bool _draw_joints) {
@@ -253,9 +253,9 @@ bool RendererImpl::DrawSkeleton(const ozz::animation::Skeleton& _skeleton,
253253
// Reallocate matrix array if necessary.
254254
prealloc_models_.resize(num_joints);
255255

256-
// Compute model space bind pose.
256+
// Compute model space rest pose.
257257
ozz::animation::LocalToModelJob job;
258-
job.input = _skeleton.joint_bind_poses();
258+
job.input = _skeleton.joint_rest_poses();
259259
job.output = make_span(prealloc_models_);
260260
job.skeleton = &_skeleton;
261261
if (!job.Run()) {

‎samples/framework/renderer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Renderer {
7979
// has a size of _cell_size.
8080
virtual bool DrawGrid(int _cell_count, float _cell_size) = 0;
8181

82-
// Renders a skeleton in its bind pose posture.
82+
// Renders a skeleton in its rest pose posture.
8383
virtual bool DrawSkeleton(const animation::Skeleton& _skeleton,
8484
const ozz::math::Float4x4& _transform,
8585
bool _draw_joints = true) = 0;
@@ -121,7 +121,7 @@ class Renderer {
121121
bool tangents; // Show tangents.
122122
bool binormals; // Show binormals, computed from the normal and tangent.
123123
bool colors; // Show vertex colors.
124-
bool wireframe; // Show vertex colors.
124+
bool wireframe; // Show vertex colors.
125125
bool skip_skinning; // Show texture (default checkered texture).
126126

127127
Options()

‎samples/framework/utils.cc

+11-17
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,22 @@
3030
#include <cassert>
3131
#include <limits>
3232

33-
#include "ozz/base/maths/box.h"
34-
#include "ozz/base/maths/simd_math.h"
35-
#include "ozz/base/maths/simd_quaternion.h"
36-
#include "ozz/base/maths/soa_transform.h"
37-
38-
#include "ozz/base/memory/allocator.h"
39-
33+
#include "framework/imgui.h"
34+
#include "framework/mesh.h"
35+
#include "ozz/animation/offline/raw_skeleton.h"
4036
#include "ozz/animation/runtime/animation.h"
4137
#include "ozz/animation/runtime/local_to_model_job.h"
4238
#include "ozz/animation/runtime/skeleton.h"
4339
#include "ozz/animation/runtime/track.h"
44-
45-
#include "ozz/animation/offline/raw_skeleton.h"
46-
47-
#include "ozz/geometry/runtime/skinning_job.h"
48-
4940
#include "ozz/base/io/archive.h"
5041
#include "ozz/base/io/stream.h"
5142
#include "ozz/base/log.h"
52-
53-
#include "framework/imgui.h"
54-
#include "framework/mesh.h"
43+
#include "ozz/base/maths/box.h"
44+
#include "ozz/base/maths/simd_math.h"
45+
#include "ozz/base/maths/simd_quaternion.h"
46+
#include "ozz/base/maths/soa_transform.h"
47+
#include "ozz/base/memory/allocator.h"
48+
#include "ozz/geometry/runtime/skinning_job.h"
5549

5650
namespace ozz {
5751
namespace sample {
@@ -224,9 +218,9 @@ void ComputeSkeletonBounds(const animation::Skeleton& _skeleton,
224218
// Allocate matrix array, out of memory is handled by the LocalToModelJob.
225219
ozz::vector<ozz::math::Float4x4> models(num_joints);
226220

227-
// Compute model space bind pose.
221+
// Compute model space rest pose.
228222
ozz::animation::LocalToModelJob job;
229-
job.input = _skeleton.joint_bind_poses();
223+
job.input = _skeleton.joint_rest_poses();
230224
job.output = make_span(models);
231225
job.skeleton = &_skeleton;
232226
if (job.Run()) {

‎samples/look_at/sample_look_at.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ class LookAtSampleApplication : public ozz::sample::Application {
478478
ozz::vector<ozz::math::Float4x4> models_;
479479

480480
// Buffer of skinning matrices, result of the joint multiplication of the
481-
// inverse bind pose with the model-space matrix.
481+
// inverse rest pose with the model-space matrix.
482482
ozz::vector<ozz::math::Float4x4> skinning_matrices_;
483483

484484
// The mesh used by the sample.

‎samples/optimize/sample_optimize.cc

+11-11
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,31 @@ class OptimizeSampleApplication : public ozz::sample::Application {
123123
}
124124

125125
// Computes difference between the optimized and non-optimized animations
126-
// in local space, and rebinds it to the bind pose.
126+
// in local space, and rebinds it to the rest pose.
127127
{
128-
const ozz::span<const ozz::math::SoaTransform>& bind_poses =
129-
skeleton_.joint_bind_poses();
130-
const ozz::math::SoaTransform* bind_pose = bind_poses.begin();
128+
const ozz::span<const ozz::math::SoaTransform>& rest_poses =
129+
skeleton_.joint_rest_poses();
130+
const ozz::math::SoaTransform* rest_pose = rest_poses.begin();
131131
const ozz::math::SoaTransform* locals_raw = locals_raw_.data();
132132
const ozz::math::SoaTransform* locals_rt = locals_rt_.data();
133133
ozz::math::SoaTransform* locals_diff = locals_diff_.data();
134-
for (; bind_pose < bind_poses.end();
135-
++locals_raw, ++locals_rt, ++locals_diff, ++bind_pose) {
134+
for (; rest_pose < rest_poses.end();
135+
++locals_raw, ++locals_rt, ++locals_diff, ++rest_pose) {
136136
assert(locals_raw < array_end(locals_raw_) &&
137137
locals_rt < array_end(locals_rt_) &&
138138
locals_diff < array_end(locals_diff_) &&
139-
bind_pose < bind_poses.end());
139+
rest_pose < rest_poses.end());
140140

141141
// Computes difference.
142142
const ozz::math::SoaTransform diff = {
143143
locals_rt->translation - locals_raw->translation,
144144
locals_rt->rotation * Conjugate(locals_raw->rotation),
145145
locals_rt->scale / locals_raw->scale};
146146

147-
// Rebinds to the bind pose in the diff buffer.
148-
locals_diff->translation = bind_pose->translation + diff.translation;
149-
locals_diff->rotation = bind_pose->rotation * diff.rotation;
150-
locals_diff->scale = bind_pose->scale * diff.scale;
147+
// Rebinds to the rest pose in the diff buffer.
148+
locals_diff->translation = rest_pose->translation + diff.translation;
149+
locals_diff->rotation = rest_pose->rotation * diff.rotation;
150+
locals_diff->scale = rest_pose->scale * diff.scale;
151151
}
152152
}
153153

‎samples/partial_blend/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ The GUI also proposes to select the "root" joint of the upper body hierarchy, wh
2424
4. Uses ozz::animation::IterateJointsDF helper function to iterate all children of the upper body root joint, and set up per-joint weight masks as follows (note that weight coefficients are stored as SoA floats):
2525
- Upper body weight mask: Affects upper body weight coefficient to all the joints that are part of the upper body, all others are set to zero.
2626
- Lower body weight mask: Affects lower body weight coefficient to all the joints that are part of the lower body (ie: all the ones that are not part of the upper body), all others are set to one.
27-
5. Sets ozz::animation::BlendingJob object with the two layers for the lower and upper body. Per-joint weight masks are provided as an input to each layer. All other arguments (bind-pose, input local-space transforms, weights, output) are the same as those used by the full skeleton hierarchy blending. See "blend" sample for more details.
27+
5. Sets ozz::animation::BlendingJob object with the two layers for the lower and upper body. Per-joint weight masks are provided as an input to each layer. All other arguments (rest-pose, input local-space transforms, weights, output) are the same as those used by the full skeleton hierarchy blending. See "blend" sample for more details.
2828
6. Converts local-space transformations, outputted from the blending stage, to model-space matrices using ozz::animation::LocalToModelJob. It also takes as input the skeleton (to know about joint's hierarchy). Output is model-space matrices array.
2929
7. Model-space matrices array can then be used for rendering (to skin a mesh) or updating the scene graph.

0 commit comments

Comments
 (0)
Please sign in to comment.