File size: 1,489 Bytes
7b853a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

#pragma once

#include "Math/Transform.h"

#include <string>
#include <vector>

namespace Animation
{
    enum IKType {
        kOneBone,
        kTwoBone
    };

    Math::Transform JointLocalToGlobal(
        const std::vector<int>& joint_parents_vec,
        int32_t index,
        const std::vector<Math::Transform>& localPose,
        const Math::Transform& rootTx = Math::Transform::Identity
    );

    struct ContactInfo {
        // index IK contact joint:
        int jointIndex;
        // mask indicating which frames are in contact:
        std::vector<float> contactMask;
        // contact type:
        IKType contactType = kTwoBone;

        // Extra info for TwoBoneIK
        Math::Vector hintOffset = Math::Vector::Zero;

        float minHeight = 0.0f;
    };

    void CorrectMotion(
        std::vector< std::vector<Math::Transform> >& poses,
        const std::vector< std::vector<Math::Transform> >& targetPoses,
        const std::vector<float>& mask,
        const std::vector<float>& rootMask,
        const std::vector<ContactInfo>& contacts,
        const std::vector<ContactInfo>& endEffectorPins,
        const std::vector<int>& joint_parents_vec,
        const std::vector<Math::Transform>& defaultPose,
        float contactThreshold,
        float root_margin,
        bool has_double_ankle_joints
    );
}