Skip to content

Commit 1e6d4b1

Browse files
committed
Cleanup
1 parent 19888c7 commit 1e6d4b1

File tree

5 files changed

+67
-42
lines changed

5 files changed

+67
-42
lines changed
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
11
# AGENT_NEXT_STEPS
2-
3-
## Align OMF → ozz Animation Conversion with Blender-XRay Workflow
4-
- Blender-XRay bakes animations in local joint space using parent-inverted matrices plus a +90° X rotation (MATRIX_BONE) before writing keys. Our converter currently does `inv_bind * parent_bind`, which leaves animations in mixed spaces.
5-
- In `ConvertSingleMotionWithBindMatrices`, switch to computing local transforms exactly like Blender-XRay: `local = parent_bind.inverted() * child_bind` (root uses the same +90° basis), then decompose.
6-
- Apply the consistent axis remap `(X, Y, Z) → (X, -Z, Y)` and matching quaternion reorder/sign adjustments when writing translation and rotation keys (use `TransformConverter` helpers).
7-
- Re-run the bind pose + animation frame comparisons (with `OZZ_SAMPLE_RATIO` for frame alignment) to confirm positional/rotational deltas drop near zero.

src/xrAnimation/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ include_directories(
1313
${CMAKE_CURRENT_SOURCE_DIR}/../xrEngine
1414
${CMAKE_CURRENT_SOURCE_DIR}/../Common
1515
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/ozz-animation/include
16+
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/ozz-animation/samples
1617
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/imgui
1718
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/imgui-proj
1819
)
@@ -65,4 +66,4 @@ install(TARGETS xrAnimation
6566
add_subdirectory(tests)
6667

6768
# Add tools
68-
add_subdirectory(tools)
69+
add_subdirectory(tools)

src/xrAnimation/tests/CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ cmake_minimum_required(VERSION 3.8)
33
add_executable(xrAnimation_converter_tests
44
test_converter.cpp)
55

6+
# Resolve ozz samples include directory (submodule lives alongside xray-16).
7+
get_filename_component(OZZ_SAMPLES_ROOT ${CMAKE_SOURCE_DIR}/../ozz-animation/samples ABSOLUTE)
8+
69
# Provide include paths for dependency headers.
710
target_include_directories(xrAnimation_converter_tests PRIVATE
811
${CMAKE_CURRENT_SOURCE_DIR}/..
9-
${CMAKE_SOURCE_DIR}/Externals/ozz-animation/include)
12+
${CMAKE_SOURCE_DIR}/Externals/ozz-animation/include
13+
${OZZ_SAMPLES_ROOT})
1014

1115
target_link_libraries(xrAnimation_converter_tests PRIVATE
16+
xrAnimation
1217
ozz_animation
13-
ozz_base)
18+
ozz_animation_offline
19+
ozz_base
20+
xrEngine
21+
xrScriptEngine)
1422

1523
target_compile_features(xrAnimation_converter_tests PRIVATE cxx_std_17)
1624

17-
get_filename_component(XRAY_WORKSPACE_ROOT ${CMAKE_SOURCE_DIR} DIRECTORY)
18-
1925
target_compile_definitions(xrAnimation_converter_tests PRIVATE
20-
WORKSPACE_ROOT="${XRAY_WORKSPACE_ROOT}")
26+
PROJECT_ROOT="${CMAKE_SOURCE_DIR}")
2127

2228
set_target_properties(xrAnimation_converter_tests PROPERTIES
2329
FOLDER "xrAnimation/Tests")

src/xrAnimation/tests/test_converter.cpp

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include <type_traits>
1515
#include <vector>
1616

17-
#ifndef WORKSPACE_ROOT
18-
#error "WORKSPACE_ROOT compile definition must be provided"
17+
#ifndef PROJECT_ROOT
18+
#error "PROJECT_ROOT compile definition must be provided"
1919
#endif
2020

