1#include <Core/Animation/HandleArray.hpp>
2#include <Core/Animation/Skeleton.hpp>
3#include <Core/Asset/HandleData.hpp>
4#include <Core/Asset/HandleToSkeleton.hpp>
5#include <Core/Containers/AlignedStdVector.hpp>
6#include <Core/CoreMacros.hpp>
8#include <Core/Utils/ContainerIntrospectionInterface.hpp>
9#include <Core/Utils/Log.hpp>
11#include <Eigen/Geometry>
18using namespace Ra::Core::Utils;
26void addBone(
const uint parent,
33 if ( !processed[dataID] ) {
34 processed[dataID] =
true;
37 parent, dd.m_frame, Ra::Core::Animation::HandleArray::SpaceType::MODEL, dd.m_name );
38 for (
const auto& edge : edgeList ) {
39 if ( edge[0] == dataID ) {
40 addBone( index, edge[1], data, edgeList, processed, skelOut );
46void addRoot(
const uint dataID,
52 if ( !processed[dataID] ) {
53 processed[dataID] =
true;
55 uint index = skelOut.
addRoot( dd.m_frame, dd.m_name );
56 for (
const auto& edge : edgeList ) {
57 if ( edge[0] == dataID ) {
58 addBone( index, edge[1], data, edgeList, processed, skelOut );
70 for ( uint i = 0; i < size; ++i ) {
76 for (
const auto& edge : edgeList ) {
77 root.
erase( edge[1] );
78 leaves.
erase( edge[0] );
82 for (
const auto& r : root ) {
83 addRoot( r, data, edgeList, processed, skelOut );
88 for ( uint i = 0; i < skelOut.
size(); ++i ) {
89 boneNameMap[skelOut.
getLabel( i )] = i;
91 for (
const auto& l : leaves ) {
92 const auto& dd = component[l];
93 if ( dd.m_weights.size() ) {
94 LOG( logDEBUG ) <<
"Adding end-bone at " << dd.m_name <<
".";
95 skelOut.
addBone( boneNameMap[dd.m_name],
96 data.
getFrame().inverse() * dd.m_frame,
97 Ra::Core::Animation::HandleArray::SpaceType::MODEL,
98 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