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

PredatorCZ / HavokLib / 91

07 Nov 2025 05:44PM UTC coverage: 62.489% (+0.03%) from 62.461%
91

push

github

PredatorCZ
add support for scene data

556 of 1151 new or added lines in 22 files covered. (48.31%)

21 existing lines in 5 files now uncovered.

2777 of 4444 relevant lines covered (62.49%)

125162.98 hits per line

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

54.55
/source/packfile/hkx_material.cpp
1
/*  Havok Format Library
2
    Copyright(C) 2016-2025 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 "internal/hkx_material.hpp"
19
#include "hkx_attribute_holder.hpp"
20

21
#include "hkx_material.inl"
22

23
struct hkxMaterialMidInterface : hkxMaterialInternalInterface,
24
                                 hkxAttributeHolderMidInterface {
25
  clgen::hkxMaterial::Interface interface;
26

27
  hkxMaterialMidInterface(clgen::LayoutLookup rules, char *data)
64✔
28
      : interface{data, rules} {}
64✔
29

NEW
30
  hkxMaterialMidInterface(const clgen::hkxMaterial::Interface &interface)
×
NEW
31
      : interface{interface} {}
×
32

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

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

39
  void SwapEndian() override {
32✔
40
    hkxAttributeHolderMidInterface::SwapEndian();
32✔
41
    clgen::EndianSwap(interface);
32✔
42
    auto stages = interface.Stages();
32✔
43
    const uint32 numStages = interface.NumStages();
44

45
    for (uint32 s = 0; s < numStages; s++, stages.Next()) {
64✔
46
      clgen::EndianSwap(stages);
32✔
47
    }
48

49
    Vector4A16 tmp = interface.DiffuseColor();
32✔
50
    FByteswapper(tmp);
51
    interface.DiffuseColor(tmp);
32✔
52

53
    tmp = interface.AmbientColor();
32✔
54
    FByteswapper(tmp);
55
    interface.AmbientColor(tmp);
32✔
56

57
    tmp = interface.SpecularColor();
32✔
58
    FByteswapper(tmp);
59
    interface.SpecularColor(tmp);
32✔
60

61
    tmp = interface.EmissiveColor();
32✔
62
    FByteswapper(tmp);
63
    interface.EmissiveColor(tmp);
32✔
64

65
    Vector2 tmp2 = interface.UvMapOffset();
32✔
66
    FByteswapper(tmp2);
67
    interface.UvMapOffset(tmp2);
32✔
68

69
    tmp2 = interface.UvMapScale();
32✔
70
    FByteswapper(tmp2);
71
    interface.UvMapScale(tmp2);
32✔
72

73
    auto props = interface.Properties();
74
    const uint32 numProps = interface.NumProperties();
75

76
    for (uint32 p = 0; p < numProps; p++) {
32✔
NEW
77
      FByteswapper(props[p].key);
×
NEW
78
      FByteswapper(props[p].value);
×
79
    }
80
  }
32✔
81

82
  clgen::hkxAttributeHolder::Interface AttribHolder() const override {
32✔
83
    return interface.BasehkxAttributeHolder();
32✔
84
  }
85

86
  std::string_view Name() const override { return safe_sw(interface.Name()); }
8✔
87
  size_t GetNumStages() const override { return interface.NumStages(); }
16✔
88
  hkxMaterialTextureStage GetStage(size_t id) const override {
8✔
89
    auto stage = interface.Stages().Next(id);
8✔
90
    return {
91
        .texture = static_cast<const hkxMaterialInternalInterface *>(this)
92
                       ->header->GetClass(stage.Texture().Object()),
16✔
93
        .usageHint = stage.UsageHint(),
94
        .tcoordChannel = stage.TcoordChannel(),
95
    };
16✔
96
  }
97
  Vector4A16 DiffuseColor() const override { return interface.DiffuseColor(); }
8✔
98
  Vector4A16 AmbientColor() const override { return interface.AmbientColor(); }
8✔
99
  Vector4A16 SpecularColor() const override {
8✔
100
    return interface.SpecularColor();
8✔
101
  }
102
  Vector4A16 EmissiveColor() const override {
8✔
103
    return interface.EmissiveColor();
8✔
104
  }
NEW
105
  size_t GetNumSubMaterials() const override {
×
NEW
106
    return interface.NumSubMaterials();
×
107
  }
NEW
108
  uni::Element<const hkxMaterial> GetSubMaterial(size_t id) const override {
×
NEW
109
    auto subMat = interface.SubMaterials().Next(id);
×
NEW
110
    return {new hkxMaterialMidInterface(**subMat), true};
×
111
  }
NEW
112
  const IhkVirtualClass *ExtraData() const override {
×
113
    const void *ptr = nullptr;
NEW
114
    if (interface.LayoutVersion() >= HK700) {
×
NEW
115
      ptr = interface.ExtraDataHK700().data;
×
116
    } else {
NEW
117
      ptr = interface.ExtraData().Object();
×
118
    }
119
    return static_cast<const hkxMaterialInternalInterface *>(this)
NEW
120
        ->header->GetClass(ptr);
×
121
  }
122

NEW
123
  Vector2 UVMapScale() const override {
×
NEW
124
    return interface.LayoutVersion() >= HK2012_1 ? interface.UvMapScale()
×
NEW
125
                                                 : Vector2(1);
×
126
  }
127

NEW
128
  Vector2 UVMapOffset() const override { return interface.UvMapOffset(); }
×
129

NEW
130
  float UVMapRotation() const override { return interface.UvMapRotation(); }
×
131

NEW
132
  UVMappingAlgorithm UVMapAlgorithm() const override {
×
133
    return interface.LayoutVersion() >= HK2012_1
NEW
134
               ? interface.UvMapAlgorithm()
×
NEW
135
               : UVMappingAlgorithm::STYPE_3DSMAX;
×
136
  }
137

NEW
138
  float SpecularMultiplier() const override {
×
139
    return interface.LayoutVersion() >= HK2012_1
NEW
140
               ? interface.SpecularMultiplier()
×
NEW
141
               : 1;
×
142
  }
143

NEW
144
  float SpecularExponent() const override {
×
NEW
145
    return interface.LayoutVersion() >= HK2012_1 ? interface.SpecularExponent()
×
NEW
146
                                                 : 1;
×
147
  }
148

NEW
149
  Transparency GetTransparency() const override {
×
NEW
150
    return interface.Transparency();
×
151
  }
152

NEW
153
  std::span<const hkxMaterialProperty> GetProperties() const override {
×
NEW
154
    return {interface.Properties(), interface.NumProperties()};
×
155
  }
156
};
157

158
hkxMaterialInternalInterface *
NEW
159
hkxMaterialInternalInterface::Create(void *interface) {
×
160
  return new hkxMaterialMidInterface(
NEW
161
      *static_cast<clgen::hkxMaterial::Interface *>(interface));
×
162
}
163

164
CREATE_HK_CLASS(hkxMaterial);
4✔
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