Subversion Repository Public Repository

Divide-Dependencies

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//  * Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//  * Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//  * Neither the name of NVIDIA CORPORATION nor the names of its
//    contributors may be used to endorse or promote products derived
//    from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2009-2018 NVIDIA Corporation. All rights reserved.


#ifndef RENDER_DEBUG_DATA_H
#define RENDER_DEBUG_DATA_H

/*!
\file
\brief debug rendering classes and structures
*/
#include "PxVec2.h"
#include "PxVec3.h"
#include "PxVec4.h"
#include "PxQuat.h"
#include "PxMat33.h"
#include "PxMat44.h"
#include "PsIntrinsics.h"
#include "RenderDebugImpl.h"
#include "RenderDebug.h"
#include <new>

#define MAX_SEND_BUFFER 16384 // send up to 16384 at a time.

namespace RENDER_DEBUG
{

PX_PUSH_PACK_DEFAULT

struct DebugPrimitive;
struct DebugGraphDesc;

//********************************************************************
//********************************************************************


// This enumeration defines the list of graphics primitives that can be generated by the debug renderer.
struct DebugCommand
{
	enum Enum
	{
		SET_CURRENT_RENDER_STATE,	// set the current render state bit flags
		SET_CURRENT_TEXT_SCALE,		// set the floating point scale for 3d text printing.
		SET_CURRENT_COLOR,			// set the current pen color
		SET_CURRENT_ARROW_COLOR,	// set the current arrow (secondary) color
		SET_CURRENT_TEXTURE1,		// set the current texture id
		SET_CURRENT_TEXTURE2,		// set the current texture id
		SET_CURRENT_TILE1,
		SET_CURRENT_TILE2,
		SET_CURRENT_TRANSFORM,		// set the current matrix transform for graphics primitives
		SET_CURRENT_RENDER_SCALE,	// set the current overall render scale.
		SET_CURRENT_ARROW_SIZE,		// set the current size of arrow heads
		SET_CURRENT_USER_ID,		// sets the current user id.
		DEBUG_LINE,					// render a single line segment
		DRAW_GRID,					// render a 3d studio max style grid.
		DEBUG_TEXT,					// display 3d text
		DEBUG_MESSAGE,	// A debug message or a command
		DEBUG_BOUND,				// display a bounding box
		DEBUG_FRUSTUM,				// debug display a view frustum
		DEBUG_POINT,				// highlight a point
		DEBUG_POINT_SCALE,			// Debug a point with different scale on x/y/z
		DEBUG_QUAD,					// Debug a scaled and oriented screen facing quad
		DEBUG_RECT2D,				// display a 2d rectangle
		DEBUG_GRADIENT_LINE,		// draw a line segment with a unique color for each point.
		DEBUG_RAY,					// draw a ray (line with arrow on the end)
		DEBUG_CYLINDER,				// draw a cylinder assuming the default orientation of the PhysX SDK
		DEBUG_POINT_CYLINDER,		// draw a cylinder between two points
		DEBUG_THICK_RAY,			// draw a thick ray, full 3d arrow head.
		DEBUG_PLANE,				// debug visualization of a plane equation (drawn as concentric circles)
		DEBUG_TRI,					// debug visualize a triangle solid/wireframe determined by the current render state.
		DEBUG_TRI_NORMALS,			// debug visualize a triangle using the provided vertex normals
		DEBUG_GRADIENT_TRI,			// debug visualize a solid shaded triangle with unique vertex colors
		DEBUG_GRADIENT_TRI_NORMALS,	// debug visualize a solid shaded triangle with unique vertex normals and vertex colors
		DEBUG_SPHERE,				// debug visualize a coarse sphere
		DEBUG_SQUASHED_SPHERE,		// debug visualize a sphere that has been squashed
		DEBUG_CAPSULE,				// debug visualize a capsule (assumed PhysX SDK orientation) i.e. Y up is 'height'
		DEBUG_AXES,					// debug visualize a set of axes using thick-rays.
		DEBUG_ARC,					// debug visualize an arc.
		DEBUG_THICK_ARC,			// debug visualize a thick arc
		DEBUG_DETAILED_SPHERE,		// debug visualize a highly detailed sphere
		DEBUG_BLOCK_INFO,			// used internally only.
		DEBUG_GRAPH,                // display a graph
		DEBUG_CAPSULE_TAPERED,		// debug visualize a capsule with y-up as height
		DEBUG_CIRCLE,				// debug visualize an oriented circle
		DEBUG_CREATE_TRIANGLE_MESH,	// Create a triangle mesh to render
		DEBUG_RENDER_TRIANGLE_MESH_INSTANCES, // render a sequence of triangle mesh instances
		DEBUG_RELEASE_TRIANGLE_MESH,
		DEBUG_CONE,
		DEBUG_REFRESH_TRIANGLE_MESH_VERTICES,
		DEBUG_TEXT2D,
		DEBUG_CREATE_CUSTOM_TEXTURE,
		DEBUG_RENDER_POINTS,
		DEBUG_RENDER_LINES,
		DEBUG_RENDER_TRIANGLES,
		DEBUG_REGISTER_INPUT_EVENT,
		DEBUG_RESET_INPUT_EVENTS,
		DEBUG_UNREGISTER_INPUT_EVENT,
		DEBUG_SKIP_FRAME,
		DEBUG_CONVEX_HULL,
		DEBUG_LAST
	};
	static PX_INLINE uint32_t getPrimtiveSize(const DebugPrimitive &p); // returns the size of the data associated with a particular primitive type.
};

PX_INLINE void swap4Bytes(void* _data) 
{
	char *data = static_cast<char*>(_data);
	char one_byte;
	one_byte = data[0]; data[0] = data[3]; data[3] = one_byte;
	one_byte = data[1]; data[1] = data[2]; data[2] = one_byte;
}

PX_INLINE void endianSwap(float &v)
{
	swap4Bytes(&v);
}

PX_INLINE void endianSwap(uint32_t &v)
{
	swap4Bytes(&v);
}

PX_INLINE void endianSwap(int32_t &v)
{
	swap4Bytes(&v);
}

PX_INLINE void endianSwap(physx::PxVec2 &v)
{
	swap4Bytes(&v.x);
	swap4Bytes(&v.y);
}

PX_INLINE void endianSwap(physx::PxVec3 &v)
{
	swap4Bytes(&v.x);
	swap4Bytes(&v.y);
	swap4Bytes(&v.z);
}

PX_INLINE void endianSwap(physx::PxVec4 &v)
{
	swap4Bytes(&v.x);
	swap4Bytes(&v.y);
	swap4Bytes(&v.z);
	swap4Bytes(&v.w);
}

PX_INLINE void endianSwap(physx::PxQuat &v)
{
	swap4Bytes(&v.x);
	swap4Bytes(&v.y);
	swap4Bytes(&v.z);
	swap4Bytes(&v.w);
}

PX_INLINE void endianSwap(physx::PxTransform &v)
{
	endianSwap(v.p);
	endianSwap(v.q);
}

PX_INLINE void endianSwap(physx::PxMat33 &v)
{
	uint32_t count = sizeof(v)/4;
	uint32_t *s = reinterpret_cast<uint32_t *>(&v);
	for (uint32_t i=0; i<count; i++)
	{
		swap4Bytes(s);
		s++;
	}
}

PX_INLINE void endianSwap(physx::PxMat44 &v)
{
	uint32_t count = sizeof(v)/4;
	uint32_t *s = reinterpret_cast<uint32_t *>(&v);
	for (uint32_t i=0; i<count; i++)
	{
		swap4Bytes(s);
		s++;
	}
}


// The base class for all debug primitives
struct DebugPrimitive
{
	DebugPrimitive(void) { }
	DebugPrimitive(DebugCommand::Enum c) : mCommand(c)
	{
	}

	void endianFixup(void)
	{
		swap4Bytes(&mCommand);
	}

	uint32_t 	mCommand;
};

// used to transmit render state, current color or other single unsigned int primitives.
struct DebugPrimitiveU32	 : public DebugPrimitive
{
	DebugPrimitiveU32(void) { }
	DebugPrimitiveU32(DebugCommand::Enum cmd,uint32_t v) :
	DebugPrimitive(cmd),
		mValue(v)
	{
	}

	void adjustEndian(void)
	{
		endianSwap(mValue);
	}

