Skip to content

Commit

Permalink
Renames reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeblanc committed Mar 31, 2024
1 parent cff1097 commit 31de353
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
12 changes: 6 additions & 6 deletions include/ozz/animation/offline/motion_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class OZZ_ANIMOFFLINE_DLL MotionExtractor {

// Defines the reference transform to use while extracting root motion.
enum class Reference {
kIdentity, // Identity / global reference
kSkeleton, // Use skeleton rest pose root bone transform
kFirstFrame, // Uses root transform of the animation's first frame
kIdentity, // Identity / global reference
kSkeleton, // Use skeleton rest pose root bone transform
kAnimation, // Uses root transform of the animation's first frame
};

struct Settings {
Expand All @@ -63,11 +63,11 @@ class OZZ_ANIMOFFLINE_DLL MotionExtractor {
bool bake; // Bake extracted data to output animation
};

Settings position_settings = {true, false, true, // X and Z projection
Reference::kFirstFrame, // Reference
Settings position_settings = {true, false, true, // X and Z projection
Reference::kAnimation, // Reference
true}; // Bake extracted position
Settings rotation_settings = {false, true, false, // Y / Yaw only
Reference::kFirstFrame, // Reference
Reference::kAnimation, // Reference
true}; // Bake extracted rotation
};
} // namespace offline
Expand Down
4 changes: 2 additions & 2 deletions src/animation/offline/motion_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ozz::math::Transform BuildReference(
case MotionExtractor::Reference::kSkeleton: {
ref.translation = _skeleton_ref.translation;
} break;
case MotionExtractor::Reference::kFirstFrame: {
case MotionExtractor::Reference::kAnimation: {
if (!_track.translations.empty()) {
ref.translation = _track.translations[0].value;
}
Expand All @@ -67,7 +67,7 @@ ozz::math::Transform BuildReference(
case MotionExtractor::Reference::kSkeleton: {
ref.rotation = _skeleton_ref.rotation;
} break;
case MotionExtractor::Reference::kFirstFrame: {
case MotionExtractor::Reference::kAnimation: {
if (!_track.rotations.empty()) {
ref.rotation = _track.rotations[0].value;
}
Expand Down
4 changes: 2 additions & 2 deletions src/animation/offline/tools/import2ozz_anim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ bool Export(OzzImporter& _importer, const RawAnimation& _input_animation,
DisplaysOptimizationstatistics(raw_animation, raw_optimized_animation);

// Brings data back to the raw animation.
raw_animation = raw_optimized_animation;
raw_animation = std::move(raw_optimized_animation);
} else {
ozz::log::LogV() << "Optimization for animation \"" << _input_animation.name
<< "\" is disabled." << std::endl;
Expand Down Expand Up @@ -256,7 +256,7 @@ bool Export(OzzImporter& _importer, const RawAnimation& _input_animation,
}

// Now use additive animation.
raw_animation = raw_additive;
raw_animation = std::move(raw_additive);
}

// Builds runtime animation.
Expand Down
15 changes: 8 additions & 7 deletions src/animation/offline/tools/import2ozz_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,9 @@ bool SanitizeTrackImport(Json::Value& _root, bool _all_options) {
return SanitizeTrackBuildSettings(_root, _all_options);
}

bool SanitizeTrackMotionComponent(Json::Value& _root, bool) {
MakeDefault(_root, "components", "xyz",
bool SanitizeTrackMotionComponent(Json::Value& _root,
const char* default_components, bool) {
MakeDefault(_root, "components", default_components,
"Components to import, can be any composition of x, y and z.");
if (_root["components"].asString().find_first_not_of("xyz") !=
std::string::npos) {
Expand All @@ -327,14 +328,14 @@ bool SanitizeTrackMotionComponent(Json::Value& _root, bool) {
}

MakeDefault(
_root, "reference", "first_frame",
_root, "reference", "animation",
"Root motion extraction reference pose, can be identity, skeleton or "
"first_frame.");
"animation.");
const char* reference_name = _root["reference"].asCString();
if (!RootMotionReferenceConfig::IsValidEnumName(reference_name)) {
ozz::log::Err() << "Invalid value \"" << reference_name
<< "\" for root motion reference. Can be identity, "
"skeleton or first_frame."
"skeleton or animation."
<< std::endl;
return false;
}
Expand Down Expand Up @@ -362,12 +363,12 @@ bool SanitizeTrackMotion(Json::Value& _root, bool _all_options) {
"to select joint 0 (aka the first root).");

MakeDefaultObject(_root, "position", "Root motion position settings.");
if (!SanitizeTrackMotionComponent(_root["position"], _all_options)) {
if (!SanitizeTrackMotionComponent(_root["position"], "xz", _all_options)) {
return false;
}

MakeDefaultObject(_root, "rotation", "Root motion rotation settings.");
if (!SanitizeTrackMotionComponent(_root["rotation"], _all_options)) {
if (!SanitizeTrackMotionComponent(_root["rotation"], "y", _all_options)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/animation/offline/tools/import2ozz_track.cc
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ PropertyTypeConfig::EnumNames PropertyTypeConfig::GetNames() {
}

RootMotionReferenceConfig::EnumNames RootMotionReferenceConfig::GetNames() {
static const char* kNames[] = {"identity", "skeleton", "first_frame"};
static const char* kNames[] = {"identity", "skeleton", "animation"};
const EnumNames enum_names = {OZZ_ARRAY_SIZE(kNames), kNames};
return enum_names;
}
Expand Down
8 changes: 4 additions & 4 deletions src/animation/offline/tools/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
// Root motion position settings.
"position" :
{
"components" : "xyz", // Components to import, can be any composition of x, y and z.
"reference" : "first_frame", // Root motion extraction reference pose, can be identity, skeleton or first_frame.
"components" : "xz", // Components to import, can be any composition of x, y and z.
"reference" : "animation", // Root motion extraction reference pose, can be identity, skeleton or animation.
"bake" : true, // Bake extracted motion into animation.
"raw" : false, // Outputs raw track.
"optimize" : true, // Activates keyframes optimization.
Expand All @@ -82,8 +82,8 @@
// Root motion rotation settings.
"rotation" :
{
"components" : "xyz", // Components to import, can be any composition of x, y and z.
"reference" : "first_frame", // Root motion extraction reference pose, can be identity, skeleton or first_frame.
"components" : "y", // Components to import, can be any composition of x, y and z.
"reference" : "animation", // Root motion extraction reference pose, can be identity, skeleton or animation.
"bake" : true, // Bake extracted motion into animation.
"raw" : false, // Outputs raw track.
"optimize" : true, // Activates keyframes optimization.
Expand Down
4 changes: 2 additions & 2 deletions test/animation/offline/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ set_tests_properties(test2ozz_track_motion_reference_identity PROPERTIES DEPENDS
add_test(NAME test2ozz_track_motion_reference_skeleton COMMAND test2ozz "--file=${ozz_temp_directory}/good.content1" "--config={\"skeleton\":{\"filename\":\"${ozz_temp_directory}/skeleton.ozz\",\"import\":{\"enable\":false}},\"animations\":[{\"filename\":\"${ozz_temp_directory}/animation_${CMAKE_CURRENT_LIST_LINE}.ozz\",\"tracks\":{\"motion\":{\"filename\":\"${ozz_temp_directory}/test2ozz_motion_${CMAKE_CURRENT_LIST_LINE}.ozz\",\"position\":{\"reference\":\"skeleton\"}}}}]}")
set_tests_properties(test2ozz_track_motion_reference_skeleton PROPERTIES DEPENDS test2ozz_skel_simple)

add_test(NAME test2ozz_track_motion_reference_first_frame COMMAND test2ozz "--file=${ozz_temp_directory}/good.content1" "--config={\"skeleton\":{\"filename\":\"${ozz_temp_directory}/skeleton.ozz\",\"import\":{\"enable\":false}},\"animations\":[{\"filename\":\"${ozz_temp_directory}/animation_${CMAKE_CURRENT_LIST_LINE}.ozz\",\"tracks\":{\"motion\":{\"filename\":\"${ozz_temp_directory}/test2ozz_motion_${CMAKE_CURRENT_LIST_LINE}.ozz\",\"position\":{\"reference\":\"first_frame\"}}}}]}")
set_tests_properties(test2ozz_track_motion_reference_first_frame PROPERTIES DEPENDS test2ozz_skel_simple)
add_test(NAME test2ozz_track_motion_reference_animation COMMAND test2ozz "--file=${ozz_temp_directory}/good.content1" "--config={\"skeleton\":{\"filename\":\"${ozz_temp_directory}/skeleton.ozz\",\"import\":{\"enable\":false}},\"animations\":[{\"filename\":\"${ozz_temp_directory}/animation_${CMAKE_CURRENT_LIST_LINE}.ozz\",\"tracks\":{\"motion\":{\"filename\":\"${ozz_temp_directory}/test2ozz_motion_${CMAKE_CURRENT_LIST_LINE}.ozz\",\"position\":{\"reference\":\"animation\"}}}}]}")
set_tests_properties(test2ozz_track_motion_reference_animation PROPERTIES DEPENDS test2ozz_skel_simple)

add_test(NAME test2ozz_track_motion_postion_components_xyz COMMAND test2ozz "--file=${ozz_temp_directory}/good.content1" "--config={\"skeleton\":{\"filename\":\"${ozz_temp_directory}/skeleton.ozz\",\"import\":{\"enable\":false}},\"animations\":[{\"filename\":\"${ozz_temp_directory}/animation_${CMAKE_CURRENT_LIST_LINE}.ozz\",\"tracks\":{\"motion\":{\"filename\":\"${ozz_temp_directory}/test2ozz_motion_${CMAKE_CURRENT_LIST_LINE}.ozz\",\"position\":{\"components\":\"xyz\"}}}}]}")
set_tests_properties(test2ozz_track_motion_postion_components_xyz PROPERTIES DEPENDS test2ozz_skel_simple)
Expand Down

0 comments on commit 31de353

Please sign in to comment.