2121
#ifdef _WIN32
@@ -33,30 +33,31 @@
3333
#include "ozz/base/maths/soa_transform.h"
3434
#include "ozz/base/maths/transform.h"
3535

36+
3637
namespace fs = std::filesystem;
3738

3839
namespace
3940
{
4041

41-
fs::path WorkspaceRoot()
42+
fs::path ProjectRoot()
4243
{
43-
static const fs::path root = fs::path(WORKSPACE_ROOT);
44+
static const fs::path root = fs::path(PROJECT_ROOT);
4445
return root;
4546
}
4647

4748
fs::path TestArtifactsDir()
4849
{
49-
return WorkspaceRoot() / "asset_tests" / "test_outputs";
50+
return ProjectRoot() / "asset_tests" / "test_outputs";
5051
}
5152

5253
fs::path SkeletonInputPath()
5354
{
54-
return WorkspaceRoot() / "xray-16" / "res" / "testdata" / "stalker_hero_1.ogf";
55+
return ProjectRoot() / "res" / "testdata" / "stalker_hero_1.ogf";
5556
}
5657

5758
fs::path AnimationInputPath()
5859
{
59-
return WorkspaceRoot() / "xray-16" / "res" / "testdata" / "critical_hit_grup_1.omf";
60+
return ProjectRoot() / "res" / "testdata" / "critical_hit_grup_1.omf";
6061
}
6162

6263
fs::path SkeletonOutputPath()
@@ -69,6 +70,11 @@ fs::path SkeletonCsvPath()
6970
return TestArtifactsDir() / "stalker_hero_bind_pose.csv";
7071
}
7172

73+
fs::path BaselineDir()
74+
{
75+
return ProjectRoot() / "src" / "xrAnimation" / "tests" / "baselines";
76+
}
77+
7278
fs::path AnimationOutputPath()
7379
{
7480
return TestArtifactsDir() / "critical_hit_grup_1.ozz";
@@ -240,15 +246,9 @@ std::string QuoteForShell(const std::string& value)
240246
#endif
241247
}
242248

243-
fs::path ResolveConverterBinary()
249+
fs::path ResolveBinary(const std::string& executable_name)
244250
{
245-
#ifdef _WIN32
246-
const std::string executable_name = "xray_to_ozz_converter.exe";
247-
#else
248-
const std::string executable_name = "xray_to_ozz_converter";
249-
#endif
250-
251-
const fs::path build_bin = WorkspaceRoot() / "xray-16" / "ozz_utils" / "bin";
251+
const fs::path build_bin = ProjectRoot() / "ozz_utils" / "bin";
252252

253253
const std::array<fs::path, 2> candidates = {
254254
build_bin / "Debug" / executable_name,
@@ -261,19 +261,37 @@ fs::path ResolveConverterBinary()
261261
}
262262

263263
std::ostringstream oss;
264-
oss << "Unable to locate xray_to_ozz_converter binary. Checked:";
264+
oss << "Unable to locate binary '" << executable_name << "'. Checked:";
265265
for (const auto& candidate : candidates)
266266
oss << '\n' << " " << candidate.string();
267267
throw std::runtime_error(oss.str());
268268
}
269269

