File: 0023-Some-unit-tests-for-heightfield-filtering-functions-.patch

package info (click to toggle)
recastnavigation 1.6.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,892 kB
  • sloc: cpp: 50,116; ansic: 2,674; xml: 182; makefile: 16
file content (1701 lines) | stat: -rw-r--r-- 46,249 bytes parent folder | download
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
From fc18ed81940ea85af94b319c314e8220e467fe75 Mon Sep 17 00:00:00 2001
From: Graham Pentheny <grahamboree@users.noreply.github.com>
Date: Sun, 31 Dec 2023 14:55:41 -0500
Subject: [PATCH 23/36] Some unit tests for heightfield filtering functions
 (#682)

This adds some unit tests for the functions in RecastFilter.cpp, and updates docs around these functions. This also splits up the Tests_Recast.cpp file into a few smaller, more focused files.
---
 Recast/Include/Recast.h             |  22 +-
 Recast/Source/RecastFilter.cpp      |  32 +-
 Tests/Recast/Bench_rcVector.cpp     | 168 ++++++++++
 Tests/Recast/Tests_Alloc.cpp        | 260 ++++++++++++++++
 Tests/Recast/Tests_Recast.cpp       | 468 ++--------------------------
 Tests/Recast/Tests_RecastFilter.cpp | 389 +++++++++++++++++++++++
 6 files changed, 872 insertions(+), 467 deletions(-)
 create mode 100644 Tests/Recast/Bench_rcVector.cpp
 create mode 100644 Tests/Recast/Tests_Alloc.cpp
 create mode 100644 Tests/Recast/Tests_RecastFilter.cpp

diff --git a/Recast/Include/Recast.h b/Recast/Include/Recast.h
index 2a5e075..2104aa5 100644
--- a/Recast/Include/Recast.h
+++ b/Recast/Include/Recast.h
@@ -321,6 +321,8 @@ struct rcHeightfield
 	float cs;			///< The size of each cell. (On the xz-plane.)
 	float ch;			///< The height of each cell. (The minimum increment along the y-axis.)
 	rcSpan** spans;		///< Heightfield of spans (width*height).
+
+	// memory pool for rcSpan instances.
 	rcSpanPool* pools;	///< Linked list of span pools.
 	rcSpan* freelist;	///< The next free span.
 
@@ -998,23 +1000,21 @@ bool rcRasterizeTriangles(rcContext* context,
                           const float* verts, const unsigned char* triAreaIDs, int numTris,
                           rcHeightfield& heightfield, int flagMergeThreshold = 1);
 
-/// Marks non-walkable spans as walkable if their maximum is within @p walkableClimb of a walkable neighbor.
+/// Marks non-walkable spans as walkable if their maximum is within @p walkableClimb of the span below them.
 ///
-/// Allows the formation of walkable regions that will flow over low lying 
-/// objects such as curbs, and up structures such as stairways. 
+/// This removes small obstacles that the agent would be able to walk over such as curbs, and also allows agents to move up structures such as stairs.
 /// 
-/// Two neighboring spans are walkable if: <tt>rcAbs(currentSpan.smax - neighborSpan.smax) < walkableClimb</tt>
+/// Obstacle spans are marked walkable if: <tt>obstacleSpan.smax - walkableSpan.smax < walkableClimb</tt>
 /// 
-/// @warning Will override the effect of #rcFilterLedgeSpans.  So if both filters are used, call
-/// #rcFilterLedgeSpans after calling this filter. 
+/// @warning Will override the effect of #rcFilterLedgeSpans.  If both filters are used, call #rcFilterLedgeSpans only after applying this filter.
 ///
 /// @see rcHeightfield, rcConfig
 /// 
 /// @ingroup recast
-/// @param[in,out]	context				The build context to use during the operation.
+/// @param[in,out]	context			The build context to use during the operation.
 /// @param[in]		walkableClimb	Maximum ledge height that is considered to still be traversable. 
 /// 								[Limit: >=0] [Units: vx]
-/// @param[in,out]	heightfield			A fully built heightfield.  (All spans have been added.)
+/// @param[in,out]	heightfield		A fully built heightfield.  (All spans have been added.)
 void rcFilterLowHangingWalkableObstacles(rcContext* context, int walkableClimb, rcHeightfield& heightfield);
 
 /// Marks spans that are ledges as not-walkable.
@@ -1037,10 +1037,12 @@ void rcFilterLowHangingWalkableObstacles(rcContext* context, int walkableClimb,
 /// @param[in,out]	heightfield			A fully built heightfield.  (All spans have been added.)
 void rcFilterLedgeSpans(rcContext* context, int walkableHeight, int walkableClimb, rcHeightfield& heightfield);
 
-/// Marks walkable spans as not walkable if the clearance above the span is less than the specified height.
+/// Marks walkable spans as not walkable if the clearance above the span is less than the specified walkableHeight.
 /// 
 /// For this filter, the clearance above the span is the distance from the span's 
-/// maximum to the next higher span's minimum. (Same grid column.)
+/// maximum to the minimum of the next higher span in the same column.
+/// If there is no higher span in the column, the clearance is computed as the
+/// distance from the top of the span to the maximum heightfield height.
 /// 
 /// @see rcHeightfield, rcConfig
 /// @ingroup recast
diff --git a/Recast/Source/RecastFilter.cpp b/Recast/Source/RecastFilter.cpp
index 8f3414b..1ecf858 100644
--- a/Recast/Source/RecastFilter.cpp
+++ b/Recast/Source/RecastFilter.cpp
@@ -21,6 +21,11 @@
 
 #include <stdlib.h>
 
+namespace
+{
+	const int MAX_HEIGHTFIELD_HEIGHT = 0xffff; // TODO (graham): Move this to a more visible constant and update usages.
+}
+
 void rcFilterLowHangingWalkableObstacles(rcContext* context, const int walkableClimb, rcHeightfield& heightfield)
 {
 	rcAssert(context);
@@ -59,8 +64,7 @@ void rcFilterLowHangingWalkableObstacles(rcContext* context, const int walkableC
 	}
 }
 
-void rcFilterLedgeSpans(rcContext* context, const int walkableHeight, const int walkableClimb,
-                        rcHeightfield& heightfield)
+void rcFilterLedgeSpans(rcContext* context, const int walkableHeight, const int walkableClimb, rcHeightfield& heightfield)
 {
 	rcAssert(context);
 	
@@ -68,7 +72,6 @@ void rcFilterLedgeSpans(rcContext* context, const int walkableHeight, const int
 
 	const int xSize = heightfield.width;
 	const int zSize = heightfield.height;
-	const int MAX_HEIGHT = 0xffff; // TODO (graham): Move this to a more visible constant and update usages.
 	
 	// Mark border spans.
 	for (int z = 0; z < zSize; ++z)
@@ -84,10 +87,10 @@ void rcFilterLedgeSpans(rcContext* context, const int walkableHeight, const int
 				}
 
 				const int bot = (int)(span->smax);
-				const int top = span->next ? (int)(span->next->smin) : MAX_HEIGHT;
+				const int top = span->next ? (int)(span->next->smin) : MAX_HEIGHTFIELD_HEIGHT;
 
 				// Find neighbours minimum height.
-				int minNeighborHeight = MAX_HEIGHT;
+				int minNeighborHeight = MAX_HEIGHTFIELD_HEIGHT;
 
 				// Min and max height of accessible neighbours.
 				int accessibleNeighborMinHeight = span->smax;
@@ -106,7 +109,7 @@ void rcFilterLedgeSpans(rcContext* context, const int walkableHeight, const int
 
 					// From minus infinity to the first span.
 					const rcSpan* neighborSpan = heightfield.spans[dx + dz * xSize];
-					int neighborTop = neighborSpan ? (int)neighborSpan->smin : MAX_HEIGHT;
+					int neighborTop = neighborSpan ? (int)neighborSpan->smin : MAX_HEIGHTFIELD_HEIGHT;
 					
 					// Skip neighbour if the gap between the spans is too small.
 					if (rcMin(top, neighborTop) - bot >= walkableHeight)
@@ -119,7 +122,7 @@ void rcFilterLedgeSpans(rcContext* context, const int walkableHeight, const int
 					for (neighborSpan = heightfield.spans[dx + dz * xSize]; neighborSpan; neighborSpan = neighborSpan->next)
 					{
 						int neighborBot = (int)neighborSpan->smax;
-						neighborTop = neighborSpan->next ? (int)neighborSpan->next->smin : MAX_HEIGHT;
+						neighborTop = neighborSpan->next ? (int)neighborSpan->next->smin : MAX_HEIGHTFIELD_HEIGHT;
 						
 						// Skip neighbour if the gap between the spans is too small.
 						if (rcMin(top, neighborTop) - rcMax(bot, neighborBot) >= walkableHeight)
@@ -137,19 +140,16 @@ void rcFilterLedgeSpans(rcContext* context, const int walkableHeight, const int
 							{
 								break;
 							}
-
 						}
 					}
 				}
 
-				// The current span is close to a ledge if the drop to any
-				// neighbour span is less than the walkableClimb.
+				// The current span is close to a ledge if the drop to any neighbour span is less than the walkableClimb.
 				if (minNeighborHeight < -walkableClimb)
 				{
 					span->area = RC_NULL_AREA;
 				}
-				// If the difference between all neighbours is too large,
-				// we are at steep slope, mark the span as ledge.
+				// If the difference between all neighbours is too large, we are at steep slope, mark the span as ledge.
 				else if ((accessibleNeighborMaxHeight - accessibleNeighborMinHeight) > walkableClimb)
 				{
 					span->area = RC_NULL_AREA;
@@ -162,13 +162,11 @@ void rcFilterLedgeSpans(rcContext* context, const int walkableHeight, const int
 void rcFilterWalkableLowHeightSpans(rcContext* context, const int walkableHeight, rcHeightfield& heightfield)
 {
 	rcAssert(context);
-	
 	rcScopedTimer timer(context, RC_TIMER_FILTER_WALKABLE);
-	
+
 	const int xSize = heightfield.width;
 	const int zSize = heightfield.height;
-	const int MAX_HEIGHT = 0xffff;
-	
+
 	// Remove walkable flag from spans which do not have enough
 	// space above them for the agent to stand there.
 	for (int z = 0; z < zSize; ++z)
@@ -178,7 +176,7 @@ void rcFilterWalkableLowHeightSpans(rcContext* context, const int walkableHeight
 			for (rcSpan* span = heightfield.spans[x + z*xSize]; span; span = span->next)
 			{
 				const int bot = (int)(span->smax);
-				const int top = span->next ? (int)(span->next->smin) : MAX_HEIGHT;
+				const int top = span->next ? (int)(span->next->smin) : MAX_HEIGHTFIELD_HEIGHT;
 				if ((top - bot) < walkableHeight)
 				{
 					span->area = RC_NULL_AREA;
diff --git a/Tests/Recast/Bench_rcVector.cpp b/Tests/Recast/Bench_rcVector.cpp
new file mode 100644
index 0000000..46c1cee
--- /dev/null
+++ b/Tests/Recast/Bench_rcVector.cpp
@@ -0,0 +1,168 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "catch2/catch_all.hpp"
+
+#include "Recast.h"
+#include "RecastAlloc.h"
+#include "RecastAssert.h"
+#include <vector>
+
+// TODO: Implement benchmarking for platforms other than posix.
+#ifdef __unix__
+#include <unistd.h>
+#ifdef _POSIX_TIMERS
+#include <time.h>
+#include <stdint.h>
+
+int64_t NowNanos() {
+	struct timespec tp;
+	clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp);
+	return tp.tv_nsec + 1000000000LL * tp.tv_sec;
+}
+
+#define BM(name, iterations) \
+	struct BM_ ## name { \
+		static void Run() { \
+			int64_t begin_time = NowNanos(); \
+			for (int i = 0 ; i < iterations; i++) { \
+				Body(); \
+			} \
+			int64_t nanos = NowNanos() - begin_time; \
+			printf("BM_%-35s %ld iterations in %10ld nanos: %10.2f nanos/it\n", #name ":", (int64_t)iterations, nanos, double(nanos) / iterations); \
+		} \
+		static void Body(); \
+	}; \
+	TEST_CASE(#name) { \
+		BM_ ## name::Run(); \
+	} \
+	void BM_ ## name::Body()
+
+const int64_t kNumLoops = 100;
+const int64_t kNumInserts = 100000;
+
+// Prevent compiler from eliding a calculation.
+// TODO: Implement for MSVC.
+template <typename T>
+void DoNotOptimize(T* v) {
+	asm volatile ("" : "+r" (v));
+}
+
+BM(FlatArray_Push, kNumLoops)
+{
+	int cap = 64;
+	int* v = (int*)rcAlloc(cap * sizeof(int), RC_ALLOC_TEMP);
+	for (int j = 0; j < kNumInserts; j++) {
+		if (j == cap) {
+			cap *= 2;
+			int* tmp  = (int*)rcAlloc(sizeof(int) * cap, RC_ALLOC_TEMP);
+			memcpy(tmp, v, j * sizeof(int));
+			rcFree(v);
+			v = tmp;
+		}
+		v[j] = 2;
+	}
+
+	DoNotOptimize(v);
+	rcFree(v);
+}
+BM(FlatArray_Fill, kNumLoops)
+{
+	int* v = (int*)rcAlloc(sizeof(int) * kNumInserts, RC_ALLOC_TEMP);
+	for (int j = 0; j < kNumInserts; j++) {
+		v[j] = 2;
+	}
+
+	DoNotOptimize(v);
+	rcFree(v);
+}
+BM(FlatArray_Memset, kNumLoops)
+{
+	int* v = (int*)rcAlloc(sizeof(int) * kNumInserts, RC_ALLOC_TEMP);
+	memset(v, 0, kNumInserts * sizeof(int));
+
+	DoNotOptimize(v);
+	rcFree(v);
+}
+
+BM(rcVector_Push, kNumLoops)
+{
+	rcTempVector<int> v;
+	for (int j = 0; j < kNumInserts; j++) {
+		v.push_back(2);
+	}
+	DoNotOptimize(v.data());
+}
+BM(rcVector_PushPreallocated, kNumLoops)
+{
+	rcTempVector<int> v;
+	v.reserve(kNumInserts);
+	for (int j = 0; j < kNumInserts; j++) {
+		v.push_back(2);
+	}
+	DoNotOptimize(v.data());
+}
+BM(rcVector_Assign, kNumLoops)
+{
+	rcTempVector<int> v;
+	v.assign(kNumInserts, 2);
+	DoNotOptimize(v.data());
+}
+BM(rcVector_AssignIndices, kNumLoops)
+{
+	rcTempVector<int> v;
+	v.resize(kNumInserts);
+	for (int j = 0; j < kNumInserts; j++) {
+		v[j] = 2;
+	}
+	DoNotOptimize(v.data());
+}
+BM(rcVector_Resize, kNumLoops)
+{
+	rcTempVector<int> v;
+	v.resize(kNumInserts, 2);
+	DoNotOptimize(v.data());
+}
+
+BM(stdvector_Push, kNumLoops)
+{
+	std::vector<int> v;
+	for (int j = 0; j < kNumInserts; j++) {
+		v.push_back(2);
+	}
+	DoNotOptimize(v.data());
+}
+BM(stdvector_PushPreallocated, kNumLoops)
+{
+	std::vector<int> v;
+	v.reserve(kNumInserts);
+	for (int j = 0; j < kNumInserts; j++) {
+		v.push_back(2);
+	}
+	DoNotOptimize(v.data());
+}
+BM(stdvector_Assign, kNumLoops)
+{
+	std::vector<int> v;
+	v.assign(kNumInserts, 2);
+	DoNotOptimize(v.data());
+}
+BM(stdvector_AssignIndices, kNumLoops)
+{
+	std::vector<int> v;
+	v.resize(kNumInserts);
+	for (int j = 0; j < kNumInserts; j++) {
+		v[j] = 2;
+	}
+	DoNotOptimize(v.data());
+}
+BM(stdvector_Resize, kNumLoops)
+{
+	std::vector<int> v;
+	v.resize(kNumInserts, 2);
+	DoNotOptimize(v.data());
+}
+
+#undef BM
+#endif  // _POSIX_TIMERS
+#endif  // __unix__
diff --git a/Tests/Recast/Tests_Alloc.cpp b/Tests/Recast/Tests_Alloc.cpp
new file mode 100644
index 0000000..2e7b2eb
--- /dev/null
+++ b/Tests/Recast/Tests_Alloc.cpp
@@ -0,0 +1,260 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "catch2/catch_all.hpp"
+
+#include "RecastAlloc.h"
+#include "RecastAssert.h"
+
+/// Used to verify that rcVector constructs/destroys objects correctly.
+struct Incrementor {
+	static int constructions;
+	static int destructions;
+	static int copies;
+	Incrementor() { constructions++; }
+	~Incrementor() { destructions++; }
+	Incrementor(const Incrementor&) { copies++; }
+	Incrementor& operator=(const Incrementor&); // Deleted assignment.
+
+	static void Reset() {
+		constructions = 0;
+		destructions = 0;
+		copies = 0;
+	}
+};
+
+int Incrementor::constructions = 0;
+int Incrementor::destructions = 0;
+int Incrementor::copies = 0;
+
+const int kMaxAllocSize = 1024;
+const unsigned char kClearValue = 0xff;
+
+/// Simple alloc/free that clears the memory on free..
+void* AllocAndInit(size_t size, rcAllocHint) {
+	rcAssert(kMaxAllocSize >= size);
+	return memset(malloc(kMaxAllocSize), 0, kMaxAllocSize);
+}
+
+void FreeAndClear(void* mem) {
+	if (mem) {
+	  memset(mem, kClearValue, kMaxAllocSize);
+	}
+	free(mem);
+}
+
+// Verifies that memory has been initialized by AllocAndInit, and not cleared by FreeAndClear.
+struct Copier {
+	const static int kAlive;
+	const static int kDead;
+	Copier() : value(kAlive) {}
+
+	// checks that the source of the copy is valid.
+	Copier(const Copier& other) : value(kAlive) {
+		other.Verify();
+	}
+	Copier& operator=(const Copier&);
+
+	// Marks the value as dead.
+	~Copier() { value = kDead; }
+	void Verify() const {
+		REQUIRE(value == kAlive);
+	}
+	volatile int value;
+};
+
+const int Copier::kAlive = 0x1f;
+const int Copier::kDead = 0xde;
+
+struct NotDefaultConstructible {
+	NotDefaultConstructible(int) {}
+};
+
+TEST_CASE("rcVector", "[recast, alloc]")
+{
+	SECTION("Vector basics.")
+	{
+		rcTempVector<int> vec;
+		REQUIRE(vec.size() == 0);
+		vec.push_back(10);
+		vec.push_back(12);
+		REQUIRE(vec.size() == 2);
+		REQUIRE(vec.capacity() >= 2);
+		REQUIRE(vec[0] == 10);
+		REQUIRE(vec[1] == 12);
+		vec.pop_back();
+		REQUIRE(vec.size() == 1);
+		REQUIRE(vec[0] == 10);
+		vec.pop_back();
+		REQUIRE(vec.size() == 0);
+		vec.resize(100, 5);
+		REQUIRE(vec.size() == 100);
+		for (int i = 0; i < 100; i++) {
+			REQUIRE(vec[i] == 5);
+			vec[i] = i;
+		}
+		for (int i = 0; i < 100; i++) {
+			REQUIRE(vec[i] == i);
+		}
+	}
+
+	SECTION("Constructors/Destructors")
+	{
+		Incrementor::Reset();
+		rcTempVector<Incrementor> vec;
+		REQUIRE(Incrementor::constructions == 0);
+		REQUIRE(Incrementor::destructions == 0);
+		REQUIRE(Incrementor::copies == 0);
+		vec.push_back(Incrementor());
+		// push_back() may create and copy objects internally.
+		REQUIRE(Incrementor::constructions == 1);
+		REQUIRE(Incrementor::destructions >= 1);
+		// REQUIRE(Incrementor::copies >= 2);
+
+		vec.clear();
+		Incrementor::Reset();
+		vec.resize(100);
+		// Initialized with default instance. Temporaries may be constructed, then destroyed.
+		REQUIRE(Incrementor::constructions == 100);
+		REQUIRE(Incrementor::destructions == 0);
+		REQUIRE(Incrementor::copies == 0);
+
+		Incrementor::Reset();
+		for (int i = 0; i < 100; i++) {
+			REQUIRE(Incrementor::destructions == i);
+			vec.pop_back();
+		}
+		REQUIRE(Incrementor::constructions == 0);
+		REQUIRE(Incrementor::destructions == 100);
+		REQUIRE(Incrementor::copies == 0);
+
+		vec.resize(100);
+		Incrementor::Reset();
+		vec.clear();
+		// One temp object is constructed for the default argument of resize().
+		REQUIRE(Incrementor::constructions == 0);
+		REQUIRE(Incrementor::destructions == 100);
+		REQUIRE(Incrementor::copies == 0);
+
+		Incrementor::Reset();
+		vec.resize(100, Incrementor());
+		REQUIRE(Incrementor::constructions == 1);
+		REQUIRE(Incrementor::destructions == 1);
+		REQUIRE(Incrementor::copies == 100);
+	}
+
+	SECTION("Copying Contents")
+	{
+
+		// veriyf event counts after doubling size -- should require a lot of copying and destroying.
+		rcTempVector<Incrementor> vec;
+		Incrementor::Reset();
+		vec.resize(100);
+		REQUIRE(Incrementor::constructions == 100);
+		REQUIRE(Incrementor::destructions == 0);
+		REQUIRE(Incrementor::copies == 0);
+		Incrementor::Reset();
+		vec.resize(200);
+		REQUIRE(vec.size() == vec.capacity());
+		REQUIRE(Incrementor::constructions == 100);  // Construc new elements.
+		REQUIRE(Incrementor::destructions == 100);  // Destroy old contents.
+		REQUIRE(Incrementor::copies == 100);  // Copy old elements into new array.
+	}
+
+	SECTION("Swap")
+	{
+		rcTempVector<int> a(10, 0xa);
+		rcTempVector<int> b;
+
+		int* a_data = a.data();
+		int* b_data = b.data();
+
+		a.swap(b);
+		REQUIRE(a.size() == 0);
+		REQUIRE(b.size() == 10);
+		REQUIRE(b[0] == 0xa);
+		REQUIRE(b[9] == 0xa);
+		REQUIRE(a.data() == b_data);
+		REQUIRE(b.data() == a_data);
+	}
+
+	SECTION("Overlapping init")
+	{
+		rcAllocSetCustom(&AllocAndInit, &FreeAndClear);
+		rcTempVector<Copier> vec;
+		// Force a realloc during push_back().
+		vec.resize(64);
+		REQUIRE(vec.capacity() == vec.size());
+		REQUIRE(vec.capacity() > 0);
+		REQUIRE(vec.size() == vec.capacity());
+
+		// Don't crash.
+		vec.push_back(vec[0]);
+		rcAllocSetCustom(NULL, NULL);
+	}
+
+	SECTION("Vector Destructor")
+	{
+		{
+			rcTempVector<Incrementor> vec;
+			vec.resize(10);
+			Incrementor::Reset();
+		}
+		REQUIRE(Incrementor::destructions == 10);
+	}
+
+	SECTION("Assign")
+	{
+		rcTempVector<int> a(10, 0xa);
+		a.assign(5, 0xb);
+		REQUIRE(a.size() == 5);
+		REQUIRE(a[0] == 0xb);
+		REQUIRE(a[4] == 0xb);
+		a.assign(15, 0xc);
+		REQUIRE(a.size() == 15);
+		REQUIRE(a[0] == 0xc);
+		REQUIRE(a[14] == 0xc);
+
+		rcTempVector<int> b;
+		b.assign(a.data(), a.data() + a.size());
+		REQUIRE(b.size() == a.size());
+		REQUIRE(b[0] == a[0]);
+	}
+
+	SECTION("Copy")
+	{
+		rcTempVector<int> a(10, 0xa);
+		rcTempVector<int> b(a);
+		REQUIRE(a.size() == 10);
+		REQUIRE(a.size() == b.size());
+		REQUIRE(a[0] == b[0]);
+		REQUIRE(a.data() != b.data());
+		rcTempVector<int> c(a.data(), a.data() + a.size());
+		REQUIRE(c.size() == a.size());
+		REQUIRE(c[0] == a[0]);
+
+		rcTempVector<Incrementor> d(10);
+		Incrementor::Reset();
+		rcTempVector<Incrementor> e(d);
+		REQUIRE(Incrementor::constructions == 0);
+		REQUIRE(Incrementor::destructions == 0);
+		REQUIRE(Incrementor::copies == 10);
+
+		Incrementor::Reset();
+		rcTempVector<Incrementor> f(d.data(), d.data() + d.size());
+		REQUIRE(Incrementor::constructions == 0);
+		REQUIRE(Incrementor::destructions == 0);
+		REQUIRE(Incrementor::copies == 10);
+	}
+
+	SECTION("Type Requirements")
+	{
+		// This section verifies that we don't enforce unnecessary
+		// requirements on the types we hold.
+
+		// Implementing clear as resize(0) will cause this to fail
+		// as resize(0) requires T to be default constructible.
+		rcTempVector<NotDefaultConstructible> v;
+		v.clear();
+	}
+}
diff --git a/Tests/Recast/Tests_Recast.cpp b/Tests/Recast/Tests_Recast.cpp
index 34c61d0..62d1507 100644
--- a/Tests/Recast/Tests_Recast.cpp
+++ b/Tests/Recast/Tests_Recast.cpp
@@ -4,13 +4,8 @@
 #include "catch2/catch_all.hpp"
 
 #include "Recast.h"
-#include "RecastAlloc.h"
-#include "RecastAssert.h"
 
-// For comparing to rcVector in benchmarks.
-#include <vector>
-
-TEST_CASE("rcSwap")
+TEST_CASE("rcSwap", "[recast]")
 {
 	SECTION("Swap two values")
 	{
@@ -22,7 +17,7 @@ TEST_CASE("rcSwap")
 	}
 }
 
-TEST_CASE("rcMin")
+TEST_CASE("rcMin", "[recast]")
 {
 	SECTION("Min returns the lowest value.")
 	{
@@ -36,7 +31,7 @@ TEST_CASE("rcMin")
 	}
 }
 
-TEST_CASE("rcMax")
+TEST_CASE("rcMax", "[recast]")
 {
 	SECTION("Max returns the greatest value.")
 	{
@@ -50,7 +45,7 @@ TEST_CASE("rcMax")
 	}
 }
 
-TEST_CASE("rcAbs")
+TEST_CASE("rcAbs", "[recast]")
 {
 	SECTION("Abs returns the absolute value.")
 	{
@@ -60,7 +55,7 @@ TEST_CASE("rcAbs")
 	}
 }
 
-TEST_CASE("rcSqr")
+TEST_CASE("rcSqr", "[recast]")
 {
 	SECTION("Sqr squares a number")
 	{
@@ -70,7 +65,7 @@ TEST_CASE("rcSqr")
 	}
 }
 
-TEST_CASE("rcClamp")
+TEST_CASE("rcClamp", "[recast]")
 {
 	SECTION("Higher than range")
 	{
@@ -88,7 +83,7 @@ TEST_CASE("rcClamp")
 	}
 }
 
-TEST_CASE("rcSqrt")
+TEST_CASE("rcSqrt", "[recast]")
 {
 	SECTION("Sqrt gets the sqrt of a number")
 	{
@@ -97,7 +92,7 @@ TEST_CASE("rcSqrt")
 	}
 }
 
-TEST_CASE("rcVcross")
+TEST_CASE("rcVcross", "[recast]")
 {
 	SECTION("Computes cross product")
 	{
@@ -121,7 +116,7 @@ TEST_CASE("rcVcross")
 	}
 }
 
-TEST_CASE("rcVdot")
+TEST_CASE("rcVdot", "[recast]")
 {
 	SECTION("Dot normalized vector with itself")
 	{
@@ -140,7 +135,7 @@ TEST_CASE("rcVdot")
 	}
 }
 
-TEST_CASE("rcVmad")
+TEST_CASE("rcVmad", "[recast]")
 {
 	SECTION("scaled add two vectors")
 	{
@@ -165,7 +160,7 @@ TEST_CASE("rcVmad")
 	}
 }
 
-TEST_CASE("rcVadd")
+TEST_CASE("rcVadd", "[recast]")
 {
 	SECTION("add two vectors")
 	{
@@ -179,7 +174,7 @@ TEST_CASE("rcVadd")
 	}
 }
 
-TEST_CASE("rcVsub")
+TEST_CASE("rcVsub", "[recast]")
 {
 	SECTION("subtract two vectors")
 	{
@@ -193,7 +188,7 @@ TEST_CASE("rcVsub")
 	}
 }
 
-TEST_CASE("rcVmin")
+TEST_CASE("rcVmin", "[recast]")
 {
 	SECTION("selects the min component from the vectors")
 	{
@@ -226,7 +221,7 @@ TEST_CASE("rcVmin")
 	}
 }
 
-TEST_CASE("rcVmax")
+TEST_CASE("rcVmax", "[recast]")
 {
 	SECTION("selects the max component from the vectors")
 	{
@@ -259,7 +254,7 @@ TEST_CASE("rcVmax")
 	}
 }
 
-TEST_CASE("rcVcopy")
+TEST_CASE("rcVcopy", "[recast]")
 {
 	SECTION("copies a vector into another vector")
 	{
@@ -275,7 +270,7 @@ TEST_CASE("rcVcopy")
 	}
 }
 
-TEST_CASE("rcVdist")
+TEST_CASE("rcVdist", "[recast]")
 {
 	SECTION("distance between two vectors")
 	{
@@ -296,7 +291,7 @@ TEST_CASE("rcVdist")
 	}
 }
 
-TEST_CASE("rcVdistSqr")
+TEST_CASE("rcVdistSqr", "[recast]")
 {
 	SECTION("squared distance between two vectors")
 	{
@@ -317,7 +312,7 @@ TEST_CASE("rcVdistSqr")
 	}
 }
 
-TEST_CASE("rcVnormalize")
+TEST_CASE("rcVnormalize", "[recast]")
 {
 	SECTION("normalizing reduces magnitude to 1")
 	{
@@ -331,7 +326,7 @@ TEST_CASE("rcVnormalize")
 	}
 }
 
-TEST_CASE("rcCalcBounds")
+TEST_CASE("rcCalcBounds", "[recast]")
 {
 	SECTION("bounds of one vector")
 	{
@@ -369,7 +364,7 @@ TEST_CASE("rcCalcBounds")
 	}
 }
 
-TEST_CASE("rcCalcGridSize")
+TEST_CASE("rcCalcGridSize", "[recast]")
 {
 	SECTION("computes the size of an x & z axis grid")
 	{
@@ -393,7 +388,7 @@ TEST_CASE("rcCalcGridSize")
 	}
 }
 
-TEST_CASE("rcCreateHeightfield")
+TEST_CASE("rcCreateHeightfield", "[recast]")
 {
 	SECTION("create a heightfield")
 	{
@@ -439,7 +434,7 @@ TEST_CASE("rcCreateHeightfield")
 	}
 }
 
-TEST_CASE("rcMarkWalkableTriangles")
+TEST_CASE("rcMarkWalkableTriangles", "[recast]")
 {
 	rcContext* ctx = 0;
 	float walkableSlopeAngle = 45;
@@ -481,7 +476,7 @@ TEST_CASE("rcMarkWalkableTriangles")
 	}
 }
 
-TEST_CASE("rcClearUnwalkableTriangles")
+TEST_CASE("rcClearUnwalkableTriangles", "[recast]")
 {
 	rcContext* ctx = 0;
 	float walkableSlopeAngle = 45;
@@ -516,7 +511,7 @@ TEST_CASE("rcClearUnwalkableTriangles")
 	}
 }
 
-TEST_CASE("rcAddSpan")
+TEST_CASE("rcAddSpan", "[recast]")
 {
 	rcContext ctx(false);
 
@@ -605,7 +600,7 @@ TEST_CASE("rcAddSpan")
 	}
 }
 
-TEST_CASE("rcRasterizeTriangle")
+TEST_CASE("rcRasterizeTriangle", "[recast]")
 {
 	rcContext ctx;
 	float verts[] = {
@@ -657,7 +652,7 @@ TEST_CASE("rcRasterizeTriangle")
 	}
 }
 
-TEST_CASE("rcRasterizeTriangle overlapping bb but non-overlapping triangle")
+TEST_CASE("rcRasterizeTriangle overlapping bb but non-overlapping triangle", "[recast]")
 {
 	// This is a minimal repro case for the issue fixed in PR #476 (https://github.com/recastnavigation/recastnavigation/pull/476)
     rcContext ctx;
@@ -694,7 +689,7 @@ TEST_CASE("rcRasterizeTriangle overlapping bb but non-overlapping triangle")
     }
 }
 
-TEST_CASE("rcRasterizeTriangle smaller than half a voxel size in x")
+TEST_CASE("rcRasterizeTriangle smaller than half a voxel size in x", "[recast]")
 {
 	SECTION("Skinny triangle along x axis")
 	{
@@ -761,7 +756,7 @@ TEST_CASE("rcRasterizeTriangle smaller than half a voxel size in x")
 	}
 }
 
-TEST_CASE("rcRasterizeTriangles")
+TEST_CASE("rcRasterizeTriangles", "[recast]")
 {
 	rcContext ctx;
 	float verts[] = {
@@ -940,410 +935,3 @@ TEST_CASE("rcRasterizeTriangles")
 		REQUIRE(!solid.spans[1 + 2 * width]->next);
 	}
 }
-
-// Used to verify that rcVector constructs/destroys objects correctly.
-struct Incrementor {
-	static int constructions;
-	static int destructions;
-	static int copies;
-	Incrementor() { constructions++; }
-	~Incrementor() { destructions++; }
-	Incrementor(const Incrementor&) { copies++; }
-	Incrementor& operator=(const Incrementor&); // Deleted assignment.
-
-	static void Reset() {
-		constructions = 0;
-		destructions = 0;
-		copies = 0;
-	}
-};
-int Incrementor::constructions = 0;
-int Incrementor::destructions = 0;
-int Incrementor::copies = 0;
-
-const int kMaxAllocSize = 1024;
-const unsigned char kClearValue = 0xff;
-// Simple alloc/free that clears the memory on free..
-void* AllocAndInit(size_t size, rcAllocHint) {
-	rcAssert(kMaxAllocSize >= size);
-	return memset(malloc(kMaxAllocSize), 0, kMaxAllocSize);
-}
-void FreeAndClear(void* mem) {
-	if (mem) {
-	  memset(mem, kClearValue, kMaxAllocSize);
-	}
-	free(mem);
-}
-// Verifies that memory has been initialized by AllocAndInit, and not cleared by FreeAndClear.
-struct Copier {
-	const static int kAlive;
-	const static int kDead;
-	Copier() : value(kAlive) {}
-
-	// checks that the source of the copy is valid.
-	Copier(const Copier& other) : value(kAlive) {
-		other.Verify();
-	}
-	Copier& operator=(const Copier&);
-
-	// Marks the value as dead.
-	~Copier() { value = kDead; }
-	void Verify() const {
-		REQUIRE(value == kAlive);
-	}
-	volatile int value;
-};
-const int Copier::kAlive = 0x1f;
-const int Copier::kDead = 0xde;
-
-struct NotDefaultConstructible {
-	NotDefaultConstructible(int) {}
-};
-
-TEST_CASE("rcVector")
-{
-	SECTION("Vector basics.")
-	{
-		rcTempVector<int> vec;
-		REQUIRE(vec.size() == 0);
-		vec.push_back(10);
-		vec.push_back(12);
-		REQUIRE(vec.size() == 2);
-		REQUIRE(vec.capacity() >= 2);
-		REQUIRE(vec[0] == 10);
-		REQUIRE(vec[1] == 12);
-		vec.pop_back();
-		REQUIRE(vec.size() == 1);
-		REQUIRE(vec[0] == 10);
-		vec.pop_back();
-		REQUIRE(vec.size() == 0);
-		vec.resize(100, 5);
-		REQUIRE(vec.size() == 100);
-		for (int i = 0; i < 100; i++) {
-			REQUIRE(vec[i] == 5);
-			vec[i] = i;
-		}
-		for (int i = 0; i < 100; i++) {
-			REQUIRE(vec[i] == i);
-		}
-	}
-
-	SECTION("Constructors/Destructors")
-	{
-		Incrementor::Reset();
-		rcTempVector<Incrementor> vec;
-		REQUIRE(Incrementor::constructions == 0);
-		REQUIRE(Incrementor::destructions == 0);
-		REQUIRE(Incrementor::copies == 0);
-		vec.push_back(Incrementor());
-		// push_back() may create and copy objects internally.
-		REQUIRE(Incrementor::constructions == 1);
-		REQUIRE(Incrementor::destructions >= 1);
-		// REQUIRE(Incrementor::copies >= 2);
-
-		vec.clear();
-		Incrementor::Reset();
-		vec.resize(100);
-		// Initialized with default instance. Temporaries may be constructed, then destroyed.
-		REQUIRE(Incrementor::constructions == 100);
-		REQUIRE(Incrementor::destructions == 0);
-		REQUIRE(Incrementor::copies == 0);
-
-		Incrementor::Reset();
-		for (int i = 0; i < 100; i++) {
-			REQUIRE(Incrementor::destructions == i);
-			vec.pop_back();
-		}
-		REQUIRE(Incrementor::constructions == 0);
-		REQUIRE(Incrementor::destructions == 100);
-		REQUIRE(Incrementor::copies == 0);
-
-		vec.resize(100);
-		Incrementor::Reset();
-		vec.clear();
-		// One temp object is constructed for the default argument of resize().
-		REQUIRE(Incrementor::constructions == 0);
-		REQUIRE(Incrementor::destructions == 100);
-		REQUIRE(Incrementor::copies == 0);
-
-		Incrementor::Reset();
-		vec.resize(100, Incrementor());
-		REQUIRE(Incrementor::constructions == 1);
-		REQUIRE(Incrementor::destructions == 1);
-		REQUIRE(Incrementor::copies == 100);
-	}
-
-	SECTION("Copying Contents")
-	{
-
-		// veriyf event counts after doubling size -- should require a lot of copying and destroying.
-		rcTempVector<Incrementor> vec;
-		Incrementor::Reset();
-		vec.resize(100);
-		REQUIRE(Incrementor::constructions == 100);
-		REQUIRE(Incrementor::destructions == 0);
-		REQUIRE(Incrementor::copies == 0);
-		Incrementor::Reset();
-		vec.resize(200);
-		REQUIRE(vec.size() == vec.capacity());
-		REQUIRE(Incrementor::constructions == 100);  // Construc new elements.
-		REQUIRE(Incrementor::destructions == 100);  // Destroy old contents.
-		REQUIRE(Incrementor::copies == 100);  // Copy old elements into new array.
-	}
-
-	SECTION("Swap")
-	{
-		rcTempVector<int> a(10, 0xa);
-		rcTempVector<int> b;
-
-		int* a_data = a.data();
-		int* b_data = b.data();
-
-		a.swap(b);
-		REQUIRE(a.size() == 0);
-		REQUIRE(b.size() == 10);
-		REQUIRE(b[0] == 0xa);
-		REQUIRE(b[9] == 0xa);
-		REQUIRE(a.data() == b_data);
-		REQUIRE(b.data() == a_data);
-	}
-
-	SECTION("Overlapping init")
-	{
-		rcAllocSetCustom(&AllocAndInit, &FreeAndClear);
-		rcTempVector<Copier> vec;
-		// Force a realloc during push_back().
-		vec.resize(64);
-		REQUIRE(vec.capacity() == vec.size());
-		REQUIRE(vec.capacity() > 0);
-		REQUIRE(vec.size() == vec.capacity());
-
-		// Don't crash.
-		vec.push_back(vec[0]);
-		rcAllocSetCustom(NULL, NULL);
-	}
-
-	SECTION("Vector Destructor")
-	{
-		{
-			rcTempVector<Incrementor> vec;
-			vec.resize(10);
-			Incrementor::Reset();
-		}
-		REQUIRE(Incrementor::destructions == 10);
-	}
-
-	SECTION("Assign")
-	{
-		rcTempVector<int> a(10, 0xa);
-		a.assign(5, 0xb);
-		REQUIRE(a.size() == 5);
-		REQUIRE(a[0] == 0xb);
-		REQUIRE(a[4] == 0xb);
-		a.assign(15, 0xc);
-		REQUIRE(a.size() == 15);
-		REQUIRE(a[0] == 0xc);
-		REQUIRE(a[14] == 0xc);
-
-		rcTempVector<int> b;
-		b.assign(a.data(), a.data() + a.size());
-		REQUIRE(b.size() == a.size());
-		REQUIRE(b[0] == a[0]);
-	}
-
-	SECTION("Copy")
-	{
-		rcTempVector<int> a(10, 0xa);
-		rcTempVector<int> b(a);
-		REQUIRE(a.size() == 10);
-		REQUIRE(a.size() == b.size());
-		REQUIRE(a[0] == b[0]);
-		REQUIRE(a.data() != b.data());
-		rcTempVector<int> c(a.data(), a.data() + a.size());
-		REQUIRE(c.size() == a.size());
-		REQUIRE(c[0] == a[0]);
-
-		rcTempVector<Incrementor> d(10);
-		Incrementor::Reset();
-		rcTempVector<Incrementor> e(d);
-		REQUIRE(Incrementor::constructions == 0);
-		REQUIRE(Incrementor::destructions == 0);
-		REQUIRE(Incrementor::copies == 10);
-
-		Incrementor::Reset();
-		rcTempVector<Incrementor> f(d.data(), d.data() + d.size());
-		REQUIRE(Incrementor::constructions == 0);
-		REQUIRE(Incrementor::destructions == 0);
-		REQUIRE(Incrementor::copies == 10);
-	}
-
-	SECTION("Type Requirements")
-	{
-		// This section verifies that we don't enforce unnecessary
-		// requirements on the types we hold.
-
-		// Implementing clear as resize(0) will cause this to fail
-		// as resize(0) requires T to be default constructible.
-		rcTempVector<NotDefaultConstructible> v;
-		v.clear();
-	}
-}
-
-// TODO: Implement benchmarking for platforms other than posix.
-#ifdef __unix__
-#include <unistd.h>
-#ifdef _POSIX_TIMERS
-#include <time.h>
-#include <stdint.h>
-
-int64_t NowNanos() {
-	struct timespec tp;
-	clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp);
-	return tp.tv_nsec + 1000000000LL * tp.tv_sec;
-}
-
-#define BM(name, iterations) \
-	struct BM_ ## name { \
-		static void Run() { \
-			int64_t begin_time = NowNanos(); \
-			for (int i = 0 ; i < iterations; i++) { \
-				Body(); \
-			} \
-			int64_t nanos = NowNanos() - begin_time; \
-			printf("BM_%-35s %ld iterations in %10ld nanos: %10.2f nanos/it\n", #name ":", (int64_t)iterations, nanos, double(nanos) / iterations); \
-		} \
-		static void Body(); \
-	}; \
-	TEST_CASE(#name) { \
-		BM_ ## name::Run(); \
-	} \
-	void BM_ ## name::Body()
-
-const int64_t kNumLoops = 100;
-const int64_t kNumInserts = 100000;
-
-// Prevent compiler from eliding a calculation.
-// TODO: Implement for MSVC.
-template <typename T>
-void DoNotOptimize(T* v) {
-	asm volatile ("" : "+r" (v));
-}
-
-BM(FlatArray_Push, kNumLoops)
-{
-	int cap = 64;
-	int* v = (int*)rcAlloc(cap * sizeof(int), RC_ALLOC_TEMP);
-	for (int j = 0; j < kNumInserts; j++) {
-		if (j == cap) {
-			cap *= 2;
-			int* tmp  = (int*)rcAlloc(sizeof(int) * cap, RC_ALLOC_TEMP);
-			memcpy(tmp, v, j * sizeof(int));
-			rcFree(v);
-			v = tmp;
-		}
-		v[j] = 2;
-	}
-
-	DoNotOptimize(v);
-	rcFree(v);
-}
-BM(FlatArray_Fill, kNumLoops)
-{
-	int* v = (int*)rcAlloc(sizeof(int) * kNumInserts, RC_ALLOC_TEMP);
-	for (int j = 0; j < kNumInserts; j++) {
-		v[j] = 2;
-	}
-
-	DoNotOptimize(v);
-	rcFree(v);
-}
-BM(FlatArray_Memset, kNumLoops)
-{
-	int* v = (int*)rcAlloc(sizeof(int) * kNumInserts, RC_ALLOC_TEMP);
-	memset(v, 0, kNumInserts * sizeof(int));
-
-	DoNotOptimize(v);
-	rcFree(v);
-}
-
-BM(rcVector_Push, kNumLoops)
-{
-	rcTempVector<int> v;
-	for (int j = 0; j < kNumInserts; j++) {
-		v.push_back(2);
-	}
-	DoNotOptimize(v.data());
-}
-BM(rcVector_PushPreallocated, kNumLoops)
-{
-	rcTempVector<int> v;
-	v.reserve(kNumInserts);
-	for (int j = 0; j < kNumInserts; j++) {
-		v.push_back(2);
-	}
-	DoNotOptimize(v.data());
-}
-BM(rcVector_Assign, kNumLoops)
-{
-	rcTempVector<int> v;
-	v.assign(kNumInserts, 2);
-	DoNotOptimize(v.data());
-}
-BM(rcVector_AssignIndices, kNumLoops)
-{
-	rcTempVector<int> v;
-	v.resize(kNumInserts);
-	for (int j = 0; j < kNumInserts; j++) {
-		v[j] = 2;
-	}
-	DoNotOptimize(v.data());
-}
-BM(rcVector_Resize, kNumLoops)
-{
-	rcTempVector<int> v;
-	v.resize(kNumInserts, 2);
-	DoNotOptimize(v.data());
-}
-
-BM(stdvector_Push, kNumLoops)
-{
-	std::vector<int> v;
-	for (int j = 0; j < kNumInserts; j++) {
-		v.push_back(2);
-	}
-	DoNotOptimize(v.data());
-}
-BM(stdvector_PushPreallocated, kNumLoops)
-{
-	std::vector<int> v;
-	v.reserve(kNumInserts);
-	for (int j = 0; j < kNumInserts; j++) {
-		v.push_back(2);
-	}
-	DoNotOptimize(v.data());
-}
-BM(stdvector_Assign, kNumLoops)
-{
-	std::vector<int> v;
-	v.assign(kNumInserts, 2);
-	DoNotOptimize(v.data());
-}
-BM(stdvector_AssignIndices, kNumLoops)
-{
-	std::vector<int> v;
-	v.resize(kNumInserts);
-	for (int j = 0; j < kNumInserts; j++) {
-		v[j] = 2;
-	}
-	DoNotOptimize(v.data());
-}
-BM(stdvector_Resize, kNumLoops)
-{
-	std::vector<int> v;
-	v.resize(kNumInserts, 2);
-	DoNotOptimize(v.data());
-}
-
-#undef BM
-#endif  // _POSIX_TIMERS
-#endif  // __unix__
diff --git a/Tests/Recast/Tests_RecastFilter.cpp b/Tests/Recast/Tests_RecastFilter.cpp
new file mode 100644
index 0000000..1882adb
--- /dev/null
+++ b/Tests/Recast/Tests_RecastFilter.cpp
@@ -0,0 +1,389 @@
+#include <stdio.h>
+#include <string.h>
+#include <vector>
+
+#include "catch2/catch_all.hpp"
+
+#include "Recast.h"
+#include "RecastAlloc.h"
+
+TEST_CASE("rcFilterLowHangingWalkableObstacles", "[recast, filtering]")
+{
+	rcContext context;
+	int walkableHeight = 5;
+
+	rcHeightfield heightfield;
+	heightfield.width = 1;
+	heightfield.height = 1;
+	heightfield.bmin[0] = 0;
+	heightfield.bmin[1] = 0;
+	heightfield.bmin[2] = 0;
+	heightfield.bmax[0] = 1;
+	heightfield.bmax[1] = 1;
+	heightfield.bmax[2] = 1;
+	heightfield.cs = 1;
+	heightfield.ch = 1;
+	heightfield.spans = (rcSpan**)rcAlloc(heightfield.width * heightfield.height * sizeof(rcSpan*), RC_ALLOC_PERM);
+	heightfield.pools = NULL;
+	heightfield.freelist = NULL;
+
+	SECTION("Span with no spans above it is unchanged")
+	{
+		rcSpan* span = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		span->area = 1;
+		span->next = NULL;
+		span->smin = 0;
+		span->smax = 1;
+		heightfield.spans[0] = span;
+
+		rcFilterLowHangingWalkableObstacles(&context, walkableHeight, heightfield);
+
+		REQUIRE(heightfield.spans[0]->area == 1);
+
+		rcFree(span);
+	}
+
+	SECTION("Span with span above that is higher than walkableHeight is unchanged")
+	{
+		// Put the second span just above the first one.
+		rcSpan* secondSpan = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		secondSpan->area = 1;
+		secondSpan->next = NULL;
+		secondSpan->smin = 1 + walkableHeight;
+		secondSpan->smax = secondSpan->smin + 1;
+
+		rcSpan* span = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		span->area = 1;
+		span->next = secondSpan;
+		span->smin = 0;
+		span->smax = 1;
+
+		heightfield.spans[0] = span;
+
+		rcFilterLowHangingWalkableObstacles(&context, walkableHeight, heightfield);
+
+		// Check that nothing has changed.
+		REQUIRE(heightfield.spans[0]->area == 1);
+		REQUIRE(heightfield.spans[0]->next->area == 1);
+
+		// Check again but with a more clearance
+		secondSpan->smin += 10;
+		secondSpan->smax += 10;
+
+		rcFilterLowHangingWalkableObstacles(&context, walkableHeight, heightfield);
+
+		// Check that nothing has changed.
+		REQUIRE(heightfield.spans[0]->area == 1);
+		REQUIRE(heightfield.spans[0]->next->area == 1);
+
+		rcFree(span);
+		rcFree(secondSpan);
+	}
+
+	SECTION("Marks low obstacles walkable if they're below the walkableClimb")
+	{
+		// Put the second span just above the first one.
+		rcSpan* secondSpan = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		secondSpan->area = RC_NULL_AREA;
+		secondSpan->next = NULL;
+		secondSpan->smin = 1 + (walkableHeight - 1);
+		secondSpan->smax = secondSpan->smin + 1;
+
+		rcSpan* span = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		span->area = 1;
+		span->next = secondSpan;
+		span->smin = 0;
+		span->smax = 1;
+
+		heightfield.spans[0] = span;
+
+		rcFilterLowHangingWalkableObstacles(&context, walkableHeight, heightfield);
+
+		// Check that the second span was changed to walkable.
+		REQUIRE(heightfield.spans[0]->area == 1);
+		REQUIRE(heightfield.spans[0]->next->area == 1);
+
+		rcFree(span);
+		rcFree(secondSpan);
+	}
+
+	SECTION("Low obstacle that overlaps the walkableClimb distance is not changed")
+	{
+		// Put the second span just above the first one.
+		rcSpan* secondSpan = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		secondSpan->area = RC_NULL_AREA;
+		secondSpan->next = NULL;
+		secondSpan->smin = 2 + (walkableHeight - 1);
+		secondSpan->smax = secondSpan->smin + 1;
+
+		rcSpan* span = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		span->area = 1;
+		span->next = secondSpan;
+		span->smin = 0;
+		span->smax = 1;
+
+		heightfield.spans[0] = span;
+
+		rcFilterLowHangingWalkableObstacles(&context, walkableHeight, heightfield);
+
+		// Check that the second span was changed to walkable.
+		REQUIRE(heightfield.spans[0]->area == 1);
+		REQUIRE(heightfield.spans[0]->next->area == RC_NULL_AREA);
+
+		rcFree(span);
+		rcFree(secondSpan);
+	}
+
+	SECTION("Only the first of multiple, low obstacles are marked walkable")
+	{
+		rcSpan* span = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		span->area = 1;
+		span->next = NULL;
+		span->smin = 0;
+		span->smax = 1;
+		heightfield.spans[0] = span;
+
+		rcSpan* previousSpan = span;
+		for (int i = 0; i < 9; ++i)
+		{
+			rcSpan* nextSpan = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+			nextSpan->area = RC_NULL_AREA;
+			nextSpan->next = NULL;
+			nextSpan->smin = previousSpan->smax + (walkableHeight - 1);
+			nextSpan->smax = nextSpan->smin + 1;
+			previousSpan->next = nextSpan;
+			previousSpan = nextSpan;
+		}
+
+		rcFilterLowHangingWalkableObstacles(&context, walkableHeight, heightfield);
+
+		rcSpan* currentSpan = heightfield.spans[0];
+		for (int i = 0; i < 10; ++i)
+		{
+			REQUIRE(currentSpan != NULL);
+			// only the first and second spans should be marked as walkabl
+			REQUIRE(currentSpan->area == (i <= 1 ? 1 : RC_NULL_AREA));
+			currentSpan = currentSpan->next;
+		}
+
+		std::vector<rcSpan*> toFree;
+		span = heightfield.spans[0];
+		for (int i = 0; i < 10; ++i)
+		{
+			toFree.push_back(span);
+			span = span->next;
+		}
+
+		for (int i = 0; i < 10; ++i)
+		{
+			rcFree(toFree[i]);
+		}
+	}
+}
+
+TEST_CASE("rcFilterLedgeSpans", "[recast, filtering]")
+{
+	rcContext context;
+	int walkableClimb = 5;
+	int walkableHeight = 10;
+
+	rcHeightfield heightfield;
+	heightfield.width = 10;
+	heightfield.height = 10;
+	heightfield.bmin[0] = 0;
+	heightfield.bmin[1] = 0;
+	heightfield.bmin[2] = 0;
+	heightfield.bmax[0] = 10;
+	heightfield.bmax[1] = 1;
+	heightfield.bmax[2] = 10;
+	heightfield.cs = 1;
+	heightfield.ch = 1;
+	heightfield.spans = (rcSpan**)rcAlloc(heightfield.width * heightfield.height * sizeof(rcSpan*), RC_ALLOC_PERM);
+	heightfield.pools = NULL;
+	heightfield.freelist = NULL;
+
+	SECTION("Edge spans are marked unwalkable")
+	{
+		// Create a flat plane.
+		for (int x = 0; x < heightfield.width; ++x)
+		{
+			for (int z = 0; z < heightfield.height; ++z)
+			{
+				rcSpan* span = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+				span->area = 1;
+				span->next = NULL;
+				span->smin = 0;
+				span->smax = 1;
+				heightfield.spans[x + z * heightfield.width] = span;
+			}
+		}
+
+		rcFilterLedgeSpans(&context, walkableHeight, walkableClimb, heightfield);
+
+		for (int x = 0; x < heightfield.width; ++x)
+		{
+			for (int z = 0; z < heightfield.height; ++z)
+			{
+				rcSpan* span = heightfield.spans[x + z * heightfield.width];
+				REQUIRE(span != NULL);
+
+				if (x == 0 || z == 0 || x == 9 || z == 9)
+				{
+					REQUIRE(span->area == RC_NULL_AREA);
+				}
+				else
+				{
+					REQUIRE(span->area == 1);
+				}
+
+				REQUIRE(span->next == NULL);
+				REQUIRE(span->smin == 0);
+				REQUIRE(span->smax == 1);
+			}
+		}
+
+		// Free all the heightfield spans
+		for (int x = 0; x < heightfield.width; ++x)
+		{
+			for (int z = 0; z < heightfield.height; ++z)
+			{
+				rcFree(heightfield.spans[x + z * heightfield.width]);
+			}
+		}
+	}
+
+	SECTION("Edge spans are marked unwalkable")
+	{
+		// Create a flat plane.
+		for (int x = 0; x < heightfield.width; ++x)
+		{
+			for (int z = 0; z < heightfield.height; ++z)
+			{
+				rcSpan* span = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+				span->area = 1;
+				span->next = NULL;
+				span->smin = 0;
+				span->smax = 1;
+				heightfield.spans[x + z * heightfield.width] = span;
+			}
+		}
+
+		rcFilterLedgeSpans(&context, walkableHeight, walkableClimb, heightfield);
+
+		for (int x = 0; x < heightfield.width; ++x)
+		{
+			for (int z = 0; z < heightfield.height; ++z)
+			{
+				rcSpan* span = heightfield.spans[x + z * heightfield.width];
+				REQUIRE(span != NULL);
+
+				if (x == 0 || z == 0 || x == 9 || z == 9)
+				{
+					REQUIRE(span->area == RC_NULL_AREA);
+				}
+				else
+				{
+					REQUIRE(span->area == 1);
+				}
+
+				REQUIRE(span->next == NULL);
+				REQUIRE(span->smin == 0);
+				REQUIRE(span->smax == 1);
+			}
+		}
+
+		// Free all the heightfield spans
+		for (int x = 0; x < heightfield.width; ++x)
+		{
+			for (int z = 0; z < heightfield.height; ++z)
+			{
+				rcFree(heightfield.spans[x + z * heightfield.width]);
+			}
+		}
+	}
+}
+
+TEST_CASE("rcFilterWalkableLowHeightSpans", "[recast, filtering]")
+{
+	rcContext context;
+	int walkableHeight = 5;
+
+	rcHeightfield heightfield;
+	heightfield.width = 1;
+	heightfield.height = 1;
+	heightfield.bmin[0] = 0;
+	heightfield.bmin[1] = 0;
+	heightfield.bmin[2] = 0;
+	heightfield.bmax[0] = 1;
+	heightfield.bmax[1] = 1;
+	heightfield.bmax[2] = 1;
+	heightfield.cs = 1;
+	heightfield.ch = 1;
+	heightfield.spans = (rcSpan**)rcAlloc(heightfield.width * heightfield.height * sizeof(rcSpan*), RC_ALLOC_PERM);
+	heightfield.pools = NULL;
+	heightfield.freelist = NULL;
+
+	SECTION("span nothing above is unchanged")
+	{
+		rcSpan* span = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		span->area = 1;
+		span->next = NULL;
+		span->smin = 0;
+		span->smax = 1;
+		heightfield.spans[0] = span;
+
+		rcFilterWalkableLowHeightSpans(&context, walkableHeight, heightfield);
+
+		REQUIRE(heightfield.spans[0]->area == 1);
+
+		rcFree(span);
+	}
+
+	SECTION("span with lots of room above is unchanged")
+	{
+		rcSpan* overheadSpan = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		overheadSpan->area = RC_NULL_AREA;
+		overheadSpan->next = NULL;
+		overheadSpan->smin = 10;
+		overheadSpan->smax = 11;
+
+		rcSpan* span = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		span->area = 1;
+		span->next = overheadSpan;
+		span->smin = 0;
+		span->smax = 1;
+		heightfield.spans[0] = span;
+
+		rcFilterWalkableLowHeightSpans(&context, walkableHeight, heightfield);
+
+		REQUIRE(heightfield.spans[0]->area == 1);
+		REQUIRE(heightfield.spans[0]->next->area == RC_NULL_AREA);
+
+		rcFree(overheadSpan);
+		rcFree(span);
+	}
+
+	SECTION("Span with low hanging obstacle is marked as unwalkable")
+	{
+		rcSpan* overheadSpan = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		overheadSpan->area = RC_NULL_AREA;
+		overheadSpan->next = NULL;
+		overheadSpan->smin = 3;
+		overheadSpan->smax = 4;
+
+		rcSpan* span = (rcSpan*)rcAlloc(sizeof(rcSpan), RC_ALLOC_PERM);
+		span->area = 1;
+		span->next = overheadSpan;
+		span->smin = 0;
+		span->smax = 1;
+		heightfield.spans[0] = span;
+
+		rcFilterWalkableLowHeightSpans(&context, walkableHeight, heightfield);
+
+		REQUIRE(heightfield.spans[0]->area == RC_NULL_AREA);
+		REQUIRE(heightfield.spans[0]->next->area == RC_NULL_AREA);
+
+		rcFree(overheadSpan);
+		rcFree(span);
+	}
+}
\ No newline at end of file
-- 
2.43.0