	uint32_t mValue;
};

// used to transmit render scale, text scale, or other single float primitives.
struct DebugPrimitiveF32	 : public DebugPrimitive
{
	DebugPrimitiveF32(void) { }
	DebugPrimitiveF32(DebugCommand::Enum cmd,float v) :
	DebugPrimitive(cmd),
		mValue(v)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mValue);
	}

	float mValue;
};
	
// Defines a primitive for a line segment
struct DebugLine : public DebugPrimitive
{
	DebugLine(void) { }
	DebugLine(const physx::PxVec3 &p1,const physx::PxVec3 &p2) :
	DebugPrimitive(DebugCommand::DEBUG_LINE),
		mP1(p1),
		mP2(p2)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mP1);
		endianSwap(mP2);
	}

	physx::PxVec3	mP1;
	physx::PxVec3	mP2;
};

// Defines a primitive to draw a grid visualization
struct DrawGrid : public DebugPrimitive
{
	DrawGrid(void) { }
	DrawGrid(bool zup,uint32_t gridSize) :
	DebugPrimitive(DebugCommand::DRAW_GRID),
		mZup(uint32_t(zup)),
		mGridSize(gridSize)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mZup);
		endianSwap(mGridSize);
	}


	uint32_t	mZup;
	uint32_t 	mGridSize;
};

// Defines a primitive to transmit a piece of 3d ASCII text.
#define MAX_DEBUG_MESSAGE_STRING 128
struct DebugMessage : public DebugPrimitive
{
	DebugMessage(void) { }
	DebugMessage(const char *text) : 
	DebugPrimitive(DebugCommand::DEBUG_MESSAGE)
	{
		const char *source = text;
		char *dest = mText;
		char *stop = &mText[MAX_DEBUG_MESSAGE_STRING-1];
		while ( *source && dest < stop )
		{
			*dest++ = *source++;
		}
		*dest = 0;
	}
	void adjustEndian(void)
	{
	}

	char		mText[MAX_DEBUG_MESSAGE_STRING];
};



// Defines a primitive to transmit a piece of 3d ASCII text.
#define MAX_DEBUG_TEXT_STRING 256
struct DebugText : public DebugPrimitive
{
	DebugText(void) { }
	DebugText(const physx::PxVec3 &position,const physx::PxMat44 &pose,const char *text) : 
	DebugPrimitive(DebugCommand::DEBUG_TEXT),
		mPosition(position),
		mPose(pose)
	{
		const char *source = text;
		char *dest = mText;
		char *stop = &mText[MAX_DEBUG_TEXT_STRING-1];
		while ( *source && dest < stop )
		{
			*dest++ = *source++;
		}
		*dest = 0;
	}
	void adjustEndian(void)
	{
		endianSwap(mPosition);
		endianSwap(mPose);
	}

	physx::PxVec3	mPosition; // relative offset from the pose
	physx::PxMat44	mPose;
	char			mText[MAX_DEBUG_TEXT_STRING];
};

struct DebugText2D : public DebugPrimitive
{
	DebugText2D(void) { }
	DebugText2D(const physx::PxVec2 &position,float scale,float shadowOffset,bool forceFixedWidthNumbers,uint32_t textColor,const char *text) : 
	DebugPrimitive(DebugCommand::DEBUG_TEXT2D),
		mPosition(position),
		mScale(scale),
		mShadowOffset(shadowOffset),
		mForceFixWidthNumbers( forceFixedWidthNumbers ? uint32_t(1) : uint32_t(0)),
		mTextColor(textColor)
	{
		const char *source = text;
		char *dest = mText;
		char *stop = &mText[MAX_DEBUG_TEXT_STRING-1];
		while ( *source && dest < stop )
		{
			*dest++ = *source++;
		}
		*dest = 0;
	}

	void adjustEndian(void)
	{
		endianSwap(mPosition);
		endianSwap(mScale);
		endianSwap(mShadowOffset);
		endianSwap(mForceFixWidthNumbers);
		endianSwap(mTextColor);
	}

	physx::PxVec2	mPosition;
	float			mScale;
	float			mShadowOffset;
	uint32_t		mForceFixWidthNumbers;
	uint32_t		mTextColor;
	char			mText[MAX_DEBUG_TEXT_STRING];
};



struct DebugFrustum : public DebugPrimitive
{
	DebugFrustum(void) { }
	DebugFrustum(const physx::PxMat44 &view,const physx::PxMat44 &proj) : 
	DebugPrimitive(DebugCommand::DEBUG_FRUSTUM),mView(view),mProj(proj)
	{

	}
	void adjustEndian(void)
	{
		endianSwap(mView);
		endianSwap(mProj);
	}


	physx::PxMat44	mView;
	physx::PxMat44 mProj;
};

struct DebugCone : public DebugPrimitive
{
	DebugCone(void) { }
	DebugCone(float length,float innerAngle,float outerAngle,uint32_t subDivision,bool closeEnd) : 
	DebugPrimitive(DebugCommand::DEBUG_CONE),mLength(length),mInnerAngle(innerAngle),mOuterAngle(outerAngle),mSubdivision(subDivision),mCloseEnd(uint32_t(closeEnd))
	{

	}
	void adjustEndian(void)
	{
		endianSwap(mLength);
		endianSwap(mInnerAngle);
		endianSwap(mOuterAngle);
		endianSwap(mSubdivision);
		endianSwap(mCloseEnd);
	}


	float			mLength;
	float			mInnerAngle;
	float			mOuterAngle;
	uint32_t		mSubdivision;
	uint32_t		mCloseEnd;
};

struct DebugRegisterInputEvent : public DebugPrimitive
{
	DebugRegisterInputEvent(void) { }
	DebugRegisterInputEvent(bool isDigital,InputEventIds::Enum eventId,float sensitivity,InputIds::Enum inputId) : 
	DebugPrimitive(DebugCommand::DEBUG_REGISTER_INPUT_EVENT),
		mDigital( isDigital ? 1U : 0U),
		mEventId( uint32_t(eventId)),
		mSensitivity( sensitivity),
		mInputId( uint32_t(inputId))
	{

	}
	void adjustEndian(void)
	{
		endianSwap(mDigital);
		endianSwap(mEventId);
		endianSwap(mSensitivity);
		endianSwap(mInputId);
	}

	uint32_t	mDigital;
	uint32_t	mEventId;
	float		mSensitivity;
	uint32_t	mInputId;
};

struct DebugUnregisterInputEvent : public DebugPrimitive
{
	DebugUnregisterInputEvent(void) { }
	DebugUnregisterInputEvent(InputEventIds::Enum eventId) : 
	DebugPrimitive(DebugCommand::DEBUG_UNREGISTER_INPUT_EVENT),
		mEventId( uint32_t( eventId))
	{

	}
	void adjustEndian(void)
	{
		endianSwap(mEventId);
	}

	uint32_t	mEventId;
};

// Defines a primitive to draw a bounding box
struct DebugBound : public DebugPrimitive
{
	DebugBound(void) { }
	DebugBound(const physx::PxVec3 &bmin,const physx::PxVec3 &bmax) : 
	DebugPrimitive(DebugCommand::DEBUG_BOUND),mBmin(bmin),mBmax(bmax)
	{

	}
	void adjustEndian(void)
	{
		endianSwap(mBmin);
		endianSwap(mBmax);
	}

	physx::PxVec3	mBmin;
	physx::PxVec3	mBmax;
};

// Defines a primitive which display a debug point visualization.
struct DebugPoint : public DebugPrimitive
{
	DebugPoint(void) {}
	DebugPoint(const physx::PxVec3 &point,float size) :
	DebugPrimitive(DebugCommand::DEBUG_POINT),
		mPos(point),
		mSize(size)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mPos);
		endianSwap(mSize);
	}


	physx::PxVec3	mPos;
	float			mSize;
};


struct DebugQuad : public DebugPrimitive
{
	DebugQuad(void) {}
	DebugQuad(const physx::PxVec3 &point,const physx::PxVec2 &scale,float rotation) :
	DebugPrimitive(DebugCommand::DEBUG_QUAD),
		mPos(point),
		mScale(scale),
		mRotation(rotation)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mPos);
		endianSwap(mScale);
		endianSwap(mRotation);
	}


	physx::PxVec3	mPos;
	physx::PxVec2	mScale;
	float			mRotation;
};


struct DebugPointScale : public DebugPrimitive
{
	DebugPointScale(void) {}
	DebugPointScale(const physx::PxVec3 &point,physx::PxVec3 size) :
	DebugPrimitive(DebugCommand::DEBUG_POINT_SCALE),
		mPos(point),
		mSize(size)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mPos);
		endianSwap(mSize);
	}


	physx::PxVec3	mPos;
	physx::PxVec3	mSize;
};


