• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PredatorCZ / HavokLib / 74

17 Jan 2025 06:48PM UTC coverage: 67.999% (-0.01%) from 68.011%
74

push

github

PredatorCZ
toolset add root node name setting

1991 of 2928 relevant lines covered (68.0%)

149596.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.24
/source/packfile/hka_animation_spline.cpp
1
/*  Havok Format Library
2
    Copyright(C) 2016-2022 Lukas Cone
3

4
    This program is free software : you can redistribute it and / or modify
5
    it under the terms of the GNU General Public License as published by
6
    the Free Software Foundation, either version 3 of the License, or
7
    (at your option) any later version.
8

9
    This program is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
12
    GNU General Public License for more details.
13

14
    You should have received a copy of the GNU General Public License
15
    along with this program.If not, see <https://www.gnu.org/licenses/>.
16
*/
17

18
#include "hka_animation.hpp"
19
#include "hka_spline_decompressor.hpp"
20

21
#include "hka_animation_spline.inl"
22

23
struct hkaSplineCompressedAnimationMidInterface
24
    : hkaSplineCompressedAnimationInternalInterface,
25
      hkaAnimationMidInterface<hkaAnimationInternalInterface> {
26
  clgen::hkaSplineCompressedAnimation::Interface interface;
27
  hkaSplineDecompressor decomp;
28

29
  hkaSplineCompressedAnimationMidInterface(clgen::LayoutLookup rules,
432✔
30
                                           char *data)
31
      : interface{data, rules} {}
432✔
32

33
  void SetDataPointer(void *ptr) override {
432✔
34
    interface.data = static_cast<char *>(ptr);
432✔
35
  }
432✔
36

37
  const void *GetPointer() const override { return interface.data; }
864✔
38

39
  clgen::hkaAnimation::Interface Anim() const override {
44,568✔
40
    return interface.BasehkaAnimation();
44,568✔
41
  }
42

43
  void SwapEndian() override {
216✔
44
    hkaAnimationMidInterface<hkaAnimationInternalInterface>::SwapEndian();
216✔
45
    clgen::EndianSwap(interface);
216✔
46

47
    for (std::span<uint32> tms(interface.FloatBlockOffsets(),
216✔
48
                               interface.NumFloatBlockOffsets());
216✔
49
         auto &i : tms) {
720✔
50
      FByteswapper(i);
504✔
51
    }
52

53
    for (std::span<uint32> tms(interface.BlockOffsets(),
216✔
54
                               interface.NumBlockOffsets());
216✔
55
         auto &i : tms) {
720✔
56
      FByteswapper(i);
504✔
57
    }
58

59
    for (std::span<uint32> tms(interface.FloatOffsets(),
216✔
60
                               interface.NumFloatOffsets());
216✔
61
         auto &i : tms) {
216✔
62
      FByteswapper(i);
×
63
    }
64

65
    for (std::span<uint32> tms(interface.TransformBlockOffsets(),
216✔
66
                               interface.NumTransformBlockOffsets());
216✔
67
         auto &i : tms) {
216✔
68
      FByteswapper(i);
×
69
    }
70
  }
216✔
71

72
  void Process() override {
432✔
73
    decomp.Assign(this);
432✔
74
    this->frameRate =
432✔
75
        static_cast<uint32>(this->GetNumFrames() / this->Duration());
432✔
76
  }
432✔
77

78
  uint32 GetNumFrames() const override { return interface.NumFrames(); }
648✔
79
  uint32 GetNumBlocks() const override { return interface.NumBlocks(); }
2,009,016✔
80
  uint32 GetMaxFramesPerBlock() const override {
216✔
81
    return interface.MaxFramesPerBlock();
216✔
82
  }
83
  float GetBlockDuration() const override { return interface.BlockDuration(); }
2,009,232✔
84
  float GetBlockInverseDuration() const override {
2,009,232✔
85
    return interface.BlockInverseDuration();
2,009,232✔
86
  }
87
  float GetFrameDuration() const override { return interface.FrameDuration(); }
432✔
88
  char *GetData() const override {
648✔
89
    return const_cast<char *>(interface.DataBuffer());
648✔
90
  }
91
  std::span<const uint32> GetBlockOffsets() const override {
648✔
92
    return {interface.BlockOffsets(), interface.NumBlockOffsets()};
648✔
93
  }
94
  std::span<const uint32> GetFloatBlockOffsets() const override {
216✔
95
    return {interface.FloatBlockOffsets(), interface.NumFloatBlockOffsets()};
216✔
96
  }
97
  std::span<const uint32> GetTransformOffsets() const override {
216✔
98
    return {interface.TransformBlockOffsets(),
99
            interface.NumTransformBlockOffsets()};
216✔
100
  }
101
  std::span<const uint32> GetFloatOffsets() const override {
216✔
102
    return {interface.FloatOffsets(), interface.NumFloatOffsets()};
216✔
103
  }
104

105
  void GetValue(uni::RTSValue &output, float time,
2,008,800✔
106
                size_t trackID) const override {
107
    const float blockInverseDuration = GetBlockInverseDuration();
2,008,800✔
108
    const float blockDuration = GetBlockDuration();
2,008,800✔
109
    size_t blockID = static_cast<size_t>(time * blockInverseDuration);
2,008,800✔
110

111
    if (blockID >= GetNumBlocks()) [[unlikely]] {
2,008,800✔
112
      blockID = GetNumBlocks() - 1;
×
113
    }
114

115
    float localTime = time - (static_cast<float>(blockID) * blockDuration);
2,008,800✔
116

117
    if (localTime < 0.f) {
2,008,800✔
118
      localTime = 0.f;
119
    }
120

121
    decomp.blocks[blockID].GetValue(trackID, localTime * frameRate, output);
2,008,800✔
122
  }
2,008,800✔
123
};
124

125
IhkVirtualClass *
126
hkaSplineCompressedAnimationInternalInterface::Create(CRule rule) {
432✔
127
  return new hkaSplineCompressedAnimationMidInterface{
128
      clgen::LayoutLookup{rule.version, rule.x64, rule.reusePadding}, nullptr};
432✔
129
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc