Skip to content

Commit 81ddecf

Browse files
committed
mod: implement explicit default-joint resolver
1 parent c5614fc commit 81ddecf

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎src/formats/mod/attachment.cpp‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "dmc_rengine/formats/mod/attachment.hpp"
2+
3+
#include <cstddef>
4+
5+
namespace dmc::rengine::formats::mod::attachment {
6+
7+
DefaultJointResolution resolve_default_joint(
8+
const Document& child,
9+
const Document& host) noexcept {
10+
DefaultJointResolution out;
11+
out.selector = child.header.default_joint_index();
12+
13+
const auto host_world =
14+
world_transform::build_model_space_world_matrices(host.transform_domain);
15+
if (!host_world.has_value()) {
16+
out.status = ResolveStatus::host_spatial_hierarchy_unavailable;
17+
return out;
18+
}
19+
20+
const auto selector = static_cast<std::size_t>(out.selector);
21+
if (selector >= host_world->size()) {
22+
out.status = ResolveStatus::selector_out_of_range;
23+
return out;
24+
}
25+
26+
out.host_joint_world = (*host_world)[selector];
27+
out.status = ResolveStatus::resolved;
28+
return out;
29+
}
30+
31+
} // namespace dmc::rengine::formats::mod::attachment

0 commit comments

Comments
 (0)