// Defines a primitive to display 2d rectangle in screenspace.
struct DebugRect2d : public DebugPrimitive
{
	DebugRect2d(void) { }
	DebugRect2d(float x1,float y1,float x2,float y2) :
	DebugPrimitive(DebugCommand::DEBUG_RECT2D),
		mX1(x1),
		mY1(y1),
		mX2(x2),
		mY2(y2)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mX1);
		endianSwap(mY1);
		endianSwap(mX2);
		endianSwap(mY2);
	}


	float	mX1;
	float	mY1;
	float	mX2;
	float	mY2;
};

// Defines a primitive for a gradient colored line segment
struct DebugGradientLine : public DebugPrimitive
{
	DebugGradientLine(void) { }
	DebugGradientLine(const physx::PxVec3 &p1,const physx::PxVec3 &p2,uint32_t c1,uint32_t c2) :
	DebugPrimitive(DebugCommand::DEBUG_GRADIENT_LINE),
		mP1(p1),
		mP2(p2),
		mC1(c1),
		mC2(c2)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mP1);
		endianSwap(mP2);
		endianSwap(mC1);
		endianSwap(mC2);
	}


	physx::PxVec3	mP1;
	physx::PxVec3	mP2;
	uint32_t		mC1;
	uint32_t		mC2;
};

// Defines a primitive to draw a ray indicator (line segment with arrow-head)
struct DebugRay : public DebugPrimitive
{
	DebugRay(void) { }
	DebugRay(const physx::PxVec3 &p1,const physx::PxVec3 &p2) :
	DebugPrimitive(DebugCommand::DEBUG_RAY),
		mP1(p1),
		mP2(p2)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mP1);
		endianSwap(mP2);
	}


	physx::PxVec3	mP1;
	physx::PxVec3	mP2;
};

// Defines a primitive to draw a thick ray (solid shaded arrow head)
struct DebugThickRay : public DebugPrimitive
{
	DebugThickRay(void) { }
	DebugThickRay(const physx::PxVec3 &p1,const physx::PxVec3 &p2,float raySize, bool arrowTip) :
	DebugPrimitive(DebugCommand::DEBUG_THICK_RAY),
		mP1(p1),
		mP2(p2),
		mRaySize(raySize),
		mArrowTip(uint32_t(arrowTip))
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mP1);
		endianSwap(mP2);
	}


	physx::PxVec3	mP1;
	physx::PxVec3	mP2;
	float			mRaySize;
	uint32_t		mArrowTip;
};

// Defines a primitive to visualize a plane equation
struct DebugPlane : public DebugPrimitive
{
	DebugPlane(void) { }
	DebugPlane(const physx::PxVec3 &normal,float dCoff,float radius1,float radius2) :
	DebugPrimitive(DebugCommand::DEBUG_PLANE),
		mNormal(normal),
		mD(dCoff),
		mRadius1(radius1),
		mRadius2(radius2)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mNormal);
		endianSwap(mD);
		endianSwap(mRadius1);
		endianSwap(mRadius2);
	}


	physx::PxVec3	mNormal;
	float			mD;
	float			mRadius1;
	float			mRadius2;
};

// Defines a primitive to visualize a single triangle, either wireframe, or solid, or both based on the current render state bit flags
struct DebugTri : public DebugPrimitive
{
	DebugTri(void) { }
	DebugTri(const physx::PxVec3 &p1,const physx::PxVec3 &p2,const physx::PxVec3 &p3) :
	DebugPrimitive(DebugCommand::DEBUG_TRI),
		mP1(p1),
		mP2(p2),
		mP3(p3)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mP1);
		endianSwap(mP2);
		endianSwap(mP3);
	}


	physx::PxVec3	mP1;
	physx::PxVec3	mP2;
	physx::PxVec3	mP3;
};

struct DebugTriNormals : public DebugPrimitive
{
	DebugTriNormals(void) { }
	DebugTriNormals(const physx::PxVec3 &p1,const physx::PxVec3 &p2,const physx::PxVec3 &p3,const physx::PxVec3 &n1,const physx::PxVec3 &n2,const physx::PxVec3 &n3) :
	DebugPrimitive(DebugCommand::DEBUG_TRI_NORMALS),
		mP1(p1),mP2(p2),mP3(p3),
		mN1(n1),mN2(n2),mN3(n3)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mP1);
		endianSwap(mP2);
		endianSwap(mP3);
		endianSwap(mN1);
		endianSwap(mN2);
		endianSwap(mN3);
	}


	physx::PxVec3	mP1;
	physx::PxVec3	mP2;
	physx::PxVec3	mP3;
	physx::PxVec3	mN1;
	physx::PxVec3	mN2;
	physx::PxVec3	mN3;
};

struct DebugGradientTri : public DebugPrimitive
{
	DebugGradientTri(void) { }
	DebugGradientTri(const physx::PxVec3 &p1,const physx::PxVec3 &p2,const physx::PxVec3 &p3,const uint32_t &c1,const uint32_t &c2,const uint32_t &c3) :
	DebugPrimitive(DebugCommand::DEBUG_GRADIENT_TRI),
		mP1(p1),mP2(p2),mP3(p3),
		mC1(c1),mC2(c2),mC3(c3)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mP1);
		endianSwap(mP2);
		endianSwap(mP3);
		endianSwap(mC1);
		endianSwap(mC2);
		endianSwap(mC3);
	}

	physx::PxVec3	mP1;
	physx::PxVec3	mP2;
	physx::PxVec3	mP3;
	uint32_t		mC1;
	uint32_t		mC2;
	uint32_t		mC3;
};

struct DebugGradientTriNormals : public DebugPrimitive
{
	DebugGradientTriNormals(void) { }
	DebugGradientTriNormals(const physx::PxVec3 &p1,const physx::PxVec3 &p2,const physx::PxVec3 &p3,const physx::PxVec3 &n1,const physx::PxVec3 &n2,const physx::PxVec3 &n3,const uint32_t &c1,const uint32_t &c2,const uint32_t &c3) :
	DebugPrimitive(DebugCommand::DEBUG_GRADIENT_TRI_NORMALS),
		mP1(p1),mP2(p2),mP3(p3),
		mN1(n1),mN2(n2),mN3(n3),
		mC1(c1),mC2(c2),mC3(c3)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mP1);
		endianSwap(mP2);
		endianSwap(mP3);
		endianSwap(mN1);
		endianSwap(mN2);
		endianSwap(mN3);
		endianSwap(mC1);
		endianSwap(mC2);
		endianSwap(mC3);
	}


	physx::PxVec3	mP1;
	physx::PxVec3	mP2;
	physx::PxVec3	mP3;
	physx::PxVec3	mN1;
	physx::PxVec3	mN2;
	physx::PxVec3	mN3;
	uint32_t		mC1;
	uint32_t		mC2;
	uint32_t		mC3;
};

struct DebugSphere : public DebugPrimitive
{
	DebugSphere(void) { }
	DebugSphere(float radius, uint32_t subdivision) :
	DebugPrimitive(DebugCommand::DEBUG_SPHERE),
		mRadius(radius),
		mSubdivision(subdivision)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mRadius);
		endianSwap(mSubdivision);
	}


	float		mRadius;
	uint32_t	mSubdivision;
};

struct DebugSquashedSphere : public DebugPrimitive
{
	DebugSquashedSphere(void) { }
	DebugSquashedSphere(const physx::PxVec3 &radius, uint32_t subdivision) :
	DebugPrimitive(DebugCommand::DEBUG_SQUASHED_SPHERE),
		mRadius(radius),
		mSubdivision(subdivision)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mRadius);
		endianSwap(mSubdivision);
	}


	physx::PxVec3	mRadius;
	uint32_t		mSubdivision;
};


struct DebugCapsule : public DebugPrimitive
{
	DebugCapsule(void) { }
	DebugCapsule(float radius,float height,uint32_t subdivision) :
	DebugPrimitive(DebugCommand::DEBUG_CAPSULE),
		mRadius(radius),
		mHeight(height),
		mSubdivision(subdivision)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mRadius);
		endianSwap(mHeight);
		endianSwap(mSubdivision);
	}


	float		mRadius;
	float		mHeight;
	uint32_t	mSubdivision;
};

