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

PredatorCZ / HavokLib / 89

06 Nov 2025 01:09PM UTC coverage: 63.837% (-3.2%) from 67.014%
89

push

github

PredatorCZ
s

3354 of 5254 relevant lines covered (63.84%)

129082.83 hits per line

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

40.0
/source/packfile/hka_animation_container.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 "base.hpp"
19
#include "hklib/hka_boneattachment.hpp"
20
#include "internal/hka_animation.hpp"
21
#include "internal/hka_animationbinding.hpp"
22
#include "internal/hka_animationcontainer.hpp"
23
#include "internal/hka_meshbinding.hpp"
24
#include "internal/hka_skeleton.hpp"
25

26
#include "hka_animation_container.inl"
27

28
struct hkaAnimationContainerSaver {
29
  const hkaAnimationContainerInternalInterface *in;
30
  const clgen::hkaAnimationContainer::Interface *out;
31

32
  void Save(BinWritterRef wr, hkFixups &fixups) {
×
33
    const size_t sBegin = wr.Tell();
×
34
    auto &locals = fixups.locals;
×
35
    auto &lay = *out->layout;
×
36
    using mm = clgen::hkaAnimationContainer::Members;
37

38
    wr.WriteBuffer(out->data, lay.totalSize);
×
39

40
    if (in->GetNumSkeletons()) {
×
41
      wr.ApplyPadding(8);
×
42
      locals.emplace_back(sBegin + out->m(mm::skeletons), wr.Tell());
×
43

44
      for (auto s : in->Skeletons()) {
×
45
        locals.emplace_back(wr.Tell(), s);
×
46
        wr.Skip(lay.ptrSize);
×
47
      }
48
    }
49

50
    if (in->GetNumAnimations()) {
×
51
      wr.ApplyPadding(8);
×
52
      locals.emplace_back(sBegin + out->m(mm::animations), wr.Tell());
×
53

54
      for (auto s : in->Animations()) {
×
55
        locals.emplace_back(wr.Tell(), s);
×
56
        wr.Skip(lay.ptrSize);
×
57
      }
58
    }
59

60
    if (in->GetNumBindings()) {
×
61
      wr.ApplyPadding(8);
×
62
      locals.emplace_back(sBegin + out->m(mm::bindings), wr.Tell());
×
63

64
      for (auto s : in->Bindings()) {
×
65
        locals.emplace_back(wr.Tell(), s);
×
66
        wr.Skip(lay.ptrSize);
×
67
      }
68
    }
69

70
    if (in->GetNumAttachments()) {
×
71
      wr.ApplyPadding(8);
×
72
      locals.emplace_back(sBegin + out->m(mm::attachments), wr.Tell());
×
73

74
      for (auto s : in->Attachments()) {
×
75
        locals.emplace_back(wr.Tell(), s);
×
76
        wr.Skip(lay.ptrSize);
×
77
      }
78
    }
79

80
    if (in->GetNumSkins()) {
×
81
      wr.ApplyPadding(8);
×
82
      locals.emplace_back(sBegin + out->m(mm::skins), wr.Tell());
×
83

84
      for (auto s : in->MeshBinds()) {
×
85
        locals.emplace_back(wr.Tell(), s);
×
86
        wr.Skip(lay.ptrSize);
×
87
      }
88
    }
89
  }
90
};
91

92
struct hkaAnimationContainerMidInterface
93
    : hkaAnimationContainerInternalInterface {
94
  clgen::hkaAnimationContainer::Interface interface;
95
  std::unique_ptr<hkaAnimationContainerSaver> saver;
96

97
  hkaAnimationContainerMidInterface(clgen::LayoutLookup rules, char *data)
906✔
98
      : interface{data, rules} {}
906✔
99

100
  void SetDataPointer(void *ptr) override {
906✔
101
    interface.data = static_cast<char *>(ptr);
906✔
102
  }
906✔
103

104
  const void *GetPointer() const override { return interface.data; }
2,418✔
105

106
  size_t GetNumSkeletons() const override { return interface.NumSkeletons(); };
537✔
107
  const hkaSkeleton *GetSkeleton(size_t id) const override {
80✔
108
    auto item = interface.Skeletons().Next(id);
80✔
109
    return safe_deref_cast<const hkaSkeleton>(header->GetClass(**item));
80✔
110
  };
111
  size_t GetNumAnimations() const override {
536✔
112
    return interface.NumAnimations();
536✔
113
  };
114
  const hkaAnimation *GetAnimation(size_t id) const override {
456✔
115
    auto item = interface.Animations().Next(id);
456✔
116
    return safe_deref_cast<const hkaAnimation>(header->GetClass(**item));
456✔
117
  };
118
  size_t GetNumBindings() const override { return interface.NumBindings(); };
536✔
119
  const hkaAnimationBinding *GetBinding(size_t id) const override {
456✔
120
    auto item = interface.Bindings().Next(id);
456✔
121
    return safe_deref_cast<const hkaAnimationBinding>(header->GetClass(**item));
456✔
122
  };
123
  size_t GetNumAttachments() const override {
536✔
124
    return interface.NumAttachments();
536✔
125
  };
126
  const hkaBoneAttachment *GetAttachment(size_t id) const override {
×
127
    auto item = interface.Attachments().Next(id);
×
128
    return safe_deref_cast<const hkaBoneAttachment>(header->GetClass(**item));
×
129
  };
130
  size_t GetNumSkins() const override { return interface.NumSkins(); };
536✔
131
  const hkaMeshBinding *GetSkin(size_t id) const override {
8✔
132
    auto item = interface.Skins().Next(id);
8✔
133
    return safe_deref_cast<const hkaMeshBinding>(header->GetClass(**item));
8✔
134
  };
135
  void SwapEndian() override { clgen::EndianSwap(interface); }
453✔
136

137
  void Reflect(const IhkVirtualClass *other) override {
×
138
    interface.data = static_cast<char *>(malloc(interface.layout->totalSize));
×
139
    saver = std::make_unique<hkaAnimationContainerSaver>();
×
140
    saver->in = static_cast<const hkaAnimationContainerInternalInterface *>(
×
141
        checked_deref_cast<const hkaAnimationContainer>(other));
×
142
    saver->out = &interface;
×
143
    interface.NumSkeletons(saver->in->GetNumSkeletons());
×
144
    interface.NumAnimations(saver->in->GetNumAnimations());
×
145
    interface.NumBindings(saver->in->GetNumBindings());
×
146
    interface.NumAttachments(saver->in->GetNumAttachments());
×
147
    interface.NumSkins(saver->in->GetNumSkins());
×
148
  }
149

150
  void Save(BinWritterRef wr, hkFixups &fixups) const override {
×
151
    saver->Save(wr, fixups);
×
152
  }
153

154
  ~hkaAnimationContainerMidInterface() {
1,812✔
155
    if (saver) {
906✔
156
      free(interface.data);
×
157
    }
158
  }
1,812✔
159
};
906✔
160

161
CREATE_HK_CLASS(hkaAnimationContainer);
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