Skip to content

Commit

Permalink
Simplifies constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeblanc committed Mar 31, 2024
1 parent fcdb9c8 commit cff1097
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 184 deletions.
12 changes: 3 additions & 9 deletions samples/additive/sample_additive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ OZZ_OPTIONS_DECLARE_STRING(
"media/animation_curl_additive.ozz", false)

class AdditiveBlendSampleApplication : public ozz::sample::Application {
public:
AdditiveBlendSampleApplication()
: base_weight_(0.f),
additive_weigths_{.3f, .9f},
auto_animate_weights_(true) {}

protected:
// Updates current animation time and skeleton pose.
virtual bool OnUpdate(float _dt, float) {
Expand Down Expand Up @@ -324,14 +318,14 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {
ozz::vector<ozz::math::SoaTransform> locals_;

// Blending weight of the base animation layer.
float base_weight_;
float base_weight_ = 0.f;

// Poses of local transforms as sampled from curl and splay animations.
// They are sampled during initialization, as a single pose is used.
ozz::vector<ozz::math::SoaTransform> additive_locals_[kNumLayers];

// Blending weight of the additive animation layer.
float additive_weigths_[kNumLayers];
float additive_weigths_[kNumLayers] = {.3f, .9f};

// Buffer of local transforms which stores the blending result.
ozz::vector<ozz::math::SoaTransform> blended_locals_;
Expand All @@ -341,7 +335,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {
ozz::vector<ozz::math::Float4x4> models_;

// Automatically animates additive weights.
bool auto_animate_weights_;
bool auto_animate_weights_ = true;
};

int main(int _argc, const char** _argv) {
Expand Down
7 changes: 2 additions & 5 deletions samples/attach/sample_attach.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ OZZ_OPTIONS_DECLARE_STRING(animation,
"media/animation.ozz", false)

class AttachSampleApplication : public ozz::sample::Application {
public:
AttachSampleApplication() : attachment_(0), offset_(-.02f, .03f, .05f) {}

protected:
// Updates current animation time and skeleton pose.
virtual bool OnUpdate(float _dt, float) {
Expand Down Expand Up @@ -204,10 +201,10 @@ class AttachSampleApplication : public ozz::sample::Application {
ozz::vector<ozz::math::Float4x4> models_;

// Joint where the object is attached.
int attachment_;
int attachment_ = 0;

// Offset, translation of the attached object from the joint.
ozz::math::Float3 offset_;
ozz::math::Float3 offset_ = {-.02f, .03f, .05f};
};

int main(int _argc, const char** _argv) {
Expand Down
5 changes: 1 addition & 4 deletions samples/baked/sample_baked.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ OZZ_OPTIONS_DECLARE_STRING(animation,
"media/animation.ozz", false)

class BakedSampleApplication : public ozz::sample::Application {
public:
BakedSampleApplication() : camera_index_(-1) {}

protected:
// Updates current animation time and skeleton pose.
virtual bool OnUpdate(float _dt, float) {
Expand Down Expand Up @@ -174,7 +171,7 @@ class BakedSampleApplication : public ozz::sample::Application {
ozz::vector<ozz::math::Float4x4> models_;

// Camera joint index. -1 if not found.
int camera_index_;
int camera_index_ = -1;
};

int main(int _argc, const char** _argv) {
Expand Down
12 changes: 3 additions & 9 deletions samples/blend/sample_blend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ OZZ_OPTIONS_DECLARE_STRING(animation3,
"media/animation3.ozz", false)

class BlendSampleApplication : public ozz::sample::Application {
public:
BlendSampleApplication()
: blend_ratio_(.3f),
manual_(false),
threshold_(ozz::animation::BlendingJob().threshold) {}

protected:
// Updates current animation time and skeleton pose.
virtual bool OnUpdate(float _dt, float) {
Expand Down Expand Up @@ -291,10 +285,10 @@ class BlendSampleApplication : public ozz::sample::Application {
// Global blend ratio in range [0,1] that controls all blend parameters and
// synchronizes playback speeds. A value of 0 gives full weight to the first
// animation, and 1 to the last.
float blend_ratio_;
float blend_ratio_ = .3f;

// Switch to manual control of animations and blending parameters.
bool manual_;
bool manual_ = false;

// The number of layers to blend.
enum {
Expand Down Expand Up @@ -325,7 +319,7 @@ class BlendSampleApplication : public ozz::sample::Application {
} samplers_[kNumLayers]; // kNumLayers animations to blend.

// Blending job rest pose threshold.
float threshold_;
float threshold_ = ozz::animation::BlendingJob().threshold;

// Buffer of local transforms which stores the blending result.
ozz::vector<ozz::math::SoaTransform> blended_locals_;
Expand Down
57 changes: 19 additions & 38 deletions samples/foot_ik/sample_foot_ik.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,6 @@ static const ozz::math::Float3 kCharacterRayHeightOffset(0.f, 10.f, 0.f);
static const ozz::math::Float3 kFootRayHeightOffset(0.f, .5f, 0.f);

class FootIKSampleApplication : public ozz::sample::Application {
public:
FootIKSampleApplication()
: pelvis_offset_(0.f, 0.f, 0.f),
root_translation_(2.17f, 2.f, -2.06f),
root_yaw_(-2.f),
foot_heigh_(.12f),
weight_(1.f),
soften_(1.f),
auto_character_height_(true),
pelvis_correction_(true),
two_bone_ik_(true),
aim_ik_(true),
show_skin_(true),
show_joints_(false),
show_raycast_(false),
show_ankle_target_(false),
show_root_(false),
show_offsetted_root_(false) {}

protected:
// Updates current animation time and foot ik.
virtual bool OnUpdate(float _dt, float) {
Expand Down Expand Up @@ -767,32 +748,32 @@ class FootIKSampleApplication : public ozz::sample::Application {

LegRayInfo capsule;

ozz::math::Float3 pelvis_offset_;
ozz::math::Float3 pelvis_offset_ = {0.f, 0.f, 0.f};

// The floor meshes used by the sample (collision and rendering).
ozz::vector<ozz::sample::Mesh> floors_;

// Root transformation.
ozz::math::Float3 root_translation_;
float root_yaw_;
ozz::math::Float3 root_translation_ = {2.17f, 2.f, -2.06f};
float root_yaw_ = -2.f;

// Foot height setting
float foot_heigh_;

float weight_;
float soften_;

bool auto_character_height_;
bool pelvis_correction_;
bool two_bone_ik_;
bool aim_ik_;

bool show_skin_;
bool show_joints_;
bool show_raycast_;
bool show_ankle_target_;
bool show_root_;
bool show_offsetted_root_;
float foot_heigh_ = .12f;

float weight_ = 1.f;
float soften_ = 1.f;

bool auto_character_height_ = true;
bool pelvis_correction_ = true;
bool two_bone_ik_ = true;
bool aim_ik_ = true;

bool show_skin_ = true;
bool show_joints_ = false;
bool show_raycast_ = false;
bool show_ankle_target_ = false;
bool show_root_ = false;
bool show_offsetted_root_ = false;
};

int main(int _argc, const char** _argv) {
Expand Down
39 changes: 12 additions & 27 deletions samples/look_at/sample_look_at.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,6 @@ static_assert(OZZ_ARRAY_SIZE(kJointUpVectors) == kMaxChainLength,
"Array size mismatch.");

class LookAtSampleApplication : public ozz::sample::Application {
public:
LookAtSampleApplication()
: target_offset_(.2f, 1.5f, -.3f),
target_extent_(1.f),
eyes_offset_(.07f, .1f, 0.f),
enable_ik_(true),
chain_length_(kMaxChainLength),
joint_weight_(.5f),
chain_weight_(1.f),
show_skin_(true),
show_joints_(false),
show_target_(true),
show_eyes_offset_(false),
show_forward_(false) {}

protected:
// Updates current animation time and skeleton pose.
virtual bool OnUpdate(float _dt, float _time) {
Expand Down Expand Up @@ -492,35 +477,35 @@ class LookAtSampleApplication : public ozz::sample::Application {
// Sample settings

// Target position management.
ozz::math::Float3 target_offset_;
float target_extent_;
ozz::math::Float3 target_offset_ = {.2f, 1.5f, -.3f};
float target_extent_ = 1.f;
ozz::math::Float3 target_;

// Offset of the look at position in (head) joint local-space.
ozz::math::Float3 eyes_offset_;
ozz::math::Float3 eyes_offset_ = {.07f, .1f, 0.f};

// IK settings

// Enable IK look at.
bool enable_ik_;
bool enable_ik_ = true;

// Set length of the chain that is IKed, between 0 and kMaxChainLength.
int chain_length_;
int chain_length_ = kMaxChainLength;

// Weight given to every joint of the chain. If any joint has a weight of 1,
// no other following joint will contribute (as the target will be reached).
float joint_weight_;
float joint_weight_ = .5f;

// Overall weight given to the IK on the full chain. This allows blending in
// and out of IK.
float chain_weight_;
float chain_weight_ = 1.f;

// Options
bool show_skin_;
bool show_joints_;
bool show_target_;
bool show_eyes_offset_;
bool show_forward_;
bool show_skin_ = true;
bool show_joints_ = false;
bool show_target_ = true;
bool show_eyes_offset_ = false;
bool show_forward_ = false;
};

int main(int _argc, const char** _argv) {
Expand Down
5 changes: 1 addition & 4 deletions samples/millipede/sample_millipede.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ const RawAnimation::TranslationKey kPrecomputedKeys[] = {
const int kPrecomputedKeyCount = OZZ_ARRAY_SIZE(kPrecomputedKeys);

class MillipedeSampleApplication : public ozz::sample::Application {
public:
MillipedeSampleApplication() : slice_count_(26) {}

protected:
virtual bool OnUpdate(float _dt, float) {
// Updates current animation time
Expand Down Expand Up @@ -413,7 +410,7 @@ class MillipedeSampleApplication : public ozz::sample::Application {
ozz::sample::PlaybackController controller_;

// Millipede skeleton number of slices. 7 joints per slice.
int slice_count_;
int slice_count_ = 26;

// The millipede skeleton.
ozz::unique_ptr<ozz::animation::Skeleton> skeleton_;
Expand Down
22 changes: 9 additions & 13 deletions samples/multithread/sample_multithread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,7 @@ bool HasThreadingSupport() {

class MultithreadSampleApplication : public ozz::sample::Application {
public:
MultithreadSampleApplication()
: characters_(kMaxCharacters),
num_characters_(kMaxCharacters / 4),
has_threading_support_(HasThreadingSupport()),
enable_theading_(has_threading_support_),
grain_size_(128) {
MultithreadSampleApplication() : characters_(kMaxCharacters) {
if (has_threading_support_) {
ozz::log::Out() << "Platform has threading support." << std::endl;
} else {
Expand Down Expand Up @@ -287,7 +282,8 @@ class MultithreadSampleApplication : public ozz::sample::Application {
ozz::sample::ImGui::OpenClose oc(_im_gui, "Sample control", &oc_open);
if (oc_open) {
char label[64];
std::snprintf(label, sizeof(label), "Number of entities: %d", num_characters_);
std::snprintf(label, sizeof(label), "Number of entities: %d",
num_characters_);
_im_gui->DoSlider(label, 1, kMaxCharacters, &num_characters_, .7f);
const int num_joints = num_characters_ * skeleton_.num_joints();
std::snprintf(label, sizeof(label), "Number of joints: %d", num_joints);
Expand All @@ -307,8 +303,8 @@ class MultithreadSampleApplication : public ozz::sample::Application {
_im_gui->DoSlider(label, kMinGrainSize, kMaxCharacters, &grain_size_,
.2f);
const int num_threads = monitor_.ThreadCount();
std::snprintf(label, sizeof(label), "Thread/task count: %d/%d", num_threads,
monitor_.TaskCount());
std::snprintf(label, sizeof(label), "Thread/task count: %d/%d",
num_threads, monitor_.TaskCount());
_im_gui->DoLabel(label);
}
}
Expand Down Expand Up @@ -356,16 +352,16 @@ class MultithreadSampleApplication : public ozz::sample::Application {
ozz::vector<Character> characters_;

// Number of used characters.
int num_characters_;
int num_characters_ = kMaxCharacters / 4;

// Does the current plateform actually has threading support.
bool has_threading_support_;
bool has_threading_support_ = HasThreadingSupport();

// Enable or disable threading.
bool enable_theading_;
bool enable_theading_ = has_threading_support_;

// Define the number of characters that a task can handle.
int grain_size_;
int grain_size_ = 128;

// Data used to monitor and analyze threading.
ParallelMonitor monitor_;
Expand Down
22 changes: 7 additions & 15 deletions samples/optimize/sample_optimize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,7 @@ OZZ_OPTIONS_DECLARE_STRING(animation, "Path to the raw animation file.",
class OptimizeSampleApplication : public ozz::sample::Application {
public:
OptimizeSampleApplication()
: selected_display_(eRuntimeAnimation),
optimize_(true),
joint_setting_enable_(true),
joint_(0),
enable_iframes_(true),
iframe_interval_(10.f),
error_record_med_(64),
error_record_max_(64),
joint_error_record_(64) {}
: error_record_med_(64), error_record_max_(64), joint_error_record_(64) {}

protected:
// Updates current animation time and skeleton pose.
Expand Down Expand Up @@ -495,10 +487,10 @@ class OptimizeSampleApplication : public ozz::sample::Application {
eRawAnimation,
eAbsoluteError,
};
int selected_display_;
int selected_display_ = eRuntimeAnimation;

// Select whether optimization should be performed.
bool optimize_;
bool optimize_ = true;

// Imported non-optimized animation.
ozz::animation::offline::RawAnimation raw_animation_;
Expand All @@ -510,13 +502,13 @@ class OptimizeSampleApplication : public ozz::sample::Application {
ozz::animation::offline::AnimationOptimizer::Setting setting_;

// Optimizer joint specific settings.
bool joint_setting_enable_;
int joint_;
bool joint_setting_enable_ = true;
int joint_ = 0;
ozz::animation::offline::AnimationOptimizer::Setting joint_setting_;

// Builder iframe interval
bool enable_iframes_;
float iframe_interval_;
bool enable_iframes_ = true;
float iframe_interval_ = 10.f;

// Playback animation controller. This is a utility class that helps with
// controlling animation playback time.
Expand Down
Loading

0 comments on commit cff1097

Please sign in to comment.