struct DebugTaperedCapsule : public DebugPrimitive
{
	DebugTaperedCapsule() { }
	DebugTaperedCapsule(float radius1, float radius2, float height, uint32_t subdivision) :
	DebugPrimitive(DebugCommand::DEBUG_CAPSULE_TAPERED),
		mRadius1(radius1),
		mRadius2(radius2),
		mHeight(height),
		mSubdivision(subdivision)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mRadius1);
		endianSwap(mRadius2);
		endianSwap(mHeight);
		endianSwap(mSubdivision);
	}


	float mRadius1;
	float mRadius2;
	float mHeight;
	uint32_t mSubdivision;
};

struct DebugPointCylinder : public DebugPrimitive
{
	DebugPointCylinder(void) { }
	DebugPointCylinder(const physx::PxVec3 &p1,const physx::PxVec3 &p2,float radius) :
	DebugPrimitive(DebugCommand::DEBUG_POINT_CYLINDER),
		mP1(p1),
		mP2(p2),
		mRadius(radius)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mP1);
		endianSwap(mP2);
		endianSwap(mRadius);
	}


	physx::PxVec3	mP1;
	physx::PxVec3	mP2;
	float			mRadius;
};


struct DebugCylinder : public DebugPrimitive
{
	DebugCylinder(void) { }
	DebugCylinder(float radius,float height,uint32_t subdivision,bool closeSides) :
	DebugPrimitive(DebugCommand::DEBUG_CYLINDER),
		mRadius1(radius),
		mRadius2(radius),
		mHeight(height),
		mSubdivision(subdivision),
		mCloseSides(uint32_t(closeSides))
	{
	}

	DebugCylinder(float radius1, float radius2, float height, uint32_t subdivision, bool closeSides) :
	DebugPrimitive(DebugCommand::DEBUG_CYLINDER),
		mRadius1(radius1),
		mRadius2(radius2),
		mHeight(height),
		mSubdivision(subdivision),
		mCloseSides(uint32_t(closeSides))
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mRadius1);
		endianSwap(mRadius2);
		endianSwap(mHeight);
		endianSwap(mSubdivision);
		endianSwap(mCloseSides);
	}


	float		mRadius1;
	float		mRadius2;
	float		mHeight;
	uint32_t	mSubdivision;
	uint32_t	mCloseSides;
};

struct DebugCircle : public DebugPrimitive
{
	DebugCircle(void) { }
	DebugCircle(float radius, 
				uint32_t subdivision, 
				bool solid) :
		DebugPrimitive(DebugCommand::DEBUG_CIRCLE),
		mTransform(physx::PxIdentity),
		mRadius(radius),
		mSubdivision(subdivision),
		mDrawSolidCircle(solid)
	{
	}

	void adjustEndian(void)
	{
		endianSwap(mRadius);
		endianSwap(mTransform);
		endianSwap(mSubdivision);
		endianSwap(mDrawSolidCircle);
	}

	physx::PxMat44 mTransform;
	float		   mRadius;
	uint32_t	   mSubdivision;
	int32_t		   mDrawSolidCircle;
};

struct DebugAxes : public DebugPrimitive
{
	DebugAxes(void) { }
	DebugAxes(const physx::PxMat44 &transform,float distance,float brightness,bool showXYZ,bool showRotation, uint32_t axisSwitch, DebugAxesRenderMode::Enum renderMode) :
	DebugPrimitive(DebugCommand::DEBUG_AXES),
		mTransform(transform),
		mDistance(distance),
		mBrightness(brightness),
		mShowXYZ(uint32_t(showXYZ)),
		mShowRotation(uint32_t(showRotation)),
		mAxisSwitch(axisSwitch),
		mRenderMode(renderMode)
	{
	}

	void adjustEndian(void)
	{
		endianSwap(mTransform);
		endianSwap(mDistance);
		endianSwap(mBrightness);
		endianSwap(mShowXYZ);
		endianSwap(mShowRotation);
		endianSwap(mAxisSwitch);
	}


	physx::PxMat44	mTransform;
	float		mDistance;
	float		mBrightness;
	uint32_t	mShowXYZ;
	uint32_t	mShowRotation;
	uint32_t	mAxisSwitch;
	uint32_t	mRenderMode;
};

struct DebugArc : public DebugPrimitive
{
	DebugArc(void) { }
	DebugArc(const physx::PxVec3 &center,const physx::PxVec3 &p1,const physx::PxVec3 &p2,float arrowSize,bool showRoot) :
	DebugPrimitive(DebugCommand::DEBUG_ARC),
		mCenter(center),
		mP1(p1),
		mP2(p2),
		mArrowSize(arrowSize),
		mShowRoot(uint32_t(showRoot))
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mCenter);
		endianSwap(mP1);
		endianSwap(mP2);
		endianSwap(mArrowSize);
		endianSwap(mShowRoot);
	}


	physx::PxVec3	mCenter;
	physx::PxVec3	mP1;
	physx::PxVec3	mP2;
	float			mArrowSize;
	uint32_t		mShowRoot;
};

struct DebugThickArc : public DebugPrimitive
{
	DebugThickArc(void) { }
	DebugThickArc(const physx::PxVec3 &center,const physx::PxVec3 &p1,const physx::PxVec3 &p2,float thickness=0.02f,bool showRoot=false) :
	DebugPrimitive(DebugCommand::DEBUG_THICK_ARC),
		mCenter(center),
		mP1(p1),
		mP2(p2),
		mThickness(thickness),
		mShowRoot(uint32_t(showRoot))
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mCenter);
		endianSwap(mP1);
		endianSwap(mP2);
		endianSwap(mThickness);
		endianSwap(mShowRoot);
	}


	physx::PxVec3	mCenter;
	physx::PxVec3	mP1;
	physx::PxVec3	mP2;
	float			mThickness;
	uint32_t		mShowRoot;
};

struct DebugDetailedSphere : public DebugPrimitive
{
	DebugDetailedSphere(void) { }
	DebugDetailedSphere(const physx::PxVec3 &pos,float radius,uint32_t stepCount) :
	DebugPrimitive(DebugCommand::DEBUG_DETAILED_SPHERE),
		mPos(pos),
		mRadius(radius),
		mStepCount(stepCount)
	{
	}

	void adjustEndian(void)
	{
		endianSwap(mPos);
		endianSwap(mRadius);
		endianSwap(mStepCount);
	}


	physx::PxVec3	mPos;
	float			mRadius;
	uint32_t		mStepCount;
};

struct DebugCreateCustomTexture : public DebugPrimitive
{
	DebugCreateCustomTexture(void) { }
	DebugCreateCustomTexture(uint32_t id,const char *textureName) :
	DebugPrimitive(DebugCommand::DEBUG_CREATE_CUSTOM_TEXTURE),
		mId(id)
	{
		const char *source = textureName;
		char *dest = mTextureName;
		char *stop = &mTextureName[MAX_DEBUG_MESSAGE_STRING-1];
		while ( *source && dest < stop )
		{
			*dest++ = *source++;
		}
		*dest = 0;
	}

	void adjustEndian(void)
	{
		endianSwap(mId);
	}


	uint32_t	mId;
	char		mTextureName[MAX_DEBUG_MESSAGE_STRING];
};


struct DebugSetCurrentTransform : public DebugPrimitive
{
	DebugSetCurrentTransform(void) { }
	DebugSetCurrentTransform(const physx::PxMat44 &m) :
	DebugPrimitive(DebugCommand::SET_CURRENT_TRANSFORM),
		mTransform(m)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mTransform);
	}

	physx::PxMat44		mTransform;
};

struct DebugGraphStream : public DebugPrimitive
{
	DebugGraphStream(void) { mAllocated = false; mBuffer = NULL;}
	DebugGraphStream(const DebugGraphDesc &d);
	~DebugGraphStream(void);

	void adjustEndian(void)
	{
		//TODO TODO!
	}


	uint32_t getSize(void) const { return mSize; }
	uint32_t mSize;
	uint8_t *mBuffer;
private:
	uint32_t mAllocated;
};

struct DebugCreateTriangleMesh : public DebugPrimitive
{
	DebugCreateTriangleMesh(void) { mAllocated = false; mBuffer = NULL;}
	DebugCreateTriangleMesh(uint32_t meshId,
							uint32_t vcount,	// The number of vertices in the triangle mesh
							const RENDER_DEBUG::RenderDebugMeshVertex *meshVertices,	// The array of vertices
							uint32_t tcount,	// The number of triangles (indices must contain tcount*3 values)
							const uint32_t *indices);	// The array of triangle mesh indices

	~DebugCreateTriangleMesh(void);

