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
|
<!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="http://www.nevrax.org/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="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/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="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/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="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
<!-- 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="http://www.nevrax.org/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>patch_render.cpp</h1><a href="patch__render_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="landscape__profile_8h.html">3d/landscape_profile.h</a>"</font>
00035 <font class="preprocessor">#include "<a class="code" href="patchdlm__context_8h.html">3d/patchdlm_context.h</a>"</font>
00036 <font class="preprocessor">#include "<a class="code" href="vector_8h.html">nel/misc/vector.h</a>"</font>
00037 <font class="preprocessor">#include "<a class="code" href="common_8h.html">nel/misc/common.h</a>"</font>
00038 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00039 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00040
00041
00042 <font class="keyword">namespace </font>NL3D
00043 {
00044
00045
00046 <font class="comment">// ***************************************************************************</font>
00047 <font class="comment">// ***************************************************************************</font>
00048 <font class="comment">// Patch Texture computation.</font>
00049 <font class="comment">// ***************************************************************************</font>
00050 <font class="comment">// ***************************************************************************</font>
00051
00052
00053 <font class="comment">// ***************************************************************************</font>
<a name="l00054"></a><a class="code" href="classNL3D_1_1CPatch.html#c8">00054</a> <font class="keywordtype">void</font> CPatch::computeNewFar(sint &newFar0, sint &newFar1)
00055 {
00056 <font class="comment">// Classify the patch.</font>
00057 <font class="comment">//========================</font>
00058 <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>= (CLandscapeGlobals::RefineCenter-<a class="code" href="classNL3D_1_1CPatch.html#o13">BSphere</a>.Center).norm() - <a class="code" href="classNL3D_1_1CPatch.html#o13">BSphere</a>.Radius;
00059 <font class="keywordtype">float</font> rr=0.0;
00060 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a><CLandscapeGlobals::TileDistNear)
00061 rr= <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>-CLandscapeGlobals::TileDistNear, newFar0= 0;
00062 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a><CLandscapeGlobals::Far0Dist)
00063 rr= <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>-CLandscapeGlobals::Far0Dist, newFar0= 1;
00064 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a><CLandscapeGlobals::Far1Dist)
00065 rr= <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>-CLandscapeGlobals::Far1Dist, newFar0= 2;
00066 <font class="keywordflow">else</font>
00067 newFar0= 3;
00068 <font class="comment">// Transition with the next level.</font>
00069 newFar1=0;
00070 <font class="keywordflow">if</font>(newFar0<3 && rr>-(CLandscapeGlobals::FarTransition+2*<a class="code" href="classNL3D_1_1CPatch.html#o13">BSphere</a>.Radius))
00071 {
00072 newFar1= newFar0+1;
00073 }
00074
00075
00076 <font class="comment">// Update Texture Info.</font>
00077 <font class="comment">//========================</font>
00078 <font class="keywordflow">if</font>(newFar0!=<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a> || newFar1!=<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>)
00079 {
00080 <font class="comment">// Backup old pass0</font>
00081 CPatchRdrPass *oldPass0=<a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass;
00082 CPatchRdrPass *oldPass1=<a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass;
00083
00084 <font class="comment">// Checks</font>
00085 <font class="keywordflow">if</font> (oldPass0==NULL)
00086 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a><=0);
00087 <font class="keywordflow">if</font> (oldPass1==NULL)
00088 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a><=0);
00089
00090 <font class="keywordtype">float</font> oldFar0UScale=<a class="code" href="classNL3D_1_1CPatch.html#o16">Far0UScale</a>;
00091 <font class="keywordtype">float</font> oldFar0VScale=<a class="code" href="classNL3D_1_1CPatch.html#o17">Far0VScale</a>;
00092 <font class="keywordtype">float</font> oldFar0UBias=<a class="code" href="classNL3D_1_1CPatch.html#o18">Far0UBias</a>;
00093 <font class="keywordtype">float</font> oldFar0VBias=<a class="code" href="classNL3D_1_1CPatch.html#o19">Far0VBias</a>;
00094 uint8 oldFlags=<a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>;
00095
00096
00097 <font class="comment">// Don't delete the pass0 if the new newFar1 will use it</font>
00098 <font class="keywordflow">if</font> ((newFar1==<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>)&&(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0))
00099 <a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass=NULL;
00100
00101 <font class="comment">// Don't delete the pass1 if the new newFar0 will use it</font>
00102 <font class="keywordflow">if</font> ((newFar0==<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>)&&(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0))
00103 <a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass=NULL;
00104
00105 <font class="comment">// Pass0 have changed ?</font>
00106 <font class="keywordflow">if</font> (newFar0!=<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>)
00107 {
00108 <font class="comment">// Compute / get the texture Far.</font>
00109 <font class="keywordflow">if</font>(newFar0>0)
00110 {
00111 <font class="comment">// Free the old pass, don't used any more</font>
00112 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass)
00113 <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->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>);
00114
00115 <font class="comment">// Can we use the old pass1 ?</font>
00116 <font class="keywordflow">if</font> (newFar0==<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>)
00117 {
00118 <font class="comment">// Yes, recycle it!</font>
00119 <a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass=oldPass1;
00120
00121 <font class="comment">// Copy uv coordinates</font>
00122 <a class="code" href="classNL3D_1_1CPatch.html#o16">Far0UScale</a>=<a class="code" href="classNL3D_1_1CPatch.html#o20">Far1UScale</a>;
00123 <a class="code" href="classNL3D_1_1CPatch.html#o17">Far0VScale</a>=<a class="code" href="classNL3D_1_1CPatch.html#o21">Far1VScale</a>;
00124 <a class="code" href="classNL3D_1_1CPatch.html#o18">Far0UBias</a>=<a class="code" href="classNL3D_1_1CPatch.html#o22">Far1UBias</a>;
00125 <a class="code" href="classNL3D_1_1CPatch.html#o19">Far0VBias</a>=<a class="code" href="classNL3D_1_1CPatch.html#o23">Far1VBias</a>;
00126
00127 <font class="comment">// Copy rotation flag</font>
00128 <a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>&=~<a class="code" href="patch_8h.html#a2">NL_PATCH_FAR0_ROTATED</a>; <font class="comment">// erase it</font>
00129 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>&<a class="code" href="patch_8h.html#a3">NL_PATCH_FAR1_ROTATED</a>)
00130 <a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>|=<a class="code" href="patch_8h.html#a2">NL_PATCH_FAR0_ROTATED</a>; <font class="comment">// copy it</font>
00131 }
00132 <font class="keywordflow">else</font> <font class="comment">// get a new render pass</font>
00133 {
00134 <font class="comment">// Rotation boolean</font>
00135 <font class="keywordtype">bool</font> bRot;
00136 <a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass=<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->getFarRenderPass(<font class="keyword">this</font>, newFar0, <a class="code" href="classNL3D_1_1CPatch.html#o16">Far0UScale</a>, <a class="code" href="classNL3D_1_1CPatch.html#o17">Far0VScale</a>, <a class="code" href="classNL3D_1_1CPatch.html#o18">Far0UBias</a>, <a class="code" href="classNL3D_1_1CPatch.html#o19">Far0VBias</a>, bRot);
00137
00138 <font class="comment">// Flags is set if the far texture is rotated of 90� to the left</font>
00139 <font class="keywordflow">if</font> (bRot)
00140 <a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>|=<a class="code" href="patch_8h.html#a2">NL_PATCH_FAR0_ROTATED</a>;
00141 <font class="keywordflow">else</font>
00142 <a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>&=~<a class="code" href="patch_8h.html#a2">NL_PATCH_FAR0_ROTATED</a>;
00143 }
00144 }
00145 <font class="keywordflow">else</font> <font class="comment">// no more far pass0</font>
00146 {
00147 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass)
00148 {
00149 <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->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>);
00150 <a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass=NULL;
00151 }
00152 }
00153 }
00154
00155 <font class="comment">// Pass1 have changed ?</font>
00156 <font class="keywordflow">if</font> (newFar1!=<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>)
00157 {
00158 <font class="comment">// Now let's go with pass1</font>
00159 <font class="keywordflow">if</font>(newFar1>0)
00160 {
00161 <font class="comment">// Delete the pass1 if not used any more</font>
00162 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass)
00163 <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->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>);
00164
00165 <font class="comment">// Can we use the old pass1 ?</font>
00166 <font class="keywordflow">if</font> (newFar1==<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>)
00167 {
00168 <font class="comment">// Yes, recycle it!</font>
00169 <a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass= oldPass0;
00170 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass);
00171
00172 <font class="comment">// Copy uv coordinates</font>
00173 <a class="code" href="classNL3D_1_1CPatch.html#o20">Far1UScale</a>=oldFar0UScale;
00174 <a class="code" href="classNL3D_1_1CPatch.html#o21">Far1VScale</a>=oldFar0VScale;
00175 <a class="code" href="classNL3D_1_1CPatch.html#o22">Far1UBias</a>=oldFar0UBias;
00176 <a class="code" href="classNL3D_1_1CPatch.html#o23">Far1VBias</a>=oldFar0VBias;
00177
00178 <font class="comment">// Copy rotation flag</font>
00179 <a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>&=~<a class="code" href="patch_8h.html#a3">NL_PATCH_FAR1_ROTATED</a>; <font class="comment">// erase it</font>
00180 <font class="keywordflow">if</font> (oldFlags&<a class="code" href="patch_8h.html#a2">NL_PATCH_FAR0_ROTATED</a>)
00181 <a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>|=<a class="code" href="patch_8h.html#a3">NL_PATCH_FAR1_ROTATED</a>; <font class="comment">// copy it</font>
00182 }
00183 <font class="keywordflow">else</font> <font class="comment">// get a new render pass</font>
00184 {
00185 <font class="comment">// Rotation boolean</font>
00186 <font class="keywordtype">bool</font> bRot;
00187 <a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass=<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->getFarRenderPass(<font class="keyword">this</font>, newFar1, <a class="code" href="classNL3D_1_1CPatch.html#o20">Far1UScale</a>, <a class="code" href="classNL3D_1_1CPatch.html#o21">Far1VScale</a>, <a class="code" href="classNL3D_1_1CPatch.html#o22">Far1UBias</a>, <a class="code" href="classNL3D_1_1CPatch.html#o23">Far1VBias</a>, bRot);
00188 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass);
00189
00190 <font class="comment">// Flags is set if the far texture is rotated of 90� to the left</font>
00191 <font class="keywordflow">if</font> (bRot)
00192 <a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>|=<a class="code" href="patch_8h.html#a3">NL_PATCH_FAR1_ROTATED</a>;
00193 <font class="keywordflow">else</font>
00194 <a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>&=~<a class="code" href="patch_8h.html#a3">NL_PATCH_FAR1_ROTATED</a>;
00195 }
00196
00197 <font class="comment">// Compute info for transition.</font>
00198 <font class="keywordtype">float</font> farDist;
00199 <font class="keywordflow">switch</font>(newFar1)
00200 {
00201 <font class="keywordflow">case</font> 1: farDist= CLandscapeGlobals::TileDistNear; <font class="keywordflow">break</font>;
00202 <font class="keywordflow">case</font> 2: farDist= CLandscapeGlobals::Far0Dist; <font class="keywordflow">break</font>;
00203 <font class="keywordflow">case</font> 3: farDist= CLandscapeGlobals::Far1Dist; <font class="keywordflow">break</font>;
00204 <font class="keywordflow">default</font>: <a class="code" href="debug_8h.html#a12">nlstop</a>;
00205 };
00206 <a class="code" href="classNL3D_1_1CPatch.html#o30">TransitionSqrMin</a>= <a class="code" href="namespaceNLMISC.html#a214">sqr</a>(farDist-CLandscapeGlobals::FarTransition);
00207 <a class="code" href="classNL3D_1_1CPatch.html#o31">OOTransitionSqrDelta</a>= 1.0f/(<a class="code" href="namespaceNLMISC.html#a214">sqr</a>(farDist)-<a class="code" href="classNL3D_1_1CPatch.html#o30">TransitionSqrMin</a>);
00208 }
00209 <font class="keywordflow">else</font> <font class="comment">// no more far pass1</font>
00210 {
00211 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass)
00212 {
00213 <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->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>);
00214 <a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass=NULL;
00215 }
00216 }
00217 }
00218
00219 }
00220
00221 <font class="comment">// Don't copy Far0 and Far1.</font>
00222 }
00223
00224
00225 <font class="comment">// ***************************************************************************</font>
<a name="l00226"></a><a class="code" href="classNL3D_1_1CPatch.html#z669_1">00226</a> <font class="keywordtype">void</font> CPatch::updateTextureFarOnly()
00227 {
00228 <font class="comment">// If visible, don't change Far, because VB must be changed too. preRender() should have been called isntead.</font>
00229 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>)
00230 <font class="keywordflow">return</font>;
00231
00232 sint newFar0,newFar1;
00233 <font class="comment">// compute new Far0 and new Far1.</font>
00234 <a class="code" href="classNL3D_1_1CPatch.html#c8">computeNewFar</a>(newFar0, newFar1);
00235
00236 <font class="comment">// Far change.</font>
00237 <font class="comment">//------------------</font>
00238 <font class="comment">// Set new far values</font>
00239 <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>= newFar0;
00240 <a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>= newFar1;
00241 }
00242
00243
00244
00245 <font class="comment">// ***************************************************************************</font>
00246 <font class="comment">// ***************************************************************************</font>
00247 <font class="comment">// Patch / Face rendering.</font>
00248 <font class="comment">// ***************************************************************************</font>
00249 <font class="comment">// ***************************************************************************</font>
00250
00251
00252 <font class="comment">// ***************************************************************************</font>
<a name="l00253"></a><a class="code" href="classNL3D_1_1CPatch.html#z669_0">00253</a> <font class="keywordtype">void</font> CPatch::preRender()
00254 {
00255 <font class="comment">// If not visible, do nothing.</font>
00256 <font class="keywordflow">if</font>(RenderClipped)
00257 <font class="keywordflow">return</font>;
00258
00259
00260 <font class="comment">// 0. Classify the patch, and update TextureInfo.</font>
00261 <font class="comment">//=======================</font>
00262 sint newFar0,newFar1;
00263 <font class="comment">// compute new Far0 and new Far1.</font>
00264 <a class="code" href="classNL3D_1_1CPatch.html#c8">computeNewFar</a>(newFar0, newFar1);
00265
00266
00267 <font class="comment">// 2. Update vertices in VB</font>
00268 <font class="comment">//========================</font>
00269 sint oldFar0= <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>, oldFar1= <a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>;
00270
00271 <font class="comment">// Test if go in or go out tileMode.</font>
00272 <font class="keywordtype">bool</font> changeTileMode;
00273 <font class="comment">// this is true if a change is made, and if old or current is in TileMode.</font>
00274 changeTileMode= (newFar0!=oldFar0) && (newFar0==0 || oldFar0==0);
00275 <font class="comment">// Or this is true if Far0 / Far1 was invalid before.</font>
00276 changeTileMode= changeTileMode || oldFar0==-1 || oldFar1==-1;
00277
00278 <font class="comment">// Pre VB change.</font>
00279 <font class="comment">//------------------</font>
00280 <font class="comment">// In this case, major change: delete all VB, then recreate after.</font>
00281 <font class="keywordflow">if</font>(changeTileMode)
00282 {
00283 <font class="comment">// delete the old VB (NB: RenderClipped==false here). </font>
00284 <font class="comment">// NB: Far0 and Far1 are still unmodified, so deleteVB() will do the good job.</font>
00285 <a class="code" href="classNL3D_1_1CPatch.html#z673_0">deleteVBAndFaceVector</a>();
00286 }
00287 <font class="keywordflow">else</font>
00288 {
00289 <font class="comment">// minor change: Far0 UV, or Far1.</font>
00290 <font class="comment">// Far0 UV: do nothing here.</font>
00291 <font class="comment">// If change in Far1, must delete Far1</font>
00292 <font class="keywordflow">if</font>(newFar1!=oldFar1)
00293 {
00294 <font class="comment">// NB: Far1 is still unmodified, so deleteVB() will do the good job.</font>
00295 <a class="code" href="classNL3D_1_1CPatch.html#z673_4">deleteVBAndFaceVectorFar1Only</a>();
00296 }
00297 }
00298
00299 <font class="comment">// Far change.</font>
00300 <font class="comment">//------------------</font>
00301 <font class="comment">// Set new far values</font>
00302 <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>= newFar0;
00303 <a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>= newFar1;
00304
00305
00306 <font class="comment">// Post VB change.</font>
00307 <font class="comment">//------------------</font>
00308 <font class="keywordflow">if</font>(changeTileMode)
00309 {
00310 <font class="comment">// major change: recreate all the VB.</font>
00311 <a class="code" href="classNL3D_1_1CPatch.html#z673_1">allocateVBAndFaceVector</a>();
00312 <font class="comment">// Then try to refill if possible.</font>
00313 <a class="code" href="classNL3D_1_1CPatch.html#z673_2">fillVB</a>();
00314 }
00315 <font class="keywordflow">else</font>
00316 {
00317 <font class="comment">// minor change: Far0 UV, or Far1.</font>
00318 <font class="comment">// If change in Far0</font>
00319 <font class="keywordflow">if</font>(newFar0!=oldFar0)
00320 {
00321 <font class="comment">// Then must recompute VB with good UVs.</font>
00322 <font class="comment">// An optimisation is to check if UVs had really change (see UScale ...)</font>
00323 <font class="comment">// but the case they don't change is very rare: 1/16.</font>
00324 <a class="code" href="classNL3D_1_1CPatch.html#z673_6">fillVBFar0Only</a>();
00325 }
00326
00327 <font class="comment">// If change in Far1, must allcoate and recompute UVs.</font>
00328 <font class="keywordflow">if</font>(newFar1!=oldFar1)
00329 {
00330 <a class="code" href="classNL3D_1_1CPatch.html#z673_5">allocateVBAndFaceVectorFar1Only</a>();
00331 <font class="comment">// try to fill if no reallocation problem</font>
00332 <a class="code" href="classNL3D_1_1CPatch.html#z673_7">fillVBFar1Only</a>();
00333 }
00334 }
00335
00336
00337 <font class="comment">// 3. Append patch to renderList.</font>
00338 <font class="comment">//=====================</font>
00339 <font class="comment">// This patch is visible. So if good far, append.</font>
00340 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0)
00341 {
00342 <a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass->appendRdrPatchFar0(&<a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>, <a class="code" href="classNL3D_1_1CPatch.html#z678_3">NumRenderableFaces</a>);
00343 }
00344 <font class="comment">// Same for Far1.</font>
00345 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0)
00346 {
00347 <a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass->appendRdrPatchFar1(&<a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>, <a class="code" href="classNL3D_1_1CPatch.html#z678_3">NumRenderableFaces</a>);
00348 }
00349
00350
00351 <font class="comment">// 4. Clip tess blocks.</font>
00352 <font class="comment">//=====================</font>
00353 <font class="comment">// If we are in Tile/FarTransition</font>
00354 <font class="keywordtype">bool</font> doClipFar= <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0 && <a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>==1;
00355 <font class="comment">// Parse all TessBlocks.</font>
00356 uint nTessBlock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size();
00357 CTessBlock *pTessBlock= nTessBlock>0? &<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[0]: NULL ;
00358 <font class="keywordflow">for</font>(; nTessBlock>0; pTessBlock++, nTessBlock--)
00359 {
00360 CTessBlock &tblock= *pTessBlock;
00361
00362 <font class="comment">// bkup the old result for clipping</font>
00363 <font class="keywordtype">bool</font> oldVisibleFar0= tblock.visibleFar0();
00364 <font class="keywordtype">bool</font> oldVisibleTile= tblock.visibleTile();
00365 <font class="keywordtype">bool</font> oldVisibleFar1= tblock.visibleFar1();
00366
00367 <font class="comment">// If this TessBlock is empty, do not need to clip</font>
00368 <font class="keywordflow">if</font>(tblock.FaceTileMaterialRefCount==0)
00369 {
00370 <font class="comment">// Simply force the clip.</font>
00371 tblock.forceClip();
00372 }
00373 <font class="keywordflow">else</font>
00374 {
00375 <font class="comment">// clip the tessBlock.</font>
00376 tblock.resetClip();
00377 tblock.clip();
00378 <font class="comment">// If we are in Tile/FarTransition</font>
00379 <font class="keywordflow">if</font>(doClipFar)
00380 tblock.clipFar(CLandscapeGlobals::RefineCenter, CLandscapeGlobals::TileDistNear, CLandscapeGlobals::FarTransition);
00381
00382 <font class="comment">// If TileMode, and if tile visible</font>
00383 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0 && tblock.visibleTile() )
00384 {
00385 <font class="comment">// Append all tiles (if any) to the renderPass list!</font>
00386 <font class="keywordflow">for</font>(uint j=0;j<<a class="code" href="tess__block_8h.html#a1">NL3D_TESSBLOCK_TILESIZE</a>; j++)
00387 {
00388 <font class="comment">// If tile exist</font>
00389 <font class="keywordflow">if</font>(tblock.RdrTileRoot[j])
00390 <font class="comment">// add it to the renderList</font>
00391 tblock.RdrTileRoot[j]->appendTileToEachRenderPass(<a class="code" href="classNL3D_1_1CPatch.html#z678_3">NumRenderableFaces</a>);
00392 }
00393 }
00394 }
00395
00396 <font class="comment">// If change of clip in tessBlock, must update the tessBlock</font>
00397 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>> 0 && oldVisibleFar0 != tblock.visibleFar0() )
00398 {
00399 <font class="keywordflow">if</font>( tblock.visibleFar0() )
00400 {
00401 <font class="comment">// allocate</font>
00402 <a class="code" href="classNL3D_1_1CPatch.html#c15">updateFar0VBAlloc</a>(tblock.FarVertexList, <font class="keyword">true</font>);
00403 <font class="comment">// fill only if possible.</font>
00404 <font class="keywordflow">if</font>(!CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs())
00405 <a class="code" href="classNL3D_1_1CPatch.html#c12">fillFar0VertexListVB</a>(tblock.FarVertexList);
00406 <font class="comment">// rebuild triangles index list.</font>
00407 tblock.refillFaceVectorFar0();
00408 }
00409 <font class="keywordflow">else</font>
00410 {
00411 <font class="comment">// delete</font>
00412 <a class="code" href="classNL3D_1_1CPatch.html#c15">updateFar0VBAlloc</a>(tblock.FarVertexList, <font class="keyword">false</font>);
00413 }
00414 }
00415 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0 && oldVisibleTile != tblock.visibleTile() )
00416 {
00417 <font class="keywordflow">if</font>( tblock.visibleTile() )
00418 {
00419 <font class="comment">// allocate</font>
00420 <a class="code" href="classNL3D_1_1CPatch.html#c17">updateTileVBAlloc</a>(tblock.NearVertexList, <font class="keyword">true</font>);
00421 <font class="comment">// fill only if possible.</font>
00422 <font class="keywordflow">if</font>(!CLandscapeGlobals::CurrentTileVBAllocator->reallocationOccurs())
00423 <a class="code" href="classNL3D_1_1CPatch.html#c14">fillTileVertexListVB</a>(tblock.NearVertexList);
00424 <font class="comment">// rebuild triangles index list.</font>
00425 tblock.refillFaceVectorTile();
00426 }
00427 <font class="keywordflow">else</font>
00428 {
00429 <font class="comment">// delete</font>
00430 <a class="code" href="classNL3D_1_1CPatch.html#c17">updateTileVBAlloc</a>(tblock.NearVertexList, <font class="keyword">false</font>);
00431 }
00432 }
00433 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>> 0 && oldVisibleFar1 != tblock.visibleFar1() )
00434 {
00435 <font class="keywordflow">if</font>( tblock.visibleFar1() )
00436 {
00437 <font class="comment">// allocate</font>
00438 <a class="code" href="classNL3D_1_1CPatch.html#c16">updateFar1VBAlloc</a>(tblock.FarVertexList, <font class="keyword">true</font>);
00439 <font class="comment">// fill only if possible.</font>
00440 <font class="keywordflow">if</font>(!CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs())
00441 <a class="code" href="classNL3D_1_1CPatch.html#c13">fillFar1VertexListVB</a>(tblock.FarVertexList);
00442 <font class="comment">// rebuild triangles index list.</font>
00443 tblock.refillFaceVectorFar1();
00444 }
00445 <font class="keywordflow">else</font>
00446 {
00447 <font class="comment">// delete</font>
00448 <a class="code" href="classNL3D_1_1CPatch.html#c16">updateFar1VBAlloc</a>(tblock.FarVertexList, <font class="keyword">false</font>);
00449 }
00450 }
00451 }
00452
00453 }
00454
00455
00456 <font class="comment">// Special profiling.</font>
00457 <font class="preprocessor">#ifdef NL3D_PROFILE_LAND</font>
00458 <font class="preprocessor"></font><font class="preprocessor">#define NL3D_PROFILE_LAND_ADD_FACE_VECTOR(_x, _fv) \</font>
00459 <font class="preprocessor"> if(_fv) \</font>
00460 <font class="preprocessor"> { \</font>
00461 <font class="preprocessor"> NL3D_PROFILE_LAND_ADD(_x, _fv->NumTri); \</font>
00462 <font class="preprocessor"> }</font>
00463 <font class="preprocessor"></font><font class="preprocessor">#else</font>
<a name="l00464"></a><a class="code" href="patch__render_8cpp.html#a0">00464</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_PROFILE_LAND_ADD_FACE_VECTOR(_x, _fv)</font>
00465 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00466 <font class="preprocessor"></font>
00467
00468 <font class="comment">// ***************************************************************************</font>
00469 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a396">renderFaceVector</a>(CLandscapeFaceVector *fv)
00470 {
00471 <font class="comment">// If not NULL (ie not empty).</font>
00472 <font class="keywordflow">if</font>(fv)
00473 {
00474 <font class="comment">// TestYoyo: Bench.</font>
00475 <font class="comment">/*</font>
00476 <font class="comment"> extern uint TEMP_NRFV;</font>
00477 <font class="comment"> extern uint TEMP_NRFVTri;</font>
00478 <font class="comment"> extern float TEMP_NRFVMeanTri;</font>
00479 <font class="comment"> extern float TEMP_NRFVDeltaTri;</font>
00480 <font class="comment"> TEMP_NRFV++;</font>
00481 <font class="comment"> TEMP_NRFVTri+= fv->NumTri;</font>
00482 <font class="comment"> TEMP_NRFVDeltaTri+= sqr(fv->NumTri-TEMP_NRFVMeanTri);</font>
00483 <font class="comment"> */</font>
00484
00485 <font class="comment">// here we have NumTri>0, because fv!=NULL.</font>
00486
00487 <font class="comment">// making lot of render() is slower than copy a block, and render it.</font>
00488 <font class="comment">//CLandscapeGlobals::PatchCurrentDriver->renderSimpleTriangles(fv->TriPtr, fv->NumTri);</font>
00489
00490 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
00491 <font class="preprocessor"></font> __asm
00492 {
00493 mov ebx, fv
00494 mov edi, <a class="code" href="namespaceNL3D.html#a71">NL3D_LandscapeGlobals_PassTriCurPtr</a>
00495
00496 mov edx, <a class="code" href="namespaceNL3D.html#a70">NL3D_LandscapeGlobals_PassNTri</a>
00497 xor eax, eax <font class="comment">// Avoid AGI stall.</font>
00498
00499 mov ecx, [ebx]fv.NumTri
00500 mov esi, [ebx]fv.TriPtr
00501
00502 mov eax, ecx <font class="comment">// eax= bkup NumTris</font>
00503 lea ecx, [ecx + ecx*2] <font class="comment">// ecx= nTriIndex= NumTris*3</font>
00504
00505 <font class="comment">// copy tri indices</font>
00506 rep movsd
00507
00508 add edx, eax <font class="comment">// edx= NL3D_LandscapeGlobals_PassNTri + fv->NumTri;</font>
00509
00510 <font class="comment">// NL3D_LandscapeGlobals_PassTriCurPtr= edi= new ptr after copy</font>
00511 mov <a class="code" href="namespaceNL3D.html#a71">NL3D_LandscapeGlobals_PassTriCurPtr</a>, edi
00512 mov <a class="code" href="namespaceNL3D.html#a70">NL3D_LandscapeGlobals_PassNTri</a>, edx
00513 }
00514 <font class="preprocessor">#else</font>
00515 <font class="preprocessor"></font> uint nTriIndex= fv->NumTri*3;
00516 <font class="comment">// Fill and increment the array.</font>
00517 memcpy( <a class="code" href="namespaceNL3D.html#a71">NL3D_LandscapeGlobals_PassTriCurPtr</a>, fv->TriPtr, nTriIndex * <font class="keyword">sizeof</font>(uint32) );
00518 <a class="code" href="namespaceNL3D.html#a71">NL3D_LandscapeGlobals_PassTriCurPtr</a>+= nTriIndex;
00519 <a class="code" href="namespaceNL3D.html#a70">NL3D_LandscapeGlobals_PassNTri</a>+= fv->NumTri;
00520 <font class="preprocessor">#endif</font>
00521 <font class="preprocessor"></font> }
00522 }
00523
00524
00525 <font class="comment">// ***************************************************************************</font>
<a name="l00526"></a><a class="code" href="classNL3D_1_1CPatch.html#z669_2">00526</a> <font class="keywordtype">void</font> CPatch::renderFar0()
00527 {
00528 <font class="comment">// Must be visible, and must be called only if the RdrPass is enabled.</font>
00529 <a class="code" href="debug_8h.html#a6">nlassert</a>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a> && <a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass);
00530
00531 <font class="comment">// Render tris of MasterBlock.</font>
00532 <a class="code" href="namespaceNL3D.html#a396">renderFaceVector</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.Far0FaceVector);
00533 <font class="comment">// profile</font>
00534 <a class="code" href="patch__render_8cpp.html#a0">NL3D_PROFILE_LAND_ADD_FACE_VECTOR</a>(<a class="code" href="namespaceNL3D.html#a74">ProfNRdrFar0</a>, <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.Far0FaceVector);
00535
00536 <font class="comment">// Render tris of TessBlocks.</font>
00537 uint nTessBlock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size();
00538 CTessBlock *pTessBlock= nTessBlock>0? &<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[0]: NULL ;
00539 <font class="keywordflow">for</font>(; nTessBlock>0; pTessBlock++, nTessBlock--)
00540 {
00541 CTessBlock &tblock= *pTessBlock;
00542 <font class="comment">// if block visible, render</font>
00543 <font class="keywordflow">if</font>( tblock.visibleFar0() )
00544 {
00545 <a class="code" href="namespaceNL3D.html#a396">renderFaceVector</a>(tblock.Far0FaceVector);
00546 <font class="comment">// profile</font>
00547 <a class="code" href="patch__render_8cpp.html#a0">NL3D_PROFILE_LAND_ADD_FACE_VECTOR</a>(<a class="code" href="namespaceNL3D.html#a74">ProfNRdrFar0</a>, tblock.Far0FaceVector);
00548 }
00549 }
00550
00551 <font class="comment">// Check the pass is in the set</font>
00552 <font class="preprocessor">#ifdef NL_DEBUG</font>
00553 <font class="preprocessor"></font> <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass)
00554 {
00555 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSet.find (<a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass)!=<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSet.end());
00556 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSet.find (<a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass)==<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSet.end())
00557 {
00558 <font class="keywordtype">bool</font> bFound=<font class="keyword">false</font>;
00559 {
00560 <font class="keywordflow">for</font> (sint <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><(sint)<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSetVectorFree.size(); <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>++)
00561 {
00562 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSetVectorFree[<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>].find (<a class="code" href="classNL3D_1_1CPatch.html#o28">Pass0</a>.PatchRdrPass)!=<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSetVectorFree[<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>].end())
00563 {
00564 bFound=<font class="keyword">true</font>;
00565 <font class="keywordflow">break</font>;
00566 }
00567 }
00568 }
00569 <a class="code" href="debug_8h.html#a6">nlassert</a> (bFound);
00570 }
00571 }
00572 <font class="preprocessor">#endif // NL_DEBUG</font>
00573 <font class="preprocessor"></font>}
00574
00575
00576 <font class="comment">// ***************************************************************************</font>
<a name="l00577"></a><a class="code" href="classNL3D_1_1CPatch.html#z669_3">00577</a> <font class="keywordtype">void</font> CPatch::renderFar1()
00578 {
00579 <font class="comment">// Must be visible, and must be called only if the RdrPass is enabled.</font>
00580 <a class="code" href="debug_8h.html#a6">nlassert</a>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a> && <a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass);
00581
00582 <font class="comment">// Render tris of MasterBlock.</font>
00583 <a class="code" href="namespaceNL3D.html#a396">renderFaceVector</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.Far1FaceVector);
00584 <font class="comment">// profile.</font>
00585 <a class="code" href="patch__render_8cpp.html#a0">NL3D_PROFILE_LAND_ADD_FACE_VECTOR</a>(<a class="code" href="namespaceNL3D.html#a75">ProfNRdrFar1</a>, <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.Far1FaceVector);
00586
00587 <font class="comment">// Render tris of TessBlocks.</font>
00588 uint nTessBlock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size();
00589 CTessBlock *pTessBlock= nTessBlock>0? &<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[0]: NULL ;
00590 <font class="keywordflow">for</font>(; nTessBlock>0; pTessBlock++, nTessBlock--)
00591 {
00592 CTessBlock &tblock= *pTessBlock;
00593 <font class="comment">// if block visible, render</font>
00594 <font class="keywordflow">if</font>( tblock.visibleFar1() )
00595 {
00596 <a class="code" href="namespaceNL3D.html#a396">renderFaceVector</a>(tblock.Far1FaceVector);
00597 <font class="comment">// profile.</font>
00598 <a class="code" href="patch__render_8cpp.html#a0">NL3D_PROFILE_LAND_ADD_FACE_VECTOR</a>(<a class="code" href="namespaceNL3D.html#a75">ProfNRdrFar1</a>, tblock.Far1FaceVector);
00599 }
00600 }
00601
00602 <font class="comment">// Check the pass is in the set</font>
00603 <font class="preprocessor">#ifdef NL_DEBUG</font>
00604 <font class="preprocessor"></font> <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass)
00605 {
00606 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSet.find (<a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass)!=<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSet.end());
00607 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSet.find (<a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass)==<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSet.end())
00608 {
00609 <font class="keywordtype">bool</font> bFound=<font class="keyword">false</font>;
00610 {
00611 <font class="keywordflow">for</font> (sint <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><(sint)<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSetVectorFree.size(); <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>++)
00612 {
00613 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSetVectorFree[<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>].find (<a class="code" href="classNL3D_1_1CPatch.html#o29">Pass1</a>.PatchRdrPass)!=<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>->Landscape->_FarRdrPassSetVectorFree[<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>].end())
00614 {
00615 bFound=<font class="keyword">true</font>;
00616 <font class="keywordflow">break</font>;
00617 }
00618 }
00619 }
00620 <a class="code" href="debug_8h.html#a6">nlassert</a> (bFound);
00621 }
00622 }
00623 <font class="preprocessor">#endif // NL_DEBUG</font>
00624 <font class="preprocessor"></font>}
00625
00626
00627 <font class="comment">// ***************************************************************************</font>
<a name="l00628"></a><a class="code" href="structNL3D_1_1CTileMaterial.html#a2">00628</a> <font class="keywordtype">void</font> CTileMaterial::renderTile(uint pass)
00629 {
00630 <font class="comment">// because precisely inserted in preRender(), and correctly tested, this tile is to be rendered,</font>
00631 <font class="comment">// If the pass is enabled.</font>
00632 <font class="keywordflow">if</font>(<a class="code" href="structNL3D_1_1CTileMaterial.html#m2">Pass</a>[pass].PatchRdrPass)
00633 {
00634 <font class="comment">// render tris of the good faceList.</font>
00635 <a class="code" href="namespaceNL3D.html#a396">renderFaceVector</a>(<a class="code" href="structNL3D_1_1CTileMaterial.html#m4">TileFaceVectors</a>[pass]);
00636
00637 <font class="comment">// profile.</font>
00638 <a class="code" href="patch__render_8cpp.html#a0">NL3D_PROFILE_LAND_ADD_FACE_VECTOR</a>(<a class="code" href="namespaceNL3D.html#a76">ProfNRdrTile</a>[pass], <a class="code" href="structNL3D_1_1CTileMaterial.html#m4">TileFaceVectors</a>[pass]);
00639 }
00640 }
00641
00642 <font class="comment">// ***************************************************************************</font>
<a name="l00643"></a><a class="code" href="structNL3D_1_1CTileMaterial.html#a3">00643</a> <font class="keywordtype">void</font> CTileMaterial::renderTilePassRGB0()
00644 {
00645 <font class="comment">// because precisely inserted in preRender(), and correctly tested, this tile is to be rendered,</font>
00646 <font class="comment">// this pass must be enabled!</font>
00647 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="structNL3D_1_1CTileMaterial.html#m2">Pass</a>[<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>].PatchRdrPass);
00648 <font class="comment">// render tris of the good faceList.</font>
00649 <a class="code" href="namespaceNL3D.html#a396">renderFaceVector</a>(<a class="code" href="structNL3D_1_1CTileMaterial.html#m4">TileFaceVectors</a>[<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>]);
00650
00651 <font class="comment">// profile.</font>
00652 <a class="code" href="patch__render_8cpp.html#a0">NL3D_PROFILE_LAND_ADD_FACE_VECTOR</a>(<a class="code" href="namespaceNL3D.html#a76">ProfNRdrTile</a>[<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>], <a class="code" href="structNL3D_1_1CTileMaterial.html#m4">TileFaceVectors</a>[<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>]);
00653 }
00654
00655 <font class="comment">// ***************************************************************************</font>
<a name="l00656"></a><a class="code" href="structNL3D_1_1CTileMaterial.html#a4">00656</a> <font class="keywordtype">void</font> CTileMaterial::renderTilePassLightmap()
00657 {
00658 <font class="comment">// because precisely inserted in preRender(), and correctly tested, this tile is to be rendered,</font>
00659 <font class="comment">// this pass must be enabled!</font>
00660 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="structNL3D_1_1CTileMaterial.html#m2">Pass</a>[<a class="code" href="landscape__def_8h.html#a6">NL3D_TILE_PASS_LIGHTMAP</a>].PatchRdrPass);
00661 <font class="comment">// render tris of the good faceList, ie the one of PassRGB0, because vertices are reused.</font>
00662 <a class="code" href="namespaceNL3D.html#a396">renderFaceVector</a>(<a class="code" href="structNL3D_1_1CTileMaterial.html#m4">TileFaceVectors</a>[<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>]);
00663
00664 <font class="comment">// profile.</font>
00665 <a class="code" href="patch__render_8cpp.html#a0">NL3D_PROFILE_LAND_ADD_FACE_VECTOR</a>(<a class="code" href="namespaceNL3D.html#a76">ProfNRdrTile</a>[<a class="code" href="landscape__def_8h.html#a6">NL3D_TILE_PASS_LIGHTMAP</a>], <a class="code" href="structNL3D_1_1CTileMaterial.html#m4">TileFaceVectors</a>[<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>]);
00666 }
00667
00668
00669 <font class="comment">// ***************************************************************************</font>
00670 <font class="comment">// ***************************************************************************</font>
00671 <font class="comment">// FaceVector Allocation</font>
00672 <font class="comment">// ***************************************************************************</font>
00673 <font class="comment">// ***************************************************************************</font>
00674
00675
00676 <font class="comment">// ***************************************************************************</font>
<a name="l00677"></a><a class="code" href="classNL3D_1_1CPatch.html#c21">00677</a> <font class="keywordtype">void</font> CPatch::createFaceVectorFar1()
00678 {
00679 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0)
00680 {
00681 <font class="comment">// Create the face for all TessBlocks.</font>
00682 <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.createFaceVectorFar1(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00683 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00684 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i].createFaceVectorFar1(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00685 }
00686 }
00687 <font class="comment">// ***************************************************************************</font>
<a name="l00688"></a><a class="code" href="classNL3D_1_1CPatch.html#c22">00688</a> <font class="keywordtype">void</font> CPatch::deleteFaceVectorFar1()
00689 {
00690 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0)
00691 {
00692 <font class="comment">// delete the face for all TessBlocks.</font>
00693 <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.deleteFaceVectorFar1(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00694 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00695 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i].deleteFaceVectorFar1(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00696 }
00697 }
00698 <font class="comment">// ***************************************************************************</font>
<a name="l00699"></a><a class="code" href="classNL3D_1_1CPatch.html#c23">00699</a> <font class="keywordtype">void</font> CPatch::createFaceVectorFar0OrTile()
00700 {
00701 <font class="comment">// If Far Mode.</font>
00702 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0)
00703 {
00704 <font class="comment">// Create the face for all TessBlocks.</font>
00705 <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.createFaceVectorFar0(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00706 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00707 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i].createFaceVectorFar0(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00708 }
00709 <font class="comment">// Or If Tile Mode.</font>
00710 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0)
00711 {
00712 <font class="comment">// Create the face for all TessBlocks.</font>
00713 <font class="comment">// No tiles in MasterBlock!</font>
00714 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00715 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i].createFaceVectorTile(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00716 }
00717 }
00718 <font class="comment">// ***************************************************************************</font>
<a name="l00719"></a><a class="code" href="classNL3D_1_1CPatch.html#c24">00719</a> <font class="keywordtype">void</font> CPatch::deleteFaceVectorFar0OrTile()
00720 {
00721 <font class="comment">// If Far Mode.</font>
00722 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0)
00723 {
00724 <font class="comment">// delete the face for all TessBlocks.</font>
00725 <a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.deleteFaceVectorFar0(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00726 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00727 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i].deleteFaceVectorFar0(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00728 }
00729 <font class="comment">// Or If Tile Mode.</font>
00730 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0)
00731 {
00732 <font class="comment">// delete the face for all TessBlocks.</font>
00733 <font class="comment">// No tiles in MasterBlock!</font>
00734 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00735 <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i].deleteFaceVectorTile(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00736 }
00737 }
00738
00739
00740 <font class="comment">// ***************************************************************************</font>
<a name="l00741"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_13">00741</a> <font class="keywordtype">void</font> CPatch::recreateTessBlockFaceVector(CTessBlock &block)
00742 {
00743 <font class="comment">// Do it Only if patch is visible.</font>
00744 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>)
00745 {
00746 <font class="comment">// Far0.</font>
00747 <font class="comment">// If Far Mode.</font>
00748 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0)
00749 {
00750 <font class="comment">// Create the face for this TessBlock only.</font>
00751 block.createFaceVectorFar0(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00752 }
00753 <font class="comment">// Or If Tile Mode.</font>
00754 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0)
00755 {
00756 <font class="comment">// No tiles in MasterBlock! So no need to call createFaceVectorTile(), if this block is the MasterBlock.</font>
00757 <font class="keywordflow">if</font>(&block != &<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>)
00758 block.createFaceVectorTile(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00759 }
00760
00761 <font class="comment">// Far1.</font>
00762 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0)
00763 {
00764 <font class="comment">// Create the face for this TessBlock only.</font>
00765 block.createFaceVectorFar1(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()->_FaceVectorManager);
00766 }
00767 }
00768
00769 }
00770
00771
00772 <font class="comment">// ***************************************************************************</font>
00773 <font class="comment">// ***************************************************************************</font>
00774 <font class="comment">// VB Allocation</font>
00775 <font class="comment">// ***************************************************************************</font>
00776 <font class="comment">// ***************************************************************************</font>
00777
00778
00779 <font class="comment">// ***************************************************************************</font>
<a name="l00780"></a><a class="code" href="classNL3D_1_1CPatch.html#c15">00780</a> <font class="keywordtype">void</font> CPatch::updateFar0VBAlloc(CTessList<CTessFarVertex> &vertList, <font class="keywordtype">bool</font> alloc)
00781 {
00782 <font class="comment">// Traverse the vertList.</font>
00783 CTessFarVertex *pVert;
00784 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
00785 {
00786 <font class="keywordflow">if</font>(alloc)
00787 pVert->Index0= CLandscapeGlobals::CurrentFar0VBAllocator->allocateVertex();
00788 <font class="keywordflow">else</font>
00789 CLandscapeGlobals::CurrentFar0VBAllocator->deleteVertex(pVert->Index0);
00790 }
00791 }
00792
00793
00794 <font class="comment">// ***************************************************************************</font>
<a name="l00795"></a><a class="code" href="classNL3D_1_1CPatch.html#c16">00795</a> <font class="keywordtype">void</font> CPatch::updateFar1VBAlloc(CTessList<CTessFarVertex> &vertList, <font class="keywordtype">bool</font> alloc)
00796 {
00797 <font class="comment">// Traverse the vertList.</font>
00798 CTessFarVertex *pVert;
00799 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
00800 {
00801 <font class="keywordflow">if</font>(alloc)
00802 pVert->Index1= CLandscapeGlobals::CurrentFar1VBAllocator->allocateVertex();
00803 <font class="keywordflow">else</font>
00804 CLandscapeGlobals::CurrentFar1VBAllocator->deleteVertex(pVert->Index1);
00805 }
00806 }
00807
00808
00809 <font class="comment">// ***************************************************************************</font>
<a name="l00810"></a><a class="code" href="classNL3D_1_1CPatch.html#c17">00810</a> <font class="keywordtype">void</font> CPatch::updateTileVBAlloc(CTessList<CTessNearVertex> &vertList, <font class="keywordtype">bool</font> alloc)
00811 {
00812 <font class="comment">// Traverse the vertList.</font>
00813 CTessNearVertex *pVert;
00814 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessNearVertex*)pVert->Next)
00815 {
00816 <font class="keywordflow">if</font>(alloc)
00817 pVert->Index= CLandscapeGlobals::CurrentTileVBAllocator->allocateVertex();
00818 <font class="keywordflow">else</font>
00819 CLandscapeGlobals::CurrentTileVBAllocator->deleteVertex(pVert->Index);
00820 }
00821 }
00822
00823
00824 <font class="comment">// ***************************************************************************</font>
<a name="l00825"></a><a class="code" href="classNL3D_1_1CPatch.html#c18">00825</a> <font class="keywordtype">void</font> CPatch::updateVBAlloc(<font class="keywordtype">bool</font> alloc)
00826 {
00827 <font class="comment">// update Far0.</font>
00828 <font class="comment">//=======</font>
00829 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0)
00830 {
00831 <font class="comment">// alloc Far0 VB.</font>
00832 <a class="code" href="classNL3D_1_1CPatch.html#c15">updateFar0VBAlloc</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList, alloc);
00833 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00834 {
00835 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
00836 <font class="comment">// need update VB only if tessBlock is visible.</font>
00837 <font class="keywordflow">if</font>( tblock.visibleFar0() )
00838 <a class="code" href="classNL3D_1_1CPatch.html#c15">updateFar0VBAlloc</a>(tblock.FarVertexList, alloc);
00839 }
00840 }
00841 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0)
00842 {
00843 <font class="comment">// alloc Tile VB.</font>
00844 <font class="comment">// No Tiles in MasterBlock!!</font>
00845 <font class="comment">// Traverse the TessBlocks to add vertices.</font>
00846 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00847 {
00848 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
00849 <font class="comment">// Add the vertices.</font>
00850 <font class="comment">// need update VB only if tessBlock is visible.</font>
00851 <font class="keywordflow">if</font>( tblock.visibleTile() )
00852 <a class="code" href="classNL3D_1_1CPatch.html#c17">updateTileVBAlloc</a>(tblock.NearVertexList, alloc);
00853 }
00854 }
00855
00856 <font class="comment">// update Far1.</font>
00857 <font class="comment">//=======</font>
00858 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0)
00859 {
00860 <font class="comment">// alloc VB.</font>
00861 <a class="code" href="classNL3D_1_1CPatch.html#c16">updateFar1VBAlloc</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList, alloc);
00862 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00863 {
00864 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
00865 <font class="comment">// need update VB only if tessBlock is visible.</font>
00866 <font class="keywordflow">if</font>( tblock.visibleFar1() )
00867 <a class="code" href="classNL3D_1_1CPatch.html#c16">updateFar1VBAlloc</a>(tblock.FarVertexList, alloc);
00868 }
00869 }
00870 }
00871
00872 <font class="comment">// ***************************************************************************</font>
<a name="l00873"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_0">00873</a> <font class="keywordtype">void</font> CPatch::deleteVBAndFaceVector()
00874 {
00875 <a class="code" href="classNL3D_1_1CPatch.html#c18">updateVBAlloc</a>(<font class="keyword">false</font>);
00876 <a class="code" href="classNL3D_1_1CPatch.html#c22">deleteFaceVectorFar1</a>();
00877 <a class="code" href="classNL3D_1_1CPatch.html#c24">deleteFaceVectorFar0OrTile</a>();
00878 }
00879
00880 <font class="comment">// ***************************************************************************</font>
<a name="l00881"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_1">00881</a> <font class="keywordtype">void</font> CPatch::allocateVBAndFaceVector()
00882 {
00883 <a class="code" href="classNL3D_1_1CPatch.html#c18">updateVBAlloc</a>(<font class="keyword">true</font>);
00884 <a class="code" href="classNL3D_1_1CPatch.html#c21">createFaceVectorFar1</a>();
00885 <a class="code" href="classNL3D_1_1CPatch.html#c23">createFaceVectorFar0OrTile</a>();
00886 }
00887
00888
00889 <font class="comment">// ***************************************************************************</font>
<a name="l00890"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_4">00890</a> <font class="keywordtype">void</font> CPatch::deleteVBAndFaceVectorFar1Only()
00891 {
00892 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0)
00893 {
00894 <font class="comment">// alloc VB.</font>
00895 <a class="code" href="classNL3D_1_1CPatch.html#c16">updateFar1VBAlloc</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList, <font class="keyword">false</font>);
00896 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00897 {
00898 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
00899 <font class="comment">// need update VB only if tessBlock is visible.</font>
00900 <font class="keywordflow">if</font>( tblock.visibleFar1() )
00901 <a class="code" href="classNL3D_1_1CPatch.html#c16">updateFar1VBAlloc</a>(tblock.FarVertexList, <font class="keyword">false</font>);
00902 }
00903 }
00904
00905 <a class="code" href="classNL3D_1_1CPatch.html#c22">deleteFaceVectorFar1</a>();
00906 }
00907
00908 <font class="comment">// ***************************************************************************</font>
<a name="l00909"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_5">00909</a> <font class="keywordtype">void</font> CPatch::allocateVBAndFaceVectorFar1Only()
00910 {
00911 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0)
00912 {
00913 <font class="comment">// alloc VB.</font>
00914 <a class="code" href="classNL3D_1_1CPatch.html#c16">updateFar1VBAlloc</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList, <font class="keyword">true</font>);
00915 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00916 {
00917 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
00918 <font class="comment">// need update VB only if tessBlock is visible.</font>
00919 <font class="keywordflow">if</font>( tblock.visibleFar1() )
00920 <a class="code" href="classNL3D_1_1CPatch.html#c16">updateFar1VBAlloc</a>(tblock.FarVertexList, <font class="keyword">true</font>);
00921 }
00922 }
00923
00924 <a class="code" href="classNL3D_1_1CPatch.html#c21">createFaceVectorFar1</a>();
00925 }
00926
00927
00928 <font class="comment">// ***************************************************************************</font>
<a name="l00929"></a><a class="code" href="classNL3D_1_1CPatch.html#c19">00929</a> <font class="keywordtype">void</font> CPatch::debugAllocationMarkIndicesFarList(CTessList<CTessFarVertex> &vertList, uint marker)
00930 {
00931 <font class="comment">// Traverse the vertList.</font>
00932 CTessFarVertex *pVert;
00933 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
00934 {
00935 pVert->Index0= marker;
00936 pVert->Index1= marker;
00937 }
00938 }
00939
<a name="l00940"></a><a class="code" href="classNL3D_1_1CPatch.html#c20">00940</a> <font class="keywordtype">void</font> CPatch::debugAllocationMarkIndicesNearList(CTessList<CTessNearVertex> &vertList, uint marker)
00941 {
00942 <font class="comment">// Traverse the vertList.</font>
00943 CTessNearVertex *pVert;
00944 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessNearVertex*)pVert->Next)
00945 {
00946 pVert->Index= marker;
00947 }
00948 }
00949
<a name="l00950"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_12">00950</a> <font class="keywordtype">void</font> CPatch::debugAllocationMarkIndices(uint marker)
00951 {
00952 sint i;
00953
00954 <font class="comment">// Do it For Far.</font>
00955 <a class="code" href="classNL3D_1_1CPatch.html#c19">debugAllocationMarkIndicesFarList</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList, marker);
00956 <font class="keywordflow">for</font>(i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00957 {
00958 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
00959 <a class="code" href="classNL3D_1_1CPatch.html#c19">debugAllocationMarkIndicesFarList</a>(tblock.FarVertexList, marker);
00960 }
00961 <font class="comment">// Do it For Near.</font>
00962 <font class="comment">// No Tiles in MasterBlock!!</font>
00963 <font class="keywordflow">for</font>(i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
00964 {
00965 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
00966 <a class="code" href="classNL3D_1_1CPatch.html#c20">debugAllocationMarkIndicesNearList</a>(tblock.NearVertexList, marker);
00967 }
00968
00969 }
00970
00971
00972
00973 <font class="comment">// ***************************************************************************</font>
00974 <font class="comment">// ***************************************************************************</font>
00975 <font class="comment">// VB Filling.</font>
00976 <font class="comment">// ***************************************************************************</font>
00977 <font class="comment">// ***************************************************************************</font>
00978
00979
00980 <font class="comment">// ***************************************************************************</font>
00981 <font class="comment">// NB: need to be inlined only for fillFar0VB() in this file.</font>
<a name="l00982"></a><a class="code" href="classNL3D_1_1CPatch.html#c9">00982</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CPatch::fillFar0VertexVB(CTessFarVertex *pVert)
00983 {
00984 <font class="comment">// The Buffers must have been locked</font>
00985 <a class="code" href="debug_8h.html#a6">nlassert</a>(CLandscapeGlobals::CurrentFar0VBAllocator);
00986 <a class="code" href="debug_8h.html#a6">nlassert</a>(CLandscapeGlobals::CurrentFar0VBAllocator->bufferLocked());
00987 <font class="comment">// VBInfo must be OK.</font>
00988 <a class="code" href="debug_8h.html#a6">nlassert</a>(!CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs());
00989
00990 <font class="keyword">static</font> uint8 *CurVBPtr;
00991 <font class="comment">// Compute/build the new vertex.</font>
00992 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar0VBInfo.VertexCoordPointer;
00993 CurVBPtr+= pVert->Index0 * CLandscapeGlobals::CurrentFar0VBInfo.VertexSize;
00994
00995 <font class="comment">// NB: the filling order of data is important, for AGP write combiners.</font>
00996
00997 <font class="comment">// compute Uvs.</font>
00998 <font class="keyword">static</font> CUV uv;
00999 CParamCoord pc= pVert->PCoord;
01000 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>&<a class="code" href="patch_8h.html#a2">NL_PATCH_FAR0_ROTATED</a>)
01001 {
01002 uv.U= pc.getT()* <a class="code" href="classNL3D_1_1CPatch.html#o16">Far0UScale</a> + <a class="code" href="classNL3D_1_1CPatch.html#o18">Far0UBias</a>;
01003 uv.V= (1.f-pc.getS())* <a class="code" href="classNL3D_1_1CPatch.html#o17">Far0VScale</a> + <a class="code" href="classNL3D_1_1CPatch.html#o19">Far0VBias</a>;
01004 }
01005 <font class="keywordflow">else</font>
01006 {
01007 uv.U= pc.getS()* <a class="code" href="classNL3D_1_1CPatch.html#o16">Far0UScale</a> + <a class="code" href="classNL3D_1_1CPatch.html#o18">Far0UBias</a>;
01008 uv.V= pc.getT()* <a class="code" href="classNL3D_1_1CPatch.html#o17">Far0VScale</a> + <a class="code" href="classNL3D_1_1CPatch.html#o19">Far0VBias</a>;
01009 }
01010
01011 <font class="comment">// compute Dynamic lightmap Uv.</font>
01012 <font class="keyword">static</font> CUV uvDLM;
01013 <font class="keywordflow">if</font>(_DLMContext) <font class="comment">// (NB: Suppose BTB kill this test).</font>
01014 {
01015 <font class="comment">// compute UV with DLM context info.</font>
01016 uvDLM.U= pc.getS()* <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMUScale + <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMUBias;
01017 uvDLM.V= pc.getT()* <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMVScale + <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMVBias;
01018 }
01019 <font class="keywordflow">else</font>
01020 {
01021 <font class="comment">// just set UV so the vertex point to a black pixel (see CTextureDLM).</font>
01022 uvDLM.U= 1;
01023 uvDLM.V= 1;
01024 }
01025
01026 <font class="comment">// If not VertexProgram (NB: Suppose BTB kill this test).</font>
01027 <font class="keywordflow">if</font>( !CLandscapeGlobals::VertexProgramEnabled )
01028 {
01029 <font class="comment">// Set Pos. Set it local to the current center of landscape</font>
01030 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
01031 <font class="comment">// Set Uvs.</font>
01032 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff0)= uv;
01033 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff1)= uvDLM;
01034 }
01035 <font class="keywordflow">else</font>
01036 {
01037 <font class="comment">// Else must setup Vertex program inputs</font>
01038 <font class="comment">// v[0]== StartPos.</font>
01039 *(CVector*)CurVBPtr= pVert->Src->StartPos;
01040 <font class="comment">// v[8]== Tex0</font>
01041 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff0)= uv;
01042 <font class="comment">// v[9]== Tex1</font>
01043 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff1)= uvDLM;
01044
01045 <font class="comment">// v[10]== GeomInfo.</font>
01046 <font class="keyword">static</font> CUV geomInfo;
01047 geomInfo.U= pVert->Src->MaxFaceSize * CLandscapeGlobals::OORefineThreshold;
01048 geomInfo.V= pVert->Src->MaxNearLimit;
01049 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.GeomInfoOff)= geomInfo;
01050
01051 <font class="comment">// v[11]== EndPos - StartPos</font>
01052 *(CVector*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.DeltaPosOff)=
01053 pVert->Src->EndPos - pVert->Src->StartPos;
01054 }
01055 }
01056 <font class="comment">// ***************************************************************************</font>
01057 <font class="comment">// NB: need to be inlined only for fillFar1VB() in this file.</font>
<a name="l01058"></a><a class="code" href="classNL3D_1_1CPatch.html#c10">01058</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CPatch::fillFar1VertexVB(CTessFarVertex *pVert)
01059 {
01060 <font class="comment">// The Buffers must have been locked</font>
01061 <a class="code" href="debug_8h.html#a6">nlassert</a>(CLandscapeGlobals::CurrentFar1VBAllocator);
01062 <a class="code" href="debug_8h.html#a6">nlassert</a>(CLandscapeGlobals::CurrentFar1VBAllocator->bufferLocked());
01063 <font class="comment">// VBInfo must be OK.</font>
01064 <a class="code" href="debug_8h.html#a6">nlassert</a>(!CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs());
01065
01066 <font class="keyword">static</font> uint8 *CurVBPtr;
01067 <font class="comment">// Compute/build the new vertex.</font>
01068 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar1VBInfo.VertexCoordPointer;
01069 CurVBPtr+= pVert->Index1 * CLandscapeGlobals::CurrentFar1VBInfo.VertexSize;
01070
01071 <font class="comment">// NB: the filling order of data is important, for AGP write combiners.</font>
01072
01073 <font class="comment">// compute Uvs.</font>
01074 <font class="keyword">static</font> CUV uv;
01075 CParamCoord pc= pVert->PCoord;
01076 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPatch.html#o24">Flags</a>&<a class="code" href="patch_8h.html#a3">NL_PATCH_FAR1_ROTATED</a>)
01077 {
01078 uv.U= pc.getT()* <a class="code" href="classNL3D_1_1CPatch.html#o20">Far1UScale</a> + <a class="code" href="classNL3D_1_1CPatch.html#o22">Far1UBias</a>;
01079 uv.V= (1.f-pc.getS())* <a class="code" href="classNL3D_1_1CPatch.html#o21">Far1VScale</a> + <a class="code" href="classNL3D_1_1CPatch.html#o23">Far1VBias</a>;
01080 }
01081 <font class="keywordflow">else</font>
01082 {
01083 uv.U= pc.getS()* <a class="code" href="classNL3D_1_1CPatch.html#o20">Far1UScale</a> + <a class="code" href="classNL3D_1_1CPatch.html#o22">Far1UBias</a>;
01084 uv.V= pc.getT()* <a class="code" href="classNL3D_1_1CPatch.html#o21">Far1VScale</a> + <a class="code" href="classNL3D_1_1CPatch.html#o23">Far1VBias</a>;
01085 }
01086
01087 <font class="comment">// compute Dynamic lightmap Uv.</font>
01088 <font class="keyword">static</font> CUV uvDLM;
01089 <font class="keywordflow">if</font>(_DLMContext) <font class="comment">// (NB: Suppose BTB kill this test).</font>
01090 {
01091 <font class="comment">// compute UV with DLM context info.</font>
01092 uvDLM.U= pc.getS()* <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMUScale + <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMUBias;
01093 uvDLM.V= pc.getT()* <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMVScale + <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMVBias;
01094 }
01095 <font class="keywordflow">else</font>
01096 {
01097 <font class="comment">// just set UV so the vertex point to a black pixel (see CTextureDLM).</font>
01098 uvDLM.U= 1;
01099 uvDLM.V= 1;
01100 }
01101
01102 <font class="comment">// If not VertexProgram (NB: Suppose BTB kill this test).</font>
01103 <font class="keywordflow">if</font>( !CLandscapeGlobals::VertexProgramEnabled )
01104 {
01105 <font class="comment">// Set Pos. Set it local to the current center of landscape</font>
01106 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
01107 <font class="comment">// Set Uvs.</font>
01108 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff0)= uv;
01109 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff1)= uvDLM;
01110 <font class="comment">// Set default color.</font>
01111 <font class="keyword">static</font> CRGBA col(255,255,255,255);
01112 *(CRGBA*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.ColorOff)= col;
01113 }
01114 <font class="keywordflow">else</font>
01115 {
01116 <font class="comment">// Else must setup Vertex program inputs</font>
01117 <font class="comment">// v[0]== StartPos.</font>
01118 *(CVector*)CurVBPtr= pVert->Src->StartPos;
01119 <font class="comment">// v[8]== Tex0</font>
01120 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff0)= uv;
01121 <font class="comment">// v[9]== Tex1</font>
01122 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff1)= uvDLM;
01123
01124 <font class="comment">// v[10]== GeomInfo.</font>
01125 <font class="keyword">static</font> CUV geomInfo;
01126 geomInfo.U= pVert->Src->MaxFaceSize * CLandscapeGlobals::OORefineThreshold;
01127 geomInfo.V= pVert->Src->MaxNearLimit;
01128 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.GeomInfoOff)= geomInfo;
01129
01130 <font class="comment">// v[11]== EndPos - StartPos</font>
01131 *(CVector*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.DeltaPosOff)=
01132 pVert->Src->EndPos - pVert->Src->StartPos;
01133
01134 <font class="comment">// v[12]== Alpha information</font>
01135 <font class="comment">// Hopefully, fillVBFar1Only() is called each Time the Far1 change, in preRender().</font>
01136 <font class="comment">// So TransitionSqrMin and OOTransitionSqrDelta in CPath are valid.</font>
01137 geomInfo.U= <a class="code" href="classNL3D_1_1CPatch.html#o30">TransitionSqrMin</a>;
01138 geomInfo.V= <a class="code" href="classNL3D_1_1CPatch.html#o31">OOTransitionSqrDelta</a>;
01139 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.AlphaInfoOff)= geomInfo;
01140
01141 }
01142 }
01143 <font class="comment">// ***************************************************************************</font>
01144 <font class="comment">// NB: need to be inlined only for fillTileVB() in this file.</font>
<a name="l01145"></a><a class="code" href="classNL3D_1_1CPatch.html#c11">01145</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CPatch::fillTileVertexVB(CTessNearVertex *pVert)
01146 {
01147 <font class="comment">// The Buffers must have been locked</font>
01148 <a class="code" href="debug_8h.html#a6">nlassert</a>(CLandscapeGlobals::CurrentTileVBAllocator);
01149 <a class="code" href="debug_8h.html#a6">nlassert</a>(CLandscapeGlobals::CurrentTileVBAllocator->bufferLocked());
01150 <font class="comment">// VBInfo must be OK.</font>
01151 <a class="code" href="debug_8h.html#a6">nlassert</a>(!CLandscapeGlobals::CurrentTileVBAllocator->reallocationOccurs());
01152
01153 <font class="keyword">static</font> uint8 *CurVBPtr;
01154 <font class="comment">// Compute/build the new vertex.</font>
01155 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentTileVBInfo.VertexCoordPointer;
01156 CurVBPtr+= pVert->Index * CLandscapeGlobals::CurrentTileVBInfo.VertexSize;
01157
01158
01159 <font class="comment">// NB: the filling order of data is important, for AGP write combiners.</font>
01160
01161 <font class="comment">// If not VertexProgram (NB: Suppose BTB kill this test).</font>
01162 <font class="keywordflow">if</font>( !CLandscapeGlobals::VertexProgramEnabled )
01163 {
01164 <font class="comment">// Set Pos. Set it local to the current center of landscape</font>
01165 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
01166 <font class="comment">// Set Uvs.</font>
01167 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff0)= pVert->PUv0;
01168 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff1)= pVert->PUv1;
01169 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff2)= pVert->PUv2;
01170 }
01171 <font class="keywordflow">else</font>
01172 {
01173 <font class="comment">// Else must setup Vertex program inputs</font>
01174 <font class="comment">// v[0]== StartPos.</font>
01175 *(CVector*)CurVBPtr= pVert->Src->StartPos;
01176 <font class="comment">// v[8]== Tex0</font>
01177 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff0)= pVert->PUv0;
01178 <font class="comment">// v[9]== Tex1</font>
01179 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff1)= pVert->PUv1;
01180 <font class="comment">// v[13]== Tex2</font>
01181 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff2)= pVert->PUv2;
01182
01183 <font class="comment">// v[10]== GeomInfo.</font>
01184 <font class="keyword">static</font> CUV geomInfo;
01185 geomInfo.U= pVert->Src->MaxFaceSize * CLandscapeGlobals::OORefineThreshold;
01186 geomInfo.V= pVert->Src->MaxNearLimit;
01187 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.GeomInfoOff)= geomInfo;
01188
01189 <font class="comment">// v[11]== EndPos - StartPos</font>
01190 *(CVector*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.DeltaPosOff)=
01191 pVert->Src->EndPos - pVert->Src->StartPos;
01192 }
01193 }
01194
01195
01196 <font class="comment">// ***************************************************************************</font>
<a name="l01197"></a><a class="code" href="classNL3D_1_1CPatch.html#c12">01197</a> <font class="keywordtype">void</font> CPatch::fillFar0VertexListVB(CTessList<CTessFarVertex> &vertList)
01198 {
01199 <font class="comment">// Traverse the vertList.</font>
01200 CTessFarVertex *pVert;
01201 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
01202 {
01203 <a class="code" href="classNL3D_1_1CPatch.html#c9">fillFar0VertexVB</a>(pVert);
01204 }
01205 }
01206
01207
01208 <font class="comment">// ***************************************************************************</font>
<a name="l01209"></a><a class="code" href="classNL3D_1_1CPatch.html#c13">01209</a> <font class="keywordtype">void</font> CPatch::fillFar1VertexListVB(CTessList<CTessFarVertex> &vertList)
01210 {
01211 <font class="comment">// Traverse the vertList.</font>
01212 CTessFarVertex *pVert;
01213 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
01214 {
01215 <a class="code" href="classNL3D_1_1CPatch.html#c10">fillFar1VertexVB</a>(pVert);
01216 }
01217 }
01218
01219
01220 <font class="comment">// ***************************************************************************</font>
<a name="l01221"></a><a class="code" href="classNL3D_1_1CPatch.html#c14">01221</a> <font class="keywordtype">void</font> CPatch::fillTileVertexListVB(CTessList<CTessNearVertex> &vertList)
01222 {
01223 <font class="comment">// Traverse the vertList.</font>
01224 CTessNearVertex *pVert;
01225 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessNearVertex*)pVert->Next)
01226 {
01227 <a class="code" href="classNL3D_1_1CPatch.html#c11">fillTileVertexVB</a>(pVert);
01228 }
01229 }
01230
01231
01232
01233 <font class="comment">// ***************************************************************************</font>
<a name="l01234"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_2">01234</a> <font class="keywordtype">void</font> CPatch::fillVB()
01235 {
01236 <font class="comment">// Fill Far0.</font>
01237 <font class="comment">//=======</font>
01238 <font class="comment">// fill only if no reallcoation occurs</font>
01239 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0 && !CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs() )
01240 {
01241 <font class="comment">// Fill Far0 VB.</font>
01242 <a class="code" href="classNL3D_1_1CPatch.html#c12">fillFar0VertexListVB</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList);
01243 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
01244 {
01245 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01246 <font class="comment">// fill only if tblock visible.</font>
01247 <font class="keywordflow">if</font>( tblock.visibleFar0() )
01248 <a class="code" href="classNL3D_1_1CPatch.html#c12">fillFar0VertexListVB</a>(tblock.FarVertexList);
01249 }
01250 }
01251 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0 && !CLandscapeGlobals::CurrentTileVBAllocator->reallocationOccurs() )
01252 {
01253 <font class="comment">// Fill Tile VB.</font>
01254 <font class="comment">// No Tiles in MasterBlock!!</font>
01255 <font class="comment">// Traverse the TessBlocks to add vertices.</font>
01256 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
01257 {
01258 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01259 <font class="comment">// fill only if tblock visible.</font>
01260 <font class="keywordflow">if</font>( tblock.visibleTile() )
01261 <a class="code" href="classNL3D_1_1CPatch.html#c14">fillTileVertexListVB</a>(tblock.NearVertexList);
01262 }
01263 }
01264
01265 <font class="comment">// Fill Far1.</font>
01266 <font class="comment">//=======</font>
01267 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0 && !CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs() )
01268 {
01269 <font class="comment">// Fill VB.</font>
01270 <a class="code" href="classNL3D_1_1CPatch.html#c13">fillFar1VertexListVB</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList);
01271 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
01272 {
01273 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01274 <font class="comment">// fill only if tblock visible.</font>
01275 <font class="keywordflow">if</font>( tblock.visibleFar1() )
01276 <a class="code" href="classNL3D_1_1CPatch.html#c13">fillFar1VertexListVB</a>(tblock.FarVertexList);
01277 }
01278 }
01279
01280 }
01281
01282
01283 <font class="comment">// ***************************************************************************</font>
<a name="l01284"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_3">01284</a> <font class="keywordtype">void</font> CPatch::fillVBIfVisible()
01285 {
01286 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>==<font class="keyword">false</font>)
01287 <a class="code" href="classNL3D_1_1CPatch.html#z673_2">fillVB</a>();
01288 }
01289
01290
01291 <font class="comment">// ***************************************************************************</font>
<a name="l01292"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_6">01292</a> <font class="keywordtype">void</font> CPatch::fillVBFar0Only()
01293 {
01294 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0 && !CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs() )
01295 {
01296 <font class="comment">// Fill Far0 VB.</font>
01297 <a class="code" href="classNL3D_1_1CPatch.html#c12">fillFar0VertexListVB</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList);
01298 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
01299 {
01300 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01301 <font class="comment">// fill only if tblock visible.</font>
01302 <font class="keywordflow">if</font>( tblock.visibleFar0() )
01303 <a class="code" href="classNL3D_1_1CPatch.html#c12">fillFar0VertexListVB</a>(tblock.FarVertexList);
01304 }
01305 }
01306 }
01307
01308
01309 <font class="comment">// ***************************************************************************</font>
<a name="l01310"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_7">01310</a> <font class="keywordtype">void</font> CPatch::fillVBFar1Only()
01311 {
01312 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0 && !CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs() )
01313 {
01314 <font class="comment">// Fill VB.</font>
01315 <a class="code" href="classNL3D_1_1CPatch.html#c13">fillFar1VertexListVB</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList);
01316 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
01317 {
01318 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01319 <font class="comment">// fill only if tblock visible.</font>
01320 <font class="keywordflow">if</font>( tblock.visibleFar1() )
01321 <a class="code" href="classNL3D_1_1CPatch.html#c13">fillFar1VertexListVB</a>(tblock.FarVertexList);
01322 }
01323 }
01324 }
01325
01326 <font class="comment">// ***************************************************************************</font>
01327 <font class="comment">// ***************************************************************************</font>
01328 <font class="comment">// VB Software Geomorph / Alpha.</font>
01329 <font class="comment">// ***************************************************************************</font>
01330 <font class="comment">// ***************************************************************************</font>
01331
01332
01333 <font class="comment">// ***************************************************************************</font>
<a name="l01334"></a><a class="code" href="classNL3D_1_1CPatch.html#c31">01334</a> <font class="keywordtype">void</font> CPatch::computeGeomorphVertexList(CTessList<CTessFarVertex> &vertList)
01335 {
01336 <font class="comment">// Traverse the vertList.</font>
01337 CTessFarVertex *pVert;
01338 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
01339 {
01340 <font class="comment">// compute geomorph.</font>
01341 pVert->Src->computeGeomPos();
01342 }
01343 }
01344
01345
01346 <font class="comment">// ***************************************************************************</font>
<a name="l01347"></a><a class="code" href="classNL3D_1_1CPatch.html#c32">01347</a> <font class="keywordtype">void</font> CPatch::computeGeomorphFar0VertexListVB(CTessList<CTessFarVertex> &vertList)
01348 {
01349 <font class="comment">// Traverse the vertList.</font>
01350 CTessFarVertex *pVert;
01351 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
01352 {
01353 <font class="keyword">static</font> uint8 *CurVBPtr;
01354 <font class="comment">// Compute/build the new vertex.</font>
01355 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar0VBInfo.VertexCoordPointer;
01356 CurVBPtr+= pVert->Index0 * CLandscapeGlobals::CurrentFar0VBInfo.VertexSize;
01357
01358 <font class="comment">// Set Geomorphed Position. Set it local to the current center of landscape</font>
01359 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
01360 }
01361 }
01362
01363
01364 <font class="comment">// ***************************************************************************</font>
<a name="l01365"></a><a class="code" href="classNL3D_1_1CPatch.html#c33">01365</a> <font class="keywordtype">void</font> CPatch::computeGeomorphAlphaFar1VertexListVB(CTessList<CTessFarVertex> &vertList)
01366 {
01367 <font class="comment">// Traverse the vertList.</font>
01368 CTessFarVertex *pVert;
01369 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
01370 {
01371 <font class="keyword">static</font> uint8 *CurVBPtr;
01372 <font class="comment">// Compute/build the new vertex.</font>
01373 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar1VBInfo.VertexCoordPointer;
01374 CurVBPtr+= pVert->Index1 * CLandscapeGlobals::CurrentFar1VBInfo.VertexSize;
01375
01376 <font class="comment">// NB: the filling order of data is important, for AGP write combiners.</font>
01377
01378 <font class="comment">// Set Geomorphed Position. Set it local to the current center of landscape</font>
01379 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
01380
01381 <font class="comment">// Set Alpha color.</font>
01382 <font class="keyword">static</font> CRGBA col(255,255,255,255);
01383 <font class="comment">// For Far1, use alpha fro transition.</font>
01384 <font class="comment">// Prefer Use Pos, because of caching. So little difference between Soft and VertexProgram mode.</font>
01385 <font class="keywordtype">float</font> f= (pVert->Src->Pos - CLandscapeGlobals::RefineCenter).sqrnorm();
01386 f= (f-<a class="code" href="classNL3D_1_1CPatch.html#o30">TransitionSqrMin</a>) * <a class="code" href="classNL3D_1_1CPatch.html#o31">OOTransitionSqrDelta</a>;
01387 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(f,0,1);
01388 col.A= (uint8)(f*255);
01389 *(CRGBA*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.ColorOff)= col;
01390 }
01391 }
01392
01393
01394 <font class="comment">// ***************************************************************************</font>
<a name="l01395"></a><a class="code" href="classNL3D_1_1CPatch.html#c34">01395</a> <font class="keywordtype">void</font> CPatch::computeGeomorphTileVertexListVB(CTessList<CTessNearVertex> &vertList)
01396 {
01397 <font class="comment">// Traverse the vertList.</font>
01398 CTessNearVertex *pVert;
01399 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessNearVertex*)pVert->Next)
01400 {
01401 <font class="keyword">static</font> uint8 *CurVBPtr;
01402 <font class="comment">// Compute/build the new vertex.</font>
01403 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentTileVBInfo.VertexCoordPointer;
01404 CurVBPtr+= pVert->Index * CLandscapeGlobals::CurrentTileVBInfo.VertexSize;
01405
01406 <font class="comment">// Set Geomorphed Position. Set it local to the current center of landscape</font>
01407 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
01408 }
01409 }
01410
01411
01412
01413 <font class="comment">// ***************************************************************************</font>
<a name="l01414"></a><a class="code" href="classNL3D_1_1CPatch.html#z669_4">01414</a> <font class="keywordtype">void</font> CPatch::computeSoftwareGeomorphAndAlpha()
01415 {
01416 <font class="keywordflow">if</font>(RenderClipped)
01417 <font class="keywordflow">return</font>;
01418
01419 <font class="comment">// Compute Geomorph.</font>
01420 <font class="comment">//=======</font>
01421 <font class="comment">// Need only to fill CTessVertex, so do it only for FarVertices</font>
01422 <font class="comment">// Hence Geomorph is done twice on edges of patches!!.</font>
01423 <font class="comment">// If not too near for precise, fast compute of geomorph.</font>
01424 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size()==0 )
01425 {
01426 <font class="comment">// Just update all vertices of master block.</font>
01427 <a class="code" href="classNL3D_1_1CPatch.html#c31">computeGeomorphVertexList</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList);
01428 }
01429 <font class="keywordflow">else</font>
01430 {
01431 <font class="comment">// update all vertices of master block.</font>
01432 <a class="code" href="classNL3D_1_1CPatch.html#c31">computeGeomorphVertexList</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList);
01433 <font class="comment">// update vertices of others block.</font>
01434 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
01435 {
01436 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01437 <font class="comment">// Precise Clip.</font>
01438 <font class="keywordflow">if</font>(!tblock.getClipped())
01439 {
01440 <font class="comment">// compute the geomorph of the vertices in the tessblock.</font>
01441 <a class="code" href="classNL3D_1_1CPatch.html#c31">computeGeomorphVertexList</a>(tblock.FarVertexList);
01442 }
01443 }
01444 }
01445
01446
01447 <font class="comment">// Fill Far0.</font>
01448 <font class="comment">//=======</font>
01449 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0)
01450 {
01451 <font class="comment">// Fill Far0 VB.</font>
01452 <a class="code" href="classNL3D_1_1CPatch.html#c32">computeGeomorphFar0VertexListVB</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList);
01453 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
01454 {
01455 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01456 <font class="comment">// Precise Clip.</font>
01457 <font class="keywordflow">if</font>( tblock.visibleFar0() )
01458 <a class="code" href="classNL3D_1_1CPatch.html#c32">computeGeomorphFar0VertexListVB</a>(tblock.FarVertexList);
01459 }
01460 }
01461 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0)
01462 {
01463 <font class="comment">// Fill Tile VB.</font>
01464 <font class="comment">// No Tiles in MasterBlock!!</font>
01465 <font class="comment">// Traverse the TessBlocks to compute vertices.</font>
01466 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
01467 {
01468 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01469 <font class="comment">// Precise Clip.</font>
01470 <font class="keywordflow">if</font>( tblock.visibleTile() )
01471 <a class="code" href="classNL3D_1_1CPatch.html#c34">computeGeomorphTileVertexListVB</a>(tblock.NearVertexList);
01472 }
01473 }
01474
01475 <font class="comment">// Fill Far1.</font>
01476 <font class="comment">//=======</font>
01477 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0)
01478 {
01479 <font class="comment">// Fill VB.</font>
01480 <a class="code" href="classNL3D_1_1CPatch.html#c33">computeGeomorphAlphaFar1VertexListVB</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList);
01481 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
01482 {
01483 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01484 <font class="comment">// Precise Clip.</font>
01485 <font class="keywordflow">if</font>( tblock.visibleFar1() )
01486 <a class="code" href="classNL3D_1_1CPatch.html#c33">computeGeomorphAlphaFar1VertexListVB</a>(tblock.FarVertexList);
01487 }
01488 }
01489 }
01490
01491
01492 <font class="comment">// ***************************************************************************</font>
01493 <font class="comment">// ***************************************************************************</font>
01494 <font class="comment">// VB clip Allocate/Filling.</font>
01495 <font class="comment">// ***************************************************************************</font>
01496 <font class="comment">// ***************************************************************************</font>
01497
01498
01499 <font class="comment">// ***************************************************************************</font>
<a name="l01500"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_11">01500</a> <font class="keywordtype">void</font> CPatch::updateClipPatchVB()
01501 {
01502 <font class="comment">// If there is a change in the clip state of this patch.</font>
01503 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CPatch.html#o27">OldRenderClipped</a> != <a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a> )
01504 {
01505 <font class="comment">// bkup this state for next time.</font>
01506 <a class="code" href="classNL3D_1_1CPatch.html#o27">OldRenderClipped</a> = <a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>;
01507
01508 <font class="comment">// If now the patch is invisible</font>
01509 <font class="keywordflow">if</font>(RenderClipped)
01510 {
01511 <font class="comment">// Then delete vertices.</font>
01512 <a class="code" href="classNL3D_1_1CPatch.html#z673_0">deleteVBAndFaceVector</a>();
01513
01514 <font class="comment">// Now, all vertices in VB are deleted.</font>
01515 <font class="comment">// Force clip state of all TessBlocks, so no allocation will be done on Vertices in VB.</font>
01516 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.empty())
01517 {
01518 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size();i++)
01519 {
01520 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01521 tblock.forceClip();
01522 }
01523 }
01524 }
01525 <font class="keywordflow">else</font>
01526 {
01527 <font class="comment">// else allocate / fill them.</font>
01528 <a class="code" href="classNL3D_1_1CPatch.html#z673_1">allocateVBAndFaceVector</a>();
01529 <font class="comment">// NB: fillVB() test if any reallocation occurs.</font>
01530 <a class="code" href="classNL3D_1_1CPatch.html#z673_2">fillVB</a>();
01531 }
01532 }
01533 }
01534
01535
01536 <font class="comment">// ***************************************************************************</font>
01537 <font class="comment">// ***************************************************************************</font>
01538 <font class="comment">// VB refine Allocate/Filling.</font>
01539 <font class="comment">// ***************************************************************************</font>
01540 <font class="comment">// ***************************************************************************</font>
01541
01542
01543
01544 <font class="comment">// ***************************************************************************</font>
<a name="l01545"></a><a class="code" href="classNL3D_1_1CPatch.html#c25">01545</a> <font class="keywordtype">void</font> CPatch::checkCreateVertexVBFar(CTessFarVertex *pVert)
01546 {
01547 <a class="code" href="debug_8h.html#a6">nlassert</a>(pVert);
01548 <font class="comment">// If visible, and Far0 in !Tile Mode, allocate.</font>
01549 <font class="comment">// NB: must test Far0>0 because vertices are reallocated in preRender() if a change of Far occurs.</font>
01550 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a> && <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0 && pVert->OwnerBlock->visibleFar0() )
01551 {
01552 pVert->Index0= CLandscapeGlobals::CurrentFar0VBAllocator->allocateVertex();
01553 }
01554
01555 <font class="comment">// Idem for Far1</font>
01556 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a> && <a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0 && pVert->OwnerBlock->visibleFar1())
01557 {
01558 pVert->Index1= CLandscapeGlobals::CurrentFar1VBAllocator->allocateVertex();
01559 }
01560
01561 }
01562
01563
01564 <font class="comment">// ***************************************************************************</font>
<a name="l01565"></a><a class="code" href="classNL3D_1_1CPatch.html#c27">01565</a> <font class="keywordtype">void</font> CPatch::checkFillVertexVBFar(CTessFarVertex *pVert)
01566 {
01567 <a class="code" href="debug_8h.html#a6">nlassert</a>(pVert);
01568 <font class="comment">// If visible, and Far0 in !Tile Mode, try to fill.</font>
01569 <font class="comment">// NB: must test Far0>0 because vertices are reallocated in preRender() if a change of Far occurs.</font>
01570 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a> && <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0 && pVert->OwnerBlock->visibleFar0())
01571 {
01572 <font class="keywordflow">if</font>( !CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs() )
01573 <a class="code" href="classNL3D_1_1CPatch.html#c9">fillFar0VertexVB</a>(pVert);
01574 }
01575
01576 <font class="comment">// Idem for Far1</font>
01577 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a> && <a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0 && pVert->OwnerBlock->visibleFar1())
01578 {
01579 <font class="keywordflow">if</font>( !CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs() )
01580 <a class="code" href="classNL3D_1_1CPatch.html#c10">fillFar1VertexVB</a>(pVert);
01581 }
01582 }
01583
01584
01585 <font class="comment">// ***************************************************************************</font>
<a name="l01586"></a><a class="code" href="classNL3D_1_1CPatch.html#c26">01586</a> <font class="keywordtype">void</font> CPatch::checkCreateVertexVBNear(CTessNearVertex *pVert)
01587 {
01588 <a class="code" href="debug_8h.html#a6">nlassert</a>(pVert);
01589 <font class="comment">// If visible, and Far0 in Tile Mode, allocate.</font>
01590 <font class="comment">// NB: must test Far0==0 because vertices are reallocated in preRender() if a change of Far occurs.</font>
01591 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a> && <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0 && pVert->OwnerBlock->visibleTile())
01592 {
01593 pVert->Index= CLandscapeGlobals::CurrentTileVBAllocator->allocateVertex();
01594 }
01595 }
01596
01597
01598 <font class="comment">// ***************************************************************************</font>
<a name="l01599"></a><a class="code" href="classNL3D_1_1CPatch.html#c28">01599</a> <font class="keywordtype">void</font> CPatch::checkFillVertexVBNear(CTessNearVertex *pVert)
01600 {
01601 <a class="code" href="debug_8h.html#a6">nlassert</a>(pVert);
01602 <font class="comment">// If visible, and Far0 in Tile Mode, try to fill.</font>
01603 <font class="comment">// NB: must test Far0==0 because vertices are reallocated in preRender() if a change of Far occurs.</font>
01604 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>&& <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0 && pVert->OwnerBlock->visibleTile() )
01605 {
01606 <font class="comment">// try to fill.</font>
01607 <font class="keywordflow">if</font>( !CLandscapeGlobals::CurrentTileVBAllocator->reallocationOccurs() )
01608 <a class="code" href="classNL3D_1_1CPatch.html#c11">fillTileVertexVB</a>(pVert);
01609 }
01610 }
01611
01612
01613 <font class="comment">// ***************************************************************************</font>
<a name="l01614"></a><a class="code" href="classNL3D_1_1CPatch.html#c29">01614</a> <font class="keywordtype">void</font> CPatch::checkDeleteVertexVBFar(CTessFarVertex *pVert)
01615 {
01616 <a class="code" href="debug_8h.html#a6">nlassert</a>(pVert);
01617 <font class="comment">// If visible, and Far0 in !Tile Mode, ok, the vertex exist in VB, so delete.</font>
01618 <font class="comment">// NB: must test Far0>0 because vertices are deleted in preRender() if a change of Far occurs.</font>
01619 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a> && <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0 && pVert->OwnerBlock->visibleFar0() )
01620 {
01621 CLandscapeGlobals::CurrentFar0VBAllocator->deleteVertex(pVert->Index0);
01622 }
01623
01624 <font class="comment">// Idem for Far1</font>
01625 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a> && <a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0 && pVert->OwnerBlock->visibleFar1() )
01626 {
01627 CLandscapeGlobals::CurrentFar1VBAllocator->deleteVertex(pVert->Index1);
01628 }
01629 }
01630
01631 <font class="comment">// ***************************************************************************</font>
<a name="l01632"></a><a class="code" href="classNL3D_1_1CPatch.html#c30">01632</a> <font class="keywordtype">void</font> CPatch::checkDeleteVertexVBNear(CTessNearVertex *pVert)
01633 {
01634 <a class="code" href="debug_8h.html#a6">nlassert</a>(pVert);
01635 <font class="comment">// If visible, and Far0 in Tile Mode, ok, the vertex exist in VB, so delete.</font>
01636 <font class="comment">// NB: must test Far0==0 because vertices are deleted in preRender() if a change of Far occurs.</font>
01637 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a> && <a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>==0 && pVert->OwnerBlock->visibleTile() )
01638 {
01639 CLandscapeGlobals::CurrentTileVBAllocator->deleteVertex(pVert->Index);
01640 }
01641 }
01642
01643
01644 <font class="comment">// ***************************************************************************</font>
01645 <font class="comment">// ***************************************************************************</font>
01646 <font class="comment">// VB DLM Filling</font>
01647 <font class="comment">// ***************************************************************************</font>
01648 <font class="comment">// ***************************************************************************</font>
01649
01650
01651 <font class="comment">// ***************************************************************************</font>
<a name="l01652"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_9">01652</a> <font class="keywordtype">void</font> CPatch::fillFar0DLMUvOnlyVertexListVB(CTessList<CTessFarVertex> &vertList)
01653 {
01654 <font class="comment">// The Buffers must have been locked</font>
01655 <a class="code" href="debug_8h.html#a6">nlassert</a>(CLandscapeGlobals::CurrentFar0VBAllocator);
01656 <a class="code" href="debug_8h.html#a6">nlassert</a>(CLandscapeGlobals::CurrentFar0VBAllocator->bufferLocked());
01657 <font class="comment">// VBInfo must be OK.</font>
01658 <a class="code" href="debug_8h.html#a6">nlassert</a>(!CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs());
01659
01660 <font class="keyword">static</font> uint8 *CurVBPtr;
01661 <font class="keyword">static</font> CUV uvDLM;
01662
01663 <font class="comment">// If the DLMContext exist</font>
01664 <font class="keywordflow">if</font>(_DLMContext)
01665 {
01666 <font class="comment">// Traverse the vertList, to compute new uvDLM</font>
01667 CTessFarVertex *pVert;
01668 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
01669 {
01670 <font class="comment">// Compute/build the new vertex.</font>
01671 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar0VBInfo.VertexCoordPointer;
01672 CurVBPtr+= pVert->Index0 * CLandscapeGlobals::CurrentFar0VBInfo.VertexSize;
01673
01674 <font class="comment">// compute Uvs.</font>
01675 CParamCoord pc= pVert->PCoord;
01676
01677 <font class="comment">// compute Dynamic lightmap Uv with DLM context info.</font>
01678 uvDLM.U= pc.getS()* <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMUScale + <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMUBias;
01679 uvDLM.V= pc.getT()* <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMVScale + <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMVBias;
01680
01681 <font class="comment">// Set Uv DLM only (NB: same code for VertexProgram or not, only TexCoordOff1 may change).</font>
01682 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff1)= uvDLM;
01683 }
01684 }
01685 <font class="comment">// else, reset all Uvs</font>
01686 <font class="keywordflow">else</font>
01687 {
01688 <font class="comment">// just set UV so the vertex point to a black pixel (see CTextureDLM).</font>
01689 uvDLM.U= 1;
01690 uvDLM.V= 1;
01691
01692 <font class="comment">// Traverse the vertList, to reset uv</font>
01693 CTessFarVertex *pVert;
01694 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
01695 {
01696 <font class="comment">// Compute/build the new vertex.</font>
01697 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar0VBInfo.VertexCoordPointer;
01698 CurVBPtr+= pVert->Index0 * CLandscapeGlobals::CurrentFar0VBInfo.VertexSize;
01699
01700 <font class="comment">// Set Uv DLM only (NB: same code for VertexProgram or not, only TexCoordOff1 may change).</font>
01701 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff1)= uvDLM;
01702 }
01703 }
01704 }
01705
01706 <font class="comment">// ***************************************************************************</font>
<a name="l01707"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_10">01707</a> <font class="keywordtype">void</font> CPatch::fillFar1DLMUvOnlyVertexListVB(CTessList<CTessFarVertex> &vertList)
01708 {
01709 <font class="comment">// The Buffers must have been locked</font>
01710 <a class="code" href="debug_8h.html#a6">nlassert</a>(CLandscapeGlobals::CurrentFar1VBAllocator);
01711 <a class="code" href="debug_8h.html#a6">nlassert</a>(CLandscapeGlobals::CurrentFar1VBAllocator->bufferLocked());
01712 <font class="comment">// VBInfo must be OK.</font>
01713 <a class="code" href="debug_8h.html#a6">nlassert</a>(!CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs());
01714
01715 <font class="keyword">static</font> uint8 *CurVBPtr;
01716 <font class="keyword">static</font> CUV uvDLM;
01717
01718 <font class="comment">// If the DLMContext exist</font>
01719 <font class="keywordflow">if</font>(_DLMContext)
01720 {
01721 <font class="comment">// Traverse the vertList, to compute new uvDLM</font>
01722 CTessFarVertex *pVert;
01723 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
01724 {
01725 <font class="comment">// Compute/build the new vertex.</font>
01726 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar1VBInfo.VertexCoordPointer;
01727 CurVBPtr+= pVert->Index1 * CLandscapeGlobals::CurrentFar1VBInfo.VertexSize;
01728
01729 <font class="comment">// compute Uvs.</font>
01730 CParamCoord pc= pVert->PCoord;
01731
01732 <font class="comment">// compute Dynamic lightmap Uv with DLM context info.</font>
01733 uvDLM.U= pc.getS()* <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMUScale + <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMUBias;
01734 uvDLM.V= pc.getT()* <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMVScale + <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>->DLMVBias;
01735
01736 <font class="comment">// Set Uv DLM only (NB: same code for VertexProgram or not, only TexCoordOff1 may change).</font>
01737 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff1)= uvDLM;
01738 }
01739 }
01740 <font class="comment">// else, reset all Uvs</font>
01741 <font class="keywordflow">else</font>
01742 {
01743 <font class="comment">// just set UV so the vertex point to a black pixel (see CTextureDLM).</font>
01744 uvDLM.U= 1;
01745 uvDLM.V= 1;
01746
01747 <font class="comment">// Traverse the vertList, to reset uv</font>
01748 CTessFarVertex *pVert;
01749 <font class="keywordflow">for</font>(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
01750 {
01751 <font class="comment">// Compute/build the new vertex.</font>
01752 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar1VBInfo.VertexCoordPointer;
01753 CurVBPtr+= pVert->Index1 * CLandscapeGlobals::CurrentFar1VBInfo.VertexSize;
01754
01755 <font class="comment">// Set Uv DLM only (NB: same code for VertexProgram or not, only TexCoordOff1 may change).</font>
01756 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff1)= uvDLM;
01757 }
01758 }
01759 }
01760
01761
01762 <font class="comment">// ***************************************************************************</font>
<a name="l01763"></a><a class="code" href="classNL3D_1_1CPatch.html#z673_8">01763</a> <font class="keywordtype">void</font> CPatch::fillVBFarsDLMUvOnly()
01764 {
01765 <font class="comment">// Do it for Far0.</font>
01766 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o14">Far0</a>>0 && !CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs() )
01767 {
01768 <font class="comment">// Fill Far0 VB.</font>
01769 <a class="code" href="classNL3D_1_1CPatch.html#z673_9">fillFar0DLMUvOnlyVertexListVB</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList);
01770 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
01771 {
01772 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01773 <font class="comment">// fill only if tblock visible.</font>
01774 <font class="keywordflow">if</font>( tblock.visibleFar0() )
01775 <a class="code" href="classNL3D_1_1CPatch.html#z673_9">fillFar0DLMUvOnlyVertexListVB</a>(tblock.FarVertexList);
01776 }
01777 }
01778
01779 <font class="comment">// Do it for Far1.</font>
01780 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#o15">Far1</a>>0 && !CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs() )
01781 {
01782 <font class="comment">// Fill VB.</font>
01783 <a class="code" href="classNL3D_1_1CPatch.html#z673_10">fillFar1DLMUvOnlyVertexListVB</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_0">MasterBlock</a>.FarVertexList);
01784 <font class="keywordflow">for</font>(sint i=0; i<(sint)<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size(); i++)
01785 {
01786 CTessBlock &tblock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[i];
01787 <font class="comment">// fill only if tblock visible.</font>
01788 <font class="keywordflow">if</font>( tblock.visibleFar1() )
01789 <a class="code" href="classNL3D_1_1CPatch.html#z673_10">fillFar1DLMUvOnlyVertexListVB</a>(tblock.FarVertexList);
01790 }
01791 }
01792 }
01793
01794
01795
01796 } <font class="comment">// NL3D</font>
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|