270-
std::string BuildCommand(const std::vector<std::string>& args)
270+
fs::path ResolveConverterBinary()
271271
{
272-
const fs::path converter = ResolveConverterBinary();
273-
const fs::path converter_dir = converter.parent_path();
272+
#ifdef _WIN32
273+
return ResolveBinary("xray_to_ozz_converter.exe");
274+
#else
275+
return ResolveBinary("xray_to_ozz_converter");
276+
#endif
277+
}
278+
279+
fs::path ResolveViewerBinary()
280+
{
281+
#ifdef _WIN32
282+
return ResolveBinary("ozz_animation_viewer.exe");
283+
#else
284+
return ResolveBinary("ozz_animation_viewer");
285+
#endif
286+
}
287+
288+
std::string BuildCommand(const fs::path& binary,
289+
const std::vector<std::string>& args)
290+
{
291+
const fs::path binary_dir = binary.parent_path();
274292

275293
#ifdef _WIN32
276-
std::string command = QuoteForShell(converter.string());
294+
std::string command = QuoteForShell(binary.string());
277295
for (const std::string& arg : args)
278296
{
279297
command.push_back(' ');
@@ -282,9 +300,9 @@ std::string BuildCommand(const std::vector<std::string>& args)
282300
return command;
283301
#else
284302
std::string command = "LD_LIBRARY_PATH=";
285-
command.append(QuoteForShell(converter_dir.string()));
303+
command.append(QuoteForShell(binary_dir.string()));
286304
command.push_back(' ');
287-
command.append(QuoteForShell(converter.string()));
305+
command.append(QuoteForShell(binary.string()));
288306
for (const std::string& arg : args)
289307
{
290308
command.push_back(' ');
@@ -294,9 +312,10 @@ std::string BuildCommand(const std::vector<std::string>& args)
294312
#endif
295313
}
296314

297-
int ExecuteCommand(const std::vector<std::string>& args)
315+
int ExecuteCommand(const fs::path& binary,
316+
const std::vector<std::string>& args)
298317
{
299-
const std::string command = BuildCommand(args);
318+
const std::string command = BuildCommand(binary, args);
300319
const int result = std::system(command.c_str());
301320
if (result == -1)
302321
return -1;
@@ -312,6 +331,11 @@ int ExecuteCommand(const std::vector<std::string>& args)
312331
#endif
313332
}
314333

334+
int ExecuteConverterCommand(const std::vector<std::string>& args)
335+
{
336+
return ExecuteCommand(ResolveConverterBinary(), args);
337+
}
338+
315339
bool ConvertSkeleton(bool force)
316340
{
317341
const fs::path output_dir = TestArtifactsDir();
@@ -333,7 +357,7 @@ bool ConvertSkeleton(bool force)
333357
"--dump-bind",
334358
SkeletonCsvPath().string()};
335359

336-
const int exit_code = ExecuteCommand(args);
360+
const int exit_code = ExecuteConverterCommand(args);
337361
if (exit_code != 0)
338362
{
339363
std::cerr << "xray_to_ozz_converter returned exit code " << exit_code << std::endl;
@@ -378,7 +402,7 @@ bool ConvertAnimation(bool force)
378402
"--metadata",
379403
AnimationMetadataPath().string()};
380404

381-
const int exit_code = ExecuteCommand(args);
405+
const int exit_code = ExecuteConverterCommand(args);
382406
if (exit_code != 0)
383407
{
384408
std::cerr << "animation conversion failed with exit code " << exit_code << std::endl;
@@ -411,7 +435,7 @@ bool ConvertSpecificMotion(const std::string& motion_name, bool force)
411435
"--motion",
412436
motion_name};
413437

414-
const int exit_code = ExecuteCommand(args);
438+
const int exit_code = ExecuteConverterCommand(args);
415439
if (exit_code != 0)
416440
{
417441
std::cerr << "animation conversion for motion '" << motion_name

src/xrAnimation/tools/ozz_animation_viewer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,9 @@ class PlaybackSampleApplication : public ozz::sample::Application {
772772
ozz::math::StorePtrU(quat_simd, quat);
773773

774774
std::array<std::string, 7> value_strings = {
775-
FormatFloat(tx, 3), FormatFloat(ty, 3), FormatFloat(tz, 3),
776-
FormatFloat(quat[3], 4), FormatFloat(quat[0], 4),
777-
FormatFloat(quat[1], 4), FormatFloat(quat[2], 4)};
775+
FormatFloat(tx), FormatFloat(ty), FormatFloat(tz),
776+
FormatFloat(quat[3]), FormatFloat(quat[0]),
777+
FormatFloat(quat[1]), FormatFloat(quat[2])};
778778

779779
std::ostringstream row_stream;
780780
row_stream.imbue(std::locale::classic());

0 commit comments

Comments
 (0)