	void adjustEndian(void)
	{
		uint32_t *s = &mSize;
		swap4Bytes(s);	// The Size.
		s++;
		swap4Bytes(s);
		uint32_t meshId = *s++;
		PX_UNUSED(meshId);
		swap4Bytes(s);
		uint32_t vcount = *s++;
		swap4Bytes(s);
		uint32_t tcount = *s++;
		uint32_t vSwapCount = (sizeof(RenderDebugMeshVertex)/4)*vcount;
		for (uint32_t i=0; i<vSwapCount; i++)
		{
			swap4Bytes(s);
			s++;
		}
		uint32_t iSwapCount = tcount*3;
		for (uint32_t i=0; i<iSwapCount; i++)
		{
			swap4Bytes(s);
			s++;
		}
	}


	uint32_t getSize(void) const { return mSize; }
	uint32_t mSize;
	uint8_t *mBuffer;
private:
	uint32_t mAllocated;
};

struct DebugRenderTriangleMeshInstances : public DebugPrimitive
{
	DebugRenderTriangleMeshInstances(void) { mAllocated = false; mBuffer = NULL;}
	DebugRenderTriangleMeshInstances(uint32_t meshId,
					uint32_t instanceCount,
					const RENDER_DEBUG::RenderDebugInstance *instances);
		

	~DebugRenderTriangleMeshInstances(void);

	void adjustEndian(void)
	{
		uint32_t *s = &mSize;
		swap4Bytes(s);
		s++;
		swap4Bytes(s);
		uint32_t meshId = *s++;
		PX_UNUSED(meshId);
		swap4Bytes(s);
		uint32_t instanceCount = *s++;
		uint32_t swapCount = (sizeof(RenderDebugInstance)/4)*instanceCount;
		for (uint32_t i=0; i<swapCount; i++)
		{
			swap4Bytes(s);
			s++;
		}
	}


	uint32_t getSize(void) const { return mSize; }
	uint32_t mSize;
	uint8_t *mBuffer;
private:
	uint32_t	 mAllocated;
};

struct DebugConvexHull : public DebugPrimitive
{
	DebugConvexHull(void) { mAllocated = false; mBuffer = NULL;}
	DebugConvexHull(uint32_t planeCount,const float *planes);


	~DebugConvexHull(void);

	void adjustEndian(void)
	{
		uint32_t *s = &mSize;
		swap4Bytes(s);
		s++;
		swap4Bytes(s);	// count
		uint32_t planeCount = *s++;
		uint32_t swapCount = 4*planeCount;
		for (uint32_t i=0; i<swapCount; i++)
		{
			swap4Bytes(s);
			s++;
		}
	}


	uint32_t getSize(void) const { return mSize; }
	uint32_t mSize;
	uint8_t *mBuffer;
private:
	uint32_t	 mAllocated;
};

struct DebugRenderPoints : public DebugPrimitive
{
	DebugRenderPoints(void) { mAllocated = false; mBuffer = NULL;}
	DebugRenderPoints(uint32_t meshId,
		PointRenderMode mode,
		uint32_t textureId1,
		float textureTile1,
		uint32_t textureId2,
		float textureTile2,
		uint32_t	pointCount,
		const float *points);


	~DebugRenderPoints(void);

	void adjustEndian(void)
	{
		uint32_t *s = &mSize;
		swap4Bytes(s);
		s++;
		swap4Bytes(s);	// meshId
		s++;
		swap4Bytes(s); // mode
		s++;
		swap4Bytes(s); // textureId1
		s++;
		swap4Bytes(s); // textureTile1;
		s++;
		swap4Bytes(s); // textureId2
		s++;
		swap4Bytes(s); // textureTile2;
		s++;
		swap4Bytes(s); // pointCount
		uint32_t pointCount = *s++;
		uint32_t swapCount = 3*pointCount;
		for (uint32_t i=0; i<swapCount; i++)
		{
			swap4Bytes(s);
			s++;
		}
	}


	uint32_t getSize(void) const { return mSize; }
	uint32_t mSize;
	uint8_t *mBuffer;
private:
	uint32_t	 mAllocated;
};


struct DebugRenderLines : public DebugPrimitive
{
	DebugRenderLines(void) { mAllocated = false; mBuffer = NULL;}
	DebugRenderLines(uint32_t lcount,		
		const RenderDebugVertex *vertices, 
		uint32_t useZ,				
		uint32_t isScreenSpace);


	~DebugRenderLines(void);

	void adjustEndian(void)
	{
		uint32_t *s = &mSize;
		swap4Bytes(s); // size
		s++;
		swap4Bytes(s);	// lcount
		uint32_t lcount = *s++;
		swap4Bytes(s); // useZ
		s++;
		swap4Bytes(s); // isScreenSpace
		s++;
		uint32_t swapCount = (sizeof(RenderDebugVertex)/4)*lcount*2;
		for (uint32_t i=0; i<swapCount; i++)
		{
			swap4Bytes(s);
			s++;
		}
	}


	uint32_t getSize(void) const { return mSize; }
	uint32_t mSize;
	uint8_t *mBuffer;
private:
	uint32_t	 mAllocated;
};

struct DebugRenderTriangles : public DebugPrimitive
{
	DebugRenderTriangles(void) { mAllocated = false; mBuffer = NULL;}
	DebugRenderTriangles(uint32_t tcount,
		const RenderDebugSolidVertex *vertices,	
		uint32_t useZ,				
		uint32_t isScreenSpace);


	~DebugRenderTriangles(void);

	void adjustEndian(void)
	{
		uint32_t *s = &mSize;
		swap4Bytes(s); //size
		s++;
		swap4Bytes(s);	// tcount
		uint32_t tcount = *s++;
		swap4Bytes(s); // useZ
		s++;
		swap4Bytes(s); // isScreenSpace
		s++;
		uint32_t swapCount = (sizeof(RenderDebugSolidVertex)/4)*tcount*3;
		for (uint32_t i=0; i<swapCount; i++)
		{
			swap4Bytes(s);
			s++;
		}
	}


	uint32_t getSize(void) const { return mSize; }
	uint32_t mSize;
	uint8_t *mBuffer;
private:
	uint32_t	 mAllocated;
};


struct DebugReleaseTriangleMesh : public DebugPrimitive
{
	DebugReleaseTriangleMesh(void) { }
	DebugReleaseTriangleMesh(uint32_t meshId) :
	DebugPrimitive(DebugCommand::DEBUG_RELEASE_TRIANGLE_MESH),
		mMeshId(meshId)
	{
	}
	void adjustEndian(void)
	{
		endianSwap(mMeshId);
	}

	uint32_t	mMeshId;
};

struct DebugRefreshTriangleMeshVertices : public DebugPrimitive
{
	DebugRefreshTriangleMeshVertices(void) { mAllocated = false; mBuffer = NULL;}
	DebugRefreshTriangleMeshVertices(uint32_t meshID,
		uint32_t vcount,
		const RenderDebugMeshVertex *refreshVertices,
		const uint32_t *refreshIndices);	// The array of triangle mesh indices

	~DebugRefreshTriangleMeshVertices(void);

	void adjustEndian(void)
	{
		uint32_t *s = &mSize;
		swap4Bytes(s);	// The Size.
		s++;
		swap4Bytes(s);
		uint32_t meshId = *s++;
		PX_UNUSED(meshId);
		swap4Bytes(s);
		uint32_t vcount = *s++;
		uint32_t vSwapCount = (sizeof(RenderDebugMeshVertex)/4)*vcount;
		for (uint32_t i=0; i<vSwapCount; i++)
		{
			swap4Bytes(s);
			s++;
		}
		uint32_t iSwapCount = vcount;
		for (uint32_t i=0; i<iSwapCount; i++)
		{
			swap4Bytes(s);
			s++;
		}
	}


	uint32_t getSize(void) const { return mSize; }
	uint32_t mSize;
	uint8_t *mBuffer;
private:
	uint32_t mAllocated;
};


