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

Razakhel / RaZ / 18064138724

27 Sep 2025 04:20PM UTC coverage: 74.093% (+0.04%) from 74.05%
18064138724

push

github

Razakhel
[Utils/Logger] Added formatted logging overloads

- Formatted calls to logging functions and made use of std::format() in several other places

100 of 170 new or added lines in 36 files covered. (58.82%)

4 existing lines in 2 files now uncovered.

8334 of 11248 relevant lines covered (74.09%)

1757.71 hits per line

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

82.8
/src/RaZ/Data/BvhFormat.cpp
1
#include "RaZ/Animation/Skeleton.hpp"
2
#include "RaZ/Data/BvhFormat.hpp"
3
#include "RaZ/Utils/FilePath.hpp"
4
#include "RaZ/Utils/StrUtils.hpp"
5

6
#include "tracy/Tracy.hpp"
7

8
#include <fstream>
9
#include <unordered_map>
10

11
namespace Raz::BvhFormat {
12

13
namespace {
14

15
void loadJoint(std::ifstream& file, std::unordered_map<std::string, SkeletonJoint&>& joints, Skeleton& skeleton, SkeletonJoint& parentJoint) {
14✔
16
  ZoneScopedN("[BvhFormat]::loadJoint");
17

18
  std::string token;
14✔
19
  file >> token;
14✔
20

21
  if (token.front() == 'E') { // "End Site" declaration, stopping recursion
14✔
22
    std::getline(file, token); // "Site"
6✔
23
    std::getline(file, token); // Opening scope '{'
6✔
24

25
    file >> token;
6✔
26
    if (token.front() != 'O') // "OFFSET"
6✔
27
      throw std::invalid_argument("Error: Invalid BVH joint offset");
×
28

29
    Vec3f offset;
6✔
30
    file >> offset.x() >> offset.y() >> offset.z();
6✔
31
    std::getline(file, token);
6✔
32

33
    // TODO: use the last offset?
34

35
    file >> token;
6✔
36
    if (token.front() != '}')
6✔
37
      throw std::invalid_argument("Error: Invalid BVH joint closing scope");
×
38
    std::getline(file, token);
6✔
39

40
    return;
6✔
41
  }
42

43
  if (token.front() != 'J') // "JOINT"
8✔
44
    throw std::invalid_argument("Error: Invalid BVH joint declaration");
×
45

46
  file >> token;
8✔
47
  SkeletonJoint& currentJoint = joints.emplace(token, skeleton.addNode()).first->second;
8✔
48
  currentJoint.addParents(parentJoint);
8✔
49

50
  std::getline(file, token);
8✔
51

52
  file >> token;
8✔
53
  if (token.front() != '{')
8✔
54
    throw std::invalid_argument("Error: Invalid BVH joint opening scope");
×
55
  std::getline(file, token);
8✔
56

57
  file >> token;
8✔
58
  if (token.front() != 'O') // "OFFSET"
8✔
59
    throw std::invalid_argument("Error: Invalid BVH joint offset");
×
60

61
  Vec3f jointOffset;
8✔
62
  file >> jointOffset.x() >> jointOffset.y() >> jointOffset.z();
8✔
63
  currentJoint.setTranslation(jointOffset);
8✔
64
  std::getline(file, token);
8✔
65

66
  file >> token;
8✔
67
  if (token.front() != 'C') // "CHANNELS"
8✔
68
    throw std::invalid_argument("Error: Invalid BVH joint channels");
×
69

70
  file >> token;
8✔
71
  if (token.front() != '3')
8✔
72
    throw std::invalid_argument("Error: Invalid BVH joint channel count");
×
73
  std::getline(file, token);
8✔
74

75
  loadJoint(file, joints, skeleton, currentJoint);
8✔
76

77
  file >> token;
8✔
78
  if (token.front() != '}')
8✔
79
    throw std::invalid_argument("Error: Invalid BVH joint closing scope");
×
80
  std::getline(file, token);
8✔
81

82
  while (!file.eof()) {
12✔
83
    file >> std::ws; // Discarding all leading white spaces
12✔
84

85
    if (file.peek() == '}') // Reaching the end of scope, no other joint is declared on this level
12✔
86
      break;
8✔
87

88
    loadJoint(file, joints, skeleton, parentJoint);
4✔
89
  }
90
}
14✔
91

92
} // namespace
93

94
Skeleton load(const FilePath& filePath) {
2✔
95
  ZoneScopedN("BvhFormat::load");
96
  ZoneTextF("Path: %s", filePath.toUtf8().c_str());
97

98
  std::ifstream file(filePath, std::ios_base::in | std::ios_base::binary);
2✔
99

100
  if (!file)
2✔
NEW
101
    throw std::invalid_argument(std::format("Error: Could not open the BVH file '{}'", filePath));
×
102

103
  const std::string format = StrUtils::toLowercaseCopy(filePath.recoverExtension().toUtf8());
2✔
104

105
  if (format != "bvh")
2✔
NEW
106
    throw std::invalid_argument(std::format("Error: '{}' doesn't have a .bvh extension", filePath));
×
107

108
  std::string token;
2✔
109

110
  file >> token;
2✔
111
  if (token != "HIERARCHY")
2✔
112
    throw std::invalid_argument("Error: Invalid BVH header");
×
113

114
  file >> token;
2✔
115
  if (token != "ROOT")
2✔
116
    throw std::invalid_argument("Error: Invalid BVH root joint");
×
117

118
  Skeleton skeleton;
2✔
119
  std::unordered_map<std::string, SkeletonJoint&> joints;
2✔
120

121
  file >> token;
2✔
122
  SkeletonJoint& rootJoint = joints.emplace(token, skeleton.addNode()).first->second;
2✔
123

124
  std::getline(file, token); // Skipping the rest of the line
2✔
125

126
  file >> token;
2✔
127
  if (token.front() != '{')
2✔
128
    throw std::invalid_argument("Error: Invalid BVH root joint opening scope");
×
129
  std::getline(file, token);
2✔
130

131
  file >> token;
2✔
132
  if (token.front() != 'O') // "OFFSET"
2✔
133
    throw std::invalid_argument("Error: Invalid BVH root joint offset");
×
134

135
  Vec3f rootPos;
2✔
136
  file >> rootPos.x() >> rootPos.y() >> rootPos.z();
2✔
137
  rootJoint.setTranslation(rootPos);
2✔
138
  std::getline(file, token);
2✔
139

140
  file >> token;
2✔
141
  if (token.front() != 'C') // "CHANNELS"
2✔
142
    throw std::invalid_argument("Error: Invalid BVH root joint channels");
×
143

144
  file >> token;
2✔
145
  if (token.front() != '6')
2✔
146
    throw std::invalid_argument("Error: Invalid BVH root joint channel count");
×
147
  std::getline(file, token);
2✔
148

149
  loadJoint(file, joints, skeleton, rootJoint);
2✔
150
  std::getline(file, token); // Root joint's closing scope
2✔
151

152
  // TODO: import animation
153

154
  return skeleton;
4✔
155
}
2✔
156

157
} // namespace Raz::BvhFormat
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

© 2025 Coveralls, Inc