Skip to content

Commit

Permalink
Renames members
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeblanc committed Jun 20, 2024
1 parent 47095c6 commit 4996e52
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 40 deletions.
18 changes: 9 additions & 9 deletions samples/additive/sample_additive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {
sampling_job.animation = &base_animation_;
sampling_job.context = &context_;
sampling_job.ratio = controller_.time_ratio();
sampling_job.output = make_span(locals_);
sampling_job.output = make_span(main_locals_);

// Samples animation.
if (!sampling_job.Run()) {
Expand All @@ -93,7 +93,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {

// Main animation is used as-is.
ozz::animation::BlendingJob::Layer layers[1];
layers[0].transform = make_span(locals_);
layers[0].transform = make_span(main_locals_);
layers[0].weight = base_weight_;
layers[0].joint_weights = make_span(base_joint_weights_);

Expand All @@ -110,7 +110,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {
blend_job.layers = layers;
blend_job.additive_layers = additive_layers;
blend_job.rest_pose = skeleton_.joint_rest_poses();
blend_job.output = make_span(blended_locals_);
blend_job.output = make_span(locals_);

// Blends.
if (!blend_job.Run()) {
Expand All @@ -122,7 +122,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {
// Setup local-to-model conversion job.
ozz::animation::LocalToModelJob ltm_job;
ltm_job.skeleton = &skeleton_;
ltm_job.input = make_span(blended_locals_);
ltm_job.input = make_span(locals_);
ltm_job.output = make_span(models_);

// Run ltm job.
Expand Down Expand Up @@ -181,13 +181,13 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {
context_.Resize(num_joints);

// Allocates local space runtime buffers for base animation.
locals_.resize(num_soa_joints);
main_locals_.resize(num_soa_joints);

// Allocates model space runtime buffers of blended data.
models_.resize(num_joints);

// Storage for blending stage output.
blended_locals_.resize(num_soa_joints);
locals_.resize(num_soa_joints);

// Allocates and sets base animation mask weights to one.
base_joint_weights_.resize(num_soa_joints, ozz::math::simd_float4::one());
Expand All @@ -196,7 +196,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {

// Reads and extract additive animations pose.
const char* filenames[] = {OPTIONS_splay_animation, OPTIONS_curl_animation};
for (int i = 0; i < kNumLayers; ++i) {
for (size_t i = 0; i < kNumLayers; ++i) {
// Reads animation on the stack as it won't need to be maintained in
// memory. Only the pose is needed.
ozz::animation::Animation animation;
Expand Down Expand Up @@ -314,7 +314,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {
ozz::animation::SamplingJob::Context context_;

// Buffer of local transforms as sampled from main animation_.
ozz::vector<ozz::math::SoaTransform> locals_;
ozz::vector<ozz::math::SoaTransform> main_locals_;

// Blending weight of the base animation layer.
float base_weight_ = 0.f;
Expand All @@ -327,7 +327,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {
float additive_weigths_[kNumLayers] = {.3f, .9f};

// Buffer of local transforms which stores the blending result.
ozz::vector<ozz::math::SoaTransform> blended_locals_;
ozz::vector<ozz::math::SoaTransform> locals_;

// Buffer of model space matrices. These are computed by the local-to-model
// job after the blending stage.
Expand Down
32 changes: 15 additions & 17 deletions samples/blend/sample_blend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ class BlendSampleApplication : public ozz::sample::Application {
// Blends animations.
// Blends the local spaces transforms computed by sampling all animations
// (1st stage just above), and outputs the result to the local space
// transform buffer blended_locals_
// transform buffer locals_

// Prepares blending layers.
ozz::animation::BlendingJob::Layer layers[kNumLayers];
for (int i = 0; i < kNumLayers; ++i) {
for (size_t i = 0; i < kNumLayers; ++i) {
layers[i].transform = make_span(samplers_[i].locals);
layers[i].weight = samplers_[i].weight;
}
Expand All @@ -112,7 +112,7 @@ class BlendSampleApplication : public ozz::sample::Application {
blend_job.threshold = threshold_;
blend_job.layers = layers;
blend_job.rest_pose = skeleton_.joint_rest_poses();
blend_job.output = make_span(blended_locals_);
blend_job.output = make_span(locals_);

// Blends.
if (!blend_job.Run()) {
Expand All @@ -125,7 +125,7 @@ class BlendSampleApplication : public ozz::sample::Application {
// Setup local-to-model conversion job.
ozz::animation::LocalToModelJob ltm_job;
ltm_job.skeleton = &skeleton_;
ltm_job.input = make_span(blended_locals_);
ltm_job.input = make_span(locals_);
ltm_job.output = make_span(models_);

// Runs ltm job.
Expand All @@ -142,7 +142,7 @@ class BlendSampleApplication : public ozz::sample::Application {
// Computes weight parameters for all samplers.
const float kNumIntervals = kNumLayers - 1;
const float kInterval = 1.f / kNumIntervals;
for (int i = 0; i < kNumLayers; ++i) {
for (size_t i = 0; i < kNumLayers; ++i) {
const float med = i * kInterval;
const float x = blend_ratio_ - med;
const float y = ((x < 0.f ? x : -x) + kInterval) * kNumIntervals;
Expand All @@ -154,8 +154,8 @@ class BlendSampleApplication : public ozz::sample::Application {
// interval that contains blend_ratio_.
// Uses a maximum value smaller that 1.f (-epsilon) to ensure that
// (relevant_sampler + 1) is always valid.
const int relevant_sampler =
static_cast<int>((blend_ratio_ - 1e-3f) * (kNumLayers - 1));
const size_t relevant_sampler =
static_cast<size_t>((blend_ratio_ - 1e-3f) * (kNumLayers - 1));
assert(relevant_sampler + 1 < kNumLayers);
Sampler& sampler_l = samplers_[relevant_sampler];
Sampler& sampler_r = samplers_[relevant_sampler + 1];
Expand Down Expand Up @@ -192,7 +192,7 @@ class BlendSampleApplication : public ozz::sample::Application {
const char* filenames[] = {OPTIONS_animation1, OPTIONS_animation2,
OPTIONS_animation3};
static_assert(OZZ_ARRAY_SIZE(filenames) == kNumLayers, "Arrays mismatch.");
for (int i = 0; i < kNumLayers; ++i) {
for (size_t i = 0; i < kNumLayers; ++i) {
Sampler& sampler = samplers_[i];

if (!ozz::sample::LoadAnimation(filenames[i], &sampler.animation)) {
Expand All @@ -207,7 +207,7 @@ class BlendSampleApplication : public ozz::sample::Application {
}

// Allocates local space runtime buffers of blended data.
blended_locals_.resize(num_soa_joints);
locals_.resize(num_soa_joints);

// Allocates model space runtime buffers of blended data.
models_.resize(num_joints);
Expand All @@ -234,10 +234,10 @@ class BlendSampleApplication : public ozz::sample::Application {
std::snprintf(label, sizeof(label), "Blend ratio: %.2f", blend_ratio_);
_im_gui->DoSlider(label, 0.f, 1.f, &blend_ratio_, 1.f, !manual_);

for (int i = 0; i < kNumLayers; ++i) {
for (size_t i = 0; i < kNumLayers; ++i) {
Sampler& sampler = samplers_[i];
std::snprintf(label, sizeof(label), "Weight %d: %.2f", i,
sampler.weight);
std::snprintf(label, sizeof(label), "Weight %d: %.2f",
static_cast<int>(i), sampler.weight);
_im_gui->DoSlider(label, 0.f, 1.f, &sampler.weight, 1.f, manual_);
}

Expand All @@ -256,7 +256,7 @@ class BlendSampleApplication : public ozz::sample::Application {
const char* oc_names[] = {"Animation 1", "Animation 2", "Animation 3"};
static_assert(OZZ_ARRAY_SIZE(oc_names) == kNumLayers,
"Arrays size mismatch");
for (int i = 0; i < kNumLayers; ++i) {
for (size_t i = 0; i < kNumLayers; ++i) {
Sampler& sampler = samplers_[i];
ozz::sample::ImGui::OpenClose loc(_im_gui, oc_names[i], nullptr);
if (open[i]) {
Expand Down Expand Up @@ -286,9 +286,7 @@ class BlendSampleApplication : public ozz::sample::Application {
bool manual_ = false;

// The number of layers to blend.
enum {
kNumLayers = 3,
};
static constexpr size_t kNumLayers = 3;

// Sampler structure contains all the data required to sample a single
// animation.
Expand Down Expand Up @@ -317,7 +315,7 @@ class BlendSampleApplication : public ozz::sample::Application {
float threshold_ = ozz::animation::BlendingJob().threshold;

// Buffer of local transforms which stores the blending result.
ozz::vector<ozz::math::SoaTransform> blended_locals_;
ozz::vector<ozz::math::SoaTransform> locals_;

// Buffer of model space matrices. These are computed by the local-to-model
// job after the blending stage.
Expand Down
26 changes: 12 additions & 14 deletions samples/partial_blend/sample_partial_blend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
virtual bool OnUpdate(float _dt, float) {
// Updates and samples both animations to their respective local space
// transform buffers.
for (int i = 0; i < kNumLayers; ++i) {
for (size_t i = 0; i < kNumLayers; ++i) {
Sampler& sampler = samplers_[i];

// Updates animations time.
Expand All @@ -89,11 +89,11 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
// Blends animations.
// Blends the local spaces transforms computed by sampling all animations
// (1st stage just above), and outputs the result to the local space
// transform buffer blended_locals_
// transform buffer locals_

// Prepares blending layers.
ozz::animation::BlendingJob::Layer layers[kNumLayers];
for (int i = 0; i < kNumLayers; ++i) {
for (size_t i = 0; i < kNumLayers; ++i) {
layers[i].transform = make_span(samplers_[i].locals);
layers[i].weight = samplers_[i].weight_setting;

Expand All @@ -106,7 +106,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
blend_job.threshold = threshold_;
blend_job.layers = layers;
blend_job.rest_pose = skeleton_.joint_rest_poses();
blend_job.output = make_span(blended_locals_);
blend_job.output = make_span(locals_);

// Blends.
if (!blend_job.Run()) {
Expand All @@ -119,7 +119,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
// Setup local-to-model conversion job.
ozz::animation::LocalToModelJob ltm_job;
ltm_job.skeleton = &skeleton_;
ltm_job.input = make_span(blended_locals_);
ltm_job.input = make_span(locals_);
ltm_job.output = make_span(models_);

// Run ltm job.
Expand All @@ -146,7 +146,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
// Reading animations.
const char* filenames[] = {OPTIONS_lower_body_animation,
OPTIONS_upper_body_animation};
for (int i = 0; i < kNumLayers; ++i) {
for (size_t i = 0; i < kNumLayers; ++i) {
Sampler& sampler = samplers_[i];

if (!ozz::sample::LoadAnimation(filenames[i], &sampler.animation)) {
Expand Down Expand Up @@ -174,7 +174,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
upper_body_sampler.joint_weight_setting = 1.f;

// Allocates local space runtime buffers of blended data.
blended_locals_.resize(num_soa_joints);
locals_.resize(num_soa_joints);

// Allocates model space runtime buffers of blended data.
models_.resize(num_joints);
Expand Down Expand Up @@ -312,7 +312,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
static bool open[kNumLayers] = {true, true};
const char* oc_names[kNumLayers] = {"Lower body animation",
"Upper body animation"};
for (int i = 0; i < kNumLayers; ++i) {
for (size_t i = 0; i < kNumLayers; ++i) {
Sampler& sampler = samplers_[i];
ozz::sample::ImGui::OpenClose loc(_im_gui, oc_names[i], nullptr);
if (open[i]) {
Expand All @@ -334,11 +334,9 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
ozz::animation::Skeleton skeleton_;

// The number of layers to blend.
enum {
kLowerBody = 0,
kUpperBody = 1,
kNumLayers = 2,
};
static constexpr size_t kLowerBody = 0;
static constexpr size_t kUpperBody = 1;
static constexpr size_t kNumLayers = 2;

// Sampler structure contains all the data required to sample a single
// animation.
Expand Down Expand Up @@ -380,7 +378,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
float threshold_ = ozz::animation::BlendingJob().threshold;

// Buffer of local transforms which stores the blending result.
ozz::vector<ozz::math::SoaTransform> blended_locals_;
ozz::vector<ozz::math::SoaTransform> locals_;

// Buffer of model space matrices. These are computed by the local-to-model
// job after the blending stage.
Expand Down

0 comments on commit 4996e52

Please sign in to comment.