-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathacclint.cpp
More file actions
1227 lines (1146 loc) · 49.6 KB
/
acclint.cpp
File metadata and controls
1227 lines (1146 loc) · 49.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* acclint - A tool that detects errors in AC3D files.
* Copyright (C) 2020-2026 Robert Reif
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
#ifdef _WIN32
#pragma warning( disable : 4996)
#endif
#include "ac3d.h"
#include "config.h"
namespace {
void usage()
{
std::cerr << "Usage: acclint [options] [-j <#>] [-T texturepath] <inputfile> [--merge <inputfile>] [-o <outputfile>] [-v <11|12>]" << std::endl;
std::cerr << "Options:" << std::endl;
// warnings
std::cerr << " -Wno-warnings Don't show any warnings." << std::endl;
// warnings with tests
std::cerr << " -Wno-ambiguous-texture Don't show ambiguous texture warnings." << std::endl;
std::cerr << " -Wno-blank-line Don't show blank line warnings." << std::endl;
std::cerr << " -Wno-collinear-surface-vertices Don't show collinear surface vertices warnings." << std::endl;
std::cerr << " -Wno-different-mat Don't show different mat warnings." << std::endl;
std::cerr << " -Wno-different-surf Don't show different surf warnings." << std::endl;
std::cerr << " -Wno-different-uv Don't show different uv warnings." << std::endl;
std::cerr << " -Wno-duplicate-materials Don't show duplicate materials warnings." << std::endl;
std::cerr << " -Wno-duplicate-surfaces Don't show duplicate surfaces warnings." << std::endl;
std::cerr << " -Wno-duplicate-surfaces-order Don't show duplicate surfaces with different vertex order warnings." << std::endl;
std::cerr << " -Wno-duplicate-surfaces-winding Don't show duplicate surfaces with different winding warnings." << std::endl;
std::cerr << " -Wno-duplicate-surface-vertices Don't show duplicate surface vertices warnings." << std::endl;
std::cerr << " -Wno-duplicate-texture Don't show duplicate texture warnings." << std::endl;
std::cerr << " -Wno-duplicate-triangles Don't show surface duplicate triangle warnings." << std::endl;
std::cerr << " -Wno-duplicate-vertices Don't show duplicate vertices warnings." << std::endl;
std::cerr << " -Wno-empty-object Don't show empty object warnings." << std::endl;
std::cerr << " -Wno-extra-object Don't show extra object warnings." << std::endl;
std::cerr << " -Wno-extra-uv-coordinates Don't show extra uv coordinates warnings." << std::endl;
std::cerr << " -Wno-group-with-geometry Don't show group with geometry warnings." << std::endl;
std::cerr << " -Wno-invalid-material Don't show invalid material warnings." << std::endl;
std::cerr << " -Wno-invalid-normal-length Don't show invalid normal length warnings." << std::endl;
std::cerr << " -Wno-invalid-object-type Don't show invalid object type warnings." << std::endl;
std::cerr << " -Wno-invalid-ref-count Don't show invalid ref count warnings." << std::endl;
std::cerr << " -Wno-material-after-object Don't show material after object warnings." << std::endl;
std::cerr << " -Wno-missing-kids Don't show missing kids warnings." << std::endl;
std::cerr << " -Wno-missing-normal Don't show missing normal warnings." << std::endl;
std::cerr << " -Wno-missing-surfaces Don't show missing surfaces warnings." << std::endl;
std::cerr << " -Wno-missing-texture Don't show missing texture warnings." << std::endl;
std::cerr << " -Wno-missing-uv-coordinates Don't show missing uv coordinates warnings." << std::endl;
std::cerr << " -Wno-multiple-crease Don't show multiple crease warnings." << std::endl;
std::cerr << " -Wno-multiple-data Don't show multiple data warnings." << std::endl;
std::cerr << " -Wno-multiple-folded Don't show multiple folded warnings." << std::endl;
std::cerr << " -Wno-multiple-hidden Don't show multiple hidden warnings." << std::endl;
std::cerr << " -Wno-multiple-loc Don't show multiple loc warnings." << std::endl;
std::cerr << " -Wno-multiple-locked Don't show multiple locked warnings." << std::endl;
std::cerr << " -Wno-multiple-name Don't show multiple name warnings." << std::endl;
std::cerr << " -Wno-multiple-rot Don't show multiple rot warnings." << std::endl;
std::cerr << " -Wno-multiple-shader Don't show multiple shader warnings." << std::endl;
std::cerr << " -Wno-multiple-subdiv Don't show multiple subdiv warnings." << std::endl;
std::cerr << " -Wno-multiple-texoff Don't show multiple texoff warnings." << std::endl;
std::cerr << " -Wno-multiple-texrep Don't show multiple texrep warnings." << std::endl;
std::cerr << " -Wno-multiple-texture Don't show multiple texture warnings." << std::endl;
std::cerr << " -Wno-multiple-url Don't show multiple url warnings." << std::endl;
std::cerr << " -Wno-multiple-world Don't show multiple world warnings." << std::endl;
std::cerr << " -Wno-overlapping-2-sided-surface Don't show overlapping 2 sided surface warnings." << std::endl;
std::cerr << " -Wno-surface-2-sided-opaque Don't show surface 2 sided opaque warnings." << std::endl;
std::cerr << " -Wno-surface-not-convex Don't show surface not convex warnings." << std::endl;
std::cerr << " -Wno-surface-not-coplanar Don't show surface not coplanar warnings." << std::endl;
std::cerr << " -Wno-surface-no-texture Don't show surface no texture warnings." << std::endl;
std::cerr << " -Wno-surface-self-intersecting Don't show surface self intersecting warnings." << std::endl;
std::cerr << " -Wno-surface-strip-degenerate Don't show surface triangle strip degenerate warnings." << std::endl;
std::cerr << " -Wno-surface-strip-size Don't show surface triangle strip with only 1 triangle warnings." << std::endl;
std::cerr << " -Wno-trailing-text Don't show trailing text warnings." << std::endl;
std::cerr << " -Wno-unsupported-version Don't show unsupported version warnings." << std::endl;
std::cerr << " -Wno-unused-material Don't show unused material warnings." << std::endl;
std::cerr << " -Wno-unused-vertex Don't show unused vertex warnings." << std::endl;
std::cerr << " -Wno-utf8-bom Don't show utf8 bom warnings." << std::endl;
// warnings without tests
std::cerr << " -Wno-floating-point Don't show floating point warnings." << std::endl;
std::cerr << " -Wno-multiple-polygon-surface Don't show multiple polygon surface warnings." << std::endl;
std::cerr << " -Wno-surface-strip-duplicate-triangles Don't show surface triangle strip with duplicate triangle warnings." << std::endl;
std::cerr << " -Wno-surface-strip-hole Don't show surface triangle strip with hole warnings." << std::endl;
// errors
std::cerr << " -Wno-errors Don't show any errors." << std::endl;
// errors with tests
std::cerr << " -Wno-invalid-kids-count Don't show invalid kids count errors." << std::endl;
std::cerr << " -Wno-invalid-material-index Don't show invalid material index errors." << std::endl;
std::cerr << " -Wno-invalid-normal Don't show invalid normal errors." << std::endl;
std::cerr << " -Wno-invalid-numsurf Don't show invalid numsurf errors." << std::endl;
std::cerr << " -Wno-invalid-numvert Don't show invalid numvert errors." << std::endl;
std::cerr << " -Wno-invalid-refs-count Don't show invalid refs count errors." << std::endl;
std::cerr << " -Wno-invalid-ref-vertex-index Don't show invalid ref vertex index errors." << std::endl;
std::cerr << " -Wno-invalid-surface-type Don't show invalid surface type errors." << std::endl;
std::cerr << " -Wno-invalid-token Don't show invalid token errors." << std::endl;
std::cerr << " -Wno-invalid-texture-coordinate Don't show invalid texture coordinate errors." << std::endl;
std::cerr << " -Wno-invalid-vertex Don't show invalid vertex errors." << std::endl;
std::cerr << " -Wno-missing-vertex Don't show missing vertex errors." << std::endl;
std::cerr << " -Wno-more-surf-than-specified Don't show more surf than specified errors." << std::endl;
// errors without tests
std::cerr << " -Wno-not-ac3d-file Don't show not AC3D file errors." << std::endl;
// options
std::cerr << " --dump group|poly|surf Dumps the hierarchy of OBJECT and SURF." << std::endl;
std::cerr << " -v 11|12 Output version 11 or 12." << std::endl;
std::cerr << " --splitPolygon Split polygon surface into separate triangle surfaces." << std::endl;
std::cerr << " --splitSURF Split objects with multiple surface types into separate objects." << std::endl;
std::cerr << " --splitMat Split objects with multiple materials into separate objects." << std::endl;
std::cerr << " --flatten Flatten objects." << std::endl;
std::cerr << " --merge filename Merge filename with inputfile." << std::endl;
std::cerr << " --removeObjects group|poly|light regex Remove objects that match type and regex." << std::endl;
std::cerr << " --combineTexture Combine objects by texture." << std::endl;
std::cerr << " --fixOverlapping2SidedSurface Fix overlapping 2 sided surfaces." << std::endl;
std::cerr << " --fixSurface2SidedOpaque Convert opaque 2 sided surfaces to single sided." << std::endl;
std::cerr << " --showTimes Show execution times of some operations." << std::endl;
std::cerr << " --quiet Don't show warning messages." << std::endl;
std::cerr << " --summary Show summary of warnings." << std::endl;
std::cerr << " -j # Set number of threads to use." << std::endl;
std::cerr << " -l Print the name of the input file." << std::endl;
std::cerr << std::endl;
std::cerr << "By default all warnings (except blank-line, duplicate-triangles, surface-2-sided-opaque and surface-strip-*) " << std::endl;
std::cerr << "and errors are enabled." << std::endl;
std::cerr << "You can enable all warnings using -Wwarnings" << std::endl;
std::cerr << "You can disable specific warnings or errors using the options above." << std::endl;
std::cerr << "You can also disable all warnings or errors and then reenable specific ones" << std::endl;
std::cerr << "using the options above but without \"no-\"." << std::endl;
std::cerr << std::endl;
std::cerr << "Examples:" << std::endl;
std::cerr << " acclint -Wno-trailing-text file.acc Don't show trailing text warnings." << std::endl;
std::cerr << " acclint -Wno-warnings -Wunused-vertex file.acc Only show unused vertex warnings." << std::endl;
std::cerr << " acclint -Wno-warnings -j 8 -T ../../../data/textures original.ac --combineTexture -o new.ac" << std::endl;
}
void showCount(size_t count, const char *text)
{
if (count > 0)
std::cout << text << count << std::endl;
}
} // namespace
int main(int argc, char *argv[])
{
if (argc < 2)
{
usage();
return EXIT_FAILURE;
}
std::string in_file;
std::string out_file;
// warnings with tests
bool ambiguous_texture = true;
bool blank_line = false;
bool collinear_surface_vertices = true;
bool different_mat = true;
bool different_surf = true;
bool different_uv = true;
bool duplicate_materials = true;
bool duplicate_surfaces = true;
bool duplicate_surfaces_order = true;
bool duplicate_surfaces_winding = true;
bool duplicate_surface_vertices = true;
bool duplicate_texture = true;
bool duplicate_triangles = false;
bool duplicate_vertices = true;
bool empty_object = true;
bool extra_object = true;
bool extra_uv_coordinates = true;
bool group_with_geometry = true;
bool invalid_material = true;
bool invalid_normal_length = true;
bool invalid_object_type = true;
bool invalid_ref_count = true;
bool material_after_object = true;
bool missing_kids = true;
bool missing_normal = true;
bool missing_surfaces = true;
bool missing_texture = true;
bool missing_uv_coordinates = true;
bool multiple_crease = true;
bool multiple_data = true;
bool multiple_folded = true;
bool multiple_hidden = true;
bool multiple_loc = true;
bool multiple_locked = true;
bool multiple_name = true;
bool multiple_rot = true;
bool multiple_shader = true;
bool multiple_subdiv = true;
bool multiple_texoff = true;
bool multiple_texrep = true;
bool multiple_texture = true;
bool multiple_url = true;
bool multiple_world = true;
bool overlapping_2_sided_surface = true;
bool surface_2_sided_opaque = false;
bool surface_not_convex = true;
bool surface_not_coplanar = true;
bool surface_no_texture = true;
bool surface_self_intersecting = true;
bool surface_strip_degenerate = false;
bool surface_strip_size = false;
bool trailing_text = true;
bool unsupported_version = true;
bool unused_material = true;
bool unused_vertex = true;
bool utf8_bom = true;
// warnings without tests
bool floating_point = true;
bool multiple_polygon_surface = true;
bool surface_strip_duplicate_triangles = false;
bool surface_strip_hole = false;
// errors with tests
bool invalid_kids_count = true;
bool invalid_material_index = true;
bool invalid_normal = true;
bool invalid_numsurf = true;
bool invalid_numvert = true;
bool invalid_refs_count = true;
bool invalid_ref_vertex_index = true;
bool invalid_surface_type = true;
bool invalid_token = true;
bool invalid_texture_coordinate = true;
bool invalid_vertex = true;
bool missing_vertex = true;
bool more_surf_than_specified = true;
// errors without tests
bool not_ac3d_file = true;
std::vector<std::string> texture_paths;
bool fix_surface_2_sided_opaque = false;
bool dump = false;
bool splitSURF = false;
bool splitMat = false;
bool flatten = false;
bool splitPolygon = false;
bool combineTexture = false;
bool fix_overlapping_2_sided_surface = false;
AC3D::DumpType dump_type = AC3D::DumpType::group;
int version = 0;
std::vector<std::string> merge_files;
std::vector<AC3D::RemoveInfo> removes;
bool show_times = false;
bool quiet = false;
bool summary = false;
unsigned int threads = 1;
bool listInput = false;
auto isEnabled = [](const std::string& a) { return !a.starts_with("-Wno-"); };
for (int i = 1; i < argc; ++i)
{
std::string arg(argv[i]);
if (arg == "-o")
{
if (i < (argc - 1))
{
out_file = argv[i + 1];
i++;
}
else
{
usage();
return EXIT_FAILURE;
}
}
else if (arg == "-T")
{
if (i < argc - 1)
{
texture_paths.emplace_back(argv[i + 1]);
i++;
}
else
{
std::cerr << "Missing texture path" << std::endl;
usage();
return EXIT_FAILURE;
}
}
else if (arg == "-j")
{
i++;
if (i == argc)
{
std::cerr << "Missing number of threads" << std::endl;
usage();
return EXIT_FAILURE;
}
arg = argv[i];
std::istringstream iss(arg);
iss >> threads;
if (!iss || threads < 1 || threads > 256)
{
std::cerr << "Invalid number of threads: " << arg << std::endl;
usage();
return EXIT_FAILURE;
}
}
else if (arg == "--version")
{
std::cout << "acclint " << acclint_VERSION_MAJOR << "." << acclint_VERSION_MINOR << std::endl;
return EXIT_SUCCESS;
}
else if (arg == "--help")
{
usage();
return EXIT_SUCCESS;
}
// warnings
else if (arg == "-Wno-warnings" || arg == "-Wwarnings")
{
const bool value = arg.starts_with("-Wno-") ? false : true;
// warnings with tests
ambiguous_texture = value;
blank_line = value;
collinear_surface_vertices = value;
different_mat = value;
different_surf = value;
different_uv = value;
duplicate_materials = value;
duplicate_surfaces = value;
duplicate_surfaces_order = value;
duplicate_surfaces_winding = value;
duplicate_surface_vertices = value;
duplicate_texture = value;
duplicate_triangles = value;
duplicate_vertices = value;
empty_object = value;
extra_object = value;
extra_uv_coordinates = value;
group_with_geometry = value;
invalid_material = value;
invalid_normal_length = value;
invalid_object_type = value;
invalid_ref_count = value;
material_after_object = value;
missing_kids = value;
missing_normal = value;
missing_surfaces = value;
missing_texture = value;
missing_uv_coordinates = value;
multiple_crease = value;
multiple_data = value;
multiple_folded = value;
multiple_hidden = value;
multiple_loc = value;
multiple_locked = value;
multiple_name = value;
multiple_rot = value;
multiple_shader = value;
multiple_subdiv = value;
multiple_texoff = value;
multiple_texrep = value;
multiple_texture = value;
multiple_url = value;
multiple_world = value;
overlapping_2_sided_surface = value;
surface_2_sided_opaque = value;
surface_not_convex = value;
surface_not_coplanar = value;
surface_no_texture = value;
surface_self_intersecting = value;
surface_strip_degenerate = value;
surface_strip_size = value;
trailing_text = value;
unsupported_version = value;
unused_material = value;
unused_vertex = value;
utf8_bom = value;
// warnings with no tests
floating_point = value;
multiple_polygon_surface = value;
surface_strip_duplicate_triangles = value;
surface_strip_hole = value;
}
// warnings with tests
else if (arg == "-Wno-ambiguous-texture" || arg == "-Wambiguous-texture")
{
ambiguous_texture = isEnabled(arg);
}
else if (arg == "-Wno-blank-line" || arg == "-Wblank-line")
{
blank_line = isEnabled(arg);
}
else if (arg == "-Wno-collinear-surface-vertices" || arg == "-Wcollinear-surface-vertices")
{
collinear_surface_vertices = isEnabled(arg);
}
else if (arg == "-Wno-different-mat" || arg == "-Wdifferent-mat")
{
different_mat = isEnabled(arg);
}
else if (arg == "-Wno-different-surf" || arg == "-Wdifferent-surf")
{
different_surf = isEnabled(arg);
}
else if (arg == "-Wno-different-uv" || arg == "-Wdifferent-uv")
{
different_uv = isEnabled(arg);
}
else if (arg == "-Wno-duplicate-materials" || arg == "-Wduplicate-materials")
{
duplicate_materials = isEnabled(arg);
}
else if (arg == "-Wno-duplicate-surfaces" || arg == "-Wduplicate-surfaces")
{
duplicate_surfaces = isEnabled(arg);
}
else if (arg == "-Wno-duplicate-surfaces-order" || arg == "-Wduplicate-surfaces-order")
{
duplicate_surfaces_order = isEnabled(arg);
}
else if (arg == "-Wno-duplicate-surfaces-winding" || arg == "-Wduplicate-surfaces-winding")
{
duplicate_surfaces_winding = isEnabled(arg);
}
else if (arg == "-Wno-duplicate-texture" || arg == "-Wduplicate-texture")
{
duplicate_texture = isEnabled(arg);
}
else if (arg == "-Wno-duplicate-surface-vertices" || arg == "-Wduplicate-surface-vertices")
{
duplicate_surface_vertices = isEnabled(arg);
}
else if (arg == "-Wno-duplicate-triangles" || arg == "-Wduplicate-triangles")
{
duplicate_triangles = isEnabled(arg);
}
else if (arg == "-Wno-duplicate-vertices" || arg == "-Wduplicate-vertices")
{
duplicate_vertices = isEnabled(arg);
}
else if (arg == "-Wno-empty-object" || arg == "-Wempty-object")
{
empty_object = isEnabled(arg);
}
else if (arg == "-Wno-extra-object" || arg == "-Wextra-object")
{
extra_object = isEnabled(arg);
}
else if (arg == "-Wno-extra-uv-coordinates" || arg == "-Wextra-uv-coordinates")
{
extra_uv_coordinates = isEnabled(arg);
}
else if (arg == "-Wno-group-with-geometry" || arg == "-Wgroup-with-geometry")
{
group_with_geometry = isEnabled(arg);
}
else if (arg == "-Wno-invalid-material" || arg == "-Winvalid-material")
{
invalid_material = isEnabled(arg);
}
else if (arg == "-Wno-invalid-normal-length" || arg == "-Winvalid-normal-length")
{
invalid_normal_length = isEnabled(arg);
}
else if (arg == "-Wno-invalid-object-type" || arg == "-Winvalid-object-type")
{
invalid_object_type = isEnabled(arg);
}
else if (arg == "-Wno-invalid-ref-count" || arg == "-Winvalid-ref-count")
{
invalid_ref_count = isEnabled(arg);
}
else if (arg == "-Wno-material-after-object" || arg == "-Wmaterial-after-object")
{
material_after_object = isEnabled(arg);
}
else if (arg == "-Wno-missing-kids" || arg == "-Wmissing-kids")
{
missing_kids = isEnabled(arg);
}
else if (arg == "-Wno-missing-normal" || arg == "-Wmissing-normal")
{
missing_normal = isEnabled(arg);
}
else if (arg == "-Wno-missing-surfaces" || arg == "-Wmissing-surfaces")
{
missing_surfaces = isEnabled(arg);
}
else if (arg == "-Wno-missing-texture" || arg == "-Wmissing-texture")
{
missing_texture = isEnabled(arg);
}
else if (arg == "-Wno-missing-uv-coordinates" || arg == "-Wmissing-uv-coordinates")
{
missing_uv_coordinates = isEnabled(arg);
}
else if (arg == "-Wno-multiple-crease" || arg == "-Wmultiple-crease")
{
multiple_crease = isEnabled(arg);
}
else if (arg == "-Wno-multiple-data" || arg == "-Wmultiple-data")
{
multiple_data = isEnabled(arg);
}
else if (arg == "-Wno-multiple-folded" || arg == "-Wmultiple-folded")
{
multiple_folded = isEnabled(arg);
}
else if (arg == "-Wno-multiple-hidden" || arg == "-Wmultiple-hidden")
{
multiple_hidden = isEnabled(arg);
}
else if (arg == "-Wno-multiple-loc" || arg == "-Wmultiple-loc")
{
multiple_loc = isEnabled(arg);
}
else if (arg == "-Wno-multiple-locked" || arg == "-Wmultiple-locked")
{
multiple_locked = isEnabled(arg);
}
else if (arg == "-Wno-multiple-name" || arg == "-Wmultiple-name")
{
multiple_name = isEnabled(arg);
}
else if (arg == "-Wno-multiple-rot" || arg == "-Wmultiple-rot")
{
multiple_rot = isEnabled(arg);
}
else if (arg == "-Wno-multiple-shader" || arg == "-Wmultiple-shader")
{
multiple_shader = isEnabled(arg);
}
else if (arg == "-Wno-multiple-subdiv" || arg == "-Wmultiple-subdiv")
{
multiple_subdiv = isEnabled(arg);
}
else if (arg == "-Wno-multiple-texoff" || arg == "-Wmultiple-texoff")
{
multiple_texoff = isEnabled(arg);
}
else if (arg == "-Wno-multiple-texrep" || arg == "-Wmultiple-texrep")
{
multiple_texrep = isEnabled(arg);
}
else if (arg == "-Wno-multiple-texture" || arg == "-Wmultiple-texture")
{
multiple_texture = isEnabled(arg);
}
else if (arg == "-Wno-multiple-url" || arg == "-Wmultiple-url")
{
multiple_url = isEnabled(arg);
}
else if (arg == "-Wno-multiple-world" || arg == "-Wmultiple-world")
{
multiple_world = isEnabled(arg);
}
else if (arg == "-Wno-overlapping-2-sided-surface" || arg == "-Woverlapping-2-sided-surface")
{
overlapping_2_sided_surface = isEnabled(arg);
}
else if (arg == "-Wno-surface-2-sided-opaque" || arg == "-Wsurface-2-sided-opaque")
{
surface_2_sided_opaque = isEnabled(arg);
}
else if (arg == "-Wno-surface-not-convex" || arg == "-Wsurface-not-convex")
{
surface_not_convex = isEnabled(arg);
}
else if (arg == "-Wno-surface-not-coplanar" || arg == "-Wsurface-not-coplanar")
{
surface_not_coplanar = isEnabled(arg);
}
else if (arg == "-Wno-surface-no-texture" || arg == "-Wsurface-no-texture")
{
surface_no_texture = isEnabled(arg);
}
else if (arg == "-Wno-surface-self-intersecting" || arg == "-Wsurface-self-intersecting")
{
surface_self_intersecting = isEnabled(arg);
}
else if (arg == "-Wno-surface-strip-degenerate" || arg == "-Wsurface-strip-degenerate")
{
surface_strip_degenerate = isEnabled(arg);
}
else if (arg == "-Wno-surface-strip-size" || arg == "-Wsurface-strip-size")
{
surface_strip_size = isEnabled(arg);
}
else if (arg == "-Wno-trailing-text" || arg == "-Wtrailing-text")
{
trailing_text = isEnabled(arg);
}
else if (arg == "-Wno-unsupported-version" || arg == "-Wunsupported-version")
{
unsupported_version = isEnabled(arg);
}
else if (arg == "-Wno-unused-material" || arg == "-Wunused-material")
{
unused_material = isEnabled(arg);
}
else if (arg == "-Wno-unused-vertex" || arg == "-Wunused-vertex")
{
unused_vertex = isEnabled(arg);
}
else if (arg == "-Wno-utf8-bom" || arg == "-Wutf8-bom")
{
utf8_bom = isEnabled(arg);
}
// warnings without tests
else if (arg == "-Wno-floating-point" || arg == "-Wfloating-point")
{
floating_point = isEnabled(arg);
}
else if (arg == "-Wno-multiple-polygon-surface" || arg == "-Wmultiple-polygon-surface")
{
multiple_polygon_surface = isEnabled(arg);
}
else if (arg == "-Wno-surface-strip-hole" || arg == "-Wsurface-strip-hole")
{
surface_strip_hole = isEnabled(arg);
}
else if (arg == "-Wno-surface-strip-duplicate-triangles" || arg == "-Wsurface-strip-duplicate-triangles")
{
surface_strip_duplicate_triangles = isEnabled(arg);
}
// errors
else if (arg == "-Wno-errors" || arg == "-Werrors")
{
const bool value = arg.starts_with("-Wno-") ? false : true;
// errors with tests
invalid_kids_count = value;
invalid_material_index = value;
invalid_normal = value;
invalid_numsurf = value;
invalid_numvert = value;
invalid_refs_count = value;
invalid_ref_vertex_index = value;
invalid_surface_type = value;
invalid_token = value;
invalid_texture_coordinate = value;
invalid_vertex = value;
missing_vertex = value;
more_surf_than_specified = value;
// errors without tests
not_ac3d_file = value;
}
// errors with tests
else if (arg == "-Wno-invalid-kids-count" || arg == "-Winvalid-kids-count")
{
invalid_kids_count = isEnabled(arg);
}
else if (arg == "-Wno-invalid-material-index" || arg == "-Winvalid-material-index")
{
invalid_material_index = isEnabled(arg);
}
else if (arg == "-Wno-invalid-normal" || arg == "-Winvalid-normal")
{
invalid_normal = isEnabled(arg);
}
else if (arg == "-Wno-invalid-numsurf" || arg == "-Winvalid-numsurf")
{
invalid_numsurf = isEnabled(arg);
}
else if (arg == "-Wno-invalid-numvert" || arg == "-Winvalid-numvert")
{
invalid_numvert = isEnabled(arg);
}
else if (arg == "-Wno-invalid-vertex" || arg == "-Winvalid-vertex")
{
invalid_vertex = isEnabled(arg);
}
else if (arg == "-Wno-invalid-refs-count" || arg == "-Winvalid-refs-count")
{
invalid_refs_count = isEnabled(arg);
}
else if (arg == "-Wno-invalid-ref-vertex-index" || arg == "-Winvalid-ref-vertex-index")
{
invalid_ref_vertex_index = isEnabled(arg);
}
else if (arg == "-Wno-invalid-surface-type" || arg == "-Winvalid-surface-type")
{
invalid_surface_type = isEnabled(arg);
}
else if (arg == "-Wno-invalid-token" || arg == "-Winvalid-token")
{
invalid_token = isEnabled(arg);
}
else if (arg == "-Wno-invalid-texture-coordinate" || arg == "-Winvalid-texture-coordinate")
{
invalid_texture_coordinate = isEnabled(arg);
}
else if (arg == "-Wno-missing-vertex" || arg == "-Wmissing-vertex")
{
missing_vertex = isEnabled(arg);
}
else if (arg == "-Wno-more-surf-than-specified" || arg == "-Wmore-surf-than-specified")
{
more_surf_than_specified = isEnabled(arg);
}
// errors without tests
else if (arg == "-Wno-not-ac3d-file" || arg == "-Wnot-ac3d-file")
{
not_ac3d_file = isEnabled(arg);
}
else if (arg == "--splitSURF")
{
splitSURF = true;
}
else if (arg == "--splitMat")
{
splitMat = true;
}
else if (arg == "--flatten")
{
flatten = true;
}
else if (arg == "--splitPolygon")
{
splitPolygon = true;
}
else if (arg == "--combineTexture")
{
combineTexture = true;
}
else if (arg == "--fixOverlapping2SidedSurface")
{
fix_overlapping_2_sided_surface = true;
}
else if (arg == "--fixSurface2SidedOpaque")
{
fix_surface_2_sided_opaque = true;
}
else if (arg == "--merge")
{
if (i < argc - 1)
{
merge_files.push_back(argv[i + 1]);
i++;
}
else
{
std::cerr << "Missing merge file" << std::endl;
usage();
return EXIT_FAILURE;
}
}
else if (arg == "--removeObjects")
{
if ((i + 2) < argc)
{
const std::string type = argv[i + 1];
const std::string expression = argv[i + 2];
if (type == "group" || type == "poly" || type == "light")
{
try
{
removes.emplace_back(type, expression);
i += 2;
}
catch (std::regex_error &ex)
{
std::cerr << "Invalid removeObjects expression: " << expression << " " << ex.what() << std::endl;
usage();
return EXIT_FAILURE;
}
}
else
{
std::cerr << "Invalid removeObjects type: " << type << std::endl;
usage();
return EXIT_FAILURE;
}
}
else
{
std::cerr << "Missing removeObjects parameters" << std::endl;
usage();
return EXIT_FAILURE;
}
}
else if (arg == "--dump")
{
i++;
if (i == argc)
{
std::cerr << "Missing dump type" << std::endl;
usage();
return EXIT_FAILURE;
}
arg = argv[i];
if (arg == "group")
dump_type = AC3D::DumpType::group;
else if (arg == "poly")
dump_type = AC3D::DumpType::poly;
else if(arg == "surf")
dump_type = AC3D::DumpType::surf;
else
{
std::cerr << "Invalid dump type: " << arg << std::endl;
usage();
return EXIT_FAILURE;
}
dump = true;
}
else if (arg == "-v")
{
i++;
if (i == argc)
{
std::cerr << "Missing output version" << std::endl;
usage();
return EXIT_FAILURE;
}
arg = argv[i];
if (arg == "11")
version = 11;
else if (arg == "12")
version = 12;
else
{
std::cerr << "Invalid output version: " << arg << std::endl;
usage();
return EXIT_FAILURE;
}
}
else if (arg == "--showTimes")
{
show_times = true;
}
else if (arg == "--quiet")
{
quiet = true;
}
else if (arg == "--summary")
{
summary = true;
}
else if (arg == "-l")
{
listInput = true;
}
else if (arg[0] != '-')
{
if (in_file.empty())
in_file = arg;
else
{
std::cerr << "Multiple input files not supported: " << arg << std::endl;
usage();
return EXIT_FAILURE;
}
}
else
{
std::cerr << "Unknown option: " << arg << std::endl;
usage();
return EXIT_FAILURE;
}
}
std::chrono::time_point<std::chrono::system_clock> start;
if (show_times)
{
start = std::chrono::system_clock::now();
std::cout << "acclint started at " << AC3D::getTime(start) << std::endl;
}
AC3D ac3d;
// warnings with tests
ac3d.ambiguousTexture(ambiguous_texture);
ac3d.blankLine(blank_line);
ac3d.collinearSurfaceVertices(collinear_surface_vertices);
ac3d.differentMat(different_mat);
ac3d.differentSURF(different_surf);
ac3d.differentUV(different_uv);
ac3d.duplicateMaterials(duplicate_materials);
ac3d.duplicateSurfaces(duplicate_surfaces);
ac3d.duplicateSurfacesOrder(duplicate_surfaces_order);
ac3d.duplicateSurfacesWinding(duplicate_surfaces_winding);
ac3d.duplicateSurfaceVertices(duplicate_surface_vertices);
ac3d.duplicateTriangles(duplicate_triangles);
ac3d.duplicateTexture(duplicate_texture);
ac3d.duplicateVertices(duplicate_vertices);
ac3d.emptyObject(empty_object);
ac3d.extraObject(extra_object);
ac3d.extraUVCoordinates(extra_uv_coordinates);
ac3d.groupWithGeometry(group_with_geometry);
ac3d.invalidMaterial(invalid_material);
ac3d.invalidNormalLength(invalid_normal_length);
ac3d.invalidObjectType(invalid_object_type);
ac3d.invalidRefCount(invalid_ref_count);
ac3d.materialAfterObject(material_after_object);
ac3d.missingKids(missing_kids);
ac3d.missingNormal(missing_normal);
ac3d.missingSurfaces(missing_surfaces);
ac3d.missingTexture(missing_texture);
ac3d.missingUVCoordinates(missing_uv_coordinates);
ac3d.multipleCrease(multiple_crease);
ac3d.multipleData(multiple_data);
ac3d.multipleFolded(multiple_folded);
ac3d.multipleHidden(multiple_hidden);
ac3d.multipleLoc(multiple_loc);
ac3d.multipleLocked(multiple_locked);
ac3d.multipleName(multiple_name);
ac3d.multipleRot(multiple_rot);
ac3d.multipleShader(multiple_shader);
ac3d.multipleSubdiv(multiple_subdiv);
ac3d.multipleTexoff(multiple_texoff);
ac3d.multipleTexrep(multiple_texrep);
ac3d.multipleTexture(multiple_texture);
ac3d.multipleUrl(multiple_url);
ac3d.multipleWorld(multiple_world);
ac3d.overlapping2SidedSurface(overlapping_2_sided_surface);
ac3d.surface2SidedOpaque(surface_2_sided_opaque);
ac3d.surfaceNotConvex(surface_not_convex);
ac3d.surfaceNotCoplanar(surface_not_coplanar);
ac3d.surfaceNoTexture(surface_no_texture);
ac3d.surfaceSelfIntersecting(surface_self_intersecting);
ac3d.surfaceStripDegenerate(surface_strip_degenerate);
ac3d.surfaceStripSize(surface_strip_size);
ac3d.trailingText(trailing_text);
ac3d.unsupportedVersion(unsupported_version);
ac3d.unusedMaterial(unused_material);
ac3d.unusedVertex(unused_vertex);
ac3d.utf8Bom(utf8_bom);
// warnings without tests
ac3d.floatingPoint(floating_point);
ac3d.multiplePolygonSurface(multiple_polygon_surface);
ac3d.surfaceStripHole(surface_strip_hole);
ac3d.surfaceStripDuplicateTriangles(surface_strip_duplicate_triangles);
// errors with tests
ac3d.invalidKidsCount(invalid_kids_count);
ac3d.invalidMaterialIndex(invalid_material_index);
ac3d.invalidNormal(invalid_normal);
ac3d.invalidNumsurf(invalid_numsurf);
ac3d.invalidNumvert(invalid_numvert);
ac3d.invalidRefsCount(invalid_refs_count);
ac3d.invalidSurfaceType(invalid_surface_type);
ac3d.invalidToken(invalid_token);
ac3d.invalidTextureCoordinate(invalid_texture_coordinate);
ac3d.invalidVertex(invalid_vertex);
ac3d.invalidRefVertexIndex(invalid_ref_vertex_index);
ac3d.missingVertex(missing_vertex);
ac3d.moreSURFThanSpecified(more_surf_than_specified);
// errors without tests
ac3d.notAC3DFile(not_ac3d_file);
ac3d.texturePaths(texture_paths);
ac3d.showTimes(show_times);
ac3d.quiet(quiet);
ac3d.summary(summary);
ac3d.threads(threads);
if (listInput)
std::cerr << in_file << std::endl;
if (in_file.empty())
{
std::cerr << "No input file specified" << std::endl;
usage();
return EXIT_FAILURE;