PX_COMPILE_TIME_ASSERT(sizeof(DebugPrimitive)==4);
PX_COMPILE_TIME_ASSERT(sizeof(DebugPrimitiveU32)==8);
PX_COMPILE_TIME_ASSERT(sizeof(DebugPrimitiveF32)==8);
PX_COMPILE_TIME_ASSERT(sizeof(DebugLine)==28);
PX_COMPILE_TIME_ASSERT(sizeof(DrawGrid)==12);
PX_COMPILE_TIME_ASSERT(sizeof(DebugMessage)==132);
PX_COMPILE_TIME_ASSERT(sizeof(DebugText)==336);
PX_COMPILE_TIME_ASSERT(sizeof(DebugText2D)==284);
PX_COMPILE_TIME_ASSERT(sizeof(DebugFrustum)==132);
PX_COMPILE_TIME_ASSERT(sizeof(DebugCone)==24);
PX_COMPILE_TIME_ASSERT(sizeof(DebugBound)==28);
PX_COMPILE_TIME_ASSERT(sizeof(DebugPoint)==20);
PX_COMPILE_TIME_ASSERT(sizeof(DebugQuad)==28);
PX_COMPILE_TIME_ASSERT(sizeof(DebugPointScale)==28);
PX_COMPILE_TIME_ASSERT(sizeof(DebugRect2d)==20);
PX_COMPILE_TIME_ASSERT(sizeof(DebugGradientLine)==36);
PX_COMPILE_TIME_ASSERT(sizeof(DebugRay)==28);
PX_COMPILE_TIME_ASSERT(sizeof(DebugThickRay)==36);
PX_COMPILE_TIME_ASSERT(sizeof(DebugPlane)==28);
PX_COMPILE_TIME_ASSERT(sizeof(DebugTri)==40);
PX_COMPILE_TIME_ASSERT(sizeof(DebugTriNormals)==76);
PX_COMPILE_TIME_ASSERT(sizeof(DebugGradientTri)==52);
PX_COMPILE_TIME_ASSERT(sizeof(DebugGradientTriNormals)==88);
PX_COMPILE_TIME_ASSERT(sizeof(DebugSphere)==12);
PX_COMPILE_TIME_ASSERT(sizeof(DebugSquashedSphere)==20);
PX_COMPILE_TIME_ASSERT(sizeof(DebugCapsule)==16);
PX_COMPILE_TIME_ASSERT(sizeof(DebugTaperedCapsule)==20);
PX_COMPILE_TIME_ASSERT(sizeof(DebugPointCylinder)==32);
PX_COMPILE_TIME_ASSERT(sizeof(DebugCylinder)==24);
PX_COMPILE_TIME_ASSERT(sizeof(DebugCircle)==80);
PX_COMPILE_TIME_ASSERT(sizeof(DebugAxes)==92);
PX_COMPILE_TIME_ASSERT(sizeof(DebugArc)==48);
PX_COMPILE_TIME_ASSERT(sizeof(DebugThickArc)==48);
PX_COMPILE_TIME_ASSERT(sizeof(DebugDetailedSphere)==24);
PX_COMPILE_TIME_ASSERT(sizeof(DebugSetCurrentTransform)==68);
#if PX_P64_FAMILY
PX_COMPILE_TIME_ASSERT(sizeof(DebugGraphStream)==24);
PX_COMPILE_TIME_ASSERT(sizeof(DebugCreateTriangleMesh)==24);
PX_COMPILE_TIME_ASSERT(sizeof(DebugRefreshTriangleMeshVertices)==24);
PX_COMPILE_TIME_ASSERT(sizeof(DebugRenderTriangleMeshInstances)==24);
#else
PX_COMPILE_TIME_ASSERT(sizeof(DebugGraphStream)==16);
PX_COMPILE_TIME_ASSERT(sizeof(DebugCreateTriangleMesh)==16);
PX_COMPILE_TIME_ASSERT(sizeof(DebugRefreshTriangleMeshVertices)==16);
PX_COMPILE_TIME_ASSERT(sizeof(DebugRenderTriangleMeshInstances)==16);
#endif

