Skip to content

Commit

Permalink
Moves members initialization to .h
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeblanc committed Mar 29, 2024
1 parent 8deec00 commit ba50761
Show file tree
Hide file tree
Showing 22 changed files with 74 additions and 157 deletions.
3 changes: 0 additions & 3 deletions include/ozz/animation/offline/additive_animation_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ struct RawAnimation;
// blending.
class OZZ_ANIMOFFLINE_DLL AdditiveAnimationBuilder {
public:
// Initializes the builder.
AdditiveAnimationBuilder();

// Builds delta animation from _input..
// Returns true on success and fills _output_animation with the delta
// version of _input animation.
Expand Down
7 changes: 2 additions & 5 deletions include/ozz/animation/offline/track_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ struct RawQuaternionTrack;
// performances and memory footprint.
class OZZ_ANIMOFFLINE_DLL TrackOptimizer {
public:
// Initializes the optimizer with default tolerances (favoring quality).
TrackOptimizer();

// Optimizes _input using *this parameters.
// Returns true on success and fills _output track with the optimized
// version of _input track.
Expand All @@ -65,8 +62,8 @@ class OZZ_ANIMOFFLINE_DLL TrackOptimizer {
bool operator()(const RawQuaternionTrack& _input,
RawQuaternionTrack* _output) const;

// Optimization tolerance.
float tolerance;
// Optimization tolerance. Default tolerance favors quality.
float tolerance = 1e-3f; // 1mm
};
} // namespace offline
} // namespace animation
Expand Down
8 changes: 4 additions & 4 deletions include/ozz/animation/runtime/animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct QuaternionKey;
class OZZ_ANIMATION_DLL Animation {
public:
// Builds a default animation.
Animation();
Animation() = default;

// Allow moves.
Animation(Animation&&);
Expand Down Expand Up @@ -188,14 +188,14 @@ class OZZ_ANIMATION_DLL Animation {
void Deallocate();

// Duration of the animation clip.
float duration_;
float duration_ = 0.f;

// The number of joint tracks. Can differ from the data stored in translation/
// rotation/scale buffers because of SoA requirements.
int num_tracks_;
int num_tracks_ = 0;

// Animation name.
char* name_;
char* name_ = nullptr;

// Stores all translation/rotation/scale keys.
span<float> timepoints_;
Expand Down
10 changes: 2 additions & 8 deletions include/ozz/animation/runtime/blending_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ namespace animation {
// The job does not owned any buffers (input/output) and will thus not delete
// them during job's destruction.
struct OZZ_ANIMATION_DLL BlendingJob {
// Default constructor, initializes default values.
BlendingJob();

// Validates job parameters.
// Returns true for a valid job, false otherwise:
// -if layer range is not valid (can be empty though).
Expand All @@ -77,13 +74,10 @@ struct OZZ_ANIMATION_DLL BlendingJob {
// Defines a layer of blending input data (local space transforms) and
// parameters (weights).
struct OZZ_ANIMATION_DLL Layer {
// Default constructor, initializes default values.
Layer();

// Blending weight of this layer. Negative values are considered as 0.
// Normalization is performed during the blending stage so weight can be in
// any range, even though range [0:1] is optimal.
float weight;
float weight = 0.f;

// The range [begin,end[ of input layer posture. This buffer expect to store
// local space transforms, that are usually outputted from a sampling job.
Expand All @@ -110,7 +104,7 @@ struct OZZ_ANIMATION_DLL BlendingJob {
// The job blends the rest pose to the output when the accumulated weight of
// all layers is less than this threshold value.
// Must be greater than 0.f.
float threshold;
float threshold = .1f;

// Job input layers, can be empty or nullptr.
// The range of layers that must be blended.
Expand Down
26 changes: 11 additions & 15 deletions include/ozz/animation/runtime/ik_aim_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
#define OZZ_OZZ_ANIMATION_RUNTIME_IK_AIM_JOB_H_

#include "ozz/animation/runtime/export.h"
#include "ozz/base/platform.h"

#include "ozz/base/maths/simd_math.h"
#include "ozz/base/platform.h"

namespace ozz {
// Forward declaration of math structures.
Expand All @@ -52,9 +51,6 @@ namespace animation {
// Result is unstable if joint-to-target direction is parallel to pole vector,
// or if target is too close to joint position.
struct OZZ_ANIMATION_DLL IKAimJob {
// Default constructor, initializes default values.
IKAimJob();

// Validates job parameters. Returns true for a valid job, or false otherwise:
// -if output quaternion pointer is nullptr
bool Validate() const;
Expand All @@ -68,47 +64,47 @@ struct OZZ_ANIMATION_DLL IKAimJob {
// Job input.

// Target position to aim at, in model-space
math::SimdFloat4 target;
math::SimdFloat4 target = math::simd_float4::zero();

// Joint forward axis, in joint local-space, to be aimed at target position.
// This vector shall be normalized, otherwise validation will fail.
// Default is x axis.
math::SimdFloat4 forward;
math::SimdFloat4 forward = math::simd_float4::x_axis();

// Offset position from the joint in local-space, that will aim at target.
math::SimdFloat4 offset;
math::SimdFloat4 offset = math::simd_float4::zero();

// Joint up axis, in joint local-space, used to keep the joint oriented in the
// same direction as the pole vector. Default is y axis.
math::SimdFloat4 up;
math::SimdFloat4 up = math::simd_float4::y_axis();

// Pole vector, in model-space. The pole vector defines the direction
// the up should point to. Note that IK chain orientation will flip when
// target vector and the pole vector are aligned/crossing each other. It's
// caller responsibility to ensure that this doesn't happen.
math::SimdFloat4 pole_vector;
math::SimdFloat4 pole_vector = math::simd_float4::y_axis();

// Twist_angle rotates joint around the target vector.
// Default is 0.
float twist_angle;
float twist_angle = 0.f;

// Weight given to the IK correction clamped in range [0,1]. This allows to
// blend / interpolate from no IK applied (0 weight) to full IK (1).
float weight;
float weight = 1.f;

// Joint model-space matrix.
const math::Float4x4* joint;
const math::Float4x4* joint = nullptr;

// Job output.

// Output local-space joint correction quaternion. It needs to be multiplied
// with joint local-space quaternion.
math::SimdQuaternion* joint_correction;
math::SimdQuaternion* joint_correction = nullptr;

// Optional boolean output value, set to true if target can be reached with IK
// computations. Target is considered not reachable when target is between
// joint and offset position.
bool* reached;
bool* reached = nullptr;
};
} // namespace animation
} // namespace ozz
Expand Down
48 changes: 22 additions & 26 deletions include/ozz/animation/runtime/ik_two_bone_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
#define OZZ_OZZ_ANIMATION_RUNTIME_IK_TWO_BONE_JOB_H_

#include "ozz/animation/runtime/export.h"
#include "ozz/base/platform.h"

#include "ozz/base/maths/simd_math.h"
#include "ozz/base/platform.h"

namespace ozz {
// Forward declaration of math structures.
Expand All @@ -53,9 +52,6 @@ namespace animation {
// Implementation is inspired by Autodesk Maya 2 bone IK, improved stability
// wise and extended with Soften IK.
struct OZZ_ANIMATION_DLL IKTwoBoneJob {
// Constructor, initializes default values.
IKTwoBoneJob();

// Validates job parameters. Returns true for a valid job, or false otherwise:
// -if any input pointer is nullptr
// -if mid_axis isn't normalized.
Expand All @@ -71,58 +67,58 @@ struct OZZ_ANIMATION_DLL IKTwoBoneJob {

// Target IK position, in model-space. This is the position the end of the
// joint chain will try to reach.
math::SimdFloat4 target;
math::SimdFloat4 target = math::simd_float4::zero();

// Normalized middle joint rotation axis, in middle joint local-space. Default
// value is z axis. This axis is usually fixed for a given skeleton (as it's
// in middle joint space). Its direction is defined like this: a positive
// rotation around this axis will open the angle between the two bones. This
// in turn also to define which side the two joints must bend. Job validation
// will fail if mid_axis isn't normalized.
math::SimdFloat4 mid_axis;
// Normalized middle joint rotation axis, in middle joint local-space.
// Default value is z axis. This axis is usually fixed for a given
// skeleton (as it's in middle joint space). Its direction is defined like
// this: a positive rotation around this axis will open the angle between
// the two bones. This in turn also to define which side the two joints
// must bend. Job validation will fail if mid_axis isn't normalized.
math::SimdFloat4 mid_axis = math::simd_float4::z_axis();

// Pole vector, in model-space. The pole vector defines the direction the
// middle joint should point to, allowing to control IK chain orientation.
// Note that IK chain orientation will flip when target vector and the pole
// vector are aligned/crossing each other. It's caller responsibility to
// ensure that this doesn't happen.
math::SimdFloat4 pole_vector;
// Note that IK chain orientation will flip when target vector and the
// pole vector are aligned/crossing each other. It's caller responsibility
// to ensure that this doesn't happen.
math::SimdFloat4 pole_vector = math::simd_float4::y_axis();

// Twist_angle rotates IK chain around the vector define by start-to-target
// vector. Default is 0.
float twist_angle;
float twist_angle = 0.f;

// Soften ratio allows the chain to gradually fall behind the target
// position. This prevents the joint chain from snapping into the final
// position, softening the final degrees before the joint chain becomes flat.
// This ratio represents the distance to the end, from which softening is
// starting.
float soften;
float soften = 1.f;

// Weight given to the IK correction clamped in range [0,1]. This allows to
// blend / interpolate from no IK applied (0 weight) to full IK (1).
float weight;
float weight = 1.f;

// Model-space matrices of the start, middle and end joints of the chain.
// The 3 joints should be ancestors. They don't need to be direct
// ancestors though.
const math::Float4x4* start_joint;
const math::Float4x4* mid_joint;
const math::Float4x4* end_joint;
const math::Float4x4* start_joint = nullptr;
const math::Float4x4* mid_joint = nullptr;
const math::Float4x4* end_joint = nullptr;

// Job output.

// Local-space corrections to apply to start and middle joints in order for
// end joint to reach target position.
// These quaternions must be multiplied to the local-space quaternion of their
// respective joints.
math::SimdQuaternion* start_joint_correction;
math::SimdQuaternion* mid_joint_correction;
math::SimdQuaternion* start_joint_correction = nullptr;
math::SimdQuaternion* mid_joint_correction = nullptr;

// Optional boolean output value, set to true if target can be reached with IK
// computations. Reachability is driven by bone chain length, soften ratio and
// target distance. Target is considered unreached if weight is less than 1.
bool* reached;
bool* reached = nullptr;
};
} // namespace animation
} // namespace ozz
Expand Down
20 changes: 9 additions & 11 deletions include/ozz/animation/runtime/local_to_model_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#define OZZ_OZZ_ANIMATION_RUNTIME_LOCAL_TO_MODEL_JOB_H_

#include "ozz/animation/runtime/export.h"
#include "ozz/animation/runtime/skeleton.h"
#include "ozz/base/platform.h"
#include "ozz/base/span.h"

Expand Down Expand Up @@ -57,9 +58,6 @@ class Skeleton;
// of affine transformations can contain shearing or complex transformation
// that cannot be represented as Transform object.
struct OZZ_ANIMATION_DLL LocalToModelJob {
// Default constructor, initializes default values.
LocalToModelJob();

// Validates job parameters. Returns true for a valid job, or false otherwise:
// -if any input pointer, including ranges, is nullptr.
// -if the size of the input is smaller than the skeleton's number of joints.
Expand All @@ -78,35 +76,35 @@ struct OZZ_ANIMATION_DLL LocalToModelJob {

// The Skeleton object describing the joint hierarchy used for local to
// model space conversion.
const Skeleton* skeleton;
const Skeleton* skeleton = nullptr;

// The root matrix will multiply to every model space matrices, default nullptr
// means an identity matrix. This can be used to directly compute world-space
// transforms for example.
const ozz::math::Float4x4* root;
// The root matrix will multiply to every model space matrices, default
// nullptr means an identity matrix. This can be used to directly compute
// world-space transforms for example.
const ozz::math::Float4x4* root = nullptr;

// Defines "from" which joint the local-to-model conversion should start.
// Default value is ozz::Skeleton::kNoParent, meaning the whole hierarchy is
// updated. This parameter can be used to optimize update by limiting
// conversion to part of the joint hierarchy. Note that "from" parent should
// be a valid matrix, as it is going to be used as part of "from" joint
// hierarchy update.
int from;
int from = Skeleton::kNoParent;

// Defines "to" which joint the local-to-model conversion should go, "to"
// included. Update will end before "to" joint is reached if "to" is not part
// of the hierarchy starting from "from". Default value is
// ozz::animation::Skeleton::kMaxJoints, meaning the hierarchy (starting from
// "from") is updated to the last joint.
int to;
int to = Skeleton::kMaxJoints;

// If true, "from" joint is not updated during job execution. Update starts
// with all children of "from". This can be used to update a model-space
// transform independently from the local-space one. To do so: set "from"
// joint model-space transform matrix, and run this Job with "from_excluded"
// to update all "from" children.
// Default value is false.
bool from_excluded;
bool from_excluded = false;

// The input range that store local transforms.
span<const ozz::math::SoaTransform> input;
Expand Down
9 changes: 3 additions & 6 deletions include/ozz/animation/runtime/sampling_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ class Animation;
// optimized through the context. The job does not owned the buffers (in/output)
// and will thus not delete them during job's destruction.
struct OZZ_ANIMATION_DLL SamplingJob {
// Default constructor, initializes default values.
SamplingJob();

// Validates job parameters. Returns true for a valid job, or false otherwise:
// -if any input pointer is nullptr
// -if output range is invalid.
Expand All @@ -73,16 +70,16 @@ struct OZZ_ANIMATION_DLL SamplingJob {
// current time in the animation , divided by animation duration.
// This ratio is clamped before job execution in order to resolves any
// approximation issue on range bounds.
float ratio;
float ratio = 0.f;

// The animation to sample.
const Animation* animation;
const Animation* animation = nullptr;

// Forward declares the context object used by the SamplingJob.
class Context;

// A context object that must be big enough to sample *this animation.
Context* context;
Context* context = nullptr;

// Job output.
// The output range to be filled with sampled joints during job execution.
Expand Down
2 changes: 1 addition & 1 deletion include/ozz/animation/runtime/skeleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class OZZ_ANIMATION_DLL Skeleton {
};

// Builds a default skeleton.
Skeleton();
Skeleton() = default;

// Allow move.
Skeleton(Skeleton&&);
Expand Down
8 changes: 3 additions & 5 deletions include/ozz/animation/runtime/track_sampling_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ template <typename _Track>
struct TrackSamplingJob {
typedef typename _Track::ValueType ValueType;

TrackSamplingJob();

// Validates all parameters.
bool Validate() const;

Expand All @@ -53,13 +51,13 @@ struct TrackSamplingJob {
// Ratio used to sample track, clamped in range [0,1] before job execution. 0
// is the beginning of the track, 1 is the end. This is a ratio rather than a
// ratio because tracks have no duration.
float ratio;
float ratio = 0.f;

// Track to sample.
const _Track* track;
const _Track* track = nullptr;

// Job output.
typename _Track::ValueType* result;
typename _Track::ValueType* result = nullptr;
};
} // namespace internal

Expand Down
Loading

0 comments on commit ba50761

Please sign in to comment.