aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/patch_8cpp-source.html
blob: 3211f194ea9983757f48162d5881b0e45686a017 (plain)
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
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
	<TITLE>nevrax.org : docs</TITLE>
	<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
	<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">

<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0>
 <TR>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
 </TR>
</TABLE> 

<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 WIDTH=100%>
 <TR><TD  BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG  SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>

<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 height=100%>
 <TR>
	<TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

		<!------ Begin Box ------>
		<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0  cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
		<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td  colspan=2 bgcolor=#FFFFFF>
		<TABLE cellspacing=0 cellpadding=1 border=0>
			<tr><td ALIGN=middle><a  class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

	</TD>
	<TD WIDTH=15><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
	<TD ALIGN=left valign=top><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

<!-- title -->
<TABLE  background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
&nbsp;

<!-- block -->
<TABLE  bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>patch.cpp</h1><a href="patch_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
00027 
00028 
00029 <font class="preprocessor">#include "<a class="code" href="patch_8h.html">3d/patch.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="tessellation_8h.html">3d/tessellation.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="bezier__patch_8h.html">3d/bezier_patch.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="src_23d_2zone_8h.html">3d/zone.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="landscape_8h.html">3d/landscape.h</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="vector_8h.html">nel/misc/vector.h</a>"</font>
00035 <font class="preprocessor">#include "<a class="code" href="common_8h.html">nel/misc/common.h</a>"</font>
00036 <font class="preprocessor">#include "<a class="code" href="patchuv__locator_8h.html">3d/patchuv_locator.h</a>"</font>
00037 <font class="preprocessor">#include "<a class="code" href="vegetable__manager_8h.html">3d/vegetable_manager.h</a>"</font>
00038 <font class="preprocessor">#include "<a class="code" href="fast__floor_8h.html">3d/fast_floor.h</a>"</font>
00039 <font class="preprocessor">#include "<a class="code" href="light__influence__interpolator_8h.html">3d/light_influence_interpolator.h</a>"</font>
00040 <font class="preprocessor">#include "<a class="code" href="patchdlm__context_8h.html">3d/patchdlm_context.h</a>"</font>
00041 
00042 <font class="keyword">using</font>   <font class="keyword">namespace       </font>std;
00043 <font class="keyword">using</font>   <font class="keyword">namespace       </font>NLMISC;
00044 
00045 
00046 <font class="keyword">namespace </font>NL3D 
00047 {
00048 
00049 
00050 <font class="comment">// ***************************************************************************</font>
<a name="l00051"></a><a class="code" href="classNL3D_1_1CPatch.html#r1">00051</a> CBezierPatch    CPatch::CachePatch;
<a name="l00052"></a><a class="code" href="classNL3D_1_1CPatch.html#r2">00052</a> <font class="keyword">const</font> CPatch    *CPatch::LastPatch= NULL;
<a name="l00053"></a><a class="code" href="classNL3D_1_1CPatch.html#r0">00053</a> uint32                  CPatch::_Version=7;
00054 
00055 
00056 <font class="comment">// ***************************************************************************</font>
<a name="l00057"></a><a class="code" href="classNL3D_1_1CPatch.html#a0">00057</a> CPatch::CPatch()
00058 {
00059         <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>= NULL;
00060         <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>=0;
00061         <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>=0;
00062         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>=NULL;
00063         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>=NULL;
00064         <a class="code" href="classNL3D_1_1CPatch.html#z678_2">TessBlockRefCount</a>=0;
00065         <a class="code" href="classNL3D_1_1CPatch.html#o25">Clipped</a>=<font class="keyword">false</font>;
00066         <a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>= <font class="keyword">true</font>;
00067         <a class="code" href="classNL3D_1_1CPatch.html#o27">OldRenderClipped</a>= <font class="keyword">true</font>;
00068         <a class="code" href="classNL3D_1_1CPatch.html#z678_3">NumRenderableFaces</a>= 0;
00069 
00070         <font class="comment">// for Pacs process. By default, false.</font>
00071         <a class="code" href="classNL3D_1_1CPatch.html#o4">ExcludeFromRefineAll</a>= <font class="keyword">false</font>;
00072 
00073         <font class="comment">// Init Passes.</font>
00074         <font class="comment">// DO NOT FILL Patch here, because of operator= problem. do it in compile().</font>
00075         <font class="comment">// By default, RdrPasses are NULL.</font>
00076 
00077         <font class="comment">// To force computation of texture info on next preRender().</font>
00078         <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>= -1;
00079         <a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>= -1;
00080 
00081         <font class="comment">// Default: not binded.</font>
00082         <a class="code" href="classNL3D_1_1CPatch.html#z684_1">_BindZoneNeighbor</a>[0]= NULL;
00083         <a class="code" href="classNL3D_1_1CPatch.html#z684_1">_BindZoneNeighbor</a>[1]= NULL;
00084         <a class="code" href="classNL3D_1_1CPatch.html#z684_1">_BindZoneNeighbor</a>[2]= NULL;
00085         <a class="code" href="classNL3D_1_1CPatch.html#z684_1">_BindZoneNeighbor</a>[3]= NULL;
00086         <a class="code" href="classNL3D_1_1CPatch.html#z668_2">NoiseRotation</a>= 0;
00087         <font class="comment">// No smooth by default.</font>
00088         <a class="code" href="classNL3D_1_1CPatch.html#z668_3">_CornerSmoothFlag</a>= 0;
00089 
00090         <font class="comment">// MasterBlock never clipped.</font>
00091         <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.resetClip();
00092 
00093         <font class="comment">// Init UL circular list to NULL (not compiled)</font>
00094         <a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>= NULL;
00095         <a class="code" href="classNL3D_1_1CPatch.html#z687_1">_ULNearNext</a>= NULL;
00096 
00097         <font class="comment">// Dynamic LightMap</font>
00098         <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>= NULL;
00099         <a class="code" href="classNL3D_1_1CPatch.html#z688_3">_DLMContextRefCount</a>= 0;
00100 }
00101 <font class="comment">// ***************************************************************************</font>
<a name="l00102"></a><a class="code" href="classNL3D_1_1CPatch.html#a1">00102</a> CPatch::~CPatch()
00103 {
00104         <a class="code" href="classNL3D_1_1CPatch.html#a3">release</a>();
00105 }
00106 
00107 <font class="comment">// ***************************************************************************</font>
<a name="l00108"></a><a class="code" href="classNL3D_1_1CPatch.html#a3">00108</a> <font class="keywordtype">void</font>                    CPatch::release()
00109 {
00110         <font class="keywordflow">if</font>(Zone)
00111         {
00112                 <font class="comment">// First, delete the VB if the zone was removed while the patch is visible.</font>
00113                 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>)
00114                 {
00115                         <font class="comment">// release VertexBuffer.</font>
00116                         <a class="code" href="classNL3D_1_1CPatch.html#z673_0">deleteVBAndFaceVector</a>();
00117 
00118                         <font class="comment">// Flag.</font>
00119                         <a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>= <font class="keyword">true</font>;
00120                 }
00121 
00122                 <font class="comment">// THIS PATCH MSUT BE UNBOUND FIRST!!!!!</font>
00123                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a> &amp;&amp; <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>);
00124                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;isLeaf() &amp;&amp; <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;isLeaf());
00125                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FLeft == NULL);
00126                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FRight == NULL);
00127                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FLeft == NULL);
00128                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FRight == NULL);
00129 
00130                 <font class="comment">// Free renderPass of landscape, and maybe force computation of texture info on next preRender().</font>
00131                 <font class="comment">// Must do it here, before deletion of Zone, OrderS/T etc...</font>
00132                 <a class="code" href="classNL3D_1_1CPatch.html#a28">resetRenderFar</a>();
00133 
00134                 <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;deleteTessFace(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>);
00135                 <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;deleteTessFace(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>);
00136                 <font class="comment">// Vertices are smartptr/deleted in zone.</font>
00137         }
00138 
00139         <font class="comment">// Flag the fact that this patch can't be rendered.</font>
00140         <a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.Patch= NULL;
00141         <a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.Patch= NULL;
00142         <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>=0;
00143         <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>=0;
00144         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>=NULL;
00145         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>=NULL;
00146         <a class="code" href="classNL3D_1_1CPatch.html#z680_2">clearTessBlocks</a>();
00147         <a class="code" href="classNL3D_1_1CPatch.html#z680_1">resetMasterBlock</a>();
00148         <a class="code" href="classNL3D_1_1CPatch.html#o25">Clipped</a>=<font class="keyword">false</font>;
00149         <a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>= <font class="keyword">true</font>;
00150         <a class="code" href="classNL3D_1_1CPatch.html#o27">OldRenderClipped</a>= <font class="keyword">true</font>;
00151 
00152         <font class="comment">// the pathc is uncompiled. must do it after clearTessBlocks(), because may use it </font>
00153         <font class="comment">// for vegetable manager, and for updateLighting</font>
00154         <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>= NULL;
00155 
00156         <font class="comment">// uncompile: reset UpdateLighting circular list to NULL.</font>
00157         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>!= NULL)
00158         {
00159                 <font class="comment">// verify the patch is correctly unlinked from any ciruclar list.</font>
00160                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>==<font class="keyword">this</font> &amp;&amp; <a class="code" href="classNL3D_1_1CPatch.html#z687_1">_ULNearNext</a>==<font class="keyword">this</font>);
00161         }
00162         <a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>= NULL;
00163         <a class="code" href="classNL3D_1_1CPatch.html#z687_1">_ULNearNext</a>= NULL;
00164 
00165         <font class="comment">// DynamciLightMap: release the _DLMContext if still exist.</font>
00166         <font class="keywordflow">if</font>(_DLMContext)
00167                 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>;
00168         <font class="comment">// reset</font>
00169         <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>= NULL;
00170         <a class="code" href="classNL3D_1_1CPatch.html#z688_3">_DLMContextRefCount</a>= 0;
00171 }
00172 
00173 
00174 <font class="comment">// ***************************************************************************</font>
<a name="l00175"></a><a class="code" href="classNL3D_1_1CPatch.html#a45">00175</a> CBezierPatch    *CPatch::unpackIntoCache()<font class="keyword"> const</font>
00176 <font class="keyword"></font>{
00177         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#r2">LastPatch</a>!=<font class="keyword">this</font>)
00178         {
00179                 <a class="code" href="classNL3D_1_1CPatch.html#a33">unpack</a>(<a class="code" href="classNL3D_1_1CPatch.html#r1">CachePatch</a>);
00180                 <a class="code" href="classNL3D_1_1CPatch.html#r2">LastPatch</a>=<font class="keyword">this</font>;
00181         }
00182         <font class="keywordflow">return</font> &amp;<a class="code" href="classNL3D_1_1CPatch.html#r1">CachePatch</a>;
00183 }
00184 <font class="comment">// ***************************************************************************</font>
<a name="l00185"></a><a class="code" href="classNL3D_1_1CPatch.html#a33">00185</a> <font class="keywordtype">void</font>                    CPatch::unpack(CBezierPatch     &amp;p)<font class="keyword"> const</font>
00186 <font class="keyword"></font>{
00187         sint    i;
00188         <font class="keyword">const</font>   CVector &amp;bias= <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;getPatchBias();
00189         <font class="keywordtype">float</font>   scale= <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;getPatchScale();
00190 
00191         <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
00192                 <a class="code" href="classNL3D_1_1CPatch.html#m0">Vertices</a>[i].unpack(p.Vertices[i], bias, scale);
00193         <font class="keywordflow">for</font>(i=0;i&lt;8;i++)
00194                 <a class="code" href="classNL3D_1_1CPatch.html#m1">Tangents</a>[i].unpack(p.Tangents[i], bias, scale);
00195         <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
00196                 <a class="code" href="classNL3D_1_1CPatch.html#m2">Interiors</a>[i].unpack(p.Interiors[i], bias, scale);
00197 }
00198 <font class="comment">// ***************************************************************************</font>
<a name="l00199"></a><a class="code" href="classNL3D_1_1CPatch.html#c3">00199</a> <font class="keywordtype">void</font>                    CPatch::computeDefaultErrorSize()
00200 {
00201         CBezierPatch    &amp;p= *<a class="code" href="classNL3D_1_1CPatch.html#a45">unpackIntoCache</a>();
00202         CVector                 &amp;v0= p.Vertices[0];
00203         CVector                 &amp;v1= p.Vertices[1];
00204         CVector                 &amp;v2= p.Vertices[2];
00205 
00206         <font class="comment">// \todo yoyo: TODO_NOISE: modulate this value with tangents (roundiness of patch), and with the displacement map.</font>
00207         <a class="code" href="classNL3D_1_1CPatch.html#o8">ErrorSize</a>= ((v1 - v0)^(v2 - v0)).norm();
00208 
00209 }
00210 
00211 
00212 
00213 <font class="comment">// ***************************************************************************</font>
<a name="l00214"></a><a class="code" href="classNL3D_1_1CPatch.html#z683_0">00214</a> <font class="keywordtype">void</font>                    CPatch::buildBBoxFromBezierPatch(<font class="keyword">const</font> CBezierPatch &amp;p, CAABBox &amp;ret)<font class="keyword"> const</font>
00215 <font class="keyword"></font>{
00216         <font class="comment">// Because of the structure of CAABBox, extend() is not fast enough for us. first compute bmin, bmax,</font>
00217         <font class="comment">// then compute the bbox.</font>
00218         CVector         bmin= p.Vertices[0];
00219         CVector         bmax= bmin; 
00220 
00221         sint                    i;
00222         <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
00223         {
00224                 bmin.minof(bmin, p.Vertices[i]);
00225                 bmax.maxof(bmax, p.Vertices[i]);
00226         }
00227         <font class="keywordflow">for</font>(i=0;i&lt;8;i++)
00228         {
00229                 bmin.minof(bmin, p.Tangents[i]);
00230                 bmax.maxof(bmax, p.Tangents[i]);
00231         }
00232         <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
00233         {
00234                 bmin.minof(bmin, p.Interiors[i]);
00235                 bmax.maxof(bmax, p.Interiors[i]);
00236         }
00237 
00238         <font class="comment">// Modulate with the maximum displacement map (usefull for patch clipping).</font>
00239         <font class="keyword">static</font>  CVector         vectorNoiseMax(<a class="code" href="patch_8h.html#a11">NL3D_NOISE_MAX</a>, <a class="code" href="patch_8h.html#a11">NL3D_NOISE_MAX</a>, <a class="code" href="patch_8h.html#a11">NL3D_NOISE_MAX</a>);
00240         bmin-= vectorNoiseMax;
00241         bmax+= vectorNoiseMax;
00242         <font class="comment">// NB: this is not very optimal, since the BBox may be very too big. eg: patch 16mx16m =&gt; bbox 18mx18m.</font>
00243         <font class="comment">// But remind that tessblocks do not use this BBox, and are computed with the real geometry.</font>
00244 
00245         ret.setMinMax(bmin, bmax);
00246 }
00247 
00248 
00249 <font class="comment">// ***************************************************************************</font>
<a name="l00250"></a><a class="code" href="classNL3D_1_1CPatch.html#a14">00250</a> CAABBox                 CPatch::buildBBox()<font class="keyword"> const</font>
00251 <font class="keyword"></font>{
00252         CBezierPatch    &amp;p= *<a class="code" href="classNL3D_1_1CPatch.html#a45">unpackIntoCache</a>();
00253 
00254         <font class="comment">// Compute Bounding Box. (easiest way...)</font>
00255         CAABBox         ret;
00256         <a class="code" href="classNL3D_1_1CPatch.html#z683_0">buildBBoxFromBezierPatch</a>(p, ret);
00257 
00258         <font class="keywordflow">return</font> ret;
00259 }
00260 
00261 
00262 <font class="comment">// ***************************************************************************</font>
<a name="l00263"></a><a class="code" href="classNL3D_1_1CPatch.html#z670_0">00263</a> <font class="keywordtype">void</font>            CPatch::addTrianglesInBBox(CPatchIdent paId, <font class="keyword">const</font> CAABBox &amp;bbox, std::vector&lt;CTrianglePatch&gt; &amp;triangles, uint8 tileTessLevel)<font class="keyword"> const</font>
00264 <font class="keyword"></font>{
00265         CBezierPatch    &amp;bpatch= *<a class="code" href="classNL3D_1_1CPatch.html#a45">unpackIntoCache</a>();
00266 
00267         <font class="comment">// call with the whole root patch.</font>
00268         <a class="code" href="classNL3D_1_1CPatch.html#z683_1">addTrianglesInBBoxRecurs</a>(paId, bbox, triangles, tileTessLevel, bpatch, 0, <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>, 0, <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>);
00269 }
00270 
00271 
00272 <font class="comment">// ***************************************************************************</font>
<a name="l00273"></a><a class="code" href="classNL3D_1_1CPatch.html#z683_1">00273</a> <font class="keywordtype">void</font>            CPatch::addTrianglesInBBoxRecurs(CPatchIdent paId, <font class="keyword">const</font> CAABBox &amp;bbox, std::vector&lt;CTrianglePatch&gt; &amp;triangles, uint8 tessLevel, 
00274                 <font class="keyword">const</font> CBezierPatch &amp;pa, uint8 s0, uint8 s1, uint8 t0, uint8 t1)<font class="keyword"> const</font>
00275 <font class="keyword"></font>{
00276         uint8   lenS=s1-s0, lenT=t1-t0;
00277         <a class="code" href="debug_8h.html#a6">nlassert</a>(lenS&gt;0);
00278         <a class="code" href="debug_8h.html#a6">nlassert</a>(lenT&gt;0);
00279 
00280         <font class="comment">// compute and compare bbox of the subdivision patch against request bbox.</font>
00281         <font class="comment">//========================</font>
00282         <font class="comment">// NB: this compute includes possible noise.</font>
00283         CAABBox         paBBox;
00284         <a class="code" href="classNL3D_1_1CPatch.html#z683_0">buildBBoxFromBezierPatch</a>(pa, paBBox);
00285         <font class="comment">// if do not intersect, stop here.</font>
00286         <font class="keywordflow">if</font>( !paBBox.intersect(bbox) )
00287                 <font class="keywordflow">return</font>;
00288         <font class="comment">// else if at tile level, then just computeTriangles.</font>
00289         <font class="comment">//========================</font>
00290         <font class="keywordflow">else</font> <font class="keywordflow">if</font>( lenS==1 &amp;&amp; lenT==1 )
00291         {
00292                 <a class="code" href="classNL3D_1_1CPatch.html#z683_2">addTileTrianglesInBBox</a>(paId, bbox, triangles, tessLevel, s0, t0);
00293         }
00294         <font class="comment">// else subdiv and reccurs.</font>
00295         <font class="comment">//========================</font>
00296         <font class="keywordflow">else</font>
00297         {
00298                 <font class="comment">// Subdivide along the bigger side.</font>
00299                 <font class="keywordflow">if</font>(lenS&gt;lenT)
00300                 {
00301                         <font class="comment">// subdivide.</font>
00302                         CBezierPatch    left, right;
00303                         pa.subdivideS(left, right);
00304                         uint8   sMiddle= (uint8)( ((uint)s0+(uint)s1) /2 );
00305                         <font class="comment">// recurs left.</font>
00306                         <a class="code" href="classNL3D_1_1CPatch.html#z683_1">addTrianglesInBBoxRecurs</a>(paId, bbox, triangles, tessLevel, left, s0, sMiddle, t0, t1);
00307                         <font class="comment">// recurs right.</font>
00308                         <a class="code" href="classNL3D_1_1CPatch.html#z683_1">addTrianglesInBBoxRecurs</a>(paId, bbox, triangles, tessLevel, right, sMiddle, s1, t0, t1);
00309                 }
00310                 <font class="keywordflow">else</font>
00311                 {
00312                         <font class="comment">// subdivide.</font>
00313                         CBezierPatch    top, bottom;
00314                         pa.subdivideT(top, bottom);
00315                         uint8   tMiddle= (uint8)( ((uint)t0+(uint)t1) /2 );
00316                         <font class="comment">// recurs top.</font>
00317                         <a class="code" href="classNL3D_1_1CPatch.html#z683_1">addTrianglesInBBoxRecurs</a>(paId, bbox, triangles, tessLevel, top, s0, s1, t0, tMiddle);
00318                         <font class="comment">// recurs bottom.</font>
00319                         <a class="code" href="classNL3D_1_1CPatch.html#z683_1">addTrianglesInBBoxRecurs</a>(paId, bbox, triangles, tessLevel, bottom, s0, s1, tMiddle, t1);
00320                 }
00321         }
00322 
00323 
00324 }
00325 
00326 
00327 <font class="comment">// ***************************************************************************</font>
<a name="l00328"></a><a class="code" href="classNL3D_1_1CPatch.html#z683_2">00328</a> <font class="keywordtype">void</font>            CPatch::addTileTrianglesInBBox(CPatchIdent paId, <font class="keyword">const</font> CAABBox &amp;bbox, std::vector&lt;CTrianglePatch&gt; &amp;triangles, uint8 tessLevel, uint8 s0, uint8 t0)<font class="keyword"> const</font>
00329 <font class="keyword"></font>{
00330         <a class="code" href="debug_8h.html#a6">nlassert</a>(s0&lt;<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>);
00331         <a class="code" href="debug_8h.html#a6">nlassert</a>(t0&lt;<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>);
00332         <a class="code" href="debug_8h.html#a6">nlassert</a>(tessLevel&lt;=2);
00333         uint    tessLen= 1&lt;&lt;tessLevel;
00334 
00335         <font class="comment">// some preca.</font>
00336         <font class="keywordtype">float</font>   startS0= (float)s0 / (float)(OrderS);
00337         <font class="keywordtype">float</font>   startT0= (float)t0 / (float)(OrderT);
00338         <font class="keywordtype">float</font>   ds= 1.0f/(float)(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>*tessLen);
00339         <font class="keywordtype">float</font>   dt= 1.0f/(float)(<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>*tessLen);
00340 
00341         <font class="comment">// Parse all quads.</font>
00342         uint    sl,tl;
00343         <font class="keywordflow">for</font>(tl=0; tl&lt;tessLen; tl++)
00344         {
00345                 <font class="keywordtype">float</font>   fs0, fs1, ft0, ft1;
00346                 <font class="comment">// compute t patch coordinates.</font>
00347                 ft0= startT0 + (float)tl * dt ;
00348                 ft1= ft0 + dt;
00349                 <font class="keywordflow">for</font>(sl=0; sl&lt;tessLen; sl++)
00350                 {
00351                         <font class="comment">// compute s patch coordinates.</font>
00352                         fs0= startS0 + (float)sl * ds ;
00353                         fs1= fs0 + ds;
00354 
00355                         <font class="comment">// Compute Quad vectors (in CCW).</font>
00356                         CVector         p0, p1, p2, p3;
00357                         CUV                     uv0, uv1, uv2, uv3;
00358                         uv0.U= fs0; uv0.V= ft0;
00359                         uv1.U= fs0; uv1.V= ft1;
00360                         uv2.U= fs1; uv2.V= ft1;
00361                         uv3.U= fs1; uv3.V= ft0;
00362                         <font class="comment">// evaluate patch (with noise). (NB: because of cache, patch decompression cost nothing).</font>
00363                         p0= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(uv0.U, uv0.V);
00364                         p1= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(uv1.U, uv1.V);
00365                         p2= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(uv2.U, uv2.V);
00366                         p3= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(uv3.U, uv3.V);
00367 
00368                         <font class="comment">// build the bbox of this quad, and test with request bbox.</font>
00369                         CAABBox         quadBBox;
00370                         quadBBox.setCenter(p0);
00371                         quadBBox.extend(p1);
00372                         quadBBox.extend(p2);
00373                         quadBBox.extend(p3);
00374 
00375                         <font class="comment">// insert only if intersect with the bbox.</font>
00376                         <font class="keywordflow">if</font>(quadBBox.intersect(bbox))
00377                         {
00378                                 <font class="comment">// build triangles (in CCW).</font>
00379                                 CTrianglePatch  tri;
00380                                 tri.PatchId= paId;
00381 
00382                                 <font class="comment">// first tri.</font>
00383                                 tri.V0= p0; tri.V1= p1; tri.V2= p2;
00384                                 tri.Uv0= uv0; tri.Uv1= uv1; tri.Uv2= uv2;
00385                                 triangles.push_back(tri);
00386 
00387                                 <font class="comment">// second tri.</font>
00388                                 tri.V0= p2; tri.V1= p3; tri.V2= p0;
00389                                 tri.Uv0= uv2; tri.Uv1= uv3; tri.Uv2= uv0;
00390                                 triangles.push_back(tri);
00391 
00392                                 <font class="comment">// NB: this is not the same tesselation than in tesselation.cpp.</font>
00393                                 <font class="comment">// But this looks like Ben's NLPACS::CLocalRetriever tesselation.</font>
00394                         }
00395                 }
00396         }
00397 
00398 }
00399 
00400 
00401 
00402 <font class="comment">// ***************************************************************************</font>
<a name="l00403"></a><a class="code" href="classNL3D_1_1CPatchQuadBlock.html#a0">00403</a> <font class="keywordtype">void</font>            CPatchQuadBlock::buildTileTriangles(uint8 quadId, CTrianglePatch  triangles[2])<font class="keyword"> const</font>
00404 <font class="keyword"></font>{
00405         <font class="comment">// copute coordinate of the tile we want.</font>
00406         uint    sd0= quadId&amp;(<a class="code" href="patch_8h.html#a9">NL_PATCH_BLOCK_MAX_QUAD</a>-1);
00407         uint    td0= quadId/(NL_PATCH_BLOCK_MAX_QUAD);
00408         uint    sd1= sd0+1;
00409         uint    td1= td0+1;
00410         uint    <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>= <a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m0">PatchBlockId</a>.S0+sd0;
00411         uint    <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>= <a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m0">PatchBlockId</a>.T0+td0;
00412         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;<a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m0">PatchBlockId</a>.S1);
00413         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>&lt;<a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m0">PatchBlockId</a>.T1);
00414 
00415         <font class="comment">// Compute UV coord.</font>
00416         <font class="keywordtype">float</font>   fs0= (float)<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> / (float)(<a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m0">PatchBlockId</a>.OrderS);
00417         <font class="keywordtype">float</font>   ft0= (float)<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a> / (float)(<a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m0">PatchBlockId</a>.OrderT);
00418         <font class="keywordtype">float</font>   fs1= (float)(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>+1) / (float)(<a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m0">PatchBlockId</a>.OrderS);
00419         <font class="keywordtype">float</font>   ft1= (float)(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>+1) / (float)(<a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m0">PatchBlockId</a>.OrderT);
00420         CUV                     uv0, uv1, uv2, uv3;
00421         uv0.U= fs0; uv0.V= ft0;
00422         uv1.U= fs0; uv1.V= ft1;
00423         uv2.U= fs1; uv2.V= ft1;
00424         uv3.U= fs1; uv3.V= ft0;
00425 
00426         <font class="comment">// get vertex coord.</font>
00427         <font class="keyword">const</font> CVector   &amp;p0= <a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m1">Vertices</a>[sd0 + td0*<a class="code" href="patch_8h.html#a10">NL_PATCH_BLOCK_MAX_VERTEX</a>];
00428         <font class="keyword">const</font> CVector   &amp;p1= <a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m1">Vertices</a>[sd0 + td1*<a class="code" href="patch_8h.html#a10">NL_PATCH_BLOCK_MAX_VERTEX</a>];
00429         <font class="keyword">const</font> CVector   &amp;p2= <a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m1">Vertices</a>[sd1 + td1*<a class="code" href="patch_8h.html#a10">NL_PATCH_BLOCK_MAX_VERTEX</a>];
00430         <font class="keyword">const</font> CVector   &amp;p3= <a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m1">Vertices</a>[sd1 + td0*<a class="code" href="patch_8h.html#a10">NL_PATCH_BLOCK_MAX_VERTEX</a>];
00431 
00432         <font class="comment">// build triangles.</font>
00433         <font class="comment">// first tri.</font>
00434         {
00435                 CTrianglePatch &amp;tri= triangles[0];
00436                 tri.PatchId= <a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m0">PatchBlockId</a>.PatchId;
00437                 tri.V0= p0; tri.V1= p1; tri.V2= p2;
00438                 tri.Uv0= uv0; tri.Uv1= uv1; tri.Uv2= uv2;
00439         }
00440 
00441         <font class="comment">// second tri.</font>
00442         {
00443                 CTrianglePatch &amp;tri= triangles[1];
00444                 tri.PatchId= <a class="code" href="classNL3D_1_1CPatchQuadBlock.html#m0">PatchBlockId</a>.PatchId;
00445                 tri.V0= p2; tri.V1= p3; tri.V2= p0;
00446                 tri.Uv0= uv2; tri.Uv1= uv3; tri.Uv2= uv0;
00447         }
00448 
00449 }
00450 
00451 
00452 <font class="comment">// ***************************************************************************</font>
<a name="l00453"></a><a class="code" href="classNL3D_1_1CPatch.html#z670_1">00453</a> <font class="keywordtype">void</font>            CPatch::fillPatchQuadBlock(CPatchQuadBlock &amp;quadBlock)  <font class="keyword">const</font>
00454 {
00455         CPatchBlockIdent        &amp;pbId= quadBlock.PatchBlockId;
00456         uint    lenS= pbId.S1-pbId.S0;
00457         uint    lenT= pbId.T1-pbId.T0;
00458         <a class="code" href="debug_8h.html#a6">nlassert</a>( pbId.OrderS==OrderS );
00459         <a class="code" href="debug_8h.html#a6">nlassert</a>( pbId.OrderT==OrderT );
00460         <a class="code" href="debug_8h.html#a6">nlassert</a>( pbId.S1&lt;=OrderS );
00461         <a class="code" href="debug_8h.html#a6">nlassert</a>( pbId.T1&lt;=OrderT );
00462         <a class="code" href="debug_8h.html#a6">nlassert</a>( pbId.S0&lt;pbId.S1 );
00463         <a class="code" href="debug_8h.html#a6">nlassert</a>( pbId.T0&lt;pbId.T1 );
00464         <a class="code" href="debug_8h.html#a6">nlassert</a>( lenS&lt;=<a class="code" href="patch_8h.html#a9">NL_PATCH_BLOCK_MAX_QUAD</a> );
00465         <a class="code" href="debug_8h.html#a6">nlassert</a>( lenT&lt;=<a class="code" href="patch_8h.html#a9">NL_PATCH_BLOCK_MAX_QUAD</a> );
00466 
00467         <font class="comment">// Fill vertices.</font>
00468         uint    s0= pbId.S0;
00469         uint    t0= pbId.T0;
00470         <font class="comment">// some preca.</font>
00471         <font class="keywordtype">float</font>   startS0= (float)s0 / (float)(OrderS);
00472         <font class="keywordtype">float</font>   startT0= (float)t0 / (float)(OrderT);
00473         <font class="keywordtype">float</font>   ds= 1.0f/(float)(OrderS);
00474         <font class="keywordtype">float</font>   dt= 1.0f/(float)(OrderT);
00475 
00476         <font class="comment">// Parse all quads vertices corner.</font>
00477         uint    sl,tl;
00478         <font class="keywordflow">for</font>(tl=0; tl&lt;lenT+1; tl++)
00479         {
00480                 <font class="keywordtype">float</font>   fs, ft;
00481                 <font class="comment">// compute t patch coordinates.</font>
00482                 ft= startT0 + (float)tl * dt ;
00483                 <font class="keywordflow">for</font>(sl=0; sl&lt;lenS+1; sl++)
00484                 {
00485                         <font class="comment">// compute s patch coordinates.</font>
00486                         fs= startS0 + (float)sl * ds ;
00487 
00488                         <font class="comment">// Must use computeContinousVertex, to ensure continous coordinate on patch edges</font>
00489                         quadBlock.Vertices[sl + tl*<a class="code" href="patch_8h.html#a10">NL_PATCH_BLOCK_MAX_VERTEX</a>]= computeContinousVertex(fs, ft);
00490                 }
00491         }
00492 
00493 }
00494 
00495 
00496 <font class="comment">// ***************************************************************************</font>
<a name="l00497"></a><a class="code" href="classNL3D_1_1CPatch.html#z670_2">00497</a> <font class="keywordtype">void</font>            CPatch::addPatchBlocksInBBox(CPatchIdent paId, <font class="keyword">const</font> CAABBox &amp;bbox, std::vector&lt;CPatchBlockIdent&gt; &amp;paBlockIds)<font class="keyword"> const</font>
00498 <font class="keyword"></font>{
00499         CBezierPatch    &amp;bpatch= *<a class="code" href="classNL3D_1_1CPatch.html#a45">unpackIntoCache</a>();
00500 
00501         <font class="comment">// call with the whole root patch.</font>
00502         <a class="code" href="classNL3D_1_1CPatch.html#z683_3">addPatchBlocksInBBoxRecurs</a>(paId, bbox, paBlockIds, bpatch, 0, <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>, 0, <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>);
00503 }
00504 
00505 
00506 <font class="comment">// ***************************************************************************</font>
<a name="l00507"></a><a class="code" href="classNL3D_1_1CPatch.html#z683_3">00507</a> <font class="keywordtype">void</font>            CPatch::addPatchBlocksInBBoxRecurs(CPatchIdent paId, <font class="keyword">const</font> CAABBox &amp;bbox, std::vector&lt;CPatchBlockIdent&gt; &amp;paBlockIds, 
00508                 <font class="keyword">const</font> CBezierPatch &amp;pa, uint8 s0, uint8 s1, uint8 t0, uint8 t1)<font class="keyword"> const</font>
00509 <font class="keyword"></font>{
00510         uint8   lenS=s1-s0, lenT=t1-t0;
00511         <a class="code" href="debug_8h.html#a6">nlassert</a>(lenS&gt;0);
00512         <a class="code" href="debug_8h.html#a6">nlassert</a>(lenT&gt;0);
00513 
00514         <font class="comment">// compute and compare bbox of the subdivision patch against request bbox.</font>
00515         <font class="comment">//========================</font>
00516         <font class="comment">// NB: this compute includes possible noise.</font>
00517         CAABBox         paBBox;
00518         <a class="code" href="classNL3D_1_1CPatch.html#z683_0">buildBBoxFromBezierPatch</a>(pa, paBBox);
00519         <font class="comment">// if do not intersect, stop here.</font>
00520         <font class="keywordflow">if</font>( !paBBox.intersect(bbox) )
00521                 <font class="keywordflow">return</font>;
00522         <font class="comment">// else if at CPatchQuadBlock tile level, then just add this Id.</font>
00523         <font class="comment">//========================</font>
00524         <font class="keywordflow">else</font> <font class="keywordflow">if</font>( lenS&lt;=<a class="code" href="patch_8h.html#a9">NL_PATCH_BLOCK_MAX_QUAD</a> &amp;&amp; lenT&lt;=<a class="code" href="patch_8h.html#a9">NL_PATCH_BLOCK_MAX_QUAD</a> )
00525         {
00526                 <font class="comment">// Add this PatchBlock desctiptor to the list.</font>
00527                 CPatchBlockIdent        pbId;
00528                 <font class="comment">// Fill struct from this and result of recursion.</font>
00529                 pbId.PatchId= paId;
00530                 pbId.OrderS= <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>;
00531                 pbId.OrderT= <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>;
00532                 pbId.S0= s0;
00533                 pbId.S1= s1;
00534                 pbId.T0= t0;
00535                 pbId.T1= t1;
00536                 <font class="comment">// Add to list.</font>
00537                 paBlockIds.push_back(pbId);
00538         }
00539         <font class="comment">// else subdiv and reccurs.</font>
00540         <font class="comment">//========================</font>
00541         <font class="keywordflow">else</font>
00542         {
00543                 <font class="comment">// Subdivide along the bigger side.</font>
00544                 <font class="keywordflow">if</font>(lenS&gt;lenT)
00545                 {
00546                         <font class="comment">// subdivide.</font>
00547                         CBezierPatch    left, right;
00548                         pa.subdivideS(left, right);
00549                         uint8   sMiddle= (uint8)( ((uint)s0+(uint)s1) /2 );
00550                         <font class="comment">// recurs left.</font>
00551                         <a class="code" href="classNL3D_1_1CPatch.html#z683_3">addPatchBlocksInBBoxRecurs</a>(paId, bbox, paBlockIds, left, s0, sMiddle, t0, t1);
00552                         <font class="comment">// recurs right.</font>
00553                         <a class="code" href="classNL3D_1_1CPatch.html#z683_3">addPatchBlocksInBBoxRecurs</a>(paId, bbox, paBlockIds, right, sMiddle, s1, t0, t1);
00554                 }
00555                 <font class="keywordflow">else</font>
00556                 {
00557                         <font class="comment">// subdivide.</font>
00558                         CBezierPatch    top, bottom;
00559                         pa.subdivideT(top, bottom);
00560                         uint8   tMiddle= (uint8)( ((uint)t0+(uint)t1) /2 );
00561                         <font class="comment">// recurs top.</font>
00562                         <a class="code" href="classNL3D_1_1CPatch.html#z683_3">addPatchBlocksInBBoxRecurs</a>(paId, bbox, paBlockIds, top, s0, s1, t0, tMiddle);
00563                         <font class="comment">// recurs bottom.</font>
00564                         <a class="code" href="classNL3D_1_1CPatch.html#z683_3">addPatchBlocksInBBoxRecurs</a>(paId, bbox, paBlockIds, bottom, s0, s1, tMiddle, t1);
00565                 }
00566         }
00567 
00568 }
00569 
00570 
00571 <font class="comment">// ***************************************************************************</font>
<a name="l00572"></a><a class="code" href="classNL3D_1_1CPatch.html#z670_3">00572</a> CVector         CPatch::getTesselatedPos(CUV uv)<font class="keyword"> const</font>
00573 <font class="keyword"></font>{
00574         <font class="comment">// clamp values.</font>
00575         <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(uv.U, 0, 1);
00576         <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(uv.V, 0, 1);
00577         <font class="comment">// recurs down the 2 sons.</font>
00578         CVector         ret= CVector::Null;
00579         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;getTesselatedPos(uv, <font class="keyword">true</font>, ret);
00580         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;getTesselatedPos(uv, <font class="keyword">true</font>, ret);
00581 
00582         <font class="keywordflow">return</font> ret;
00583 }
00584 
00585 
00586 <font class="comment">// ***************************************************************************</font>
00587 <font class="comment">// ***************************************************************************</font>
00588 <font class="comment">// RENDER LIST.</font>
00589 <font class="comment">// ***************************************************************************</font>
00590 <font class="comment">// ***************************************************************************</font>
00591 
00592 
00593 <font class="comment">// ***************************************************************************</font>
<a name="l00594"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_3">00594</a> <font class="keywordtype">void</font>                    CPatch::addRefTessBlocks()
00595 {
00596         uint    i;
00597 
00598         <a class="code" href="classNL3D_1_1CPatch.html#z678_2">TessBlockRefCount</a>++;
00599         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size()==0)
00600         {
00601                 <font class="comment">// Allocate the tessblocks.</font>
00602                 <font class="comment">//==========</font>
00603 
00604                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="tess__block_8h.html#a1">NL3D_TESSBLOCK_TILESIZE</a>==4);
00605                 <font class="comment">// A tessblock is 2*2 tiles.</font>
00606                 sint os= <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;&gt;1;
00607                 sint ot= <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>&gt;&gt;1;
00608                 <a class="code" href="debug_8h.html#a6">nlassert</a>(os&gt;0);
00609                 <a class="code" href="debug_8h.html#a6">nlassert</a>(ot&gt;0);
00610                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.resize(os*ot);
00611                 <font class="comment">// init all tessBlocks with the Patch ptr.</font>
00612                 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00613                         <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i].init(<font class="keyword">this</font>);
00614 
00615 
00616 
00617                 <font class="comment">// Vegetable management</font>
00618                 <font class="comment">//==========</font>
00619                 CVegetableManager       *vegetableManager= <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;_VegetableManager;
00620 
00621                 <font class="comment">// Create ClipBlocks.</font>
00622                 uint    nTbPerCb= <a class="code" href="patch_8h.html#a13">NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK</a>;
00623                 uint    wCB= (os + nTbPerCb-1) &gt;&gt; <a class="code" href="patch_8h.html#a12">NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT</a>;
00624                 uint    hCB= (ot + nTbPerCb-1) &gt;&gt; <a class="code" href="patch_8h.html#a12">NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT</a>;
00625                 <a class="code" href="classNL3D_1_1CPatch.html#z679_0">VegetableClipBlocks</a>.resize(wCB * hCB);
00626                 <font class="comment">// allocate ClipBlocks</font>
00627                 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="classNL3D_1_1CPatch.html#z679_0">VegetableClipBlocks</a>.size(); i++)
00628                 {
00629                         <a class="code" href="classNL3D_1_1CPatch.html#z679_0">VegetableClipBlocks</a>[i]= vegetableManager-&gt;createClipBlock();
00630                 }
00631 
00632 
00633                 <font class="comment">// updateLighting management.</font>
00634                 <font class="comment">//==========</font>
00635                 <font class="comment">// append patch for Near updateLighting, since TessBlock lightmap may/will exist.</font>
00636                 <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;linkPatchToNearUL(<font class="keyword">this</font>);
00637         }
00638 }
00639 
00640 <font class="comment">// ***************************************************************************</font>
<a name="l00641"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_4">00641</a> <font class="keywordtype">void</font>                    CPatch::decRefTessBlocks()
00642 {
00643         <a class="code" href="classNL3D_1_1CPatch.html#z678_2">TessBlockRefCount</a>--;
00644         <font class="comment">// If no loinger need the tessblocks, delete them.</font>
00645         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#z678_2">TessBlockRefCount</a>==0)
00646                 <a class="code" href="classNL3D_1_1CPatch.html#z680_2">clearTessBlocks</a>();
00647         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_2">TessBlockRefCount</a>&gt;=0);
00648 }
00649 
00650 
00651 <font class="comment">// ***************************************************************************</font>
<a name="l00652"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_2">00652</a> <font class="keywordtype">void</font>                    CPatch::clearTessBlocks()
00653 {
00654         uint    i;
00655 
00656         <font class="comment">// Vegetable management</font>
00657         <font class="comment">//==========</font>
00658         <font class="comment">// if compiled.</font>
00659         <font class="keywordflow">if</font>(Zone)
00660         {
00661                 CVegetableManager       *vegetableManager= <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;_VegetableManager;
00662 
00663                 <font class="comment">// delete still existing vegetable Igs.</font>
00664                 <a class="code" href="classNL3D_1_1CPatch.html#z674_0">deleteAllVegetableIgs</a>();
00665 
00666                 <font class="comment">// delete ClipBlocks.</font>
00667                 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="classNL3D_1_1CPatch.html#z679_0">VegetableClipBlocks</a>.size(); i++)
00668                 {
00669                         vegetableManager-&gt;deleteClipBlock(<a class="code" href="classNL3D_1_1CPatch.html#z679_0">VegetableClipBlocks</a>[i]);
00670                 }
00671                 <a class="code" href="namespaceNLMISC.html#a222">contReset</a>(<a class="code" href="classNL3D_1_1CPatch.html#z679_0">VegetableClipBlocks</a>);
00672         }
00673 
00674 
00675         <font class="comment">// updateLighting management.</font>
00676         <font class="comment">//==========</font>
00677         <font class="keywordflow">if</font>(Zone)
00678         {
00679                 <font class="comment">// remove patch from Near updateLighting, since no more TessBlock lightmap can exist.</font>
00680                 <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;unlinkPatchFromNearUL(<font class="keyword">this</font>);
00681         }
00682 
00683 
00684         <font class="comment">// Delete TessBlocks</font>
00685         <font class="comment">//==========</font>
00686         <a class="code" href="classNL3D_1_1CPatch.html#z678_2">TessBlockRefCount</a>=0;
00687         <a class="code" href="namespaceNLMISC.html#a222">contReset</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>);
00688 }
00689 
00690 
00691 <font class="comment">// ***************************************************************************</font>
<a name="l00692"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_1">00692</a> <font class="keywordtype">void</font>                    CPatch::resetMasterBlock()
00693 {
00694         <font class="comment">// We should be not visible so FaceVector no more exist.</font>
00695         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>);
00696 
00697         <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList.clear();
00698         <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarFaceList.clear();
00699         <a class="code" href="classNL3D_1_1CPatch.html#z678_3">NumRenderableFaces</a>= 0;
00700         <font class="comment">// no tiles should be here!!</font>
00701         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.NearVertexList.size()==0);
00702 }
00703 
00704 <font class="comment">// ***************************************************************************</font>
<a name="l00705"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_5">00705</a> uint                    CPatch::getNumTessBlock(CTessFace *face)
00706 {
00707         <font class="comment">// To which tessBlocks link the face?</font>
00708         <font class="comment">// compute an approx middle of the face.</font>
00709         CParamCoord     edgeMid(face-&gt;PVLeft, face-&gt;PVRight);
00710         CParamCoord     middle(edgeMid, face-&gt;PVBase);
00711         <font class="comment">// Coordinate of the tessblock (2*2 a tile!! so the &gt;&gt;1).</font>
00712         uint ts= ((uint)middle.S * (uint)(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;&gt;1)) / 0x8000;
00713         uint tt= ((uint)middle.T * (uint)(<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>&gt;&gt;1)) / 0x8000;
00714         uint numtb= tt*(uint)(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;&gt;1) + ts;
00715 
00716         <font class="keywordflow">return</font> numtb;
00717 }
00718 
00719 
00720 <font class="comment">// ***************************************************************************</font>
<a name="l00721"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_6">00721</a> <font class="keywordtype">void</font>                    CPatch::getNumTessBlock(CParamCoord pc, TFarVertType &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>, uint &amp;numtb)
00722 {
00723         uint    tboS= (uint)(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;&gt;1);
00724         uint    tboT= (uint)(<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>&gt;&gt;1);
00725 
00726         <font class="comment">// Coordinate of the tessblock (2*2 a tile!! so the &gt;&gt;1).</font>
00727         uint ts= ((uint)pc.S * tboS) / 0x8000;
00728         uint tt= ((uint)pc.T * tboT) / 0x8000;
00729         numtb= tt*tboS + ts;
00730 
00731         <font class="keywordtype">bool</font>    edgeS= (ts*0x8000) == ((uint)pc.S * tboS);
00732         <font class="keywordtype">bool</font>    edgeT= (tt*0x8000) == ((uint)pc.T * tboT);
00733 
00734         <font class="comment">// Does this vertex lies on a corner of a TessBlock?</font>
00735         <font class="keywordflow">if</font>(edgeS &amp;&amp; edgeT)
00736                 <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>= <a class="code" href="classNL3D_1_1CPatch.html#z680_0u0">FVMasterBlock</a>;
00737         <font class="comment">// Does this vertex lies on a edge of a TessBlock?</font>
00738         <font class="keywordflow">else</font> <font class="keywordflow">if</font>(edgeS || edgeT)
00739                 <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>= <a class="code" href="classNL3D_1_1CPatch.html#z680_0u2">FVTessBlockEdge</a>;
00740         <font class="comment">// Else it lies exclusively IN a TessBlock.</font>
00741         <font class="keywordflow">else</font>
00742                 <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>= <a class="code" href="classNL3D_1_1CPatch.html#z680_0u1">FVTessBlock</a>;
00743 
00744 }
00745 
00746 
00747 
00748 <font class="comment">// ***************************************************************************</font>
<a name="l00749"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_12">00749</a> <font class="keywordtype">void</font>                    CPatch::extendTessBlockWithEndPos(CTessFace *face)
00750 {
00751         <font class="keywordflow">if</font>(face-&gt;Level&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o5">TessBlockLimitLevel</a>)
00752         {
00753                 <font class="comment">// get the tessBlock of the face.</font>
00754                 uint    numtb= <a class="code" href="classNL3D_1_1CPatch.html#z680_5">getNumTessBlock</a>(face);
00755 
00756                 <font class="comment">// Must enlarge the BSphere of the tesblock!!</font>
00757                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].extendSphereFirst(face-&gt;VBase-&gt;EndPos);
00758                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].extendSphereAdd(face-&gt;VLeft-&gt;EndPos);
00759                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].extendSphereAdd(face-&gt;VRight-&gt;EndPos);
00760                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].extendSphereCompile();
00761         }
00762 }
00763 
00764 
00765 <font class="comment">// ***************************************************************************</font>
<a name="l00766"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_7">00766</a> <font class="keywordtype">void</font>                    CPatch::dirtTessBlockFaceVector(CTessBlock &amp;tb)
00767 {
00768         <font class="comment">// If patch is visible, block's faceVector should exist, but are no more valid.</font>
00769         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>)
00770         {
00771                 <font class="comment">// If this tessBlock not already notified to modification.</font>
00772                 <font class="keywordflow">if</font>(!tb.isInModifyList())
00773                 {
00774                         <font class="comment">// Then append, and delete all FaceVector.</font>
00775                         <font class="comment">// NB: delete FaceVector now, because the TessBlock himself may disapear soon.</font>
00776                         tb.appendToModifyListAndDeleteFaceVector(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;_TessBlockModificationRoot, <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;_FaceVectorManager);
00777                 }
00778         }
00779 }
00780 
00781 
00782 <font class="comment">// ***************************************************************************</font>
<a name="l00783"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_8">00783</a> <font class="keywordtype">void</font>                    CPatch::appendFaceToRenderList(CTessFace *face)
00784 {
00785         <font class="comment">// Update the number of renderable Faces</font>
00786         <a class="code" href="classNL3D_1_1CPatch.html#z678_3">NumRenderableFaces</a>++;
00787 
00788         <font class="comment">// Update Gnal render.</font>
00789         <font class="comment">//====================</font>
00790         <font class="keywordflow">if</font>(face-&gt;Level&lt;<a class="code" href="classNL3D_1_1CPatch.html#o5">TessBlockLimitLevel</a>)
00791         {
00792                 <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarFaceList.append(face);
00793                 <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FaceTileMaterialRefCount++;
00794 
00795                 <font class="comment">// The facelist is modified, so we must update the faceVector, if visible.</font>
00796                 <a class="code" href="classNL3D_1_1CPatch.html#z680_7">dirtTessBlockFaceVector</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>);
00797         }
00798         <font class="keywordflow">else</font>
00799         {
00800                 <font class="comment">// Alloc if necessary the TessBlocks.</font>
00801                 <a class="code" href="classNL3D_1_1CPatch.html#z680_3">addRefTessBlocks</a>();
00802 
00803                 <font class="comment">// link the face to the good tessblock.</font>
00804                 uint    numtb= <a class="code" href="classNL3D_1_1CPatch.html#z680_5">getNumTessBlock</a>(face);
00805                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].FarFaceList.append(face);
00806                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].FaceTileMaterialRefCount++;
00807 
00808                 <font class="comment">// The facelist is modified, so we must update the faceVector, if visible.</font>
00809                 <a class="code" href="classNL3D_1_1CPatch.html#z680_7">dirtTessBlockFaceVector</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb]);
00810 
00811                 <font class="comment">// Must enlarge the BSphere of the tesblock!!</font>
00812                 <font class="comment">// We must do it on a per-face approach, because of tessblocks 's corners which are outside of tessblocks.</font>
00813                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].extendSphereFirst(face-&gt;VBase-&gt;EndPos);
00814                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].extendSphereAdd(face-&gt;VLeft-&gt;EndPos);
00815                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].extendSphereAdd(face-&gt;VRight-&gt;EndPos);
00816                 <font class="comment">// I think this should be done too on StartPos, for geomorph (rare??...) problems.</font>
00817                 <font class="comment">// \todo yoyo: is this necessary???</font>
00818                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].extendSphereAdd(face-&gt;VBase-&gt;StartPos);
00819                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].extendSphereAdd(face-&gt;VLeft-&gt;StartPos);
00820                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].extendSphereAdd(face-&gt;VRight-&gt;StartPos);
00821                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].extendSphereCompile();
00822 
00823 
00824                 <font class="comment">// Update Tile render (no need to do it if face not at least at tessblock level).</font>
00825                 <a class="code" href="classNL3D_1_1CPatch.html#z680_10">appendFaceToTileRenderList</a>(face);
00826         }
00827 }
00828 
00829 
00830 <font class="comment">// ***************************************************************************</font>
<a name="l00831"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_9">00831</a> <font class="keywordtype">void</font>                    CPatch::removeFaceFromRenderList(CTessFace *face)
00832 {
00833         <font class="comment">// Update the number of renderable Faces</font>
00834         <a class="code" href="classNL3D_1_1CPatch.html#z678_3">NumRenderableFaces</a>--;
00835         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_3">NumRenderableFaces</a>&gt;=0);
00836 
00837         <font class="comment">// Update Gnal render.</font>
00838         <font class="comment">//====================</font>
00839         <font class="keywordflow">if</font>(face-&gt;Level&lt;<a class="code" href="classNL3D_1_1CPatch.html#o5">TessBlockLimitLevel</a>)
00840         {
00841                 <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarFaceList.remove(face);
00842                 <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FaceTileMaterialRefCount--;
00843 
00844                 <font class="comment">// The facelist is modified, so we must update the faceVector, if visible.</font>
00845                 <a class="code" href="classNL3D_1_1CPatch.html#z680_7">dirtTessBlockFaceVector</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>);
00846         }
00847         <font class="keywordflow">else</font>
00848         {
00849                 <font class="comment">// link the face to the good tessblock.</font>
00850                 uint    numtb= <a class="code" href="classNL3D_1_1CPatch.html#z680_5">getNumTessBlock</a>(face);
00851                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].FarFaceList.remove(face);
00852                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].FaceTileMaterialRefCount--;
00853 
00854                 <font class="comment">// The facelist is modified, so we must update the faceVector, if visible.</font>
00855                 <a class="code" href="classNL3D_1_1CPatch.html#z680_7">dirtTessBlockFaceVector</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb]);
00856 
00857                 <font class="comment">// Update Tile render (no need to do it if face not at least at tessblock level).</font>
00858                 <a class="code" href="classNL3D_1_1CPatch.html#z680_11">removeFaceFromTileRenderList</a>(face);
00859 
00860                 <font class="comment">// Destroy if necessary the TessBlocks.</font>
00861                 <a class="code" href="classNL3D_1_1CPatch.html#z680_4">decRefTessBlocks</a>();
00862         }
00863 }
00864 
00865 
00866 <font class="comment">// ***************************************************************************</font>
<a name="l00867"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_10">00867</a> <font class="keywordtype">void</font>                    CPatch::appendFaceToTileRenderList(CTessFace *face)
00868 {
00869         <font class="keywordflow">if</font>(face-&gt;TileMaterial)
00870         {
00871                 <font class="comment">// For all valid faces, update their links.</font>
00872                 <font class="comment">// Do not do this for lightmap, since it use same face from RGB0 pass.</font>
00873                 <font class="keywordflow">for</font>(sint i=0;i&lt;<a class="code" href="landscape__def_8h.html#a1">NL3D_MAX_TILE_FACE</a>;i++)
00874                 {
00875                         CPatchRdrPass   *tilePass= face-&gt;TileMaterial-&gt;Pass[i].PatchRdrPass;
00876                         <font class="comment">// If tile i enabled.</font>
00877                         <font class="keywordflow">if</font>(tilePass)
00878                         {
00879                                 <font class="comment">// a face should have created for this pass.</font>
00880                                 <a class="code" href="debug_8h.html#a6">nlassert</a>(face-&gt;TileFaces[i]);
00881                                 face-&gt;TileMaterial-&gt;TileFaceList[i].append(face-&gt;TileFaces[i]);
00882                         }
00883                 }
00884 
00885                 <font class="comment">// The facelist is modified, so we must update the faceVector, if visible.</font>
00886                 uint    numtb= <a class="code" href="classNL3D_1_1CPatch.html#z680_5">getNumTessBlock</a>(face);
00887                 <a class="code" href="classNL3D_1_1CPatch.html#z680_7">dirtTessBlockFaceVector</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb]);
00888         }
00889 }
00890 
00891 
00892 <font class="comment">// ***************************************************************************</font>
<a name="l00893"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_11">00893</a> <font class="keywordtype">void</font>                    CPatch::removeFaceFromTileRenderList(CTessFace *face)
00894 {
00895         <font class="keywordflow">if</font>(face-&gt;TileMaterial)
00896         {
00897                 <font class="comment">// For all valid faces, update their links.</font>
00898                 <font class="comment">// Do not do this for lightmap, since it use same face from RGB0 pass.</font>
00899                 <font class="keywordflow">for</font>(sint i=0;i&lt;<a class="code" href="landscape__def_8h.html#a1">NL3D_MAX_TILE_FACE</a>;i++)
00900                 {
00901                         CPatchRdrPass   *tilePass= face-&gt;TileMaterial-&gt;Pass[i].PatchRdrPass;
00902                         <font class="comment">// If tile i enabled.</font>
00903                         <font class="keywordflow">if</font>(tilePass)
00904                         {
00905                                 <font class="comment">// a face should have created for this pass.</font>
00906                                 <a class="code" href="debug_8h.html#a6">nlassert</a>(face-&gt;TileFaces[i]);
00907                                 face-&gt;TileMaterial-&gt;TileFaceList[i].remove(face-&gt;TileFaces[i]);
00908                         }
00909                 }
00910 
00911                 <font class="comment">// The facelist is modified, so we must update the faceVector, if visible.</font>
00912                 uint    numtb= <a class="code" href="classNL3D_1_1CPatch.html#z680_5">getNumTessBlock</a>(face);
00913                 <a class="code" href="classNL3D_1_1CPatch.html#z680_7">dirtTessBlockFaceVector</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb]);
00914         }
00915 }
00916 
00917 
00918 <font class="comment">// ***************************************************************************</font>
<a name="l00919"></a><a class="code" href="classNL3D_1_1CPatch.html#c35">00919</a> <font class="keywordtype">void</font>                    CPatch::computeTbTm(uint &amp;numtb, uint &amp;numtm, uint ts, uint tt)
00920 {
00921         sint    is= ts&amp;1;
00922         sint    it= tt&amp;1;
00923         ts&gt;&gt;=1;
00924         tt&gt;&gt;=1;
00925         
00926         numtb= tt*(uint)(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;&gt;1) + ts;
00927         numtm= it*2+is;
00928 }
00929 
00930 
00931 <font class="comment">// ***************************************************************************</font>
<a name="l00932"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_13">00932</a> <font class="keywordtype">void</font>                    CPatch::appendTileMaterialToRenderList(CTileMaterial *tm)
00933 {
00934         <a class="code" href="debug_8h.html#a6">nlassert</a>(tm);
00935 
00936         <font class="comment">// Alloc if necessary the TessBlocks.</font>
00937         <a class="code" href="classNL3D_1_1CPatch.html#z680_3">addRefTessBlocks</a>();
00938 
00939         uint    numtb, numtm;
00940         <a class="code" href="classNL3D_1_1CPatch.html#c35">computeTbTm</a>(numtb, numtm, tm-&gt;TileS, tm-&gt;TileT);
00941         <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].RdrTileRoot[numtm]= tm;
00942         <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].FaceTileMaterialRefCount++;
00943         <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].TileMaterialRefCount++;
00944         <font class="comment">// The master block contains the whole patch TileMaterialRefCount</font>
00945         <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.TileMaterialRefCount++;
00946 
00947         <font class="comment">// DynamicLighting. When in near, must compute the context, to have good UVs.</font>
00948         <font class="comment">//==========</font>
00949         <font class="comment">// inc ref to the context, creating it if needed.</font>
00950         <a class="code" href="classNL3D_1_1CPatch.html#z688_0">addRefDLMContext</a>();
00951         <font class="comment">// NB: do it before creating the vegetableBlock, because vegetables use DLM Uvs.</font>
00952 
00953         <font class="comment">// if was no tiles before in this tessBlock, create a Vegetable block.</font>
00954         <font class="comment">//==========</font>
00955         <font class="comment">// one Tile &lt;=&gt; was 0 before</font>
00956         <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].TileMaterialRefCount == 1 &amp;&amp; <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;isVegetableActive() )
00957         {
00958                 <a class="code" href="classNL3D_1_1CPatch.html#z686_0">createVegetableBlock</a>(numtb, tm-&gt;TileS, tm-&gt;TileT);
00959         }
00960 
00961 }
00962 <font class="comment">// ***************************************************************************</font>
<a name="l00963"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_14">00963</a> <font class="keywordtype">void</font>                    CPatch::removeTileMaterialFromRenderList(CTileMaterial *tm)
00964 {
00965         <a class="code" href="debug_8h.html#a6">nlassert</a>(tm);
00966 
00967         uint    numtb, numtm;
00968         <a class="code" href="classNL3D_1_1CPatch.html#c35">computeTbTm</a>(numtb, numtm, tm-&gt;TileS, tm-&gt;TileT);
00969         <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].RdrTileRoot[numtm]= NULL;
00970         <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].FaceTileMaterialRefCount--;
00971         <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].TileMaterialRefCount--;
00972         <font class="comment">// The master block contains the whole patch TileMaterialRefCount</font>
00973         <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.TileMaterialRefCount--;
00974 
00975         <font class="comment">// if no more tiles in this tessBlock, delete the vegetable Block.</font>
00976         <font class="comment">//==========</font>
00977         <font class="comment">// if no more tiles in this tessBlock</font>
00978         <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].TileMaterialRefCount==0 )
00979         {
00980                 <font class="comment">// release the vegetableBlock (if any)</font>
00981                 <a class="code" href="classNL3D_1_1CPatch.html#z686_1">releaseVegetableBlock</a>(numtb);
00982         }
00983 
00984         <font class="comment">// Destroy if necessary the TessBlocks.</font>
00985         <a class="code" href="classNL3D_1_1CPatch.html#z680_4">decRefTessBlocks</a>();
00986 
00987         <font class="comment">// DynamicLighting. When in near, must compute the context, to have good UVs.</font>
00988         <font class="comment">//==========</font>
00989         <font class="comment">// dec ref the context, deleting it if needed.</font>
00990         <a class="code" href="classNL3D_1_1CPatch.html#z688_1">decRefDLMContext</a>();
00991 }
00992 
00993 
00994 <font class="comment">// ***************************************************************************</font>
<a name="l00995"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_15">00995</a> <font class="keywordtype">void</font>                    CPatch::appendFarVertexToRenderList(CTessFarVertex *fv)
00996 {
00997         <a class="code" href="classNL3D_1_1CPatch.html#z680_0">TFarVertType</a>    <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>;
00998         uint                    numtb;
00999         <a class="code" href="classNL3D_1_1CPatch.html#z680_5">getNumTessBlock</a>(fv-&gt;PCoord, <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>, numtb);
01000         
01001         
01002         <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==<a class="code" href="classNL3D_1_1CPatch.html#z680_0u0">FVMasterBlock</a> || <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==<a class="code" href="classNL3D_1_1CPatch.html#z680_0u2">FVTessBlockEdge</a>)
01003         {
01004                 fv-&gt;OwnerBlock= &amp;<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>;
01005                 <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList.append(fv);
01006         }
01007         <font class="keywordflow">else</font> 
01008         {
01009                 <font class="comment">// Alloc if necessary the TessBlocks.</font>
01010                 <a class="code" href="classNL3D_1_1CPatch.html#z680_3">addRefTessBlocks</a>();
01011 
01012                 fv-&gt;OwnerBlock= &amp;<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb];
01013                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].FarVertexList.append(fv);
01014         }
01015 }
01016 <font class="comment">// ***************************************************************************</font>
<a name="l01017"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_16">01017</a> <font class="keywordtype">void</font>                    CPatch::removeFarVertexFromRenderList(CTessFarVertex *fv)
01018 {
01019         <a class="code" href="classNL3D_1_1CPatch.html#z680_0">TFarVertType</a>    <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>;
01020         uint                    numtb;
01021         <a class="code" href="classNL3D_1_1CPatch.html#z680_5">getNumTessBlock</a>(fv-&gt;PCoord, <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>, numtb);
01022         
01023         
01024         <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==<a class="code" href="classNL3D_1_1CPatch.html#z680_0u0">FVMasterBlock</a> || <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==<a class="code" href="classNL3D_1_1CPatch.html#z680_0u2">FVTessBlockEdge</a>)
01025         {
01026                 <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList.remove(fv);
01027                 fv-&gt;OwnerBlock= NULL;
01028         }
01029         <font class="keywordflow">else</font> 
01030         {
01031                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].FarVertexList.remove(fv);
01032                 fv-&gt;OwnerBlock= NULL;
01033 
01034                 <font class="comment">// Destroy if necessary the TessBlocks.</font>
01035                 <a class="code" href="classNL3D_1_1CPatch.html#z680_4">decRefTessBlocks</a>();
01036         }
01037 }
01038 
01039 
01040 <font class="comment">// ***************************************************************************</font>
<a name="l01041"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_17">01041</a> <font class="keywordtype">void</font>                    CPatch::appendNearVertexToRenderList(CTileMaterial *tileMat, CTessNearVertex *nv)
01042 {
01043         <a class="code" href="debug_8h.html#a6">nlassert</a>(tileMat);
01044 
01045         <font class="comment">// Alloc if necessary the TessBlocks.</font>
01046         <a class="code" href="classNL3D_1_1CPatch.html#z680_3">addRefTessBlocks</a>();
01047 
01048         uint    numtb, numtm;
01049         <a class="code" href="classNL3D_1_1CPatch.html#c35">computeTbTm</a>(numtb, numtm, tileMat-&gt;TileS, tileMat-&gt;TileT);
01050         nv-&gt;OwnerBlock= &amp;<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb];
01051         <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].NearVertexList.append(nv);
01052 }
01053 <font class="comment">// ***************************************************************************</font>
<a name="l01054"></a><a class="code" href="classNL3D_1_1CPatch.html#z680_18">01054</a> <font class="keywordtype">void</font>                    CPatch::removeNearVertexFromRenderList(CTileMaterial *tileMat, CTessNearVertex *nv)
01055 {
01056         <a class="code" href="debug_8h.html#a6">nlassert</a>(tileMat);
01057 
01058         uint    numtb, numtm;
01059         <a class="code" href="classNL3D_1_1CPatch.html#c35">computeTbTm</a>(numtb, numtm, tileMat-&gt;TileS, tileMat-&gt;TileT);
01060         <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb].NearVertexList.remove(nv);
01061         nv-&gt;OwnerBlock= NULL;
01062 
01063         <font class="comment">// Destroy if necessary the TessBlocks.</font>
01064         <a class="code" href="classNL3D_1_1CPatch.html#z680_4">decRefTessBlocks</a>();
01065 }
01066 
01067 
01068 
01069 <font class="comment">// ***************************************************************************</font>
01070 <font class="comment">// ***************************************************************************</font>
01071 <font class="comment">// BASIC BUILD.</font>
01072 <font class="comment">// ***************************************************************************</font>
01073 <font class="comment">// ***************************************************************************</font>
01074 
01075 
01076 
01077 
01078 <font class="comment">// ***************************************************************************</font>
<a name="l01079"></a><a class="code" href="classNL3D_1_1CPatch.html#c4">01079</a> <font class="keywordtype">void</font>                    CPatch::makeRoots()
01080 {
01081         CTessVertex *a= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[0];
01082         CTessVertex *b= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[1];
01083         CTessVertex *c= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[2];
01084         CTessVertex *d= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[3];
01085 
01086         <font class="comment">// Set positions.</font>
01087         a-&gt;Pos= a-&gt;StartPos= a-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(0,0);
01088         b-&gt;Pos= b-&gt;StartPos= b-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(0,1);
01089         c-&gt;Pos= c-&gt;StartPos= c-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(1,1);
01090         d-&gt;Pos= d-&gt;StartPos= d-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(1,0);
01091 
01092         <font class="comment">// Init Far vetices.</font>
01093         CTessFarVertex *fa= &amp;<a class="code" href="classNL3D_1_1CPatch.html#o12">BaseFarVertices</a>[0];
01094         CTessFarVertex *fb= &amp;<a class="code" href="classNL3D_1_1CPatch.html#o12">BaseFarVertices</a>[1];
01095         CTessFarVertex *fc= &amp;<a class="code" href="classNL3D_1_1CPatch.html#o12">BaseFarVertices</a>[2];
01096         CTessFarVertex *fd= &amp;<a class="code" href="classNL3D_1_1CPatch.html#o12">BaseFarVertices</a>[3];
01097         fa-&gt;Src= a;
01098         fa-&gt;PCoord.setST(0,0);
01099         fb-&gt;Src= b;
01100         fb-&gt;PCoord.setST(0,1);
01101         fc-&gt;Src= c;
01102         fc-&gt;PCoord.setST(1,1);
01103         fd-&gt;Src= d;
01104         fd-&gt;PCoord.setST(1,0);
01105 
01106         <font class="comment">// We don't have to fill the Far vertices VB here, because this patch is still not visible.</font>
01107         <font class="comment">// NB: we can't because we don't have any driver here.</font>
01108         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>==<font class="keyword">true</font>);
01109 
01110 
01111         <font class="comment">// Make Roots.</font>
01112         <font class="comment">/*</font>
01113 <font class="comment">                Tesselation layout. For Square Face, and if OrderS&gt;=OrderT.</font>
01114 <font class="comment"></font>
01115 <font class="comment">                A-------D</font>
01116 <font class="comment">                |\ Son1 |</font>
01117 <font class="comment">                |  \    |</font>
01118 <font class="comment">                |    \  |</font>
01119 <font class="comment">                | Son0 \|</font>
01120 <font class="comment">                B-------C</font>
01121 <font class="comment"></font>
01122 <font class="comment">                For rectangles whith OrderT&gt;OrderS. It is VERY IMPORTANT, for splitRectangular() reasons.</font>
01123 <font class="comment"></font>
01124 <font class="comment">                A-------D</font>
01125 <font class="comment">                | Son0 /|</font>
01126 <font class="comment">                |    /  |</font>
01127 <font class="comment">                |  /    |</font>
01128 <font class="comment">                |/ Son1 |</font>
01129 <font class="comment">                B-------C</font>
01130 <font class="comment"></font>
01131 <font class="comment">        */</font>
01132         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>==NULL);
01133         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>==NULL);
01134         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>= <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;newTessFace();
01135         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>= <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;newTessFace();
01136 
01137         <font class="comment">// Son0.</font>
01138         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;Patch= <font class="keyword">this</font>;
01139         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;Level= 0;
01140         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>)
01141         {
01142                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VBase= b;
01143                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VLeft= c;
01144                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VRight= a;
01145                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FVBase= fb;
01146                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FVLeft= fc;
01147                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FVRight= fa;
01148                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;PVBase.setST(0, 1);
01149                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;PVLeft.setST(1, 1);
01150                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;PVRight.setST(0, 0);
01151         }
01152         <font class="keywordflow">else</font>
01153         {
01154                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VBase= a;
01155                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VLeft= b;
01156                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VRight= d;
01157                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FVBase= fa;
01158                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FVLeft= fb;
01159                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FVRight= fd;
01160                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;PVBase.setST(0, 0);
01161                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;PVLeft.setST(0, 1);
01162                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;PVRight.setST(1, 0);
01163         }
01164         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FBase= <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>;
01165         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FLeft= NULL;
01166         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FRight= NULL;
01167         <font class="comment">// No tile info.</font>
01168         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;Size= <a class="code" href="classNL3D_1_1CPatch.html#o8">ErrorSize</a>/2;
01169         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;computeSplitPoint();
01170 
01171         <font class="comment">// Son1.</font>
01172         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;Patch= <font class="keyword">this</font>;
01173         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;Level= 0;
01174         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>)
01175         {
01176                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VBase= d;
01177                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VLeft= a;
01178                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VRight= c;
01179                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FVBase= fd;
01180                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FVLeft= fa;
01181                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FVRight= fc;
01182                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;PVBase.setST(1, 0);
01183                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;PVLeft.setST(0, 0);
01184                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;PVRight.setST(1, 1);
01185         }
01186         <font class="keywordflow">else</font>
01187         {
01188                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VBase= c;
01189                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VLeft= d;
01190                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VRight= b;
01191                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FVBase= fc;
01192                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FVLeft= fd;
01193                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FVRight= fb;
01194                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;PVBase.setST(1, 1);
01195                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;PVLeft.setST(1, 0);
01196                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;PVRight.setST(0, 1);
01197         }
01198         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FBase= <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>;
01199         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FLeft= NULL;
01200         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FRight= NULL;
01201         <font class="comment">// No tile info.</font>
01202         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;Size= <a class="code" href="classNL3D_1_1CPatch.html#o8">ErrorSize</a>/2;
01203         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;computeSplitPoint();
01204 
01205 
01206         <font class="comment">// Prepare the render list...</font>
01207         <a class="code" href="classNL3D_1_1CPatch.html#z680_2">clearTessBlocks</a>();
01208         <a class="code" href="classNL3D_1_1CPatch.html#z680_1">resetMasterBlock</a>();
01209         <a class="code" href="classNL3D_1_1CPatch.html#z680_15">appendFarVertexToRenderList</a>(fa);
01210         <a class="code" href="classNL3D_1_1CPatch.html#z680_15">appendFarVertexToRenderList</a>(fb);
01211         <a class="code" href="classNL3D_1_1CPatch.html#z680_15">appendFarVertexToRenderList</a>(fc);
01212         <a class="code" href="classNL3D_1_1CPatch.html#z680_15">appendFarVertexToRenderList</a>(fd);
01213         <a class="code" href="classNL3D_1_1CPatch.html#z680_8">appendFaceToRenderList</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>);
01214         <a class="code" href="classNL3D_1_1CPatch.html#z680_8">appendFaceToRenderList</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>);
01215 
01216         <font class="comment">// Usefull for geomorph: Init 2 root faces MaxNearLimit, and MaxFaceSize</font>
01217         <font class="comment">// NB: since no geomorph is made on endpoints (StartPos==EndPos) of patchs, this is not usefull.</font>
01218         <font class="comment">// but it is important to ensure the VP or software geomorph won't crash with bad float values.</font>
01219         <font class="comment">// Init MaxFaceSize.</font>
01220         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VBase-&gt;MaxFaceSize= 1;
01221         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VLeft-&gt;MaxFaceSize= 1;
01222         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VRight-&gt;MaxFaceSize= 1;
01223         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VBase-&gt;MaxFaceSize= 1;
01224         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VLeft-&gt;MaxFaceSize= 1;
01225         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VRight-&gt;MaxFaceSize= 1;
01226         <font class="comment">// Init MaxNearLimit.</font>
01227         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VBase-&gt;MaxNearLimit= 1;
01228         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VLeft-&gt;MaxNearLimit= 1;
01229         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VRight-&gt;MaxNearLimit= 1;
01230         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VBase-&gt;MaxNearLimit= 1;
01231         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VLeft-&gt;MaxNearLimit= 1;
01232         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VRight-&gt;MaxNearLimit= 1;
01233 
01234 }
01235 
01236 
01237 <font class="comment">// ***************************************************************************</font>
<a name="l01238"></a><a class="code" href="classNL3D_1_1CPatch.html#a2">01238</a> <font class="keywordtype">void</font>                    CPatch::compile(CZone *<a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>, uint patchId, uint8 orderS, uint8 orderT, CTessVertex *baseVertices[4], <font class="keywordtype">float</font> errorSize)
01239 {
01240         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>);
01241         <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>;
01242 
01243         <font class="comment">// For updateLighting, get the correct pointer now.</font>
01244         <font class="comment">// Init UL circular list to me</font>
01245         <a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>= <font class="keyword">this</font>;
01246         <a class="code" href="classNL3D_1_1CPatch.html#z687_1">_ULNearNext</a>= <font class="keyword">this</font>;
01247 
01248 
01249         <font class="comment">// Once the patch is inserted and compiled in a zone, it is ready to be rendered.</font>
01250         <font class="comment">// So now fill the Patch info in render pass.</font>
01251         <a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.Patch= <font class="keyword">this</font>;
01252         <a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.Patch= <font class="keyword">this</font>;
01253 
01254         <font class="comment">// init also the MasterBlock.</font>
01255         <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.init(<font class="keyword">this</font>);
01256 
01257         <font class="comment">// only 65536 patch per zone allowed.</font>
01258         <a class="code" href="debug_8h.html#a6">nlassert</a>(patchId&lt;0x10000);
01259         <a class="code" href="classNL3D_1_1CPatch.html#o1">PatchId</a>= (uint16)patchId;
01260 
01261         <font class="keywordflow">if</font>(errorSize==0)
01262                 <a class="code" href="classNL3D_1_1CPatch.html#c3">computeDefaultErrorSize</a>();
01263         <font class="keywordflow">else</font>
01264                 <a class="code" href="classNL3D_1_1CPatch.html#o8">ErrorSize</a>= errorSize;
01265 
01266         <a class="code" href="debug_8h.html#a6">nlassert</a>(orderS==2 || orderS==4 || orderS==8 || orderS==16);
01267         <a class="code" href="debug_8h.html#a6">nlassert</a>(orderT==2 || orderT==4 || orderT==8 || orderT==16);
01268         <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>==orderS);
01269         <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>==orderT);
01270 
01271         <font class="comment">// Compile additional infos.</font>
01272         sint    ps= <a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a>(orderS) , pt= <a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a>(orderT);
01273         sint    pmin= <a class="code" href="bit__set_8cpp.html#a0">min</a>(ps,pt);
01274         sint    pmax= max(ps,pt);
01275         <font class="comment">// Rectangular patch OK.</font>
01276         <font class="comment">// Work, since patch 1xX are illegal. =&gt; The TileLimitLevel is at least 2 level distant from the time where</font>
01277         <font class="comment">// the rectangular patch is said "un-rectangular-ed" (tesselation looks like square). Hence, there is no problem</font>
01278         <font class="comment">// with rectangular UV geomorph (well don't bother me, make a draw :) ).</font>
01279         <a class="code" href="classNL3D_1_1CPatch.html#o6">TileLimitLevel</a>= pmin*2 + pmax-pmin;
01280         <font class="comment">// A TessBlock is a 2*2 tile. This simple formula works because patch 1xX are illegal.</font>
01281         <a class="code" href="classNL3D_1_1CPatch.html#o5">TessBlockLimitLevel</a>= <a class="code" href="classNL3D_1_1CPatch.html#o6">TileLimitLevel</a>-2;
01282         <font class="comment">// This tell us when the tess face is "un-rectangular-ed" (to say a square). Before, it is a "rectangular" face, </font>
01283         <font class="comment">// which has a strange fxxxxxg split.</font>
01284         <font class="comment">// If patch is square, then SquareLimitLevel=0 (ok!!).</font>
01285         <a class="code" href="classNL3D_1_1CPatch.html#o7">SquareLimitLevel</a>= pmax-pmin;
01286 
01287         <font class="comment">// Buil the BSPhere.</font>
01288         CAABBox bb= <a class="code" href="classNL3D_1_1CPatch.html#a14">buildBBox</a>();
01289         <a class="code" href="classNL3D_1_1CPatch.html#o13">BSphere</a>.Center= bb.getCenter();
01290         <a class="code" href="classNL3D_1_1CPatch.html#o13">BSphere</a>.Radius= bb.getRadius();
01291 
01292         <font class="comment">// Bind vertices, to zone base vertices.</font>
01293         <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[0]= baseVertices[0];
01294         <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[1]= baseVertices[1];
01295         <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[2]= baseVertices[2];
01296         <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[3]= baseVertices[3];
01297 
01298         <font class="comment">// build Sons.</font>
01299         <a class="code" href="classNL3D_1_1CPatch.html#c4">makeRoots</a>();
01300 }
01301 <font class="comment">// ***************************************************************************</font>
<a name="l01302"></a><a class="code" href="classNL3D_1_1CPatch.html#a16">01302</a> CVector                 CPatch::computeVertex(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)<font class="keyword"> const</font>
01303 <font class="keyword"></font>{
01304         <font class="comment">// \todo yoyo: TODO_UVCORRECT: use UV correction.</font>
01305 
01306         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;getNoiseMode())
01307         {
01308                 <font class="comment">// compute displacement map to disturb result.</font>
01309                 CVector         displace;
01310                 <a class="code" href="classNL3D_1_1CPatch.html#z685_10">computeNoise</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, displace);
01311 
01312                 <font class="comment">// return patch(s,t) + dispalcement result.</font>
01313                 <font class="comment">// unpack. Do it after computeNoise(), because this last may change the cache.</font>
01314                 CBezierPatch    *patch= <a class="code" href="classNL3D_1_1CPatch.html#a45">unpackIntoCache</a>();
01315                 <font class="keywordflow">return</font> patch-&gt;eval(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>) + displace;
01316         }
01317         <font class="keywordflow">else</font>
01318         {
01319                 <font class="comment">// unpack and return patch(s,t).</font>
01320                 CBezierPatch    *patch= <a class="code" href="classNL3D_1_1CPatch.html#a45">unpackIntoCache</a>();
01321                 <font class="keywordflow">return</font> patch-&gt;eval(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>);
01322         }
01323 }
01324 
01325 
01326 <font class="comment">// ***************************************************************************</font>
<a name="l01327"></a><a class="code" href="classNL3D_1_1CPatch.html#a17">01327</a> CVector                 CPatch::computeContinousVertex(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)<font class="keyword"> const</font>
01328 <font class="keyword"></font>{
01329         <font class="comment">// must be compiled</font>
01330         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>);
01331 
01332         <font class="comment">// Test is on a edge/corner of the patch</font>
01333         sint    edgeIdS= -1;
01334         sint    edgeIdT= -1;
01335         <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>==0)                edgeIdS= 0;
01336         <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>==1)   edgeIdS= 2;
01337         <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>==0)                edgeIdT= 3;
01338         <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>==1)   edgeIdT= 1;
01339 
01340         <font class="comment">// test if on a corner</font>
01341         <font class="keywordflow">if</font>(edgeIdS&gt;=0 &amp;&amp; edgeIdT&gt;=0)
01342         {
01343                 <font class="comment">// return the baseVertex according to edge falgs</font>
01344                 <font class="keywordflow">if</font>(edgeIdS==0 &amp;&amp; edgeIdT==3)    <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[0]-&gt;EndPos;
01345                 <font class="keywordflow">if</font>(edgeIdS==0 &amp;&amp; edgeIdT==1)    <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[1]-&gt;EndPos;
01346                 <font class="keywordflow">if</font>(edgeIdS==2 &amp;&amp; edgeIdT==1)    <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[2]-&gt;EndPos;
01347                 <font class="keywordflow">if</font>(edgeIdS==2 &amp;&amp; edgeIdT==3)    <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[3]-&gt;EndPos;
01348                 <a class="code" href="debug_8h.html#a12">nlstop</a>;
01349                 <font class="comment">// Error, but Avoid warning</font>
01350                 <font class="keywordflow">return</font> CVector::Null;
01351         }
01352         <font class="comment">// test if on an edge</font>
01353         <font class="keywordflow">else</font> <font class="keywordflow">if</font>(edgeIdS&gt;=0 || edgeIdT&gt;=0)
01354         {
01355                 <font class="comment">// Yes, must compute myslef</font>
01356                 CVector         vertexOnMe= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>);
01357 
01358                 <font class="comment">// Then, must compute my neighbor.</font>
01359                 sint    edgeId;
01360                 <font class="keywordflow">if</font>(edgeIdS&gt;=0)
01361                         edgeId= edgeIdS;
01362                 <font class="keywordflow">else</font>
01363                         edgeId= edgeIdT;
01364 
01365                 <font class="comment">// Get my neighbor, if any.</font>
01366                 CBindInfo       bindInfo;
01367                 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edgeId, bindInfo);
01368                 <font class="comment">// Fast reject: if no neighbor on the edge, just return my pos.</font>
01369                 <font class="keywordflow">if</font>(!bindInfo.Zone)
01370                 {
01371                         <font class="keywordflow">return</font> vertexOnMe;
01372                 }
01373                 <font class="comment">// else must get vertex pos of my neighbor, and average.</font>
01374                 <font class="keywordflow">else</font>
01375                 {
01376                         <font class="comment">// use a CPatchUVLocator to get UV in neighbor patch</font>
01377                         CPatchUVLocator         uvLocator;
01378                         uvLocator.build(<font class="keyword">this</font>, edgeId, bindInfo);
01379 
01380                         <font class="comment">// UVlocator use OrderS/OrderT coordinate system.</font>
01381                         CVector2f       stTileIn, stTileOut;
01382                         stTileIn.x= <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> * <a class="code" href="classNL3D_1_1CPatch.html#a6">getOrderS</a>();
01383                         stTileIn.y= <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a> * <a class="code" href="classNL3D_1_1CPatch.html#a7">getOrderT</a>();
01384 
01385                         <font class="comment">// transform coordinate to get into the neigbhor patch</font>
01386                         uint    pid= uvLocator.selectPatch(stTileIn);
01387                         <a class="code" href="classNL3D_1_1CPatch.html#a0">CPatch</a>  *nebPatch;
01388                         uvLocator.locateUV(stTileIn, pid, nebPatch, stTileOut);
01389 
01390                         <font class="comment">// transform neigbhor coord in 0..1 coordinate space.</font>
01391                         stTileOut.x/= nebPatch-&gt;getOrderS();
01392                         stTileOut.y/= nebPatch-&gt;getOrderT();
01393 
01394                         <font class="comment">// and compute vertex. NB: if binded on 2 or 4 patch, it is then possible that stTileOut is on a</font>
01395                         <font class="comment">// a corner ( (0,0), (0,1) ...).</font>
01396                         <font class="comment">// In this case, we must use the precomputed Vertex pos, for completeness.</font>
01397                         <font class="keywordtype">bool</font>            onCorner;
01398                         CVector         vertexOnNeb= nebPatch-&gt;computeVertexButCorner(stTileOut.x, stTileOut.y, onCorner);
01399 
01400                         <font class="comment">// If the neighbor is on a corner, then use its corner value.</font>
01401                         <font class="keywordflow">if</font>(onCorner)
01402                                 <font class="keywordflow">return</font> vertexOnNeb;
01403                         <font class="keywordflow">else</font>
01404                         {
01405                                 <font class="comment">// Average the 2 and return this result.</font>
01406                                 vertexOnMe+= vertexOnNeb;
01407                                 vertexOnMe/= 2;
01408                                 <font class="keywordflow">return</font> vertexOnMe;
01409                         }
01410                 }
01411 
01412         }
01413         <font class="comment">// else, std case</font>
01414         <font class="keywordflow">else</font>
01415                 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>);
01416 }
01417 
01418 
01419 <font class="comment">// ***************************************************************************</font>
<a name="l01420"></a><a class="code" href="classNL3D_1_1CPatch.html#z683_4">01420</a> CVector                 CPatch::computeVertexButCorner(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, <font class="keywordtype">bool</font> &amp;onCorner)<font class="keyword"> const</font>
01421 <font class="keyword"></font>{
01422         <font class="comment">// must be compiled</font>
01423         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>);
01424 
01425         <font class="comment">// Test is on a edge/corner of the patch</font>
01426         sint    edgeIdS= -1;
01427         sint    edgeIdT= -1;
01428         <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>==0)                edgeIdS= 0;
01429         <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>==1)   edgeIdS= 2;
01430         <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>==0)                edgeIdT= 3;
01431         <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>==1)   edgeIdT= 1;
01432 
01433         <font class="comment">// test if on a corner</font>
01434         <font class="keywordflow">if</font>(edgeIdS&gt;=0 &amp;&amp; edgeIdT&gt;=0)
01435         {
01436                 <font class="comment">// indicate that yes, we are on a corner</font>
01437                 onCorner= <font class="keyword">true</font>;
01438                 <font class="comment">// return the baseVertex according to edge falgs</font>
01439                 <font class="keywordflow">if</font>(edgeIdS==0 &amp;&amp; edgeIdT==3)    <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[0]-&gt;EndPos;
01440                 <font class="keywordflow">if</font>(edgeIdS==0 &amp;&amp; edgeIdT==1)    <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[1]-&gt;EndPos;
01441                 <font class="keywordflow">if</font>(edgeIdS==2 &amp;&amp; edgeIdT==1)    <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[2]-&gt;EndPos;
01442                 <font class="keywordflow">if</font>(edgeIdS==2 &amp;&amp; edgeIdT==3)    <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[3]-&gt;EndPos;
01443                 <a class="code" href="debug_8h.html#a12">nlstop</a>;
01444                 <font class="comment">// Error, but Avoid warning</font>
01445                 <font class="keywordflow">return</font> CVector::Null;
01446         }
01447         <font class="comment">// else, std case</font>
01448         <font class="keywordflow">else</font>
01449         {
01450                 onCorner= <font class="keyword">false</font>;
01451                 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>);
01452         }
01453 }
01454 
01455 
01456 <font class="comment">// ***************************************************************************</font>
<a name="l01457"></a><a class="code" href="classNL3D_1_1CPatch.html#a27">01457</a> <font class="keywordtype">void</font>                    CPatch::refineAll()
01458 {
01459         <font class="comment">// refineAll.</font>
01460         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>);
01461         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>);
01462         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;refineAll();
01463         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;refineAll();
01464 }
01465 
01466 
01467 
01468 <font class="comment">// ***************************************************************************</font>
<a name="l01469"></a><a class="code" href="classNL3D_1_1CPatch.html#a21">01469</a> <font class="keywordtype">void</font>                    CPatch::averageTesselationVertices()
01470 {
01471         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>);
01472         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>);
01473 
01474         <font class="comment">// Recompute the BaseVertices. This is usefull for Pacs.</font>
01475         <font class="comment">// Because CLandscape::averageTesselationVertices() is made on a strict order for patchs (map of zones, then </font>
01476         <font class="comment">// array of patchs), we are sure to overwrite BaseVertices in this order.</font>
01477         CTessVertex *a= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[0];
01478         CTessVertex *b= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[1];
01479         CTessVertex *c= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[2];
01480         CTessVertex *d= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[3];
01481         <font class="comment">// Set positions.</font>
01482         a-&gt;Pos= a-&gt;StartPos= a-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(0,0);
01483         b-&gt;Pos= b-&gt;StartPos= b-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(0,1);
01484         c-&gt;Pos= c-&gt;StartPos= c-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(1,1);
01485         d-&gt;Pos= d-&gt;StartPos= d-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(1,0);
01486 
01487 
01488         <font class="comment">// Average the tesselation of sons.</font>
01489         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;averageTesselationVertices();
01490         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;averageTesselationVertices();
01491 }
01492 
01493 
01494 <font class="comment">// ***************************************************************************</font>
<a name="l01495"></a><a class="code" href="classNL3D_1_1CPatch.html#a31">01495</a> <font class="keywordtype">void</font>                    CPatch::refreshTesselationGeometry()
01496 {
01497         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>);
01498         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>);
01499 
01500         <font class="comment">// Recompute the BaseVertices.</font>
01501         CTessVertex *a= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[0];
01502         CTessVertex *b= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[1];
01503         CTessVertex *c= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[2];
01504         CTessVertex *d= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[3];
01505         <font class="comment">// Set positions.</font>
01506         a-&gt;Pos= a-&gt;StartPos= a-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(0,0);
01507         b-&gt;Pos= b-&gt;StartPos= b-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(0,1);
01508         c-&gt;Pos= c-&gt;StartPos= c-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(1,1);
01509         d-&gt;Pos= d-&gt;StartPos= d-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(1,0);
01510 
01511 
01512         <font class="comment">// refresh the tesselation of sons.</font>
01513         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;refreshTesselationGeometry();
01514         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;refreshTesselationGeometry();
01515 }
01516 
01517 
01518 
01519 <font class="comment">// ***************************************************************************</font>
<a name="l01520"></a><a class="code" href="classNL3D_1_1CPatch.html#a26">01520</a> <font class="keywordtype">void</font>                    CPatch::clip(<font class="keyword">const</font> std::vector&lt;CPlane&gt;  &amp;pyramid)
01521 {
01522         <a class="code" href="classNL3D_1_1CPatch.html#o25">Clipped</a>= <font class="keyword">false</font>;
01523         <font class="keywordflow">for</font>(sint i=0;i&lt;(sint)pyramid.size();i++)
01524         {
01525                 <font class="comment">// If entirely out.</font>
01526                 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o13">BSphere</a>.clipBack(pyramid[i]))
01527                 {
01528                         <a class="code" href="classNL3D_1_1CPatch.html#o25">Clipped</a>= <font class="keyword">true</font>;
01529                         <font class="keywordflow">break</font>;
01530                 }
01531         }
01532 
01533         <font class="comment">// A patch clipped is clipped to render too.</font>
01534         <a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>= <a class="code" href="classNL3D_1_1CPatch.html#o25">Clipped</a>;
01535 }
01536 
01537 
01538 <font class="comment">// ***************************************************************************</font>
<a name="l01539"></a><a class="code" href="classNL3D_1_1CPatch.html#a28">01539</a> <font class="keywordtype">void</font>                    CPatch::resetRenderFar()
01540 {
01541         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass)
01542         {
01543                 <font class="comment">// free the render pass.</font>
01544                 <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;Landscape-&gt;freeFarRenderPass (<font class="keyword">this</font>, <a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass, <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>);
01545                 <a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass= NULL;
01546         }
01547         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass)
01548         {
01549                 <font class="comment">// free the render pass.</font>
01550                 <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;Landscape-&gt;freeFarRenderPass (<font class="keyword">this</font>, <a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass, <a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>);
01551                 <a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass= NULL;
01552         }
01553 
01554         <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>= -1;
01555         <a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>= -1;
01556 }
01557 
01558 
01559 <font class="comment">// ***************************************************************************</font>
<a name="l01560"></a><a class="code" href="classNL3D_1_1CPatch.html#a32">01560</a> <font class="keywordtype">void</font>                    CPatch::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f)
01561 {
01562         <font class="comment">/*</font>
01563 <font class="comment">        Version 7:</font>
01564 <font class="comment">                - remove unused information from CTileColor. just keep 565 color</font>
01565 <font class="comment">        Version 6:</font>
01566 <font class="comment">                - default UnderWater flags for tileElements before version 6.</font>
01567 <font class="comment">        Version 5:</font>
01568 <font class="comment">                - TileLightInfluences serialized.</font>
01569 <font class="comment">        Version 4:</font>
01570 <font class="comment">                - Smooth flag serialized</font>
01571 <font class="comment">        Version 3:</font>
01572 <font class="comment">                - NoiseRotation.</font>
01573 <font class="comment">                - NoiseSmooth.</font>
01574 <font class="comment">        Version 2:</font>
01575 <font class="comment">                - Lumels.</font>
01576 <font class="comment">        Version 1:</font>
01577 <font class="comment">                - Tile color.</font>
01578 <font class="comment">        Version 0:</font>
01579 <font class="comment">                - base version.</font>
01580 <font class="comment">        */</font>
01581         uint    ver= f.<a class="code" href="classNLMISC_1_1IStream.html#a29">serialVersion</a>(<a class="code" href="classNL3D_1_1CPatch.html#r0">_Version</a>);
01582 
01583         <font class="comment">// No more compatibility before version 2, because OrderS / OrderT not serialized in preceding version</font>
01584         <font class="comment">// Doens't matter since CZone::serial() do not support it too.</font>
01585         <font class="keywordflow">if</font> (ver&lt;2)
01586         {
01587                 <font class="keywordflow">throw</font> EOlderStream(f);
01588         }
01589 
01590         f.<a class="code" href="classNLMISC_1_1IStream.html#a34">xmlSerial</a> (<a class="code" href="classNL3D_1_1CPatch.html#m0">Vertices</a>[0], <a class="code" href="classNL3D_1_1CPatch.html#m0">Vertices</a>[1], <a class="code" href="classNL3D_1_1CPatch.html#m0">Vertices</a>[2], <a class="code" href="classNL3D_1_1CPatch.html#m0">Vertices</a>[3], <font class="stringliteral">"VERTICIES"</font>);
01591 
01592         f.<a class="code" href="classNLMISC_1_1IStream.html#a38">xmlPush</a> (<font class="stringliteral">"TANGENTS"</font>);
01593         f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a> (<a class="code" href="classNL3D_1_1CPatch.html#m1">Tangents</a>[0], <a class="code" href="classNL3D_1_1CPatch.html#m1">Tangents</a>[1], <a class="code" href="classNL3D_1_1CPatch.html#m1">Tangents</a>[2], <a class="code" href="classNL3D_1_1CPatch.html#m1">Tangents</a>[3]);
01594         f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a> (<a class="code" href="classNL3D_1_1CPatch.html#m1">Tangents</a>[4], <a class="code" href="classNL3D_1_1CPatch.html#m1">Tangents</a>[5], <a class="code" href="classNL3D_1_1CPatch.html#m1">Tangents</a>[6], <a class="code" href="classNL3D_1_1CPatch.html#m1">Tangents</a>[7]);
01595         f.<a class="code" href="classNLMISC_1_1IStream.html#a41">xmlPop</a> ();
01596         
01597         f.<a class="code" href="classNLMISC_1_1IStream.html#a34">xmlSerial</a> (<a class="code" href="classNL3D_1_1CPatch.html#m2">Interiors</a>[0], <a class="code" href="classNL3D_1_1CPatch.html#m2">Interiors</a>[1], <a class="code" href="classNL3D_1_1CPatch.html#m2">Interiors</a>[2], <a class="code" href="classNL3D_1_1CPatch.html#m2">Interiors</a>[3], <font class="stringliteral">"INTERIORS"</font>);
01598 
01599         f.<a class="code" href="classNLMISC_1_1IStream.html#a38">xmlPush</a> (<font class="stringliteral">"TILES"</font>);
01600         f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>);
01601         f.<a class="code" href="classNLMISC_1_1IStream.html#a41">xmlPop</a> ();
01602 
01603         <font class="keywordflow">if</font>(ver&gt;=1)
01604         {
01605                 <font class="comment">// Read/Write TileColors.</font>
01606                 <font class="keywordflow">if</font>(ver&lt;=6)
01607                 {
01608                         <a class="code" href="debug_8h.html#a6">nlassert</a>(f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>());
01609 
01610                         <font class="comment">// read old version of tilesColors (ie with LightX/LightY/LightZ, which are deprecated now)</font>
01611                         vector&lt;CTileColorOldPatchVersion6&gt;      tmpArray;
01612                         f.<a class="code" href="classNLMISC_1_1IStream.html#a38">xmlPush</a> (<font class="stringliteral">"TILE_COLORS"</font>);
01613                         f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(tmpArray);
01614                         f.<a class="code" href="classNLMISC_1_1IStream.html#a41">xmlPop</a> ();
01615 
01616                         <font class="comment">// then just copy to TileColors.</font>
01617                         <a class="code" href="classNL3D_1_1CPatch.html#m5">TileColors</a>.resize(tmpArray.size());
01618                         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#m5">TileColors</a>.size()&gt;0)
01619                         {
01620                                 memcpy(&amp;<a class="code" href="classNL3D_1_1CPatch.html#m5">TileColors</a>[0], &amp;tmpArray[0], <a class="code" href="classNL3D_1_1CPatch.html#m5">TileColors</a>.size()*<font class="keyword">sizeof</font>(CTileColor));
01621                         }
01622                 }
01623                 <font class="keywordflow">else</font>
01624                 {
01625                         <font class="comment">// version &gt;=7, just serial array of TileColors (16 bits TileColor only)</font>
01626                         f.<a class="code" href="classNLMISC_1_1IStream.html#a38">xmlPush</a> (<font class="stringliteral">"TILE_COLORS"</font>);
01627                         f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNL3D_1_1CPatch.html#m5">TileColors</a>);
01628                         f.<a class="code" href="classNLMISC_1_1IStream.html#a41">xmlPop</a> ();
01629                 }
01630         }
01631         <font class="keywordflow">if</font>(ver&gt;=2)
01632         {
01633                 f.<a class="code" href="classNLMISC_1_1IStream.html#a34">xmlSerial</a> (<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>, <font class="stringliteral">"ORDER_S"</font>);
01634                 f.<a class="code" href="classNLMISC_1_1IStream.html#a34">xmlSerial</a> (<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>, <font class="stringliteral">"ORDER_T"</font>);
01635 
01636                 f.<a class="code" href="classNLMISC_1_1IStream.html#a38">xmlPush</a> (<font class="stringliteral">"COMPRESSED_LUMELS"</font>);
01637                         f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNL3D_1_1CPatch.html#m3">CompressedLumels</a>);
01638                 f.<a class="code" href="classNLMISC_1_1IStream.html#a41">xmlPop</a> ();
01639         }
01640         <font class="comment">// Else cannot create here the TileColors, because we need the OrderS/OrderT information... Done into CZone serial.</font>
01641         <font class="keywordflow">if</font>(ver&gt;=3)
01642         {
01643                 f.<a class="code" href="classNLMISC_1_1IStream.html#a34">xmlSerial</a> (<a class="code" href="classNL3D_1_1CPatch.html#z668_2">NoiseRotation</a>, <font class="stringliteral">"NOISE_ROTATION"</font>);
01644                 f.<a class="code" href="classNLMISC_1_1IStream.html#a34">xmlSerial</a> (<a class="code" href="classNL3D_1_1CPatch.html#z668_3">_CornerSmoothFlag</a>, <font class="stringliteral">"CORNER_SMOOTH_FLAG"</font>);
01645         }
01646         <font class="keywordflow">else</font>
01647         {
01648                 <font class="comment">// No Rotation / not smooth by default.</font>
01649                 <a class="code" href="classNL3D_1_1CPatch.html#z668_2">NoiseRotation</a>= 0;
01650                 <a class="code" href="classNL3D_1_1CPatch.html#z668_3">_CornerSmoothFlag</a>= 0;
01651         }
01652         <font class="keywordflow">if</font>(ver&gt;=4)
01653         {
01654                 f.<a class="code" href="classNLMISC_1_1IStream.html#a34">xmlSerial</a>(<a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>, <font class="stringliteral">"FLAGS"</font>);
01655         }
01656         <font class="keywordflow">else</font>
01657         {
01658                 <a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>=<a class="code" href="patch_8h.html#a5">NL_PATCH_SMOOTH_FLAG_MASK</a>;
01659         }
01660 
01661         <font class="comment">// Serialize TileLightInfluences</font>
01662         <font class="keywordflow">if</font>(ver&gt;=5)
01663         {
01664                 f.<a class="code" href="classNLMISC_1_1IStream.html#a38">xmlPush</a> (<font class="stringliteral">"TILE_LIGHT_INFLUENCES"</font>);
01665                 f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNL3D_1_1CPatch.html#m6">TileLightInfluences</a>);
01666                 f.<a class="code" href="classNLMISC_1_1IStream.html#a41">xmlPop</a> ();
01667         }
01668         <font class="keywordflow">else</font>
01669         {
01670                 <font class="keywordflow">if</font>(f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>())
01671                 {
01672                         <font class="comment">// Fill default.</font>
01673                         <a class="code" href="classNL3D_1_1CPatch.html#z675_0">resetTileLightInfluences</a>();
01674                 }
01675         }
01676 
01677         <font class="comment">// if read a too old version, </font>
01678         <font class="keywordflow">if</font>(ver&lt;6 &amp;&amp; f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>())
01679         {
01680                 <font class="comment">// reset tileElements vegetableState to AboveWater.</font>
01681                 <font class="keywordflow">for</font>(uint i=0; i&lt;<a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>.size(); i++)
01682                 {
01683                         <a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[i].setVegetableState(CTileElement::AboveWater);
01684                 }
01685         }
01686 
01687 
01688 }
01689 
01690 
01691 
01692 <font class="comment">// ***************************************************************************</font>
01693 <font class="comment">// ***************************************************************************</font>
01694 <font class="comment">// Bind / UnBind.</font>
01695 <font class="comment">// ***************************************************************************</font>
01696 <font class="comment">// ***************************************************************************</font>
01697 
01698 
01699 
01700 <font class="comment">// ***************************************************************************</font>
<a name="l01701"></a><a class="code" href="classNL3D_1_1CPatch.html#a18">01701</a> <font class="keywordtype">void</font>                    CPatch::unbind()
01702 {
01703         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a> &amp;&amp; <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>);
01704 
01705         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;unbind();
01706         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;unbind();
01707         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;forceMerge();
01708         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;forceMerge();
01709         <font class="comment">// forcemerge should have be completed.</font>
01710         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;isLeaf() &amp;&amp; <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;isLeaf());
01711         <font class="comment">// unbind should have be completed.</font>
01712         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FLeft == NULL);
01713         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FRight == NULL);
01714         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FLeft == NULL);
01715         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FRight == NULL);
01716 
01717 
01718         <font class="comment">// unbind Noise.</font>
01719         <a class="code" href="classNL3D_1_1CPatch.html#z684_1">_BindZoneNeighbor</a>[0]= NULL;
01720         <a class="code" href="classNL3D_1_1CPatch.html#z684_1">_BindZoneNeighbor</a>[1]= NULL;
01721         <a class="code" href="classNL3D_1_1CPatch.html#z684_1">_BindZoneNeighbor</a>[2]= NULL;
01722         <a class="code" href="classNL3D_1_1CPatch.html#z684_1">_BindZoneNeighbor</a>[3]= NULL;
01723 
01724 }
01725 
01726 
01727 <font class="comment">// ***************************************************************************</font>
<a name="l01728"></a><a class="code" href="classNL3D_1_1CPatch.html#c5">01728</a> CTessFace               *CPatch::getRootFaceForEdge(sint edge)<font class="keyword"> const</font>
01729 <font class="keyword"></font>{
01730         <a class="code" href="debug_8h.html#a6">nlassert</a>(edge&gt;=0 &amp;&amp; edge&lt;=3);
01731 
01732         <font class="comment">// See tessellation rules.</font>
01733         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>)
01734         {
01735                 <font class="keywordflow">if</font>(edge==0 || edge==1)
01736                         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>;
01737                 <font class="keywordflow">else</font>
01738                         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>;
01739         }
01740         <font class="keywordflow">else</font>
01741         {
01742                 <font class="keywordflow">if</font>(edge==0 || edge==3)
01743                         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>;
01744                 <font class="keywordflow">else</font>
01745                         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>;
01746         }
01747 }
01748 
01749 <font class="comment">// ***************************************************************************</font>
<a name="l01750"></a><a class="code" href="classNL3D_1_1CPatch.html#c6">01750</a> CTessVertex             *CPatch::getRootVertexForEdge(sint edge)<font class="keyword"> const</font>
01751 <font class="keyword"></font>{
01752         <font class="comment">// Return the vertex which is the start of edge.</font>
01753         <a class="code" href="debug_8h.html#a6">nlassert</a>(edge&gt;=0 &amp;&amp; edge&lt;=3);
01754 
01755         <font class="comment">// See tessellation rules.</font>
01756         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>)
01757         {
01758                 <font class="keywordflow">switch</font>(edge)
01759                 {
01760                         <font class="keywordflow">case</font> 0: <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VRight;
01761                         <font class="keywordflow">case</font> 1: <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VBase;
01762                         <font class="keywordflow">case</font> 2: <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VLeft;
01763                         <font class="keywordflow">case</font> 3: <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VBase;
01764                         <font class="keywordflow">default</font>: <font class="keywordflow">return</font> NULL;
01765                 }
01766         }
01767         <font class="keywordflow">else</font>
01768         {
01769                 <font class="keywordflow">switch</font>(edge)
01770                 {
01771                         <font class="keywordflow">case</font> 0: <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VBase;
01772                         <font class="keywordflow">case</font> 1: <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VLeft;
01773                         <font class="keywordflow">case</font> 2: <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;VBase;
01774                         <font class="keywordflow">case</font> 3: <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;VRight;
01775                         <font class="keywordflow">default</font>: <font class="keywordflow">return</font> NULL;
01776                 }
01777         }
01778 }
01779 
01780 
01781 <font class="comment">// ***************************************************************************</font>
<a name="l01782"></a><a class="code" href="classNL3D_1_1CPatch.html#c7">01782</a> <font class="keywordtype">void</font>                    CPatch::changeEdgeNeighbor(sint edge, CTessFace *to)
01783 {
01784         <a class="code" href="debug_8h.html#a6">nlassert</a>(edge&gt;=0 &amp;&amp; edge&lt;=3);
01785 
01786         <font class="comment">// See tessellation rules.</font>
01787         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>)
01788         {
01789                 <font class="keywordflow">switch</font>(edge)
01790                 {
01791                         <font class="keywordflow">case</font> 0: <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FRight= to; <font class="keywordflow">break</font>;
01792                         <font class="keywordflow">case</font> 1: <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FLeft= to; <font class="keywordflow">break</font>;
01793                         <font class="keywordflow">case</font> 2: <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FRight= to; <font class="keywordflow">break</font>;
01794                         <font class="keywordflow">case</font> 3: <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FLeft= to; <font class="keywordflow">break</font>;
01795                 }
01796         }
01797         <font class="keywordflow">else</font>
01798         {
01799                 <font class="keywordflow">switch</font>(edge)
01800                 {
01801                         <font class="keywordflow">case</font> 0: <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FLeft= to; <font class="keywordflow">break</font>;
01802                         <font class="keywordflow">case</font> 1: <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FRight= to; <font class="keywordflow">break</font>;
01803                         <font class="keywordflow">case</font> 2: <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FLeft= to; <font class="keywordflow">break</font>;
01804                         <font class="keywordflow">case</font> 3: <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FRight= to; <font class="keywordflow">break</font>;
01805                 }
01806         }
01807 }
01808 
01809 
01810 <font class="comment">// ***************************************************************************</font>
<a name="l01811"></a><a class="code" href="classNL3D_1_1CPatch.html#z684_0">01811</a> CTessFace               *CPatch::linkTessFaceWithEdge(<font class="keyword">const</font> CVector2f &amp;uv0, <font class="keyword">const</font> CVector2f &amp;uv1, CTessFace *linkTo)
01812 {
01813         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a> &amp;&amp; <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>);
01814         <font class="comment">// Try to link with Root Son0</font>
01815         <a class="code" href="classNL3D_1_1CPatch.html#l0">CTessFace</a>       *face= <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;linkTessFaceWithEdge(uv0, uv1, linkTo);
01816         <font class="comment">// if Failed Try to link with Root Son1</font>
01817         <font class="keywordflow">if</font>(!face)
01818                 face= <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;linkTessFaceWithEdge(uv0, uv1, linkTo);
01819         <font class="keywordflow">return</font> face;
01820 }
01821 
01822 
01823 <font class="comment">// ***************************************************************************</font>
<a name="l01824"></a><a class="code" href="classNL3D_1_1CPatch.html#a19">01824</a> <font class="keywordtype">void</font>                    CPatch::bind(CBindInfo  Edges[4], <font class="keywordtype">bool</font> rebind)
01825 {
01826         <font class="comment">// The multiple Patch Face.</font>
01827         <font class="comment">// By default, Patch==NULL, FLeft, FRight and FBase==NULL so ok!</font>
01828         <font class="keyword">static</font>  <a class="code" href="classNL3D_1_1CPatch.html#l0">CTessFace</a>       bind1_2[4];
01829         <font class="keyword">static</font>  <a class="code" href="classNL3D_1_1CPatch.html#l0">CTessFace</a>       bind1_4[8];
01830 
01831 
01832         <font class="comment">// THIS PATCH MUST BE UNBOUND FIRST!!!!!</font>
01833         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a> &amp;&amp; <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>);
01834         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;isLeaf() &amp;&amp; <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;isLeaf());
01835         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FLeft == NULL);
01836         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FRight == NULL);
01837         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FLeft == NULL);
01838         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FRight == NULL);
01839 
01840 
01841         <font class="comment">// bind the Realtime bind info here (before any computeVertex, and before bind too).</font>
01842         sint    i;
01843         <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
01844         {
01845                 <font class="comment">// just Copy zone (if not NULL).</font>
01846                 <a class="code" href="classNL3D_1_1CPatch.html#z684_1">_BindZoneNeighbor</a>[i]= Edges[i].Zone;
01847         }
01848 
01849 
01850         <font class="keywordflow">if</font>(!rebind)
01851         {
01852                 <font class="comment">// Just recompute base vertices.</font>
01853                 CTessVertex *a= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[0];
01854                 CTessVertex *b= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[1];
01855                 CTessVertex *c= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[2];
01856                 CTessVertex *d= <a class="code" href="classNL3D_1_1CPatch.html#o11">BaseVertices</a>[3];
01857                 <font class="comment">// Set positions.</font>
01858                 a-&gt;Pos= a-&gt;StartPos= a-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(0,0);
01859                 b-&gt;Pos= b-&gt;StartPos= b-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(0,1);
01860                 c-&gt;Pos= c-&gt;StartPos= c-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(1,1);
01861                 d-&gt;Pos= d-&gt;StartPos= d-&gt;EndPos= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(1,0);
01862                 <font class="comment">// NB: no propagation problem, since the patch has root only (since has to be unbound!!!)</font>
01863                 <font class="comment">// Recompute centers.</font>
01864                 <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;computeSplitPoint();
01865                 <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;computeSplitPoint();
01866         }
01867         <font class="keywordflow">else</font>
01868         {
01869                 <font class="comment">// Keep old Vertices as computed from neighbors, but reFill the 4 FarVertices.</font>
01870                 <font class="comment">// NB: don't do it on NearVertices because suppose that Near is Off when a bind occurs (often far away).</font>
01871                 <a class="code" href="classNL3D_1_1CPatch.html#c27">checkFillVertexVBFar</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FVBase);
01872                 <a class="code" href="classNL3D_1_1CPatch.html#c27">checkFillVertexVBFar</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FVLeft);
01873                 <a class="code" href="classNL3D_1_1CPatch.html#c27">checkFillVertexVBFar</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;FVRight);
01874                 <a class="code" href="classNL3D_1_1CPatch.html#c27">checkFillVertexVBFar</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;FVBase);
01875         }
01876 
01877 
01878         <font class="comment">// Bind the roots.</font>
01879         <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
01880         {
01881                 CBindInfo       &amp;<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>= Edges[i];
01882 
01883                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.NPatchs==0 || <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.NPatchs==1 || <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.NPatchs==2 || <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.NPatchs==4 || <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.NPatchs==5);
01884                 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.NPatchs==1)
01885                 {
01886                         <font class="comment">// Bind me on Next.</font>
01887                         this-&gt;<a class="code" href="classNL3D_1_1CPatch.html#c7">changeEdgeNeighbor</a>(i, <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[0]-&gt;getRootFaceForEdge(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[0]));
01888                         <font class="comment">// Bind Next on me.</font>
01889                         <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[0]-&gt;changeEdgeNeighbor(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[0], this-&gt;getRootFaceForEdge(i));
01890                 }
01891                 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.NPatchs==2)
01892                 {
01893                         <font class="comment">// Setup multiple bind.</font>
01894                         this-&gt;<a class="code" href="classNL3D_1_1CPatch.html#c7">changeEdgeNeighbor</a>(i, bind1_2+i);
01895                         bind1_2[i].FBase= this-&gt;<a class="code" href="classNL3D_1_1CPatch.html#c5">getRootFaceForEdge</a>(i);
01896                         <font class="comment">// Setup the multiple face.</font>
01897                         <font class="comment">// Follow the conventions! Make a draw for understand. Small Patchs are numbered in CCW.</font>
01898                         bind1_2[i].SonRight= <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[0]-&gt;getRootFaceForEdge(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[0]);
01899                         bind1_2[i].SonLeft= <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[1]-&gt;getRootFaceForEdge(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[1]);
01900                         bind1_2[i].VBase= <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[0]-&gt;getRootVertexForEdge(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[0]);
01901                         <font class="comment">// Set a "flag" to neighbors, so they know what edge is to be bind on me.</font>
01902                         <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[0]-&gt;changeEdgeNeighbor(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[0], &amp;CTessFace::MultipleBindFace);
01903                         <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[1]-&gt;changeEdgeNeighbor(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[1], &amp;CTessFace::MultipleBindFace);
01904                 }
01905                 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.NPatchs==4)
01906                 {
01907                         <font class="comment">// Setup multiple bind level 0.</font>
01908                         this-&gt;<a class="code" href="classNL3D_1_1CPatch.html#c7">changeEdgeNeighbor</a>(i, bind1_2+i);
01909                         bind1_2[i].FBase= this-&gt;<a class="code" href="classNL3D_1_1CPatch.html#c5">getRootFaceForEdge</a>(i);
01910 
01911                         <font class="comment">// Setup multiple bind level 1.</font>
01912                         <font class="comment">// Follow the conventions! Make a draw for understand. Small Patchs are numbered in CCW.</font>
01913                         bind1_2[i].SonRight= bind1_4 + 2*i+0;
01914                         bind1_2[i].SonLeft= bind1_4 + 2*i+1;
01915                         bind1_2[i].VBase= <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[1]-&gt;getRootVertexForEdge(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[1]);
01916                         <font class="comment">// Make first multiple face bind level1.</font>
01917                         bind1_4[2*i+0].FBase= &amp;CTessFace::MultipleBindFace;     <font class="comment">// to link correctly when the root face will be splitted.</font>
01918                         bind1_4[2*i+0].SonRight= <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[0]-&gt;getRootFaceForEdge(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[0]);
01919                         bind1_4[2*i+0].SonLeft= <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[1]-&gt;getRootFaceForEdge(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[1]);
01920                         bind1_4[2*i+0].VBase= <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[0]-&gt;getRootVertexForEdge(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[0]);
01921                         <font class="comment">// Make second multiple face bind level1.</font>
01922                         bind1_4[2*i+1].FBase= &amp;CTessFace::MultipleBindFace;     <font class="comment">// to link correctly when the root face will be splitted.</font>
01923                         bind1_4[2*i+1].SonRight= <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[2]-&gt;getRootFaceForEdge(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[2]);
01924                         bind1_4[2*i+1].SonLeft= <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[3]-&gt;getRootFaceForEdge(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[3]);
01925                         bind1_4[2*i+1].VBase= <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[2]-&gt;getRootVertexForEdge(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[2]);
01926 
01927                         <font class="comment">// Set a "flag" to neighbors, so they know what edge is to be bind on me.</font>
01928                         <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[0]-&gt;changeEdgeNeighbor(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[0], &amp;CTessFace::MultipleBindFace);
01929                         <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[1]-&gt;changeEdgeNeighbor(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[1], &amp;CTessFace::MultipleBindFace);
01930                         <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[2]-&gt;changeEdgeNeighbor(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[2], &amp;CTessFace::MultipleBindFace);
01931                         <a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Next[3]-&gt;changeEdgeNeighbor(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.Edge[3], &amp;CTessFace::MultipleBindFace);
01932                 }
01933                 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#a19">bind</a>.NPatchs==5)
01934                 {
01935                         <font class="comment">/* I am binded to a bigger patch and this one has already done the binding on me =&gt; </font>
01936 <font class="comment">                                It must be correclty tesselated. Note also that bind 1/X are only possible on interior of zone.</font>
01937 <font class="comment">                        */</font>
01938 
01939                         <font class="comment">// First, make the link with the face to which I must connect.</font>
01940                         <font class="comment">// -----------------</font>
01941 
01942                         <font class="comment">// Get the coordinate of the current edge of this patch</font>
01943                         CVector2f       uvi0, uvi1;
01944                         <font class="keywordflow">switch</font>(i)
01945                         {
01946                         <font class="keywordflow">case</font> 0: uvi0.set(0,0); uvi1.set(0,1);  <font class="keywordflow">break</font>;
01947                         <font class="keywordflow">case</font> 1: uvi0.set(0,1); uvi1.set(1,1);  <font class="keywordflow">break</font>;
01948                         <font class="keywordflow">case</font> 2: uvi0.set(1,1); uvi1.set(1,0);  <font class="keywordflow">break</font>;
01949                         <font class="keywordflow">case</font> 3: uvi0.set(1,0); uvi1.set(0,0);  <font class="keywordflow">break</font>;
01950                         };
01951                         <font class="comment">// mul by OrderS/OrderT for CPatchUVLocator</font>
01952                         uvi0.x*= <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>;
01953                         uvi0.y*= <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>;
01954                         uvi1.x*= <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>;
01955                         uvi1.y*= <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>;
01956                         <font class="comment">// build a CPatchUVLocator to transpose coorindate ot this edge in coordinate on the bigger Neighbor patch.</font>
01957                         CBindInfo       bindInfo;
01958                         <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(i, bindInfo);
01959                         <a class="code" href="debug_8h.html#a6">nlassert</a>(bindInfo.Zone!=NULL &amp;&amp; bindInfo.NPatchs==1);
01960                         CPatchUVLocator         puvloc;
01961                         puvloc.build(<font class="keyword">this</font>, i, bindInfo);
01962 
01963                         <font class="comment">// transpose from this patch coord in neighbor patch coord.</font>
01964                         CVector2f       uvo0, uvo1;
01965                         uint    pid;
01966                         <a class="code" href="classNL3D_1_1CPatch.html#a0">CPatch</a>  *patchNeighbor;
01967                         <font class="comment">// Do it for uvi0</font>
01968                         pid= puvloc.selectPatch(uvi0);
01969                         puvloc.locateUV(uvi0, pid, patchNeighbor, uvo0);
01970                         <a class="code" href="debug_8h.html#a6">nlassert</a>(patchNeighbor == bindInfo.Next[0]);
01971                         <font class="comment">// Do it for uvi1</font>
01972                         pid= puvloc.selectPatch(uvi1);
01973                         puvloc.locateUV(uvi1, pid, patchNeighbor, uvo1);
01974                         <a class="code" href="debug_8h.html#a6">nlassert</a>(patchNeighbor == bindInfo.Next[0]);
01975                         <font class="comment">// Rescale to have uv in 0,1 basis.</font>
01976                         uvo0.x/= patchNeighbor-&gt;OrderS;
01977                         uvo0.y/= patchNeighbor-&gt;OrderT;
01978                         uvo1.x/= patchNeighbor-&gt;OrderS;
01979                         uvo1.y/= patchNeighbor-&gt;OrderT;
01980 
01981                         <font class="comment">// Now, traverse the tesselation and find the first CTessFace which use this edge.</font>
01982                         <a class="code" href="classNL3D_1_1CPatch.html#l0">CTessFace</a>       *faceNeighbor;
01983                         faceNeighbor= patchNeighbor-&gt;linkTessFaceWithEdge(uvo0, uvo1, this-&gt;getRootFaceForEdge(i));
01984                         <a class="code" href="debug_8h.html#a6">nlassert</a>(faceNeighbor);
01985                         <font class="comment">// Bind me on Next.</font>
01986                         this-&gt;<a class="code" href="classNL3D_1_1CPatch.html#c7">changeEdgeNeighbor</a>(i, faceNeighbor);
01987                 }
01988 
01989         }
01990 
01991         <font class="comment">// Propagate the binds to sons.</font>
01992         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;updateBind();
01993         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;updateBind();
01994 
01995 }
01996 
01997 
01998 <font class="comment">// ***************************************************************************</font>
<a name="l01999"></a><a class="code" href="classNL3D_1_1CPatch.html#a20">01999</a> <font class="keywordtype">void</font>                    CPatch::forceMergeAtTileLevel()
02000 {
02001         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a> &amp;&amp; <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>);
02002 
02003         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;forceMergeAtTileLevel();
02004         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;forceMergeAtTileLevel();
02005 }
02006 
02007 
02008 
02009 <font class="comment">// ***************************************************************************</font>
02010 <font class="comment">// ***************************************************************************</font>
02011 <font class="comment">// Texturing.</font>
02012 <font class="comment">// ***************************************************************************</font>
02013 <font class="comment">// ***************************************************************************</font>
02014 
02015 
02016 <font class="comment">// ***************************************************************************</font>
<a name="l02017"></a><a class="code" href="classNL3D_1_1CPatch.html#z681_0">02017</a> CPatchRdrPass   *CPatch::getTileRenderPass(sint tileId, sint pass)
02018 {
02019         <font class="comment">// All but lightmap.</font>
02020         <a class="code" href="debug_8h.html#a6">nlassert</a>(pass==<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a> || pass==<a class="code" href="landscape__def_8h.html#a3">NL3D_TILE_PASS_RGB1</a> || pass==<a class="code" href="landscape__def_8h.html#a4">NL3D_TILE_PASS_RGB2</a> || 
02021                 pass==<a class="code" href="landscape__def_8h.html#a5">NL3D_TILE_PASS_ADD</a>);
02022 
02023         <font class="keywordtype">bool</font>    additive= (pass==<a class="code" href="landscape__def_8h.html#a5">NL3D_TILE_PASS_ADD</a>);
02024         sint    passNum= pass-<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>;
02025         <font class="comment">// If additive, take the additve tile of bigger existing pass.</font>
02026         <font class="keywordflow">if</font>(additive)
02027         {
02028                 <font class="comment">// Default: take addtive of pass 0.</font>
02029                 passNum= 0;
02030                 <font class="comment">// If the pass1 is not empty, may take its tile.</font>
02031                 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[tileId].Tile[1]!=0xFFFF)
02032                 {
02033                         passNum= 1;
02034                         <font class="comment">// If the pass2 is not empty, take its tile.</font>
02035                         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[tileId].Tile[2]!=0xFFFF)
02036                                 passNum= 2;
02037                 }
02038         }
02039 
02040         sint    tileNumber= <a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[tileId].Tile[passNum];
02041         <font class="keywordflow">if</font>(tileNumber==0xFFFF)
02042         {
02043                 <font class="comment">// Display a "fake" only if pass 0.</font>
02044                 <font class="keywordflow">if</font>(pass==<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>)
02045                         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;Landscape-&gt;getTileRenderPass(0xFFFF, <font class="keyword">false</font>);
02046                 <font class="comment">// Else, this tile do not have such a pass (not a transition).</font>
02047                 <font class="keywordflow">return</font> NULL;
02048         }
02049         <font class="keywordflow">else</font>
02050         {
02051                 <font class="comment">// return still may be NULL, in additive case.</font>
02052                 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;Landscape-&gt;getTileRenderPass(tileNumber, additive);
02053         }
02054 }
02055 
02056 <font class="comment">// ***************************************************************************</font>
<a name="l02057"></a><a class="code" href="classNL3D_1_1CPatch.html#z681_1">02057</a> <font class="keywordtype">void</font>                    CPatch::getTileUvInfo(sint tileId, sint pass, <font class="keywordtype">bool</font> <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>, uint8 &amp;orient, CVector &amp;uvScaleBias, <font class="keywordtype">bool</font> &amp;is256x256, uint8 &amp;uvOff)
02058 {
02059         <font class="comment">// All but lightmap.</font>
02060         <a class="code" href="debug_8h.html#a6">nlassert</a>(pass==<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a> || pass==<a class="code" href="landscape__def_8h.html#a3">NL3D_TILE_PASS_RGB1</a> || pass==<a class="code" href="landscape__def_8h.html#a4">NL3D_TILE_PASS_RGB2</a> || 
02061                 pass==<a class="code" href="landscape__def_8h.html#a5">NL3D_TILE_PASS_ADD</a>);
02062 
02063         <font class="keywordtype">bool</font>    additive= (pass==<a class="code" href="landscape__def_8h.html#a5">NL3D_TILE_PASS_ADD</a>);
02064         sint    passNum= pass-<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>;
02065         <font class="comment">// If additive, take the additve tile of bigger existing pass.</font>
02066         <font class="keywordflow">if</font>(additive)
02067         {
02068                 <font class="comment">// Default: take addtive of pass 0.</font>
02069                 passNum= 0;
02070                 <font class="comment">// If the pass1 is not empty, may take its tile.</font>
02071                 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[tileId].Tile[1]!=0xFFFF)
02072                 {
02073                         passNum= 1;
02074                         <font class="comment">// If the pass2 is not empty, take its tile.</font>
02075                         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[tileId].Tile[2]!=0xFFFF)
02076                                 passNum= 2;
02077                 }
02078         }
02079 
02080         sint    tileNumber= <a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[tileId].Tile[passNum];
02081         <font class="keywordflow">if</font>(tileNumber==0xFFFF)
02082         {
02083                 <font class="comment">// dummy... Should not be called here.</font>
02084                 orient= 0;
02085                 uvScaleBias.x=0;
02086                 uvScaleBias.y=0;
02087                 uvScaleBias.z=1;
02088                 is256x256=<font class="keyword">false</font>;
02089                 uvOff=0;
02090         }
02091         <font class="keywordflow">else</font>
02092         {
02093                 orient= <a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[tileId].getTileOrient(passNum);
02094                 <a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[tileId].getTile256Info(is256x256, uvOff);
02095                 CTile::TBitmap <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>;
02096                 <font class="comment">// If alpha wanted, return its UV info (works either for Alpha in Diffuse Pass and Alpha in Additive Pass)</font>
02097                 <font class="keywordflow">if</font>(alpha)
02098                         <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>= CTile::alpha;
02099                 <font class="keywordflow">else</font>
02100                 {
02101                         <font class="keywordflow">if</font>(additive)
02102                                 <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>= CTile::additive;
02103                         <font class="keywordflow">else</font>
02104                                 <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>= CTile::diffuse;
02105                 }
02106 
02107                 uint8   rotalpha;
02108                 <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;Landscape-&gt;getTileUvScaleBiasRot(tileNumber, <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>, uvScaleBias, rotalpha);
02109 
02110                 <font class="comment">// Add the special rotation of alpha.</font>
02111                 <font class="keywordflow">if</font>(alpha)
02112                         orient= (orient+rotalpha)&amp;3;
02113         }
02114 
02115 }
02116 
02117 
02118 <font class="comment">// ***************************************************************************</font>
<a name="l02119"></a><a class="code" href="classNL3D_1_1CPatch.html#a29">02119</a> <font class="keywordtype">void</font>                    CPatch::deleteTileUvs()
02120 {
02121         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;deleteTileUvs();
02122         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;deleteTileUvs();
02123 }
02124 
02125 
02126 <font class="comment">// ***************************************************************************</font>
<a name="l02127"></a><a class="code" href="classNL3D_1_1CPatch.html#a30">02127</a> <font class="keywordtype">void</font>                    CPatch::recreateTileUvs()
02128 {
02129         <font class="comment">// Reset the Tile rdr list.</font>
02130         <font class="keywordflow">for</font>(sint tb=0; tb&lt;(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size();tb++)
02131         {
02132                 <font class="comment">// Vertices must all be reseted.</font>
02133                 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[tb].NearVertexList.clear();
02134                 <font class="keywordflow">for</font>(sint i=0;i&lt;<a class="code" href="tess__block_8h.html#a1">NL3D_TESSBLOCK_TILESIZE</a>;i++)
02135                 {
02136                         CTileMaterial   *tm= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[tb].RdrTileRoot[i];
02137                         <font class="keywordflow">if</font>(tm)
02138                         {
02139                                 <font class="keywordflow">for</font>(sint pass=0;pass&lt;<a class="code" href="landscape__def_8h.html#a1">NL3D_MAX_TILE_FACE</a>;pass++)
02140                                 {
02141                                         tm-&gt;TileFaceList[pass].clear();
02142                                 }
02143                         }
02144                 }
02145         }
02146 
02147         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;recreateTileUvs();
02148         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;recreateTileUvs();
02149 }
02150 
02151 
02152 <font class="comment">// ***************************************************************************</font>
<a name="l02153"></a><a class="code" href="classNL3D_1_1CPatch.html#z670_4">02153</a> <font class="keywordtype">void</font>            CPatch::appendTessellationLeaves(std::vector&lt;const CTessFace*&gt;  &amp;leaves)<font class="keyword"> const</font>
02154 <font class="keyword"></font>{
02155         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>);
02156         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>);
02157         <a class="code" href="classNL3D_1_1CPatch.html#o9">Son0</a>-&gt;appendTessellationLeaves(leaves);
02158         <a class="code" href="classNL3D_1_1CPatch.html#o10">Son1</a>-&gt;appendTessellationLeaves(leaves);
02159 }
02160 
02161 
02162 <font class="comment">// ***************************************************************************</font>
<a name="l02163"></a><a class="code" href="classNL3D_1_1CPatch.html#a4">02163</a> CLandscape              *CPatch::getLandscape ()<font class="keyword"> const</font>
02164 <font class="keyword"></font>{
02165         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;getLandscape();
02166 }
02167 
02168 
02169 
02170 
02171 
02172 <font class="comment">// ***************************************************************************</font>
<a name="l02173"></a><a class="code" href="classNL3D_1_1CPatch.html#a8">02173</a> uint8                   CPatch::getOrderForEdge(sint8 edge)<font class="keyword"> const</font>
02174 <font class="keyword"></font>{
02175         uint    e= ((sint)edge + 256)&amp;3;
02176         <font class="comment">// If an horizontal edge.</font>
02177         <font class="keywordflow">if</font>( e&amp;1 )       <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>;
02178         <font class="keywordflow">else</font>            <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>;
02179 }
02180 
02181 
02182 <font class="comment">// ***************************************************************************</font>
02183 <font class="comment">// ***************************************************************************</font>
02184 <font class="comment">// Realtime Bind info.</font>
02185 <font class="comment">// ***************************************************************************</font>
02186 <font class="comment">// ***************************************************************************</font>
02187 
02188 
02189 <font class="comment">// ***************************************************************************</font>
<a name="l02190"></a><a class="code" href="classNL3D_1_1CPatch.html#a13">02190</a> <font class="keywordtype">void</font>    CPatch::getBindNeighbor(uint edge, CBindInfo &amp;neighborEdge)<font class="keyword"> const</font>
02191 <font class="keyword"></font>{
02192         <a class="code" href="debug_8h.html#a6">nlassert</a>(edge&lt;4);
02193 
02194         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#z684_1">_BindZoneNeighbor</a>[edge]!=NULL)
02195         {
02196                 <a class="code" href="classNL3D_1_1CPatch.html#a5">getZone</a>()-&gt;buildBindInfo(<a class="code" href="classNL3D_1_1CPatch.html#o1">PatchId</a>, edge, <a class="code" href="classNL3D_1_1CPatch.html#z684_1">_BindZoneNeighbor</a>[edge], neighborEdge);
02197         }
02198         <font class="keywordflow">else</font>
02199         {
02200                 neighborEdge.Zone= NULL;
02201                 neighborEdge.NPatchs= 0;
02202                 neighborEdge.MultipleBindNum= 0;
02203         }
02204 }
02205 
02206 <font class="comment">// ***************************************************************************</font>
<a name="l02208"></a><a class="code" href="classNL3D_1_1CPatch.html#a37">02208</a> <font class="comment">void CPatch::setupColorsFromTileFlags(const NLMISC::CRGBA colors[4])</font>
02209 {
02210         <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> = 0; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> &lt;= OrderS; ++<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>)
02211         {
02212                 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a> = 0; <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a> &lt;= OrderT; ++<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)
02213                 {
02214                         uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, (uint) (OrderT - 1)) * OrderS 
02215                                          + <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, (uint) (OrderS - 1));
02216                         TileColors[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a> * (OrderS + 1)].Color565 = colors[(uint) (Tiles[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].getVegetableState())].get565();                                 
02217                 }
02218         }
02219 }
02220 
02221 <font class="comment">// ***************************************************************************</font>
<a name="l02222"></a><a class="code" href="classNL3D_1_1CPatch.html#a38">02222</a> <font class="keywordtype">void</font> CPatch::copyTileFlagsFromPatch(<font class="keyword">const</font> CPatch *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>)
02223 {
02224         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a> == <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;OrderS
02225                          &amp;&amp; <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a> == <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;OrderT);
02226 
02227         <font class="keywordflow">for</font> (uint k = 0; k  &lt; <a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>.size(); ++k)
02228         {
02229                 <a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[k].copyFlagsFromOther(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;Tiles[k]);
02230         }
02231 }
02232 
02233 
02234 <font class="comment">// ***************************************************************************</font>
02235 <font class="comment">// ***************************************************************************</font>
02236 <font class="comment">// Tiles get interface.</font>
02237 <font class="comment">// ***************************************************************************</font>
02238 <font class="comment">// ***************************************************************************</font>
02239 
02240 
02241 <font class="comment">// ***************************************************************************</font>
<a name="l02242"></a><a class="code" href="classNL3D_1_1CPatch.html#z672_0">02242</a> CTileElement *CPatch::getTileElement(<font class="keyword">const</font> CUV &amp;uv)
02243 {
02244         <font class="comment">// compute tile coord and lumel coord.</font>
02245         sint    ts, tt;
02246 
02247         <font class="comment">// fastFloor: use a precision of 256 to avoid doing OptFastFloorBegin.</font>
02248         <font class="comment">// add 128, to round and get cneter of lumel.</font>
02249         ts= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(uv.U* (<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&lt;&lt;8) + 128);      ts&gt;&gt;=8;
02250         tt= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(uv.V* (<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>&lt;&lt;8) + 128);      tt&gt;&gt;=8;
02251         <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(ts, 0, <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>-1);
02252         <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(tt, 0, <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>-1);
02253 
02254         <font class="comment">// get the lumel</font>
02255         <font class="keywordflow">return</font> &amp;(<a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[ts+tt*<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>]);
02256 }
02257 
02258 
02259 } <font class="comment">// NL3D</font>
02260 
</pre></div>

<!-- footer -->
<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
</TD>
<TD WIDTH=15><IMG  SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>