Skip to content

Commit 5730d1c

Browse files
authored
Apply clang-format to all our source. (facebookincubator#149)
Apply clang-format to all our source.
1 parent be1b754 commit 5730d1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+5453
-5276
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ BreakBeforeTernaryOperators: true
3535
BreakConstructorInitializersBeforeComma: false
3636
BreakAfterJavaFieldAnnotations: false
3737
BreakStringLiterals: false
38-
ColumnLimit: 80
38+
ColumnLimit: 100
3939
CommentPragmas: '^ IWYU pragma:'
4040
ConstructorInitializerAllOnOneLineOrOnePerLine: true
4141
ConstructorInitializerIndentWidth: 4

src/FBX2glTF.cpp

+22-53
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ int main(int argc, char* argv[]) {
3535

3636
CLI::App app{
3737
fmt::sprintf(
38-
"FBX2glTF %s: Generate a glTF 2.0 representation of an FBX model.",
39-
FBX2GLTF_VERSION),
38+
"FBX2glTF %s: Generate a glTF 2.0 representation of an FBX model.", FBX2GLTF_VERSION),
4039
"FBX2glTF"};
4140

4241
app.add_flag(
@@ -45,32 +44,22 @@ int main(int argc, char* argv[]) {
4544
"Include blend shape tangents, if reported present by the FBX SDK.");
4645

4746
app.add_flag_function("-V,--version", [&](size_t count) {
48-
fmt::printf(
49-
"FBX2glTF version %s\nCopyright (c) 2016-2018 Oculus VR, LLC.\n",
50-
FBX2GLTF_VERSION);
47+
fmt::printf("FBX2glTF version %s\nCopyright (c) 2016-2018 Oculus VR, LLC.\n", FBX2GLTF_VERSION);
5148
exit(0);
5249
});
5350

5451
std::string inputPath;
55-
app.add_option("FBX Model", inputPath, "The FBX model to convert.")
56-
->check(CLI::ExistingFile);
57-
app.add_option("-i,--input", inputPath, "The FBX model to convert.")
58-
->check(CLI::ExistingFile);
52+
app.add_option("FBX Model", inputPath, "The FBX model to convert.")->check(CLI::ExistingFile);
53+
app.add_option("-i,--input", inputPath, "The FBX model to convert.")->check(CLI::ExistingFile);
5954

6055
std::string outputPath;
61-
app.add_option(
62-
"-o,--output",
63-
outputPath,
64-
"Where to generate the output, without suffix.");
56+
app.add_option("-o,--output", outputPath, "Where to generate the output, without suffix.");
6557

6658
app.add_flag(
6759
"-e,--embed",
6860
gltfOptions.embedResources,
6961
"Inline buffers as data:// URIs within generated non-binary glTF.");
70-
app.add_flag(
71-
"-b,--binary",
72-
gltfOptions.outputBinary,
73-
"Output a single binary format .glb file.");
62+
app.add_flag("-b,--binary", gltfOptions.outputBinary, "Output a single binary format .glb file.");
7463

7564
app.add_option(
7665
"--long-indices",
@@ -119,32 +108,28 @@ int main(int argc, char* argv[]) {
119108
"--flip-u",
120109
[&](size_t count) {
121110
if (count > 0) {
122-
texturesTransforms.emplace_back(
123-
[](Vec2f uv) { return Vec2f(1.0f - uv[0], uv[1]); });
111+
texturesTransforms.emplace_back([](Vec2f uv) { return Vec2f(1.0f - uv[0], uv[1]); });
124112
if (verboseOutput) {
125113
fmt::printf("Flipping texture coordinates in the 'U' dimension.\n");
126114
}
127115
}
128116
},
129117
"Flip all U texture coordinates.");
130118

131-
app.add_flag("--no-flip-u", "Don't flip U texture coordinates.")
132-
->excludes("--flip-u");
119+
app.add_flag("--no-flip-u", "Don't flip U texture coordinates.")->excludes("--flip-u");
133120

134121
app.add_flag_function(
135122
"--no-flip-v",
136123
[&](size_t count) {
137124
if (count > 0) {
138-
texturesTransforms.emplace_back(
139-
[](Vec2f uv) { return Vec2f(uv[0], 1.0f - uv[1]); });
125+
texturesTransforms.emplace_back([](Vec2f uv) { return Vec2f(uv[0], 1.0f - uv[1]); });
140126
if (verboseOutput) {
141127
fmt::printf("NOT flipping texture coordinates in the 'V' dimension.\n");
142128
}
143129
}
144130
},
145131
"Flip all V texture coordinates.");
146-
app.add_flag("--flip-v", "Don't flip U texture coordinates.")
147-
->excludes("--no-flip-v");
132+
app.add_flag("--flip-v", "Don't flip U texture coordinates.")->excludes("--no-flip-v");
148133

149134
app.add_flag(
150135
"--pbr-metallic-rougnness",
@@ -181,8 +166,8 @@ int main(int argc, char* argv[]) {
181166
app.add_option(
182167
"-k,--keep-attribute",
183168
[&](std::vector<std::string> attributes) -> bool {
184-
gltfOptions.keepAttribs = RAW_VERTEX_ATTRIBUTE_JOINT_INDICES |
185-
RAW_VERTEX_ATTRIBUTE_JOINT_WEIGHTS;
169+
gltfOptions.keepAttribs =
170+
RAW_VERTEX_ATTRIBUTE_JOINT_INDICES | RAW_VERTEX_ATTRIBUTE_JOINT_WEIGHTS;
186171
for (std::string attribute : attributes) {
187172
if (attribute == "position") {
188173
gltfOptions.keepAttribs |= RAW_VERTEX_ATTRIBUTE_POSITION;
@@ -212,9 +197,7 @@ int main(int argc, char* argv[]) {
212197
->type_name("(position|normal|tangent|binormial|color|uv0|uv1|auto)");
213198

214199
app.add_flag(
215-
"-d,--draco",
216-
gltfOptions.draco.enabled,
217-
"Apply Draco mesh compression to geometries.")
200+
"-d,--draco", gltfOptions.draco.enabled, "Apply Draco mesh compression to geometries.")
218201
->group("Draco");
219202

220203
app.add_option(
@@ -301,16 +284,12 @@ int main(int argc, char* argv[]) {
301284

302285
} else {
303286
// in gltf mode, we create a folder and write into that
304-
outputFolder = fmt::format(
305-
"{}_out{}",
306-
outputPath.c_str(),
307-
(const char)StringUtils::GetPathSeparator());
308-
modelPath =
309-
outputFolder + StringUtils::GetFileNameString(outputPath) + ".gltf";
287+
outputFolder =
288+
fmt::format("{}_out{}", outputPath.c_str(), (const char)StringUtils::GetPathSeparator());
289+
modelPath = outputFolder + StringUtils::GetFileNameString(outputPath) + ".gltf";
310290
}
311291
if (!FileUtils::CreatePath(modelPath.c_str())) {
312-
fmt::fprintf(
313-
stderr, "ERROR: Failed to create folder: %s'\n", outputFolder.c_str());
292+
fmt::fprintf(stderr, "ERROR: Failed to create folder: %s'\n", outputFolder.c_str());
314293
return 1;
315294
}
316295

@@ -334,14 +313,9 @@ int main(int argc, char* argv[]) {
334313
std::ofstream outStream; // note: auto-flushes in destructor
335314
const auto streamStart = outStream.tellp();
336315

337-
outStream.open(
338-
modelPath,
339-
std::ios::trunc | std::ios::ate | std::ios::out | std::ios::binary);
316+
outStream.open(modelPath, std::ios::trunc | std::ios::ate | std::ios::out | std::ios::binary);
340317
if (outStream.fail()) {
341-
fmt::fprintf(
342-
stderr,
343-
"ERROR:: Couldn't open file for writing: %s\n",
344-
modelPath.c_str());
318+
fmt::fprintf(stderr, "ERROR:: Couldn't open file for writing: %s\n", modelPath.c_str());
345319
return 1;
346320
}
347321
data_render_model = Raw2Gltf(outStream, outputFolder, raw, gltfOptions);
@@ -371,8 +345,7 @@ int main(int argc, char* argv[]) {
371345
const std::string binaryPath = outputFolder + extBufferFilename;
372346
FILE* fp = fopen(binaryPath.c_str(), "wb");
373347
if (fp == nullptr) {
374-
fmt::fprintf(
375-
stderr, "ERROR:: Couldn't open file '%s' for writing.\n", binaryPath);
348+
fmt::fprintf(stderr, "ERROR:: Couldn't open file '%s' for writing.\n", binaryPath);
376349
return 1;
377350
}
378351

@@ -381,16 +354,12 @@ int main(int argc, char* argv[]) {
381354
unsigned long binarySize = data_render_model->binary->size();
382355
if (fwrite(binaryData, binarySize, 1, fp) != 1) {
383356
fmt::fprintf(
384-
stderr,
385-
"ERROR: Failed to write %lu bytes to file '%s'.\n",
386-
binarySize,
387-
binaryPath);
357+
stderr, "ERROR: Failed to write %lu bytes to file '%s'.\n", binarySize, binaryPath);
388358
fclose(fp);
389359
return 1;
390360
}
391361
fclose(fp);
392-
fmt::printf(
393-
"Wrote %lu bytes of binary data to %s.\n", binarySize, binaryPath);
362+
fmt::printf("Wrote %lu bytes of binary data to %s.\n", binarySize, binaryPath);
394363
}
395364

396365
delete data_render_model;

0 commit comments

Comments
 (0)