Updated ozz-animation to version 0.14.1 @35b2efd4

This commit is contained in:
Martin Felis
2023-03-26 13:28:12 +02:00
parent bf3189ff49
commit 15871f349c
194 changed files with 3495 additions and 1957 deletions
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_ADDITIVE_ANIMATION_BUILDER_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_ADDITIVE_ANIMATION_BUILDER_H_
#include "ozz/animation/offline/export.h"
#include "ozz/base/platform.h"
#include "ozz/base/span.h"
@@ -46,7 +47,7 @@ struct RawAnimation;
// Defines the class responsible for building a delta animation from an offline
// raw animation. This is used to create animations compatible with additive
// blending.
class AdditiveAnimationBuilder {
class OZZ_ANIMOFFLINE_DLL AdditiveAnimationBuilder {
public:
// Initializes the builder.
AdditiveAnimationBuilder();
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_ANIMATION_BUILDER_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_ANIMATION_BUILDER_H_
#include "ozz/animation/offline/export.h"
#include "ozz/base/memory/unique_ptr.h"
namespace ozz {
@@ -44,7 +45,7 @@ struct RawAnimation;
// Defines the class responsible of building runtime animation instances from
// offline raw animations.
// No optimization at all is performed on the raw animation.
class AnimationBuilder {
class OZZ_ANIMOFFLINE_DLL AnimationBuilder {
public:
// Creates an Animation based on _raw_animation and *this builder parameters.
// Returns a valid Animation on success.
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_ANIMATION_OPTIMIZER_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_ANIMATION_OPTIMIZER_H_
#include "ozz/animation/offline/export.h"
#include "ozz/base/containers/map.h"
namespace ozz {
@@ -54,7 +55,7 @@ struct RawAnimation;
// that leads to the hand if user wants it to be precise. Default optimization
// tolerances are set in order to favor quality over runtime performances and
// memory footprint.
class AnimationOptimizer {
class OZZ_ANIMOFFLINE_DLL AnimationOptimizer {
public:
// Initializes the optimizer with default tolerances (favoring quality).
AnimationOptimizer();
@@ -89,7 +90,7 @@ class AnimationOptimizer {
float distance;
};
// Golbal optimization settings. These settings apply to all joints of the
// Global optimization settings. These settings apply to all joints of the
// hierarchy, unless overriden by joint specific settings.
Setting setting;
@@ -0,0 +1,44 @@
//----------------------------------------------------------------------------//
// //
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
// and distributed under the MIT License (MIT). //
// //
// Copyright (c) Guillaume Blanc //
// //
// Permission is hereby granted, free of charge, to any person obtaining a //
// copy of this software and associated documentation files (the "Software"), //
// to deal in the Software without restriction, including without limitation //
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
// and/or sell copies of the Software, and to permit persons to whom the //
// Software is furnished to do so, subject to the following conditions: //
// //
// The above copyright notice and this permission notice shall be included in //
// all copies or substantial portions of the Software. //
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
// DEALINGS IN THE SOFTWARE. //
// //
//----------------------------------------------------------------------------//
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_EXPORT_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_EXPORT_H_
#if defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#ifdef OZZ_BUILD_ANIMOFFLINE_LIB
// Import/Export for dynamic linking while building ozz
#define OZZ_ANIMOFFLINE_DLL __declspec(dllexport)
#else
#define OZZ_ANIMOFFLINE_DLL __declspec(dllimport)
#endif
#else // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
// Static or non msvc linking
#define OZZ_ANIMOFFLINE_DLL
#endif // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#endif // OZZ_OZZ_ANIMATION_OFFLINE_EXPORT_H_
@@ -0,0 +1,44 @@
//----------------------------------------------------------------------------//
// //
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
// and distributed under the MIT License (MIT). //
// //
// Copyright (c) Guillaume Blanc //
// //
// Permission is hereby granted, free of charge, to any person obtaining a //
// copy of this software and associated documentation files (the "Software"), //
// to deal in the Software without restriction, including without limitation //
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
// and/or sell copies of the Software, and to permit persons to whom the //
// Software is furnished to do so, subject to the following conditions: //
// //
// The above copyright notice and this permission notice shall be included in //
// all copies or substantial portions of the Software. //
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
// DEALINGS IN THE SOFTWARE. //
// //
//----------------------------------------------------------------------------//
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_FBX_EXPORT_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_FBX_EXPORT_H_
#if defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#ifdef OZZ_BUILD_ANIMATIONFBX_LIB
// Import/Export for dynamic linking while building ozz
#define OZZ_ANIMFBX_DLL __declspec(dllexport)
#else
#define OZZ_ANIMFBX_DLL __declspec(dllimport)
#endif
#else // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
// Static or non msvc linking
#define OZZ_ANIMFBX_DLL
#endif // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#endif // OZZ_OZZ_ANIMATION_OFFLINE_FBX_EXPORT_H_
@@ -30,6 +30,7 @@
#include <fbxsdk.h>
#include "ozz/animation/offline/fbx/export.h"
#include "ozz/base/maths/simd_math.h"
#include "ozz/base/maths/transform.h"
@@ -42,7 +43,7 @@ namespace offline {
namespace fbx {
// Manages FbxManager instance.
class FbxManagerInstance {
class OZZ_ANIMFBX_DLL FbxManagerInstance {
public:
// Instantiates FbxManager.
FbxManagerInstance();
@@ -58,7 +59,7 @@ class FbxManagerInstance {
};
// Default io settings used to import a scene.
class FbxDefaultIOSettings {
class OZZ_ANIMFBX_DLL FbxDefaultIOSettings {
public:
// Instantiates default settings.
explicit FbxDefaultIOSettings(const FbxManagerInstance& _manager);
@@ -77,13 +78,13 @@ class FbxDefaultIOSettings {
};
// Io settings used to import an animation from a scene.
class FbxAnimationIOSettings : public FbxDefaultIOSettings {
class OZZ_ANIMFBX_DLL FbxAnimationIOSettings : public FbxDefaultIOSettings {
public:
FbxAnimationIOSettings(const FbxManagerInstance& _manager);
};
// Io settings used to import a skeleton from a scene.
class FbxSkeletonIOSettings : public FbxDefaultIOSettings {
class OZZ_ANIMFBX_DLL FbxSkeletonIOSettings : public FbxDefaultIOSettings {
public:
FbxSkeletonIOSettings(const FbxManagerInstance& _manager);
};
@@ -94,7 +95,7 @@ class FbxSkeletonIOSettings : public FbxDefaultIOSettings {
// While Fbx sdk FbxAxisSystem::ConvertScene and FbxSystem::ConvertScene only
// affect scene root, this class functions can be used to bake nodes, vertices,
// animations transformations...
class FbxSystemConverter {
class OZZ_ANIMFBX_DLL FbxSystemConverter {
public:
// Initialize converter with fbx scene systems.
FbxSystemConverter(const FbxAxisSystem& _from_axis,
@@ -133,7 +134,7 @@ class FbxSystemConverter {
};
// Loads a scene from a Fbx file.
class FbxSceneLoader {
class OZZ_ANIMFBX_DLL FbxSceneLoader {
public:
// Loads the scene that can then be obtained with scene() function.
FbxSceneLoader(const char* _filename, const char* _password,
@@ -28,6 +28,8 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_FBX_FBX_ANIMATION_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_FBX_FBX_ANIMATION_H_
#include "ozz/animation/offline/fbx/export.h"
#include "ozz/animation/offline/fbx/fbx.h"
#include "ozz/animation/offline/tools/import2ozz.h"
@@ -51,34 +53,40 @@ struct RawquaternionTrack;
namespace fbx {
OzzImporter::AnimationNames GetAnimationNames(FbxSceneLoader& _scene_loader);
OZZ_ANIMFBX_DLL OzzImporter::AnimationNames GetAnimationNames(
FbxSceneLoader& _scene_loader);
bool ExtractAnimation(const char* _animation_name,
OZZ_ANIMFBX_DLL bool ExtractAnimation(const char* _animation_name,
FbxSceneLoader& _scene_loader, const Skeleton& _skeleton,
float _sampling_rate, RawAnimation* _animation);
OzzImporter::NodeProperties GetNodeProperties(FbxSceneLoader& _scene_loader,
OZZ_ANIMFBX_DLL OzzImporter::NodeProperties GetNodeProperties(
FbxSceneLoader& _scene_loader,
const char* _node_name);
bool ExtractTrack(const char* _animation_name, const char* _node_name,
OZZ_ANIMFBX_DLL bool ExtractTrack(const char* _animation_name,
const char* _node_name,
const char* _track_name,
OzzImporter::NodeProperty::Type _type,
FbxSceneLoader& _scene_loader, float _sampling_rate,
RawFloatTrack* _track);
bool ExtractTrack(const char* _animation_name, const char* _node_name,
OZZ_ANIMFBX_DLL bool ExtractTrack(const char* _animation_name,
const char* _node_name,
const char* _track_name,
OzzImporter::NodeProperty::Type _type,
FbxSceneLoader& _scene_loader, float _sampling_rate,
RawFloat2Track* _track);
bool ExtractTrack(const char* _animation_name, const char* _node_name,
OZZ_ANIMFBX_DLL bool ExtractTrack(const char* _animation_name,
const char* _node_name,
const char* _track_name,
OzzImporter::NodeProperty::Type _type,
FbxSceneLoader& _scene_loader, float _sampling_rate,
RawFloat3Track* _track);
bool ExtractTrack(const char* _animation_name, const char* _node_name,
OZZ_ANIMFBX_DLL bool ExtractTrack(const char* _animation_name,
const char* _node_name,
const char* _track_name,
OzzImporter::NodeProperty::Type _type,
FbxSceneLoader& _scene_loader, float _sampling_rate,
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_FBX_FBX_SKELETON_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_FBX_FBX_SKELETON_H_
#include "ozz/animation/offline/fbx/export.h"
#include "ozz/animation/offline/fbx/fbx.h"
#include "ozz/animation/offline/tools/import2ozz.h"
@@ -39,7 +40,7 @@ struct RawSkeleton;
namespace fbx {
bool ExtractSkeleton(FbxSceneLoader& _loader,
OZZ_ANIMFBX_DLL bool ExtractSkeleton(FbxSceneLoader& _loader,
const OzzImporter::NodeType& _types,
RawSkeleton* _skeleton);
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_RAW_ANIMATION_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_RAW_ANIMATION_H_
#include "ozz/animation/offline/export.h"
#include "ozz/base/containers/string.h"
#include "ozz/base/containers/vector.h"
#include "ozz/base/io/archive_traits.h"
@@ -55,7 +56,7 @@ namespace offline {
// 3. Keyframes' time are all within [0,animation duration] range.
// Animations that would fail this validation will fail to be converted by the
// AnimationBuilder.
struct RawAnimation {
struct OZZ_ANIMOFFLINE_DLL RawAnimation {
// Constructs a valid RawAnimation with a 1s default duration.
RawAnimation();
@@ -146,7 +147,7 @@ OZZ_IO_TYPE_TAG("ozz-raw_animation", animation::offline::RawAnimation)
// Should not be called directly but through io::Archive << and >> operators.
template <>
struct Extern<animation::offline::RawAnimation> {
struct OZZ_ANIMOFFLINE_DLL Extern<animation::offline::RawAnimation> {
static void Save(OArchive& _archive,
const animation::offline::RawAnimation* _animations,
size_t _count);
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_RAW_ANIMATION_UTILS_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_RAW_ANIMATION_UTILS_H_
#include "ozz/animation/offline/export.h"
#include "ozz/animation/offline/raw_animation.h"
#include "ozz/base/maths/transform.h"
@@ -38,22 +39,25 @@ namespace animation {
namespace offline {
// Translation interpolation method.
math::Float3 LerpTranslation(const math::Float3& _a, const math::Float3& _b,
OZZ_ANIMOFFLINE_DLL math::Float3 LerpTranslation(const math::Float3& _a,
const math::Float3& _b,
float _alpha);
// Rotation interpolation method.
math::Quaternion LerpRotation(const math::Quaternion& _a,
OZZ_ANIMOFFLINE_DLL math::Quaternion LerpRotation(const math::Quaternion& _a,
const math::Quaternion& _b, float _alpha);
// Scale interpolation method.
math::Float3 LerpScale(const math::Float3& _a, const math::Float3& _b,
OZZ_ANIMOFFLINE_DLL math::Float3 LerpScale(const math::Float3& _a,
const math::Float3& _b,
float _alpha);
// Samples a RawAnimation track. This function shall be used for offline
// purpose. Use ozz::animation::Animation and ozz::animation::SamplingJob for
// runtime purpose.
// Returns false if track is invalid.
bool SampleTrack(const RawAnimation::JointTrack& _track, float _time,
OZZ_ANIMOFFLINE_DLL bool SampleTrack(const RawAnimation::JointTrack& _track,
float _time,
ozz::math::Transform* _transform);
// Samples a RawAnimation. This function shall be used for offline
@@ -61,7 +65,8 @@ bool SampleTrack(const RawAnimation::JointTrack& _track, float _time,
// runtime purpose.
// _animation must be valid.
// Returns false output range is too small or animation is invalid.
bool SampleAnimation(const RawAnimation& _animation, float _time,
OZZ_ANIMOFFLINE_DLL bool SampleAnimation(
const RawAnimation& _animation, float _time,
const span<ozz::math::Transform>& _transforms);
// Implement fixed rate keyframe time iteration. This utility purpose is to
@@ -69,7 +74,7 @@ bool SampleAnimation(const RawAnimation& _animation, float _time,
// between consecutive time samples have a fixed period.
// This sounds trivial, but floating point error could occur if keyframe time
// was accumulated for a long duration.
class FixedRateSamplingTime {
class OZZ_ANIMOFFLINE_DLL FixedRateSamplingTime {
public:
FixedRateSamplingTime(float _duration, float _frequency);
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_RAW_SKELETON_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_RAW_SKELETON_H_
#include "ozz/animation/offline/export.h"
#include "ozz/base/containers/string.h"
#include "ozz/base/containers/vector.h"
#include "ozz/base/io/archive_traits.h"
@@ -41,13 +42,13 @@ namespace offline {
// This skeleton type is not intended to be used in run time. It is used to
// define the offline skeleton object that can be converted to the runtime
// skeleton using the SkeletonBuilder. This skeleton structure exposes joints'
// hierarchy. A joint is defined with a name, a transformation (its bind pose),
// and its children. Children are exposed as a public std::vector of joints.
// This same type is used for skeleton roots, also exposed from the public API.
// The public API exposed through std:vector's of joints can be used freely with
// the only restriction that the total number of joints does not exceed
// Skeleton::kMaxJoints.
struct RawSkeleton {
// hierarchy. A joint is defined with a name, a transformation (its rest_pose
// pose), and its children. Children are exposed as a public std::vector of
// joints. This same type is used for skeleton roots, also exposed from the
// public API. The public API exposed through std:vector's of joints can be used
// freely with the only restriction that the total number of joints does not
// exceed Skeleton::kMaxJoints.
struct OZZ_ANIMOFFLINE_DLL RawSkeleton {
// Construct an empty skeleton.
RawSkeleton();
@@ -65,7 +66,7 @@ struct RawSkeleton {
// The name of the joint.
ozz::string name;
// Joint bind pose transformation in local space.
// Joint rest pose transformation in local space.
math::Transform transform;
};
@@ -139,7 +140,7 @@ OZZ_IO_TYPE_TAG("ozz-raw_skeleton", animation::offline::RawSkeleton)
// Should not be called directly but through io::Archive << and >> operators.
template <>
struct Extern<animation::offline::RawSkeleton> {
struct OZZ_ANIMOFFLINE_DLL Extern<animation::offline::RawSkeleton> {
static void Save(OArchive& _archive,
const animation::offline::RawSkeleton* _skeletons,
size_t _count);
@@ -28,11 +28,10 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_RAW_TRACK_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_RAW_TRACK_H_
#include "ozz/animation/offline/export.h"
#include "ozz/base/containers/string.h"
#include "ozz/base/containers/vector.h"
#include "ozz/base/io/archive_traits.h"
#include "ozz/base/maths/quaternion.h"
#include "ozz/base/maths/vec_float.h"
@@ -85,7 +84,7 @@ namespace internal {
// RawTrack that would fail this validation will fail to be converted by
// the RawTrackBuilder.
template <typename _ValueType>
struct RawTrack {
struct OZZ_ANIMOFFLINE_DLL RawTrack {
typedef _ValueType ValueType;
typedef RawTrackKeyframe<ValueType> Keyframe;
@@ -109,11 +108,15 @@ struct RawTrack {
} // namespace internal
// Offline user-channel animation track type instantiation.
struct RawFloatTrack : public internal::RawTrack<float> {};
struct RawFloat2Track : public internal::RawTrack<math::Float2> {};
struct RawFloat3Track : public internal::RawTrack<math::Float3> {};
struct RawFloat4Track : public internal::RawTrack<math::Float4> {};
struct RawQuaternionTrack : public internal::RawTrack<math::Quaternion> {};
struct OZZ_ANIMOFFLINE_DLL RawFloatTrack : public internal::RawTrack<float> {};
struct OZZ_ANIMOFFLINE_DLL RawFloat2Track
: public internal::RawTrack<math::Float2> {};
struct OZZ_ANIMOFFLINE_DLL RawFloat3Track
: public internal::RawTrack<math::Float3> {};
struct OZZ_ANIMOFFLINE_DLL RawFloat4Track
: public internal::RawTrack<math::Float4> {};
struct OZZ_ANIMOFFLINE_DLL RawQuaternionTrack
: public internal::RawTrack<math::Quaternion> {};
} // namespace offline
} // namespace animation
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_SKELETON_BUILDER_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_SKELETON_BUILDER_H_
#include "ozz/animation/offline/export.h"
#include "ozz/base/maths/transform.h"
#include "ozz/base/memory/unique_ptr.h"
@@ -43,7 +44,7 @@ namespace offline {
struct RawSkeleton;
// Defines the class responsible of building Skeleton instances.
class SkeletonBuilder {
class OZZ_ANIMOFFLINE_DLL SkeletonBuilder {
public:
// Creates a Skeleton based on _raw_skeleton and *this builder parameters.
// Returns a Skeleton instance on success, an empty unique_ptr on failure. See
@@ -0,0 +1,44 @@
//----------------------------------------------------------------------------//
// //
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
// and distributed under the MIT License (MIT). //
// //
// Copyright (c) Guillaume Blanc //
// //
// Permission is hereby granted, free of charge, to any person obtaining a //
// copy of this software and associated documentation files (the "Software"), //
// to deal in the Software without restriction, including without limitation //
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
// and/or sell copies of the Software, and to permit persons to whom the //
// Software is furnished to do so, subject to the following conditions: //
// //
// The above copyright notice and this permission notice shall be included in //
// all copies or substantial portions of the Software. //
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
// DEALINGS IN THE SOFTWARE. //
// //
//----------------------------------------------------------------------------//
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_TOOLS_EXPORT_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_TOOLS_EXPORT_H_
#if defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#ifdef OZZ_BUILD_ANIMATIONTOOLS_LIB
// Import/Export for dynamic linking while building ozz
#define OZZ_ANIMTOOLS_DLL __declspec(dllexport)
#else
#define OZZ_ANIMTOOLS_DLL __declspec(dllimport)
#endif
#else // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
// Static or non msvc linking
#define OZZ_ANIMTOOLS_DLL
#endif // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#endif // OZZ_OZZ_ANIMATION_OFFLINE_TOOLS_EXPORT_H_
@@ -28,6 +28,8 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_TOOLS_IMPORT2OZZ_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_TOOLS_IMPORT2OZZ_H_
#include "ozz/animation/offline/tools/export.h"
#include "ozz/base/containers/string.h"
#include "ozz/base/containers/vector.h"
@@ -35,6 +37,8 @@
#include "ozz/animation/offline/raw_skeleton.h"
#include "ozz/animation/offline/raw_track.h"
#include "ozz/base/platform.h"
namespace ozz {
namespace animation {
@@ -51,7 +55,7 @@ namespace offline {
// To import a new source data format, one will implement the pure virtual
// functions of this interface. All the conversions end error processing are
// done by the tool.
class OzzImporter {
class OZZ_ANIMTOOLS_DLL OzzImporter {
public:
virtual ~OzzImporter() {}
@@ -72,6 +76,7 @@ class OzzImporter {
bool camera : 1; // Uses camera nodes as skeleton joints.
bool geometry : 1; // Uses geometry nodes as skeleton joints.
bool light : 1; // Uses light nodes as skeleton joints.
bool null : 1; // Uses null nodes as skeleton joints.
bool any : 1; // Uses any node type as skeleton joints, including those
// listed above and any other.
};
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_TRACK_BUILDER_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_TRACK_BUILDER_H_
#include "ozz/animation/offline/export.h"
#include "ozz/base/memory/unique_ptr.h"
namespace ozz {
@@ -53,7 +54,7 @@ struct RawQuaternionTrack;
// offline tracks.The input raw track is first validated. Runtime conversion of
// a validated raw track cannot fail. Note that no optimization is performed on
// the data at all.
class TrackBuilder {
class OZZ_ANIMOFFLINE_DLL TrackBuilder {
public:
// Creates a Track based on _raw_track and *this builder parameters.
// Returns a track instance on success, an empty unique_ptr on failure. See
@@ -28,6 +28,9 @@
#ifndef OZZ_OZZ_ANIMATION_OFFLINE_TRACK_OPTIMIZER_H_
#define OZZ_OZZ_ANIMATION_OFFLINE_TRACK_OPTIMIZER_H_
#include "ozz/animation/offline/export.h"
#include "ozz/base/platform.h"
namespace ozz {
namespace animation {
namespace offline {
@@ -44,7 +47,7 @@ struct RawQuaternionTrack;
// keyframes (within a tolerance value) are removed from the track. Default
// optimization tolerances are set in order to favor quality over runtime
// performances and memory footprint.
class TrackOptimizer {
class OZZ_ANIMOFFLINE_DLL TrackOptimizer {
public:
// Initializes the optimizer with default tolerances (favoring quality).
TrackOptimizer();
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_ANIMATION_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_ANIMATION_H_
#include "ozz/animation/runtime/export.h"
#include "ozz/base/io/archive_traits.h"
#include "ozz/base/platform.h"
#include "ozz/base/span.h"
@@ -58,11 +59,19 @@ struct QuaternionKey;
// joints order of the runtime skeleton structure. In order to optimize cache
// coherency when sampling the animation, Keyframes in this array are sorted by
// time, then by track number.
class Animation {
class OZZ_ANIMATION_DLL Animation {
public:
// Builds a default animation.
Animation();
// Allow moves.
Animation(Animation&&);
Animation& operator=(Animation&&);
// Delete copies.
Animation(Animation const&) = delete;
Animation& operator=(Animation const&) = delete;
// Declares the public non-virtual destructor.
~Animation();
@@ -80,9 +89,7 @@ class Animation {
const char* name() const { return name_ ? name_ : ""; }
// Gets the buffer of translations keys.
span<const Float3Key> translations() const {
return translations_;
}
span<const Float3Key> translations() const { return translations_; }
// Gets the buffer of rotation keys.
span<const QuaternionKey> rotations() const { return rotations_; }
@@ -98,12 +105,7 @@ class Animation {
void Save(ozz::io::OArchive& _archive) const;
void Load(ozz::io::IArchive& _archive, uint32_t _version);
protected:
private:
// Disables copy and assignation.
Animation(Animation const&);
void operator=(Animation const&);
// AnimationBuilder class is allowed to instantiate an Animation.
friend class offline::AnimationBuilder;
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_ANIMATION_UTILS_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_ANIMATION_UTILS_H_
#include "ozz/animation/runtime/export.h"
#include "ozz/animation/runtime/animation.h"
namespace ozz {
@@ -35,9 +36,12 @@ namespace animation {
// Count translation, rotation or scale keyframes for a given track number. Use
// a negative _track value to count all tracks.
int CountTranslationKeyframes(const Animation& _animation, int _track = -1);
int CountRotationKeyframes(const Animation& _animation, int _track = -1);
int CountScaleKeyframes(const Animation& _animation, int _track = -1);
OZZ_ANIMATION_DLL int CountTranslationKeyframes(const Animation& _animation,
int _track = -1);
OZZ_ANIMATION_DLL int CountRotationKeyframes(const Animation& _animation,
int _track = -1);
OZZ_ANIMATION_DLL int CountScaleKeyframes(const Animation& _animation,
int _track = -1);
} // namespace animation
} // namespace ozz
#endif // OZZ_OZZ_ANIMATION_RUNTIME_ANIMATION_UTILS_H_
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_BLENDING_JOB_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_BLENDING_JOB_H_
#include "ozz/animation/runtime/export.h"
#include "ozz/base/maths/simd_math.h"
#include "ozz/base/span.h"
@@ -44,15 +45,15 @@ namespace animation {
// (the result of a sampled animation) according to their respective weight,
// into one output pose.
// The number of transforms/joints blended by the job is defined by the number
// of transforms of the bind pose (note that this is a SoA format). This means
// that all buffers must be at least as big as the bind pose buffer.
// of transforms of the rest pose (note that this is a SoA format). This means
// that all buffers must be at least as big as the rest pose buffer.
// Partial animation blending is supported through optional joint weights that
// can be specified with layers joint_weights buffer. Unspecified joint weights
// are considered as a unit weight of 1.f, allowing to mix full and partial
// blend operations in a single pass.
// The job does not owned any buffers (input/output) and will thus not delete
// them during job's destruction.
struct BlendingJob {
struct OZZ_ANIMATION_DLL BlendingJob {
// Default constructor, initializes default values.
BlendingJob();
@@ -63,7 +64,7 @@ struct BlendingJob {
// -if any layer is not valid.
// -if output range is not valid.
// -if any buffer (including layers' content : transform, joint weights...) is
// smaller than the bind pose buffer.
// smaller than the rest pose buffer.
// -if the threshold value is less than or equal to 0.f.
bool Validate() const;
@@ -75,7 +76,7 @@ struct BlendingJob {
// Defines a layer of blending input data (local space transforms) and
// parameters (weights).
struct Layer {
struct OZZ_ANIMATION_DLL Layer {
// Default constructor, initializes default values.
Layer();
@@ -86,8 +87,8 @@ struct BlendingJob {
// The range [begin,end[ of input layer posture. This buffer expect to store
// local space transforms, that are usually outputted from a sampling job.
// This range must be at least as big as the bind pose buffer, even though
// only the number of transforms defined by the bind pose buffer will be
// This range must be at least as big as the rest pose buffer, even though
// only the number of transforms defined by the rest pose buffer will be
// processed.
span<const math::SoaTransform> transform;
@@ -95,8 +96,8 @@ struct BlendingJob {
// layer.
// If both pointers are nullptr (default case) then per joint weight
// blending is disabled. A valid range is defined as being at least as big
// as the bind pose buffer, even though only the number of transforms
// defined by the bind pose buffer will be processed. When a layer doesn't
// as the rest pose buffer, even though only the number of transforms
// defined by the rest pose buffer will be processed. When a layer doesn't
// specifies per joint weights, then it is implicitly considered as
// being 1.f. This default value is a reference value for the normalization
// process, which implies that the range of values for joint weights should
@@ -106,7 +107,7 @@ struct BlendingJob {
span<const math::SimdFloat4> joint_weights;
};
// The job blends the bind pose to the output when the accumulated weight of
// 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;
@@ -119,18 +120,18 @@ struct BlendingJob {
// The range of layers that must be added to the output.
span<const Layer> additive_layers;
// The skeleton bind pose. The size of this buffer defines the number of
// The skeleton rest pose. The size of this buffer defines the number of
// transforms to blend. This is the reference because this buffer is defined
// by the skeleton that all the animations belongs to.
// It is used when the accumulated weight for a bone on all layers is
// less than the threshold value, in order to fall back on valid transforms.
span<const ozz::math::SoaTransform> bind_pose;
span<const ozz::math::SoaTransform> rest_pose;
// Job output.
// The range of output transforms to be filled with blended layer
// transforms during job execution.
// Must be at least as big as the bind pose buffer, but only the number of
// transforms defined by the bind pose buffer size will be processed.
// Must be at least as big as the rest pose buffer, but only the number of
// transforms defined by the rest pose buffer size will be processed.
span<ozz::math::SoaTransform> output;
};
} // namespace animation
@@ -0,0 +1,44 @@
//----------------------------------------------------------------------------//
// //
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
// and distributed under the MIT License (MIT). //
// //
// Copyright (c) Guillaume Blanc //
// //
// Permission is hereby granted, free of charge, to any person obtaining a //
// copy of this software and associated documentation files (the "Software"), //
// to deal in the Software without restriction, including without limitation //
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
// and/or sell copies of the Software, and to permit persons to whom the //
// Software is furnished to do so, subject to the following conditions: //
// //
// The above copyright notice and this permission notice shall be included in //
// all copies or substantial portions of the Software. //
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
// DEALINGS IN THE SOFTWARE. //
// //
//----------------------------------------------------------------------------//
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_EXPORT_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_EXPORT_H_
#if defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#ifdef OZZ_BUILD_ANIMATION_LIB
// Import/Export for dynamic linking while building ozz
#define OZZ_ANIMATION_DLL __declspec(dllexport)
#else
#define OZZ_ANIMATION_DLL __declspec(dllimport)
#endif
#else // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
// Static or non msvc linking
#define OZZ_ANIMATION_DLL
#endif // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#endif // OZZ_OZZ_ANIMATION_RUNTIME_EXPORT_H_
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_IK_AIM_JOB_H_
#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"
@@ -50,7 +51,7 @@ namespace animation {
// vector should aim the target.
// Result is unstable if joint-to-target direction is parallel to pole vector,
// or if target is too close to joint position.
struct IKAimJob {
struct OZZ_ANIMATION_DLL IKAimJob {
// Default constructor, initializes default values.
IKAimJob();
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_IK_TWO_BONE_JOB_H_
#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"
@@ -51,7 +52,7 @@ namespace animation {
// ancestors (joints in-between will simply remain fixed).
// Implementation is inspired by Autodesk Maya 2 bone IK, improved stability
// wise and extended with Soften IK.
struct IKTwoBoneJob {
struct OZZ_ANIMATION_DLL IKTwoBoneJob {
// Constructor, initializes default values.
IKTwoBoneJob();
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_LOCAL_TO_MODEL_JOB_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_LOCAL_TO_MODEL_JOB_H_
#include "ozz/animation/runtime/export.h"
#include "ozz/base/platform.h"
#include "ozz/base/span.h"
@@ -55,7 +56,7 @@ class Skeleton;
// ordered like skeleton's joints. Output are matrices, because the combination
// of affine transformations can contain shearing or complex transformation
// that cannot be represented as Transform object.
struct LocalToModelJob {
struct OZZ_ANIMATION_DLL LocalToModelJob {
// Default constructor, initializes default values.
LocalToModelJob();
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_SAMPLING_JOB_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_SAMPLING_JOB_H_
#include "ozz/animation/runtime/export.h"
#include "ozz/base/platform.h"
#include "ozz/base/span.h"
@@ -43,19 +44,16 @@ namespace animation {
// Forward declares the animation type to sample.
class Animation;
// Forward declares the cache object used by the SamplingJob.
class SamplingCache;
// Samples an animation at a given time ratio in the unit interval [0,1] (where
// 0 is the beginning of the animation, 1 is the end), to output the
// corresponding posture in local-space.
// SamplingJob uses a cache (aka SamplingCache) to store intermediate values
// (decompressed animation keyframes...) while sampling. This cache also stores
// pre-computed values that allows drastic optimization while playing/sampling
// the animation forward. Backward sampling works, but isn't optimized through
// the cache. The job does not owned the buffers (in/output) and will thus not
// delete them during job's destruction.
struct SamplingJob {
// SamplingJob uses a context (aka SamplingJob::Context) to store intermediate
// values (decompressed animation keyframes...) while sampling. This context
// also stores pre-computed values that allows drastic optimization while
// playing/sampling the animation forward. Backward sampling works, but isn't
// 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();
@@ -80,8 +78,11 @@ struct SamplingJob {
// The animation to sample.
const Animation* animation;
// A cache object that must be big enough to sample *this animation.
SamplingCache* cache;
// 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;
// Job output.
// The output range to be filled with sampled joints during job execution.
@@ -98,61 +99,62 @@ struct InterpSoaFloat3;
struct InterpSoaQuaternion;
} // namespace internal
// Declares the cache object used by the workload to take advantage of the
// Declares the context object used by the workload to take advantage of the
// frame coherency of animation sampling.
class SamplingCache {
class OZZ_ANIMATION_DLL SamplingJob::Context {
public:
// Constructs an empty cache. The cache needs to be resized with the
// Constructs an empty context. The context needs to be resized with the
// appropriate number of tracks before it can be used with a SamplingJob.
SamplingCache();
Context();
// Constructs a cache that can be used to sample any animation with at most
// Constructs a context that can be used to sample any animation with at most
// _max_tracks tracks. _num_tracks is internally aligned to a multiple of
// soa size, which means max_tracks() can return a different (but bigger)
// value than _max_tracks.
explicit SamplingCache(int _max_tracks);
explicit Context(int _max_tracks);
// Deallocates cache.
~SamplingCache();
// Disables copy and assignation.
Context(Context const&) = delete;
Context& operator=(Context const&) = delete;
// Resize the number of joints that the cache can support.
// This also implicitly invalidate the cache.
// Deallocates context.
~Context();
// Resize the number of joints that the context can support.
// This also implicitly invalidate the context.
void Resize(int _max_tracks);
// Invalidate the cache.
// The SamplingJob automatically invalidates a cache when required
// Invalidate the context.
// The SamplingJob automatically invalidates a context when required
// during sampling. This automatic mechanism is based on the animation
// address and sampling time ratio. The weak point is that it can result in a
// crash if ever the address of an animation is used again with another
// animation (could be the result of successive call to delete / new).
// Therefore it is recommended to manually invalidate a cache when it is
// known that this cache will not be used for with an animation again.
// Therefore it is recommended to manually invalidate a context when it is
// known that this context will not be used for with an animation again.
void Invalidate();
// The maximum number of tracks that the cache can handle.
// The maximum number of tracks that the context can handle.
int max_tracks() const { return max_soa_tracks_ * 4; }
int max_soa_tracks() const { return max_soa_tracks_; }
private:
// Disables copy and assignation.
SamplingCache(SamplingCache const&);
void operator=(SamplingCache const&);
friend struct SamplingJob;
// Steps the cache in order to use it for a potentially new animation and
// Steps the context in order to use it for a potentially new animation and
// ratio. If the _animation is different from the animation currently cached,
// or if the _ratio shows that the animation is played backward, then the
// cache is invalidated and reseted for the new _animation and _ratio.
// context is invalidated and reset for the new _animation and _ratio.
void Step(const Animation& _animation, float _ratio);
// The animation this cache refers to. nullptr means that the cache is invalid.
// The animation this context refers to. nullptr means that the context is
// invalid.
const Animation* animation_;
// The current time ratio in the animation.
float ratio_;
// The number of soa tracks that can store this cache.
// The number of soa tracks that can store this context.
int max_soa_tracks_;
// Soa hot data to interpolate.
@@ -166,7 +168,7 @@ class SamplingCache {
int* rotation_keys_;
int* scale_keys_;
// Current cursors in the animation. 0 means that the cache is invalid.
// Current cursors in the animation. 0 means that the context is invalid.
int translation_cursor_;
int rotation_cursor_;
int scale_cursor_;
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_SKELETON_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_SKELETON_H_
#include "ozz/animation/runtime/export.h"
#include "ozz/base/io/archive_traits.h"
#include "ozz/base/platform.h"
#include "ozz/base/span.h"
@@ -48,16 +49,16 @@ class SkeletonBuilder;
}
// This runtime skeleton data structure provides a const-only access to joint
// hierarchy, joint names and bind-pose. This structure is filled by the
// hierarchy, joint names and rest-pose. This structure is filled by the
// SkeletonBuilder and can be serialize/deserialized.
// Joint names, bind-poses and hierarchy information are all stored in separate
// Joint names, rest-poses and hierarchy information are all stored in separate
// arrays of data (as opposed to joint structures for the RawSkeleton), in order
// to closely match with the way runtime algorithms use them. Joint hierarchy is
// packed as an array of parent jont indices (16 bits), stored in depth-first
// order. This is enough to traverse the whole joint hierarchy. See
// IterateJointsDF() from skeleton_utils.h that implements a depth-first
// traversal utility.
class Skeleton {
class OZZ_ANIMATION_DLL Skeleton {
public:
// Defines Skeleton constant values.
enum Constants {
@@ -81,6 +82,14 @@ class Skeleton {
// Builds a default skeleton.
Skeleton();
// Allow move.
Skeleton(Skeleton&&);
Skeleton& operator=(Skeleton&&);
// Disables copy and assignation.
Skeleton(Skeleton const&) = delete;
Skeleton& operator=(Skeleton const&) = delete;
// Declares the public non-virtual destructor.
~Skeleton();
@@ -91,9 +100,9 @@ class Skeleton {
// skeleton. This value is useful to allocate SoA runtime data structures.
int num_soa_joints() const { return (num_joints() + 3) / 4; }
// Returns joint's bind poses. Bind poses are stored in soa format.
span<const math::SoaTransform> joint_bind_poses() const {
return joint_bind_poses_;
// Returns joint's rest poses. Rest poses are stored in soa format.
span<const math::SoaTransform> joint_rest_poses() const {
return joint_rest_poses_;
}
// Returns joint's parent indices range.
@@ -110,10 +119,6 @@ class Skeleton {
void Load(ozz::io::IArchive& _archive, uint32_t _version);
private:
// Disables copy and assignation.
Skeleton(Skeleton const&);
void operator=(Skeleton const&);
// Internal allocation/deallocation function.
// Allocate returns the beginning of the contiguous buffer of names.
char* Allocate(size_t _char_count, size_t _num_joints);
@@ -125,8 +130,8 @@ class Skeleton {
// Buffers below store joint informations in joing depth first order. Their
// size is equal to the number of joints of the skeleton.
// Bind pose of every joint in local space.
span<math::SoaTransform> joint_bind_poses_;
// Rest pose of every joint in local space.
span<math::SoaTransform> joint_rest_poses_;
// Array of joint parent indexes.
span<int16_t> joint_parents_;
@@ -28,17 +28,18 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_SKELETON_UTILS_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_SKELETON_UTILS_H_
#include <cassert>
#include "ozz/animation/runtime/export.h"
#include "ozz/animation/runtime/skeleton.h"
#include "ozz/base/maths/transform.h"
#include <cassert>
namespace ozz {
namespace animation {
// Get bind-pose of a skeleton joint.
ozz::math::Transform GetJointLocalBindPose(const Skeleton& _skeleton,
int _joint);
// Get rest-pose of a skeleton joint.
OZZ_ANIMATION_DLL ozz::math::Transform GetJointLocalRestPose(
const Skeleton& _skeleton, int _joint);
// Test if a joint is a leaf. _joint number must be in range [0, num joints].
// "_joint" is a leaf if it's the last joint, or next joint's parent isn't
@@ -51,12 +52,15 @@ inline bool IsLeaf(const Skeleton& _skeleton, int _joint) {
return next == num_joints || parents[next] != _joint;
}
// Finds joint index by name. Uses a case sensitive comparison.
OZZ_ANIMATION_DLL int FindJoint(const Skeleton& _skeleton, const char* _name);
// Applies a specified functor to each joint in a depth-first order.
// _Fct is of type void(int _current, int _parent) where the first argument is
// the child of the second argument. _parent is kNoParent if the
// _current joint is a root. _from indicates the joint from which the joint
// hierarchy traversal begins. Use Skeleton::kNoParent to traverse the
// whole hierarchy, in case there are multiple roots.
// _Fct is of type void(int _current, int _parent) where the first argument
// is the child of the second argument. _parent is kNoParent if the _current
// joint is a root. _from indicates the joint from which the joint hierarchy
// traversal begins. Use Skeleton::kNoParent to traverse the whole
// hierarchy, in case there are multiple roots.
template <typename _Fct>
inline _Fct IterateJointsDF(const Skeleton& _skeleton, _Fct _fct,
int _from = Skeleton::kNoParent) {
+20 -14
View File
@@ -28,12 +28,12 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_TRACK_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_TRACK_H_
#include "ozz/animation/runtime/export.h"
#include "ozz/base/io/archive_traits.h"
#include "ozz/base/platform.h"
#include "ozz/base/span.h"
#include "ozz/base/maths/quaternion.h"
#include "ozz/base/maths/vec_float.h"
#include "ozz/base/platform.h"
#include "ozz/base/span.h"
namespace ozz {
namespace animation {
@@ -54,11 +54,20 @@ namespace internal {
// coherently. Ratios are usually accessed/read alone from the jobs that all
// start by looking up the keyframes to interpolate indeed.
template <typename _ValueType>
class Track {
class OZZ_ANIMATION_DLL Track {
public:
typedef _ValueType ValueType;
Track();
// Allow move.
Track(Track&& _other);
Track& operator=(Track&& _other);
// Disables copy and assignation.
Track(Track const&) = delete;
void operator=(Track const&) = delete;
~Track();
// Keyframe accessors.
@@ -78,10 +87,6 @@ class Track {
void Load(ozz::io::IArchive& _archive, uint32_t _version);
private:
// Disables copy and assignation.
Track(Track const&);
void operator=(Track const&);
// TrackBuilder class is allowed to allocate a Track.
friend class offline::TrackBuilder;
@@ -99,7 +104,7 @@ class Track {
span<uint8_t> steps_;
// Track name.
char* name_;
char* name_ = nullptr;
};
// Definition of operations policies per track value type.
@@ -146,11 +151,12 @@ inline math::Quaternion TrackPolicy<math::Quaternion>::identity() {
} // namespace internal
// Runtime track data structure instantiation.
class FloatTrack : public internal::Track<float> {};
class Float2Track : public internal::Track<math::Float2> {};
class Float3Track : public internal::Track<math::Float3> {};
class Float4Track : public internal::Track<math::Float4> {};
class QuaternionTrack : public internal::Track<math::Quaternion> {};
class OZZ_ANIMATION_DLL FloatTrack : public internal::Track<float> {};
class OZZ_ANIMATION_DLL Float2Track : public internal::Track<math::Float2> {};
class OZZ_ANIMATION_DLL Float3Track : public internal::Track<math::Float3> {};
class OZZ_ANIMATION_DLL Float4Track : public internal::Track<math::Float4> {};
class OZZ_ANIMATION_DLL QuaternionTrack
: public internal::Track<math::Quaternion> {};
} // namespace animation
namespace io {
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_TRACK_SAMPLING_JOB_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_TRACK_SAMPLING_JOB_H_
#include "ozz/animation/runtime/export.h"
#include "ozz/animation/runtime/track.h"
namespace ozz {
@@ -65,14 +66,15 @@ struct TrackSamplingJob {
// Track sampling job implementation. Track sampling allows to query a track
// value for a specified ratio. This is a ratio rather than a time because
// tracks have no duration.
struct FloatTrackSamplingJob : public internal::TrackSamplingJob<FloatTrack> {};
struct Float2TrackSamplingJob : public internal::TrackSamplingJob<Float2Track> {
};
struct Float3TrackSamplingJob : public internal::TrackSamplingJob<Float3Track> {
};
struct Float4TrackSamplingJob : public internal::TrackSamplingJob<Float4Track> {
};
struct QuaternionTrackSamplingJob
struct OZZ_ANIMATION_DLL FloatTrackSamplingJob
: public internal::TrackSamplingJob<FloatTrack> {};
struct OZZ_ANIMATION_DLL Float2TrackSamplingJob
: public internal::TrackSamplingJob<Float2Track> {};
struct OZZ_ANIMATION_DLL Float3TrackSamplingJob
: public internal::TrackSamplingJob<Float3Track> {};
struct OZZ_ANIMATION_DLL Float4TrackSamplingJob
: public internal::TrackSamplingJob<Float4Track> {};
struct OZZ_ANIMATION_DLL QuaternionTrackSamplingJob
: public internal::TrackSamplingJob<QuaternionTrack> {};
} // namespace animation
@@ -28,6 +28,7 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_TRACK_TRIGGERING_JOB_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_TRACK_TRIGGERING_JOB_H_
#include "ozz/animation/runtime/export.h"
#include "ozz/base/platform.h"
namespace ozz {
@@ -46,7 +47,7 @@ class FloatTrack;
// track types isn't possible.
// The job execution actually performs a lazy evaluation of edges. It builds an
// iterator that will process the next edge on each call to ++ operator.
struct TrackTriggeringJob {
struct OZZ_ANIMATION_DLL TrackTriggeringJob {
TrackTriggeringJob();
// Validates job parameters.
@@ -95,7 +96,7 @@ struct TrackTriggeringJob {
// Iterator implementation. Calls to ++ operator will compute the next edge. It
// should be compared (using operator !=) to job's end iterator to test if the
// last edge has been reached.
class TrackTriggeringJob::Iterator {
class OZZ_ANIMATION_DLL TrackTriggeringJob::Iterator {
public:
Iterator() : job_(nullptr), outer_(0.f), inner_(0) {}
@@ -28,6 +28,8 @@
#ifndef OZZ_OZZ_ANIMATION_RUNTIME_TRACK_TRIGGERING_JOB_TRAIT_H_
#define OZZ_OZZ_ANIMATION_RUNTIME_TRACK_TRIGGERING_JOB_TRAIT_H_
#include "ozz/animation/runtime/export.h"
// Defines iterator traits required to use TrackTriggeringJob::Iterator
// with stl algorithms.
// This is a separate file from "track_triggering_job.h" to prevent everyone
@@ -0,0 +1,73 @@
//----------------------------------------------------------------------------//
// //
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
// and distributed under the MIT License (MIT). //
// //
// Copyright (c) Guillaume Blanc //
// //
// Permission is hereby granted, free of charge, to any person obtaining a //
// copy of this software and associated documentation files (the "Software"), //
// to deal in the Software without restriction, including without limitation //
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
// and/or sell copies of the Software, and to permit persons to whom the //
// Software is furnished to do so, subject to the following conditions: //
// //
// The above copyright notice and this permission notice shall be included in //
// all copies or substantial portions of the Software. //
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
// DEALINGS IN THE SOFTWARE. //
// //
//----------------------------------------------------------------------------//
#ifndef OZZ_OZZ_BASE_CONTAINERS_ARRAY_H_
#define OZZ_OZZ_BASE_CONTAINERS_ARRAY_H_
#include <array>
#include "ozz/base/platform.h"
namespace ozz {
// Redirects std::array to ozz::array .
template <class _Ty, size_t _N>
using array = std::array<_Ty, _N>;
// Extends std::array with two functions that gives access to the begin and the
// end of its array of elements.
// Returns the mutable begin of the array of elements, or nullptr if
// array's empty.
template <class _Ty, size_t _N>
inline _Ty* array_begin(std::array<_Ty, _N>& _array) {
return _array.data();
}
// Returns the non-mutable begin of the array of elements, or nullptr if
// array's empty.
template <class _Ty, size_t _N>
inline const _Ty* array_begin(const std::array<_Ty, _N>& _array) {
return _array.data();
}
// Returns the mutable end of the array of elements, or nullptr if
// array's empty. Array end is one element past the last element of the
// array, it cannot be dereferenced.
template <class _Ty, size_t _N>
inline _Ty* array_end(std::array<_Ty, _N>& _array) {
return _array.data() + _N;
}
// Returns the non-mutable end of the array of elements, or nullptr if
// array's empty. Array end is one element past the last element of the
// array, it cannot be dereferenced.
template <class _Ty, size_t _N>
inline const _Ty* array_end(const std::array<_Ty, _N>& _array) {
return _array.data() + _N;
}
} // namespace ozz
#endif // OZZ_OZZ_BASE_CONTAINERS_ARRAY_H_
@@ -0,0 +1,63 @@
//----------------------------------------------------------------------------//
// //
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
// and distributed under the MIT License (MIT). //
// //
// Copyright (c) Guillaume Blanc //
// //
// Permission is hereby granted, free of charge, to any person obtaining a //
// copy of this software and associated documentation files (the "Software"), //
// to deal in the Software without restriction, including without limitation //
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
// and/or sell copies of the Software, and to permit persons to whom the //
// Software is furnished to do so, subject to the following conditions: //
// //
// The above copyright notice and this permission notice shall be included in //
// all copies or substantial portions of the Software. //
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
// DEALINGS IN THE SOFTWARE. //
// //
//----------------------------------------------------------------------------//
#ifndef OZZ_OZZ_BASE_CONTAINERS_ARRAY_ARCHIVE_H_
#define OZZ_OZZ_BASE_CONTAINERS_ARRAY_ARCHIVE_H_
#include "ozz/base/containers/array.h"
#include "ozz/base/io/archive.h"
namespace ozz {
namespace io {
OZZ_IO_TYPE_NOT_VERSIONABLE_T2(class _Ty, size_t _N, std::array<_Ty, _N>)
template <class _Ty, size_t _N>
struct Extern<std::array<_Ty, _N>> {
inline static void Save(OArchive& _archive,
const std::array<_Ty, _N>* _values, size_t _count) {
if (void(0), _N != 0) {
for (size_t i = 0; i < _count; i++) {
const std::array<_Ty, _N>& array = _values[i];
_archive << ozz::io::MakeArray(array.data(), _N);
}
}
}
inline static void Load(IArchive& _archive, std::array<_Ty, _N>* _values,
size_t _count, uint32_t _version) {
(void)_version;
if (void(0), _N != 0) {
for (size_t i = 0; i < _count; i++) {
std::array<_Ty, _N>& array = _values[i];
_archive >> ozz::io::MakeArray(array.data(), _N);
}
}
}
};
} // namespace io
} // namespace ozz
#endif // OZZ_OZZ_BASE_CONTAINERS_ARRAY_ARCHIVE_H_
@@ -49,7 +49,7 @@ class StdAllocator {
StdAllocator(const StdAllocator&) noexcept {}
template <class _Other>
StdAllocator<value_type>(const StdAllocator<_Other>&) noexcept {}
StdAllocator(const StdAllocator<_Other>&) noexcept {}
template <class _Other>
struct rebind {
@@ -38,7 +38,7 @@ namespace io {
OZZ_IO_TYPE_NOT_VERSIONABLE(ozz::string)
template <>
struct Extern<ozz::string> {
struct OZZ_BASE_DLL Extern<ozz::string> {
static void Save(OArchive& _archive, const ozz::string* _values,
size_t _count);
static void Load(IArchive& _archive, ozz::string* _values, size_t _count,
@@ -48,7 +48,7 @@ struct Extern<std::vector<_Ty, _Allocator>> {
const uint32_t size = static_cast<uint32_t>(vector.size());
_archive << size;
if (size > 0) {
_archive << ozz::io::MakeArray(&vector[0], size);
_archive << ozz::io::MakeArray(vector.data(), size);
}
}
}
@@ -62,7 +62,7 @@ struct Extern<std::vector<_Ty, _Allocator>> {
_archive >> size;
vector.resize(size);
if (size > 0) {
_archive >> ozz::io::MakeArray(&vector[0], size);
_archive >> ozz::io::MakeArray(vector.data(), size);
}
}
}
+12 -15
View File
@@ -66,20 +66,17 @@ template <typename _Ty, size_t _size = sizeof(_Ty)>
struct EndianSwapper;
// Internal macro used to swap two bytes.
#define OZZ_BYTE_SWAP(_a, _b) \
do { \
const char temp = _a; \
_a = _b; \
_b = temp; \
#define OZZ_BYTE_SWAP(_a, _b) \
do { \
const ozz::byte temp = (_a); \
(_a) = (_b); \
(_b) = temp; \
} while (0)
// EndianSwapper specialization for 1 byte types.
template <typename _Ty>
struct EndianSwapper<_Ty, 1> {
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
(void)_ty;
(void)_count;
}
OZZ_INLINE static void Swap(_Ty*, size_t) {}
OZZ_INLINE static _Ty Swap(_Ty _ty) { return _ty; }
};
@@ -87,13 +84,13 @@ struct EndianSwapper<_Ty, 1> {
template <typename _Ty>
struct EndianSwapper<_Ty, 2> {
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
char* alias = reinterpret_cast<char*>(_ty);
byte* alias = reinterpret_cast<byte*>(_ty);
for (size_t i = 0; i < _count * 2; i += 2) {
OZZ_BYTE_SWAP(alias[i + 0], alias[i + 1]);
}
}
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
char* alias = reinterpret_cast<char*>(&_ty);
byte* alias = reinterpret_cast<byte*>(&_ty);
OZZ_BYTE_SWAP(alias[0], alias[1]);
return _ty;
}
@@ -103,14 +100,14 @@ struct EndianSwapper<_Ty, 2> {
template <typename _Ty>
struct EndianSwapper<_Ty, 4> {
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
char* alias = reinterpret_cast<char*>(_ty);
byte* alias = reinterpret_cast<byte*>(_ty);
for (size_t i = 0; i < _count * 4; i += 4) {
OZZ_BYTE_SWAP(alias[i + 0], alias[i + 3]);
OZZ_BYTE_SWAP(alias[i + 1], alias[i + 2]);
}
}
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
char* alias = reinterpret_cast<char*>(&_ty);
byte* alias = reinterpret_cast<byte*>(&_ty);
OZZ_BYTE_SWAP(alias[0], alias[3]);
OZZ_BYTE_SWAP(alias[1], alias[2]);
return _ty;
@@ -121,7 +118,7 @@ struct EndianSwapper<_Ty, 4> {
template <typename _Ty>
struct EndianSwapper<_Ty, 8> {
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
char* alias = reinterpret_cast<char*>(_ty);
byte* alias = reinterpret_cast<byte*>(_ty);
for (size_t i = 0; i < _count * 8; i += 8) {
OZZ_BYTE_SWAP(alias[i + 0], alias[i + 7]);
OZZ_BYTE_SWAP(alias[i + 1], alias[i + 6]);
@@ -130,7 +127,7 @@ struct EndianSwapper<_Ty, 8> {
}
}
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
char* alias = reinterpret_cast<char*>(&_ty);
byte* alias = reinterpret_cast<byte*>(&_ty);
OZZ_BYTE_SWAP(alias[0], alias[7]);
OZZ_BYTE_SWAP(alias[1], alias[6]);
OZZ_BYTE_SWAP(alias[2], alias[5]);
+44
View File
@@ -0,0 +1,44 @@
//----------------------------------------------------------------------------//
// //
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
// and distributed under the MIT License (MIT). //
// //
// Copyright (c) Guillaume Blanc //
// //
// Permission is hereby granted, free of charge, to any person obtaining a //
// copy of this software and associated documentation files (the "Software"), //
// to deal in the Software without restriction, including without limitation //
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
// and/or sell copies of the Software, and to permit persons to whom the //
// Software is furnished to do so, subject to the following conditions: //
// //
// The above copyright notice and this permission notice shall be included in //
// all copies or substantial portions of the Software. //
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
// DEALINGS IN THE SOFTWARE. //
// //
//----------------------------------------------------------------------------//
#ifndef OZZ_OZZ_BASE_EXPORT_H_
#define OZZ_OZZ_BASE_EXPORT_H_
#if defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#ifdef OZZ_BUILD_BASE_LIB
// Import/Export for dynamic linking while building ozz
#define OZZ_BASE_DLL __declspec(dllexport)
#else
#define OZZ_BASE_DLL __declspec(dllimport)
#endif
#else // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
// Static or non msvc linking
#define OZZ_BASE_DLL
#endif // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#endif // OZZ_OZZ_BASE_EXPORT_H_
+10 -10
View File
@@ -77,16 +77,16 @@
// integrity, like data corruption or file truncation, must also be validated on
// the user side.
#include <stdint.h>
#include <cassert>
#include "ozz/base/endianness.h"
#include "ozz/base/io/archive_traits.h"
#include "ozz/base/io/stream.h"
#include "ozz/base/platform.h"
#include "ozz/base/span.h"
#include <stdint.h>
#include <cassert>
#include "ozz/base/io/archive_traits.h"
namespace ozz {
namespace io {
namespace internal {
@@ -102,7 +102,7 @@ struct Tagger;
// The output endianness mode is set at construction time. It is written to the
// stream to allow the IArchive to perform the required conversion to the native
// endianness mode while reading.
class OArchive {
class OZZ_BASE_DLL OArchive {
public:
// Constructs an output archive from the Stream _stream that must be valid
// and opened for writing.
@@ -126,7 +126,7 @@ class OArchive {
}
// Primitive type saving.
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
void operator<<(_type _v) { \
_type v = endian_swap_ ? EndianSwapper<_type>::Swap(_v) : _v; \
OZZ_IF_DEBUG(size_t size =) stream_->Write(&v, sizeof(v)); \
@@ -171,7 +171,7 @@ class OArchive {
// Implements input archive concept used to load/de-serialize data to a Stream.
// Endianness conversions are automatically performed according to the Archive
// and the native formats.
class IArchive {
class OZZ_BASE_DLL IArchive {
public:
// Constructs an input archive from the Stream _stream that must be opened for
// reading, at the same tell (position in the stream) as when it was passed to
@@ -199,7 +199,7 @@ class IArchive {
}
// Primitive type loading.
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
void operator>>(_type& _v) { \
_type v; \
OZZ_IF_DEBUG(size_t size =) stream_->Read(&v, sizeof(v)); \
@@ -314,7 +314,7 @@ struct Version<const Array<_Ty>> {
};
// Specializes Array Save/Load for primitive types.
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
template <> \
inline void Array<const _type>::Save(OArchive& _archive) const { \
if (_archive.endian_swap()) { \
+6 -6
View File
@@ -31,16 +31,16 @@
// Provides Stream interface used to read/write a memory buffer or a file with
// Crt fread/fwrite/fseek/ftell like functions.
#include "ozz/base/platform.h"
#include <cstddef>
#include "ozz/base/platform.h"
namespace ozz {
namespace io {
// Declares a stream access interface that conforms with CRT FILE API.
// This interface should be used to remap io operations.
class Stream {
class OZZ_BASE_DLL Stream {
public:
// Tests whether a file is opened.
virtual bool opened() const = 0;
@@ -86,7 +86,7 @@ class Stream {
};
// Implements Stream of type File.
class File : public Stream {
class OZZ_BASE_DLL File : public Stream {
public:
// Test if a file at path _filename exists.
// Note that this function is costly. If you aim to open the file right after,
@@ -133,7 +133,7 @@ class File : public Stream {
// Implements an in-memory Stream. Allows to use a memory buffer as a Stream.
// The opening mode is equivalent to fopen w+b (binary read/write).
class MemoryStream : public Stream {
class OZZ_BASE_DLL MemoryStream : public Stream {
public:
// Construct an empty memory stream opened in w+b mode.
MemoryStream();
@@ -172,7 +172,7 @@ class MemoryStream : public Stream {
static const size_t kMaxSize;
// Buffer of data.
char* buffer_;
byte* buffer_;
// The size of the buffer, which is greater or equal to the size of the data
// it contains (end_).
+10 -8
View File
@@ -34,6 +34,8 @@
// So it is included here to ensure a portable behavior.
#include <cstring>
#include "platform.h"
// Proposes a logging interface that redirects logs to std::cout, clog and cerr
// output streams. This interface adds a logging level functionality (kSilent,
// kStandard, kVerbose) to the std API, which can be set using
@@ -50,17 +52,17 @@ enum Level {
};
// Sets the global logging level.
Level SetLevel(Level _level);
OZZ_BASE_DLL Level SetLevel(Level _level);
// Gets the global logging level.
Level GetLevel();
OZZ_BASE_DLL Level GetLevel();
// Implements logging base class.
// This class is not intended to be used publicly, it is derived by user
// classes LogV, Log, Out, Err...
// Forwards ostream::operator << to a standard ostream or a silent
// ostringstream according to the logging level at construction time.
class Logger {
class OZZ_BASE_DLL Logger {
public:
// Forwards ostream::operator << for any type.
template <typename _T>
@@ -101,28 +103,28 @@ class Logger {
// Logs verbose output to the standard error stream (std::clog).
// Enabled if logging level is Verbose.
class LogV : public Logger {
class OZZ_BASE_DLL LogV : public Logger {
public:
LogV();
};
// Logs output to the standard error stream (std::clog).
// Enabled if logging level is not Silent.
class Log : public Logger {
class OZZ_BASE_DLL Log : public Logger {
public:
Log();
};
// Logs output to the standard output (std::cout).
// Enabled if logging level is not Silent.
class Out : public Logger {
class OZZ_BASE_DLL Out : public Logger {
public:
Out();
};
// Logs error to the standard error stream (std::cerr).
// Enabled if logging level is not Silent.
class Err : public Logger {
class OZZ_BASE_DLL Err : public Logger {
public:
Err();
};
@@ -131,7 +133,7 @@ class Err : public Logger {
// settings when exiting scope.
// User is reponsible for making sure stream still exist upon RAII destruction.
// See std::setprecision() for more details.
class FloatPrecision {
class OZZ_BASE_DLL FloatPrecision {
public:
FloatPrecision(const Logger& _logger, int _precision);
~FloatPrecision();
+2 -2
View File
@@ -39,7 +39,7 @@ namespace math {
struct Float4x4;
// Defines an axis aligned box.
struct Box {
struct OZZ_BASE_DLL Box {
// Constructs an invalid box.
Box();
@@ -78,7 +78,7 @@ OZZ_INLINE Box Merge(const Box& _a, const Box& _b) {
}
// Compute box transformation by a matrix.
Box TransformBox(const Float4x4& _matrix, const Box& _box);
OZZ_BASE_DLL Box TransformBox(const Float4x4& _matrix, const Box& _box);
} // namespace math
} // namespace ozz
#endif // OZZ_OZZ_BASE_MATHS_BOX_H_
@@ -152,7 +152,8 @@ typedef const SimdInt4& _SimdInt4;
} // namespace ozz
#endif // OZZ_SIMD_x
// Native SIMD operator already exist on some compilers, so they have to be disable from ozz implementation
// Native SIMD operator already exist on some compilers, so they have to be
// disable from ozz implementation
#if !defined(OZZ_SIMD_REF) && (defined(__GNUC__) || defined(__llvm__))
#define OZZ_DISABLE_SSE_NATIVE_OPERATORS
#endif
@@ -31,6 +31,7 @@
// SIMD refence implementation, based on scalar floats.
#include <stdint.h>
#include <cassert>
#include <cmath>
#include <cstddef>
@@ -1820,22 +1821,9 @@ OZZ_INLINE bool ToAffine(const Float4x4& _m, SimdFloat4* _translation,
}
OZZ_INLINE Float4x4 Float4x4::FromEuler(_SimdFloat4 _v) {
const float ch = std::cos(_v.x);
const float sh = std::sin(_v.x);
const float ca = std::cos(_v.y);
const float sa = std::sin(_v.y);
const float cb = std::cos(_v.z);
const float sb = std::sin(_v.z);
const float sa_cb = sa * cb;
const float sa_sb = sa * sb;
const Float4x4 ret = {
{{ch * ca, sh * sb - ch * sa_cb, ch * sa_sb + sh * cb, 0.f},
{sa, ca * cb, -ca * sb, 0.f},
{-sh * ca, sh * sa_cb + ch * sb, -sh * sa_sb + ch * cb, 0.f},
{0.f, 0.f, 0.f, 1.f}}};
return ret;
return Float4x4::FromAxisAngle(simd_float4::y_axis(), SplatX(_v)) *
Float4x4::FromAxisAngle(simd_float4::x_axis(), SplatY(_v)) *
Float4x4::FromAxisAngle(simd_float4::z_axis(), SplatZ(_v));
}
OZZ_INLINE Float4x4 Float4x4::FromAxisAngle(_SimdFloat4 _axis,
@@ -31,6 +31,7 @@
// SIMD SSE2+ implementation, based on scalar floats.
#include <stdint.h>
#include <cassert>
// Temporarly needed while trigonometric functions aren't implemented.
@@ -1294,7 +1295,7 @@ OZZ_INLINE SimdInt4 Sign(_SimdInt4 _v) {
OZZ_INLINE SimdInt4 Min(_SimdInt4 _a, _SimdInt4 _b) {
#ifdef OZZ_SIMD_SSE4_1
return _mm_min_epi32(_a, _b);
#else // OZZ_SIMD_SSE4_1
#else // OZZ_SIMD_SSE4_1
return OZZ_SSE_SELECT_I(_mm_cmplt_epi32(_a, _b), _a, _b);
#endif // OZZ_SIMD_SSE4_1
}
@@ -1302,7 +1303,7 @@ OZZ_INLINE SimdInt4 Min(_SimdInt4 _a, _SimdInt4 _b) {
OZZ_INLINE SimdInt4 Max(_SimdInt4 _a, _SimdInt4 _b) {
#ifdef OZZ_SIMD_SSE4_1
return _mm_max_epi32(_a, _b);
#else // OZZ_SIMD_SSE4_1
#else // OZZ_SIMD_SSE4_1
return OZZ_SSE_SELECT_I(_mm_cmpgt_epi32(_a, _b), _a, _b);
#endif // OZZ_SIMD_SSE4_1
}
@@ -1775,26 +1776,9 @@ inline bool ToAffine(const Float4x4& _m, SimdFloat4* _translation,
}
inline Float4x4 Float4x4::FromEuler(_SimdFloat4 _v) {
const __m128 cos = Cos(_v);
const __m128 sin = Sin(_v);
const float cx = GetX(cos);
const float sx = GetX(sin);
const float cy = GetY(cos);
const float sy = GetY(sin);
const float cz = GetZ(cos);
const float sz = GetZ(sin);
const float sycz = sy * cz;
const float sysz = sy * sz;
const Float4x4 ret = {{simd_float4::Load(cx * cy, sx * sz - cx * sycz,
cx * sysz + sx * cz, 0.f),
simd_float4::Load(sy, cy * cz, -cy * sz, 0.f),
simd_float4::Load(-sx * cy, sx * sycz + cx * sz,
-sx * sysz + cx * cz, 0.f),
simd_float4::w_axis()}};
return ret;
return Float4x4::FromAxisAngle(simd_float4::y_axis(), SplatX(_v)) *
Float4x4::FromAxisAngle(simd_float4::x_axis(), SplatY(_v)) *
Float4x4::FromAxisAngle(simd_float4::z_axis(), SplatZ(_v));
}
inline Float4x4 Float4x4::FromAxisAngle(_SimdFloat4 _axis, _SimdFloat4 _angle) {
@@ -45,7 +45,7 @@ struct RectInt;
namespace io {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Float2)
template <>
struct Extern<math::Float2> {
struct OZZ_BASE_DLL Extern<math::Float2> {
static void Save(OArchive& _archive, const math::Float2* _values,
size_t _count);
static void Load(IArchive& _archive, math::Float2* _values, size_t _count,
@@ -54,7 +54,7 @@ struct Extern<math::Float2> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Float3)
template <>
struct Extern<math::Float3> {
struct OZZ_BASE_DLL Extern<math::Float3> {
static void Save(OArchive& _archive, const math::Float3* _values,
size_t _count);
static void Load(IArchive& _archive, math::Float3* _values, size_t _count,
@@ -63,7 +63,7 @@ struct Extern<math::Float3> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Float4)
template <>
struct Extern<math::Float4> {
struct OZZ_BASE_DLL Extern<math::Float4> {
static void Save(OArchive& _archive, const math::Float4* _values,
size_t _count);
static void Load(IArchive& _archive, math::Float4* _values, size_t _count,
@@ -72,7 +72,7 @@ struct Extern<math::Float4> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Quaternion)
template <>
struct Extern<math::Quaternion> {
struct OZZ_BASE_DLL Extern<math::Quaternion> {
static void Save(OArchive& _archive, const math::Quaternion* _values,
size_t _count);
static void Load(IArchive& _archive, math::Quaternion* _values, size_t _count,
@@ -81,7 +81,7 @@ struct Extern<math::Quaternion> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Transform)
template <>
struct Extern<math::Transform> {
struct OZZ_BASE_DLL Extern<math::Transform> {
static void Save(OArchive& _archive, const math::Transform* _values,
size_t _count);
static void Load(IArchive& _archive, math::Transform* _values, size_t _count,
@@ -90,7 +90,7 @@ struct Extern<math::Transform> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Box)
template <>
struct Extern<math::Box> {
struct OZZ_BASE_DLL Extern<math::Box> {
static void Save(OArchive& _archive, const math::Box* _values, size_t _count);
static void Load(IArchive& _archive, math::Box* _values, size_t _count,
uint32_t _version);
@@ -98,7 +98,7 @@ struct Extern<math::Box> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::RectFloat)
template <>
struct Extern<math::RectFloat> {
struct OZZ_BASE_DLL Extern<math::RectFloat> {
static void Save(OArchive& _archive, const math::RectFloat* _values,
size_t _count);
static void Load(IArchive& _archive, math::RectFloat* _values, size_t _count,
@@ -107,7 +107,7 @@ struct Extern<math::RectFloat> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::RectInt)
template <>
struct Extern<math::RectInt> {
struct OZZ_BASE_DLL Extern<math::RectInt> {
static void Save(OArchive& _archive, const math::RectInt* _values,
size_t _count);
static void Load(IArchive& _archive, math::RectInt* _values, size_t _count,
+1 -1
View File
@@ -38,7 +38,7 @@
namespace ozz {
namespace math {
struct Quaternion {
struct OZZ_BASE_DLL Quaternion {
float x, y, z, w;
// Constructs an uninitialized quaternion.
+4 -2
View File
@@ -28,12 +28,14 @@
#ifndef OZZ_OZZ_BASE_MATHS_RECT_H_
#define OZZ_OZZ_BASE_MATHS_RECT_H_
#include "../platform.h"
namespace ozz {
namespace math {
// Defines a rectangle by the integer coordinates of its lower-left and
// width-height.
struct RectInt {
struct OZZ_BASE_DLL RectInt {
// Constructs a uninitialized rectangle.
RectInt() {}
@@ -65,7 +67,7 @@ struct RectInt {
// Defines a rectangle by the floating point coordinates of its lower-left
// and width-height.
struct RectFloat {
struct OZZ_BASE_DLL RectFloat {
// Constructs a uninitialized rectangle.
RectFloat() {}
+1 -5
View File
@@ -35,7 +35,7 @@ namespace ozz {
namespace math {
// Returns SIMDimplementation name has decided at library build time.
const char* SimdImplementationName();
OZZ_BASE_DLL const char* SimdImplementationName();
namespace simd_float4 {
// Returns a SimdFloat4 vector with all components set to 0.
@@ -241,10 +241,6 @@ OZZ_INLINE void Transpose4x1(const SimdFloat4 _in[4], SimdFloat4 _out[1]);
// Remaining y, z and w are set to 0.
OZZ_INLINE void Transpose1x4(const SimdFloat4 _in[1], SimdFloat4 _out[4]);
// Transposes the 1 SimdFloat4 of _in into the x components of the 4
// SimdFloat4 of _out. Remaining y, z and w are set to 0.
OZZ_INLINE void Transpose2x4(const SimdFloat4 _in[2], SimdFloat4 _out[4]);
// Transposes the x and y components of the 4 SimdFloat4 of _in into the 2
// SimdFloat4 of _out.
OZZ_INLINE void Transpose4x2(const SimdFloat4 _in[4], SimdFloat4 _out[2]);
@@ -36,7 +36,7 @@ namespace ozz {
namespace io {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SimdFloat4)
template <>
struct Extern<math::SimdFloat4> {
struct OZZ_BASE_DLL Extern<math::SimdFloat4> {
static void Save(OArchive& _archive, const math::SimdFloat4* _values,
size_t _count);
static void Load(IArchive& _archive, math::SimdFloat4* _values, size_t _count,
@@ -45,7 +45,7 @@ struct Extern<math::SimdFloat4> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SimdInt4)
template <>
struct Extern<math::SimdInt4> {
struct OZZ_BASE_DLL Extern<math::SimdInt4> {
static void Save(OArchive& _archive, const math::SimdInt4* _values,
size_t _count);
static void Load(IArchive& _archive, math::SimdInt4* _values, size_t _count,
@@ -54,7 +54,7 @@ struct Extern<math::SimdInt4> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Float4x4)
template <>
struct Extern<math::Float4x4> {
struct OZZ_BASE_DLL Extern<math::Float4x4> {
static void Save(OArchive& _archive, const math::Float4x4* _values,
size_t _count);
static void Load(IArchive& _archive, math::Float4x4* _values, size_t _count,
@@ -43,7 +43,7 @@ struct SoaTransform;
namespace io {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaFloat2)
template <>
struct Extern<math::SoaFloat2> {
struct OZZ_BASE_DLL Extern<math::SoaFloat2> {
static void Save(OArchive& _archive, const math::SoaFloat2* _values,
size_t _count);
static void Load(IArchive& _archive, math::SoaFloat2* _values, size_t _count,
@@ -52,7 +52,7 @@ struct Extern<math::SoaFloat2> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaFloat3)
template <>
struct Extern<math::SoaFloat3> {
struct OZZ_BASE_DLL Extern<math::SoaFloat3> {
static void Save(OArchive& _archive, const math::SoaFloat3* _values,
size_t _count);
static void Load(IArchive& _archive, math::SoaFloat3* _values, size_t _count,
@@ -61,7 +61,7 @@ struct Extern<math::SoaFloat3> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaFloat4)
template <>
struct Extern<math::SoaFloat4> {
struct OZZ_BASE_DLL Extern<math::SoaFloat4> {
static void Save(OArchive& _archive, const math::SoaFloat4* _values,
size_t _count);
static void Load(IArchive& _archive, math::SoaFloat4* _values, size_t _count,
@@ -70,7 +70,7 @@ struct Extern<math::SoaFloat4> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaQuaternion)
template <>
struct Extern<math::SoaQuaternion> {
struct OZZ_BASE_DLL Extern<math::SoaQuaternion> {
static void Save(OArchive& _archive, const math::SoaQuaternion* _values,
size_t _count);
static void Load(IArchive& _archive, math::SoaQuaternion* _values,
@@ -79,7 +79,7 @@ struct Extern<math::SoaQuaternion> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaFloat4x4)
template <>
struct Extern<math::SoaFloat4x4> {
struct OZZ_BASE_DLL Extern<math::SoaFloat4x4> {
static void Save(OArchive& _archive, const math::SoaFloat4x4* _values,
size_t _count);
static void Load(IArchive& _archive, math::SoaFloat4x4* _values,
@@ -88,7 +88,7 @@ struct Extern<math::SoaFloat4x4> {
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaTransform)
template <>
struct Extern<math::SoaTransform> {
struct OZZ_BASE_DLL Extern<math::SoaTransform> {
static void Save(OArchive& _archive, const math::SoaTransform* _values,
size_t _count);
static void Load(IArchive& _archive, math::SoaTransform* _values,
+1 -1
View File
@@ -37,7 +37,7 @@ namespace math {
// Stores an affine transformation with separate translation, rotation and scale
// attributes.
struct Transform {
struct OZZ_BASE_DLL Transform {
// Translation affine transformation component.
Float3 translation;
+3 -3
View File
@@ -38,7 +38,7 @@ namespace ozz {
namespace math {
// Declares a 2d float vector.
struct Float2 {
struct OZZ_BASE_DLL Float2 {
float x, y;
// Constructs an uninitialized vector.
@@ -64,7 +64,7 @@ struct Float2 {
};
// Declares a 3d float vector.
struct Float3 {
struct OZZ_BASE_DLL Float3 {
float x, y, z;
// Constructs an uninitialized vector.
@@ -96,7 +96,7 @@ struct Float3 {
};
// Declares a 4d float vector.
struct Float4 {
struct OZZ_BASE_DLL Float4 {
float x, y, z, w;
// Constructs an uninitialized vector.
+3 -3
View File
@@ -41,18 +41,18 @@ namespace memory {
class Allocator;
// Defines the default allocator accessor.
Allocator* default_allocator();
OZZ_BASE_DLL Allocator* default_allocator();
// Set the default allocator, used for all dynamic allocation inside ozz.
// Returns current memory allocator, such that in can be restored if needed.
Allocator* SetDefaulAllocator(Allocator* _allocator);
OZZ_BASE_DLL Allocator* SetDefaulAllocator(Allocator* _allocator);
// Defines an abstract allocator class.
// Implements helper methods to allocate/deallocate POD typed objects instead of
// raw memory.
// Implements New and Delete function to allocate C++ objects, as a replacement
// of new and delete operators.
class Allocator {
class OZZ_BASE_DLL Allocator {
public:
// Default virtual destructor.
virtual ~Allocator() {}
+6 -1
View File
@@ -41,8 +41,13 @@
#include <cassert>
#include <cstddef>
#include "ozz/base/export.h"
namespace ozz {
// Defines a byte type, unsigned so right shift doesn't propagate sign bit.
typedef uint8_t byte;
// Finds the number of elements of a statically allocated array.
#define OZZ_ARRAY_SIZE(_array) (sizeof(_array) / sizeof(_array[0]))
@@ -80,7 +85,7 @@ namespace ozz {
// Case sensitive wildcard string matching:
// - a ? sign matches any character, except an empty string.
// - a * sign matches any string, including an empty string.
bool strmatch(const char* _str, const char* _pattern);
OZZ_BASE_DLL bool strmatch(const char* _str, const char* _pattern);
// Tests whether _block is aligned to _alignment boundary.
template <typename _Ty>
+27 -17
View File
@@ -52,7 +52,8 @@ struct span {
span() : data_(nullptr), size_(0) {}
// Constructs a range from its extreme values.
span(_Ty* _begin, _Ty* _end) : data_(_begin), size_(static_cast<size_t>(_end - _begin)) {
span(_Ty* _begin, _Ty* _end)
: data_(_begin), size_(static_cast<size_t>(_end - _begin)) {
assert(_begin <= _end && "Invalid range.");
}
@@ -84,6 +85,25 @@ struct span {
// Implement cast operator to allow conversions to span<const _Ty>.
operator span<const _Ty>() const { return span<const _Ty>(data_, size_); }
// Subspan
span<element_type> first(index_type _count) const {
assert(_count <= size_ && "Count out of range");
return {data(), _count};
}
span<element_type> last(index_type _count) const {
assert(_count <= size_ && "Count out of range");
return {data() + size_ - _count, _count};
}
span<element_type> subspan(index_type _offset, index_type _count) const {
assert(_offset <= size_ && "Offset out of range");
assert(_count <= size_ && "Count out of range");
assert(_offset <= size_ - _count && "Offset + count out of range");
return {data_ + _offset, _count};
}
// Returns a const reference to element _i of range [begin,end[.
_Ty& operator[](size_t _i) const {
assert(_i < size_ && "Index out of range.");
@@ -135,35 +155,25 @@ inline span<const typename _Container::value_type> make_span(
// As bytes
template <typename _Ty>
inline span<const char> as_bytes(const span<_Ty>& _span) {
return {reinterpret_cast<const char*>(_span.data()), _span.size_bytes()};
inline span<const byte> as_bytes(const span<_Ty>& _span) {
return {reinterpret_cast<const byte*>(_span.data()), _span.size_bytes()};
}
template <typename _Ty>
inline span<char> as_writable_bytes(const span<_Ty>& _span) {
inline span<byte> as_writable_bytes(const span<_Ty>& _span) {
// Compilation will fail here if _Ty is const. This prevents from writing to
// const data.
return {reinterpret_cast<char*>(_span.data()), _span.size_bytes()};
}
template <>
inline span<const char> as_bytes(const span<char>& _span) {
return _span;
}
template <>
inline span<char> as_writable_bytes(const span<char>& _span) {
return _span;
return {reinterpret_cast<byte*>(_span.data()), _span.size_bytes()};
}
// Fills a typed span from a byte source span. Source byte span is modified to
// reflect remain size.
template <typename _Ty>
inline span<_Ty> fill_span(span<char>& _src, size_t _count) {
inline span<_Ty> fill_span(span<byte>& _src, size_t _count) {
assert(ozz::IsAligned(_src.data(), alignof(_Ty)) && "Invalid alignment.");
const span<_Ty> ret = {reinterpret_cast<_Ty*>(_src.data()), _count};
// Validity assertion is done by span constructor.
_src = {reinterpret_cast<char*>(ret.end()), _src.end()};
_src = {reinterpret_cast<byte*>(ret.end()), _src.end()};
return ret;
}
@@ -0,0 +1,44 @@
//----------------------------------------------------------------------------//
// //
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
// and distributed under the MIT License (MIT). //
// //
// Copyright (c) Guillaume Blanc //
// //
// Permission is hereby granted, free of charge, to any person obtaining a //
// copy of this software and associated documentation files (the "Software"), //
// to deal in the Software without restriction, including without limitation //
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
// and/or sell copies of the Software, and to permit persons to whom the //
// Software is furnished to do so, subject to the following conditions: //
// //
// The above copyright notice and this permission notice shall be included in //
// all copies or substantial portions of the Software. //
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
// DEALINGS IN THE SOFTWARE. //
// //
//----------------------------------------------------------------------------//
#ifndef OZZ_OZZ_GEOMETRY_EXPORT_H_
#define OZZ_OZZ_GEOMETRY_EXPORT_H_
#if defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#ifdef OZZ_BUILD_GEOMETRY_LIB
// Import/Export for dynamic linking while building ozz
#define OZZ_GEOMETRY_DLL __declspec(dllexport)
#else
#define OZZ_GEOMETRY_DLL __declspec(dllimport)
#endif
#else // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
// Static or non msvc linking
#define OZZ_GEOMETRY_DLL
#endif // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#endif // OZZ_OZZ_GEOMETRY_EXPORT_H_
@@ -30,6 +30,7 @@
#include "ozz/base/platform.h"
#include "ozz/base/span.h"
#include "ozz/geometry/runtime/export.h"
namespace ozz {
namespace math {
@@ -73,7 +74,7 @@ namespace geometry {
// should only be used when input matrices have non uniform scaling or shearing.
// The job does not owned the buffers (in/output) and will thus not delete them
// during job's destruction.
struct SkinningJob {
struct OZZ_GEOMETRY_DLL SkinningJob {
// Default constructor, initializes default values.
SkinningJob();
+44
View File
@@ -0,0 +1,44 @@
//----------------------------------------------------------------------------//
// //
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
// and distributed under the MIT License (MIT). //
// //
// Copyright (c) Guillaume Blanc //
// //
// Permission is hereby granted, free of charge, to any person obtaining a //
// copy of this software and associated documentation files (the "Software"), //
// to deal in the Software without restriction, including without limitation //
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
// and/or sell copies of the Software, and to permit persons to whom the //
// Software is furnished to do so, subject to the following conditions: //
// //
// The above copyright notice and this permission notice shall be included in //
// all copies or substantial portions of the Software. //
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
// DEALINGS IN THE SOFTWARE. //
// //
//----------------------------------------------------------------------------//
#ifndef OZZ_OZZ_OPTIONS_EXPORT_H_
#define OZZ_OZZ_OPTIONS_EXPORT_H_
#if defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#ifdef OZZ_BUILD_OPTIONS_LIB
// Import/Export for dynamic linking while building ozz
#define OZZ_OPTIONS_DLL __declspec(dllexport)
#else
#define OZZ_OPTIONS_DLL __declspec(dllimport)
#endif
#else // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
// Static or non msvc linking
#define OZZ_OPTIONS_DLL
#endif // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
#endif // OZZ_OZZ_OPTIONS_EXPORT_H_
+15 -13
View File
@@ -80,8 +80,8 @@
// registered options.
// --version displays executable's version.
#include <cstddef>
#include <string>
#include "ozz/options/export.h"
#include "ozz/base/containers/string.h"
namespace ozz {
namespace options {
@@ -108,26 +108,28 @@ enum ParseResult {
// _version and _usage are not copied, ParseCommandLine caller is in charge of
// maintaining their allocation during application lifetime.
// See ParseResult for more details about returned values.
ParseResult ParseCommandLine(int _argc, const char* const* _argv,
const char* _version, const char* _usage);
OZZ_OPTIONS_DLL ParseResult ParseCommandLine(int _argc,
const char* const* _argv,
const char* _version,
const char* _usage);
// Get the executable path that was extracted from the last call to
// ParseCommandLine.
// If ParseCommandLine has never been called, then ParsedExecutablePath
// returns a default empty string.
std::string ParsedExecutablePath();
OZZ_OPTIONS_DLL ozz::string ParsedExecutablePath();
// Get the executable name that was extracted from the last call to
// ParseCommandLine.
// If ParseCommandLine has never been called, then ParsedExecutableName
// returns a default empty string.
const char* ParsedExecutableName();
OZZ_OPTIONS_DLL const char* ParsedExecutableName();
// Get the executable usage that was extracted from the last call to
// ParseCommandLine.
// If ParseCommandLine has never been called, then ParsedExecutableUsage
// returns a default empty string.
const char* ParsedExecutableUsage();
OZZ_OPTIONS_DLL const char* ParsedExecutableUsage();
#define OZZ_OPTIONS_DECLARE_BOOL(_name, _help, _default, _required) \
OZZ_OPTIONS_DECLARE_VARIABLE(ozz::options::BoolOption, _name, _help, \
@@ -168,7 +170,7 @@ const char* ParsedExecutableUsage();
#_name, _help, _default, _required, _fn);
// Defines option interface.
class Option {
class OZZ_OPTIONS_DLL Option {
public:
// Returns option's name.
const char* name() const { return name_; }
@@ -196,7 +198,7 @@ class Option {
void RestoreDefault();
// Outputs default value as a string.
virtual std::string FormatDefault() const = 0;
virtual ozz::string FormatDefault() const = 0;
// Outputs type of value as a c string.
virtual const char* FormatType() const = 0;
@@ -246,7 +248,7 @@ class Option {
// Defines a strongly typed option class
template <typename _Type>
class TypedOption : public Option {
class OZZ_OPTIONS_DLL TypedOption : public Option {
public:
// Lets the type be known.
typedef _Type Type;
@@ -277,7 +279,7 @@ class TypedOption : public Option {
virtual void RestoreDefaultImpl() { value_ = default_; }
// Outputs default value as a string.
virtual std::string FormatDefault() const;
virtual ozz::string FormatDefault() const;
// Outputs type of value as a string.
virtual const char* FormatType() const;
@@ -298,7 +300,7 @@ typedef TypedOption<const char*> StringOption;
// Declares the option parser class.
// Option are registered by the parser and updated when command line arguments
// are parsed.
class Parser {
class OZZ_OPTIONS_DLL Parser {
public:
// Construct a parser with only built-in options.
Parser();
@@ -354,7 +356,7 @@ class Parser {
const char* version() const;
// Returns the path of the executable that was extracted from argument 0.
std::string executable_path() const;
ozz::string executable_path() const;
// Returns the name of the executable that was extracted from argument 0.
const char* executable_name() const;