PX_COMPILE_TIME_ASSERT(sizeof(DebugReleaseTriangleMesh)==8);
PX_INLINE void endianSwap(DebugPrimitive *prim)
{
	prim->endianFixup();
	switch ( prim->mCommand )
	{
		case DebugCommand::SET_CURRENT_TRANSFORM:
			{
				DebugSetCurrentTransform *d = static_cast< DebugSetCurrentTransform *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_SKIP_FRAME:
		case DebugCommand::DEBUG_RESET_INPUT_EVENTS:
		case DebugCommand::SET_CURRENT_COLOR:
		case DebugCommand::SET_CURRENT_RENDER_STATE:
		case DebugCommand::SET_CURRENT_ARROW_COLOR:
		case DebugCommand::SET_CURRENT_TEXTURE1:
		case DebugCommand::SET_CURRENT_TEXTURE2:
		case DebugCommand::SET_CURRENT_USER_ID:
			{
				DebugPrimitiveU32 *d = static_cast< DebugPrimitiveU32 *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_BOUND:
			{
				DebugBound *d = static_cast< DebugBound *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::SET_CURRENT_TEXT_SCALE:
		case DebugCommand::SET_CURRENT_RENDER_SCALE:
		case DebugCommand::SET_CURRENT_ARROW_SIZE:
		case DebugCommand::SET_CURRENT_TILE1:
		case DebugCommand::SET_CURRENT_TILE2:
			{
				DebugPrimitiveF32 *d = static_cast< DebugPrimitiveF32 *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_LINE:
			{
				DebugLine *d = static_cast< DebugLine *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DRAW_GRID:
			{
				DrawGrid *d = static_cast< DrawGrid *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_TEXT:
			{
				DebugText *d = static_cast< DebugText *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_TEXT2D:
			{
				DebugText2D *d = static_cast< DebugText2D *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_QUAD:
			{
				DebugQuad *d = static_cast< DebugQuad *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_POINT:
			{
				DebugPoint *d = static_cast< DebugPoint *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_RECT2D:
			{
				DebugRect2d *d = static_cast< DebugRect2d *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_GRADIENT_LINE:
			{
				DebugGradientLine *d = static_cast< DebugGradientLine *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_RAY:
			{
				DebugRay *d = static_cast< DebugRay *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_CYLINDER:
			{
				DebugCylinder *d = static_cast< DebugCylinder *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_CIRCLE:
			{
				DebugCircle *d = static_cast< DebugCircle *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_POINT_CYLINDER:
			{
				DebugPointCylinder *d = static_cast< DebugPointCylinder *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_THICK_RAY:
			{
				DebugThickRay *d = static_cast< DebugThickRay *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_PLANE:
			{
				DebugPlane *d = static_cast< DebugPlane *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_TRI:
			{
				DebugTri *d = static_cast< DebugTri *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_TRI_NORMALS:
			{
				DebugTriNormals *d = static_cast< DebugTriNormals *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_GRADIENT_TRI:
			{
				DebugGradientTri *d = static_cast< DebugGradientTri *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_GRADIENT_TRI_NORMALS:
			{
				DebugGradientTriNormals *d = static_cast< DebugGradientTriNormals *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_SPHERE:
			{
				DebugSphere *d = static_cast< DebugSphere *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_SQUASHED_SPHERE:
			{
				DebugSquashedSphere *d = static_cast< DebugSquashedSphere *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_CAPSULE:
			{
				DebugCapsule *d = static_cast< DebugCapsule *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_AXES:
			{
				DebugAxes *d = static_cast< DebugAxes *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_ARC:
			{
				DebugArc *d = static_cast< DebugArc *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_THICK_ARC:
			{
				DebugThickArc *d = static_cast< DebugThickArc *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_DETAILED_SPHERE:
			{
				DebugDetailedSphere *d = static_cast< DebugDetailedSphere *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_BLOCK_INFO:
			{
				PX_ALWAYS_ASSERT();
			}
			break;
		case DebugCommand::DEBUG_GRAPH:
			{
				DebugGraphStream *d = static_cast< DebugGraphStream *>(prim);
				d->adjustEndian();
				PX_ALWAYS_ASSERT();
			}
			break;
		case DebugCommand::DEBUG_CAPSULE_TAPERED:
			{
				DebugTaperedCapsule *d = static_cast< DebugTaperedCapsule *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_POINT_SCALE:
			{
				DebugPointScale *d = static_cast< DebugPointScale *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_MESSAGE:
			{
				DebugMessage *d = static_cast< DebugMessage *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_CREATE_CUSTOM_TEXTURE:
			{
				DebugCreateCustomTexture *d = static_cast< DebugCreateCustomTexture *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_FRUSTUM:
			{
				DebugFrustum *d = static_cast< DebugFrustum *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_CONE:
			{
				DebugCone *d = static_cast< DebugCone *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_REGISTER_INPUT_EVENT:
			{
				DebugRegisterInputEvent *d = static_cast< DebugRegisterInputEvent *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_UNREGISTER_INPUT_EVENT:
			{
				DebugUnregisterInputEvent *d = static_cast< DebugUnregisterInputEvent *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_CREATE_TRIANGLE_MESH:
			{
				DebugCreateTriangleMesh *d = static_cast< DebugCreateTriangleMesh *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_RENDER_TRIANGLE_MESH_INSTANCES:
			{
				DebugRenderTriangleMeshInstances *d = static_cast< DebugRenderTriangleMeshInstances *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_RENDER_POINTS:
			{
				DebugRenderPoints *d = static_cast< DebugRenderPoints *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_CONVEX_HULL:
			{
				DebugConvexHull *d = static_cast< DebugConvexHull *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_RENDER_LINES:
			{
				DebugRenderLines *d = static_cast< DebugRenderLines *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_RENDER_TRIANGLES:
			{
				DebugRenderTriangles *d = static_cast< DebugRenderTriangles *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_RELEASE_TRIANGLE_MESH:
			{
				DebugReleaseTriangleMesh *d = static_cast< DebugReleaseTriangleMesh *>(prim);
				d->adjustEndian();
			}
			break;
		case DebugCommand::DEBUG_REFRESH_TRIANGLE_MESH_VERTICES:
			{
				DebugRefreshTriangleMeshVertices *d = static_cast< DebugRefreshTriangleMeshVertices *>(prim);
				d->adjustEndian();
			}
			break;
	}
}

//********************************************************************
//********************************************************************

// data structure used to track draw groups.  Used internally only.
struct BlockInfo
{
public:

	BlockInfo(void)
	{
		mHashValue = 0;
		mVisibleState = true;
		mChanged = false;
	}

	uint32_t getHashValue(void) const
	{
		return mHashValue;
	}

	physx::PxMat44		mPose;  // transform for block of data
	uint32_t		mHashValue;
	bool			mVisibleState;
	bool			mChanged; // a semaphore indicating that the state has changed for this block
};



// The current render state data block.
class RenderState
{
public:

	RenderState()
	{
		mStates = 0;
		mColor = 0xcfcfcfcf; // needs to be symmetric to be platform independent.
		mDisplayTime = 0.0001f;
		mArrowColor = 0x5f5f5f5f; // needs to be symmetric to be platform independent.
		mOutlineColor = 0xFFFFFFFF;
		mArrowSize = 0.1f;
		mRenderScale = 1.0f;
		mTextScale = 1.0f;
		mUserId = 0;
		mPose = NULL;
		mBlockInfo = NULL;
		mChangeCount = 0;
		mCurrentPose = physx::PxMat44(physx::PxIdentity);
		mTexture1 = 0;
		mTexture2 = 0;
		mTileRate1 = 1.0f;
		mTileRate2 = 1.0f;
	}

	RenderState(uint32_t s,uint32_t c,float d,uint32_t a,float as,float rs,float ts)
	{
		mStates = s;
		mOutlineColor = 0xFFFFFFFF;
		mColor = c;
		mDisplayTime = d;
		mArrowColor = a;
		mArrowSize = as;
		mRenderScale = rs;
		mTextScale = ts;
		mUserId = 0;
		mPose = NULL;
		mCurrentPose = physx::PxMat44(physx::PxIdentity);
		mBlockInfo = NULL;
		mChangeCount = 0;
		mTexture1 = 0;
		mTexture2 = 0;
		mTileRate1 = 1.0f;
		mTileRate2 = 1.0f;
	}

	PX_INLINE bool isScreen(void) const { return (mStates & RENDER_DEBUG::DebugRenderState::ScreenSpace); }
	PX_INLINE bool isUseZ(void) const { return !(mStates & RENDER_DEBUG::DebugRenderState::NoZbuffer); }
	PX_INLINE bool isSolid(void) const { return (mStates & (RENDER_DEBUG::DebugRenderState::SolidShaded | RENDER_DEBUG::DebugRenderState::SolidWireShaded)) ? true : false; }
	PX_INLINE bool isClockwise(void) const { return !(mStates & RENDER_DEBUG::DebugRenderState::CounterClockwise); }
	PX_INLINE bool isWireframeOverlay(void) const { return (mStates & RENDER_DEBUG::DebugRenderState::SolidWireShaded) ? true : false; }
	PX_INLINE bool isWireframe(void) const
	{
		bool ret = true;
		if ( isSolid() && !isWireframeOverlay() )
		{
			ret = false;
		}
		return ret;
	}

	PX_INLINE  float getDisplayTime(void) const
	{
		return (mStates & RENDER_DEBUG::DebugRenderState::InfiniteLifeSpan) ? PX_MAX_F32 : mDisplayTime;
	}

	PX_INLINE bool isCentered(void) const { return (mStates & RENDER_DEBUG::DebugRenderState::CenterText) ? true : false; }
	PX_INLINE bool isCameraFacing(void) const { return (mStates & RENDER_DEBUG::DebugRenderState::CameraFacing) ? true : false; }
	PX_INLINE bool isCounterClockwise(void) const { return (mStates & RENDER_DEBUG::DebugRenderState::CounterClockwise) ? true : false; }
	PX_INLINE int32_t getUserId(void) const { return mUserId; }

	PX_INLINE void incrementChangeCount(void) { mChangeCount++; }
	PX_INLINE uint32_t getChangeCount(void) const { return mChangeCount; }

	PX_INLINE uint32_t setRenderState(RENDER_DEBUG::DebugRenderState::Enum state)
	{
		mStates|=state;
		return mStates;
	}

	PX_INLINE uint32_t clearRenderState(RENDER_DEBUG::DebugRenderState::Enum state)
	{
		mStates&=~state;
		return mStates;
	}

	PX_INLINE bool hasRenderState(RENDER_DEBUG::DebugRenderState::Enum state) const
	{
		return (state&mStates) ? true : false;
	}

	PX_INLINE void setCurrentColor(uint32_t c1,uint32_t c2)
	{
		mColor = c1;
		mArrowColor = c2;
	}


	uint32_t 		mStates;
	uint32_t 		mColor;
	uint32_t		mTexture1;
	float			mTileRate1;
	uint32_t		mTexture2;
	float			mTileRate2;
	float 			mDisplayTime;
	uint32_t 		mArrowColor;
	uint32_t		mOutlineColor;
	float 			mArrowSize;
	float 			mRenderScale;
	float 			mTextScale;
	uint32_t		mChangeCount;
	int32_t 		 mUserId;
	BlockInfo		*mBlockInfo;
	physx::PxMat44 *mPose;
	physx::PxMat44	 mCurrentPose;
};

struct DebugBlockInfo : public DebugPrimitive
{
	DebugBlockInfo(void) { }
	DebugBlockInfo(BlockInfo *info) :
	DebugPrimitive(DebugCommand::DEBUG_BLOCK_INFO),
		mInfo(info)
	{
		if ( info )
		{
			new ( &mCurrentTransform ) DebugSetCurrentTransform(info->mPose);
		}
	}
	BlockInfo				*mInfo;
	DebugSetCurrentTransform mCurrentTransform; // contains the transform for this block; updated each time it changes.
};

/**
\brief The maximum number of graphs that can be displayed at one time.  (0-5)
*/
#define MAX_GRAPHS 6
/**
\brief The width of the graphs (x axis) when created automatically
*/
#define GRAPH_WIDTH_DEFAULT 0.8f
/**
\brief The height of the graphs (y axis) when created automatically
*/
#define GRAPH_HEIGHT_DEFAULT 0.4f

/**
\brief definition of the debugGraph descriptor used to create graphs
*/
struct DebugGraphDesc 
{
	DebugGraphDesc(void) 
	{ 
		mPoints = NULL;
		mGraphXLabel = NULL;
		mGraphYLabel = NULL;
	}


	/**
	\brief The number of float data points to graph
	*/
	uint32_t	mNumPoints;
	/**
	\brief Pointer to the float data points to graph
	*/
	const float*	mPoints;
	/**
	\brief optional cutoff line drawn horizontally on the graph.  It should be between 0 and mGraphMax.
	0.0f indicates not to draw the cutoff line.
	*/
	float	mCutOffLevel;
	/**
	\brief The maximum value that the graph should be be able to display.
	Noramlly this is slightly larger than the greatest value in the mPoints array to make room for
	future samples that are higher then the current set.
	*/
	float	mGraphMax;
	/**
	\brief The bottom left x coordinate of the graph.
	This is set automatically by the constructor that takes graphNum as an argument.
	NOTE: display coordinates range from -1.0f - + 1.0f
	*/
	float	mGraphXPos;
	/**
	\brief bottom left y coordinate of the graph.
	This is set automatically by the constructor that takes graphNum as an argument.
	NOTE: display coordinates range from -1.0f - + 1.0f
	*/
	float	mGraphYPos;
	/**
	\brief The width of the graph.
	This is set automatically by the constructor that takes graphNum as an argument.
	NOTE: display coordinates range from -1.0f - + 1.0f
	*/
	float	mGraphWidth;
	/**
	\brief The height of the graph.
	This is set automatically by the constructor that takes graphNum as an argument.
	NOTE: display coordinates range from -1.0f - + 1.0f
	*/
	float	mGraphHeight;
	/**
	\brief The color of the data.
	This is set automatically by the constructor that takes graphNum as an argument.
	NOTE: display coordinates range from -1.0f - + 1.0f
	This is set automatically by the constructor that takes graphNum as an argument.
	*/
	uint32_t	mGraphColor;
	/**
	\brief The alternate color of the data if mColorSwitchIndex is set to a value that is a valid
	index to the mPoints array.  The points after mColorSwitchIndex are drawn in this color.
	This is set automatically by the constructor that takes graphNum as an argument.
	*/
	uint32_t	mArrowColor;
	/**
	\brief A pointer to the label for the X axis.
	*/
	const char*	mGraphXLabel;
	/**
	\brief A pointer to the label for the Y axis.
	*/
	const char*	mGraphYLabel;
	/**
	\brief The (optional!) index in the data set at which to switch the color to the color specified by
	mArrorColor.  By default this is set to -1 indicating that no color switch should be performed.
	*/
	uint32_t	mColorSwitchIndex;

};





PX_INLINE uint32_t DebugCommand::getPrimtiveSize(const DebugPrimitive &p)
{
	uint32_t ret=0;

	RENDER_DEBUG::DebugCommand::Enum c = static_cast<RENDER_DEBUG::DebugCommand::Enum>(p.mCommand);
	switch ( c )
	{
		case SET_CURRENT_TRANSFORM:
			ret = sizeof(DebugSetCurrentTransform);
			break;
		case DEBUG_SKIP_FRAME:
		case DEBUG_RESET_INPUT_EVENTS:
		case SET_CURRENT_COLOR:
		case SET_CURRENT_RENDER_STATE:
		case SET_CURRENT_ARROW_COLOR:
		case SET_CURRENT_USER_ID:
		case SET_CURRENT_TEXTURE1:
		case SET_CURRENT_TEXTURE2:
			ret = sizeof(DebugPrimitiveU32);
			break;
		case DEBUG_BOUND:
			ret = sizeof(DebugBound);
			break;
		case SET_CURRENT_TEXT_SCALE:
		case SET_CURRENT_RENDER_SCALE:
		case SET_CURRENT_ARROW_SIZE:
		case SET_CURRENT_TILE1:
		case SET_CURRENT_TILE2:
			ret = sizeof(DebugPrimitiveF32);
			break;
		case DEBUG_LINE:
			ret = sizeof(DebugLine);
			break;
		case DRAW_GRID:
			ret = sizeof(DrawGrid);
			break;
		case DEBUG_TEXT:
			ret = sizeof(DebugText);
			break;
		case DEBUG_TEXT2D:
			ret = sizeof(DebugText2D);
			break;
		case DEBUG_QUAD:
			ret = sizeof(DebugQuad);
			break;
		case DEBUG_POINT:
			ret = sizeof(DebugPoint);
			break;
		case DEBUG_RECT2D:
			ret = sizeof(DebugRect2d);
			break;
		case DEBUG_GRADIENT_LINE:
			ret = sizeof(DebugGradientLine);
			break;
		case DEBUG_RAY:
			ret = sizeof(DebugRay);
			break;
		case DEBUG_CYLINDER:
			ret = sizeof(DebugCylinder);
			break;
		case DEBUG_CIRCLE:
			ret = sizeof(DebugCircle);
			break;
		case DEBUG_POINT_CYLINDER:
			ret = sizeof(DebugPointCylinder);
			break;
		case DEBUG_THICK_RAY:
			ret = sizeof(DebugThickRay);
			break;
		case DEBUG_PLANE:
			ret = sizeof(DebugPlane);
			break;
		case DEBUG_TRI:
			ret = sizeof(DebugTri);
			break;
		case DEBUG_TRI_NORMALS:
			ret = sizeof(DebugTriNormals);
			break;
		case DEBUG_GRADIENT_TRI:
			ret = sizeof(DebugGradientTri);
			break;
		case DEBUG_GRADIENT_TRI_NORMALS:
			ret = sizeof(DebugGradientTriNormals);
			break;
		case DEBUG_SPHERE:
			ret = sizeof(DebugSphere);
			break;
		case DEBUG_SQUASHED_SPHERE:
			ret = sizeof(DebugSquashedSphere);
			break;
		case DEBUG_CAPSULE:
			ret = sizeof(DebugCapsule);
			break;
		case DEBUG_AXES:
			ret = sizeof(DebugAxes);
			break;
		case DEBUG_ARC:
			ret = sizeof(DebugArc);
			break;
		case DEBUG_THICK_ARC:
			ret = sizeof(DebugThickArc);
			break;
		case DEBUG_DETAILED_SPHERE:
			ret = sizeof(DebugDetailedSphere);
			break;
		case DEBUG_BLOCK_INFO:
			ret = sizeof(DebugBlockInfo);
			break;
		case DEBUG_GRAPH:
			{
				const DebugGraphStream *d = static_cast< const DebugGraphStream *>(&p);
				ret = d->getSize();
			}
			break;
		case DEBUG_CAPSULE_TAPERED:
			ret = sizeof(DebugTaperedCapsule);
			break;
		case DEBUG_POINT_SCALE:
			ret = sizeof(DebugPointScale);
			break;
		case DEBUG_MESSAGE:
			ret = sizeof(DebugMessage);
			break;
		case DEBUG_CREATE_CUSTOM_TEXTURE:
			ret = sizeof(DebugCreateCustomTexture);
			break;
		case DEBUG_FRUSTUM:
			ret = sizeof(DebugFrustum);
			break;
		case DEBUG_CONE:
			ret = sizeof(DebugCone);
			break;
		case DEBUG_REGISTER_INPUT_EVENT:
			ret = sizeof(DebugRegisterInputEvent);
			break;
		case DEBUG_UNREGISTER_INPUT_EVENT:
			ret = sizeof(DebugUnregisterInputEvent);
			break;
		case DEBUG_CREATE_TRIANGLE_MESH:
			{
				const DebugCreateTriangleMesh *d = static_cast< const DebugCreateTriangleMesh *>(&p);
				ret = d->getSize();
			}
			break;
		case DEBUG_RENDER_TRIANGLE_MESH_INSTANCES:
			{
				const DebugRenderTriangleMeshInstances *d = static_cast< const DebugRenderTriangleMeshInstances *>(&p);
				ret = d->getSize();
			}
			break;
		case DEBUG_RENDER_POINTS:
			{
				const DebugRenderPoints *d = static_cast< const DebugRenderPoints *>(&p);
				ret = d->getSize();
			}
			break;
		case DEBUG_CONVEX_HULL:
			{
				const DebugConvexHull *d = static_cast< const DebugConvexHull *>(&p);
				ret = d->getSize();
			}
			break;
		case DEBUG_RENDER_LINES:
			{
				const DebugRenderLines *d = static_cast< const DebugRenderLines *>(&p);
				ret = d->getSize();
			}
			break;
		case DEBUG_RENDER_TRIANGLES:
			{
				const DebugRenderTriangles *d = static_cast< const DebugRenderTriangles *>(&p);
				ret = d->getSize();
			}
			break;
		case DEBUG_RELEASE_TRIANGLE_MESH:
			ret = sizeof(DebugReleaseTriangleMesh);
			break;
		case DEBUG_REFRESH_TRIANGLE_MESH_VERTICES:
			{
				const DebugRefreshTriangleMeshVertices *d = static_cast< const DebugRefreshTriangleMeshVertices *>(&p);
				ret = d->getSize();
			}
			break;
		case DEBUG_LAST:
			break;
		default:
			PX_ALWAYS_ASSERT();
			ret = 0;
			break;
	}
	return ret;
}

PX_POP_PACK

} // end of namespace

#endif // RENDER_DEBUG_DATA_H

Commits for Divide-Dependencies/physx/APEX_1.4/shared/general/RenderDebug/include/RenderDebugData.h

Diff revisions: vs.
Revision Author Commited Message
105 IonutCava picture IonutCava Tue 16 Apr, 2019 19:55:41 +0000

Forgot to actually add physx