1#include <Core/Asset/HandleToSkeleton.hpp>
5#include <Core/Animation/Skeleton.hpp>
6#include <Core/Asset/HandleData.hpp>
7#include <Core/Utils/Log.hpp>
9using namespace Ra::Core::Utils;
17void addBone(
const uint parent,
24 if ( !processed[dataID] ) {
25 processed[dataID] =
true;
28 parent, dd.m_frame, Ra::Core::Animation::HandleArray::SpaceType::MODEL, dd.m_name );
29 for (
const auto& edge : edgeList ) {
30 if ( edge[0] == dataID ) {
31 addBone( index, edge[1], data, edgeList, processed, skelOut );
37void addRoot(
const uint dataID,
43 if ( !processed[dataID] ) {
44 processed[dataID] =
true;
46 uint index = skelOut.
addRoot( dd.m_frame, dd.m_name );
47 for (
const auto& edge : edgeList ) {
48 if ( edge[0] == dataID ) {
49 addBone( index, edge[1], data, edgeList, processed, skelOut );
61 for ( uint i = 0; i < size; ++i ) {
67 for (
const auto& edge : edgeList ) {
68 root.
erase( edge[1] );
69 leaves.
erase( edge[0] );
73 for (
const auto& r : root ) {
74 addRoot( r, data, edgeList, processed, skelOut );
79 for ( uint i = 0; i < skelOut.
size(); ++i ) {
80 boneNameMap[skelOut.
getLabel( i )] = i;
82 for (
const auto& l : leaves ) {
83 const auto& dd = component[l];
84 if ( dd.m_weights.size() ) {
85 LOG( logDEBUG ) <<
"Adding end-bone at " << dd.m_name <<
".";
86 skelOut.
addBone( boneNameMap[dd.m_name],
87 data.
getFrame().inverse() * dd.m_frame,
88 Ra::Core::Animation::HandleArray::SpaceType::MODEL,
89 dd.m_name +
"_Ra_endBone" );
Label getLabel(const uint i) const
uint addRoot(const Transform &T=Transform::Identity(), const Label label="")
uint size() const override
uint addBone(const uint parent, const Transform &T=Transform::Identity(), const SpaceType MODE=SpaceType::LOCAL, const Label label="")
uint getComponentDataSize() const
const Core::AlignedStdVector< HandleComponentData > & getComponentData() const
bool needsEndNodes() const
const Core::AlignedStdVector< Core::Vector2ui > & getEdgeData() const
Core::Transform getFrame() const
hepler function to manage enum as underlying types in VariableSet