aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/zone__symmetrisation_8cpp-source.html
blob: 3137e52fa411996974df789cfb4ef4e4f90ae0b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
	<TITLE>nevrax.org : docs</TITLE>
	<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
	<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">

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

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

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

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

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

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

<!-- block -->
<TABLE  bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>zone_symmetrisation.cpp</h1><a href="zone__symmetrisation_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2000-2002 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 <font class="preprocessor">#include "<a class="code" href="zone__symmetrisation_8h.html">3d/zone_symmetrisation.h</a>"</font>
00028 <font class="preprocessor">#include "<a class="code" href="src_23d_2zone_8h.html">3d/zone.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="tile__bank_8h.html">3d/tile_bank.h</a>"</font>
00030 
00031 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00032 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00033 
00034 <font class="keyword">namespace </font>NL3D 
00035 {
00036 
00037 <font class="comment">// ***************************************************************************</font>
00038 
<a name="l00039"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a0">00039</a> CZoneSymmetrisation::CZoneSymmetrisation()
00040 {
00041 }
00042 
00043 <font class="comment">// ***************************************************************************</font>
00044 
00045 <font class="comment">/*</font>
00046 <font class="comment">Bit field</font>
00047 <font class="comment">        1-0 : state layer 0</font>
00048 <font class="comment">        3-2 : state layer 1</font>
00049 <font class="comment">        5-4 : state layer 2</font>
00050 <font class="comment">        7-6 : border state</font>
00051 <font class="comment">        9-8 : oriented border state</font>
00052 <font class="comment">        10  : corner flag</font>
00053 <font class="comment">*/</font>
00054 
00055 <font class="comment">// ***************************************************************************</font>
00056 
<a name="l00057"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a1">00057</a> CZoneSymmetrisation::TState CZoneSymmetrisation::getTileState (uint patch, uint tile, uint layer)<font class="keyword"> const</font>
00058 <font class="keyword"></font>{
00059         <a class="code" href="debug_8h.html#a6">nlassert</a> (layer&lt;5);
00060         <font class="keywordflow">return</font> (TState)((<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#o0">_TilesLayerStates</a>[patch][tile]&gt;&gt;(layer*2))&amp;0x3);
00061 }
00062 
00063 <font class="comment">// ***************************************************************************</font>
00064 
<a name="l00065"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a2">00065</a> CZoneSymmetrisation::TState CZoneSymmetrisation::getTileBorderState (uint patch, uint tile)<font class="keyword"> const</font>
00066 <font class="keyword"></font>{
00067         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a1">getTileState</a> (patch, tile, 3);
00068 }
00069 
00070 <font class="comment">// ***************************************************************************</font>
00071 
<a name="l00072"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a3">00072</a> CZoneSymmetrisation::TState CZoneSymmetrisation::getOrientedTileBorderState (uint patch, uint tile)<font class="keyword"> const</font>
00073 <font class="keyword"></font>{
00074         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a1">getTileState</a> (patch, tile, 4);
00075 }
00076 
00077 <font class="comment">// ***************************************************************************</font>
00078 
<a name="l00079"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a4">00079</a> <font class="keywordtype">bool</font> CZoneSymmetrisation::getOrientedTileCorner (uint patch, uint tile)
00080 {
00081         <font class="keywordflow">return</font> ( ( <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#o0">_TilesLayerStates</a>[patch][tile] &gt;&gt; 10 ) &amp; 1 ) != 0;
00082 }
00083 
00084 <font class="comment">// ***************************************************************************</font>
00085 
<a name="l00086"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c1">00086</a> <font class="keywordtype">void</font> CZoneSymmetrisation::setTileState (uint patch, uint tile, uint layer, TState state)
00087 {
00088         uint16 &amp;ref = <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#o0">_TilesLayerStates</a>[patch][tile];
00089         ref &amp;= ~(3&lt;&lt;(layer*2));
00090         ref |= ((uint16)state)&lt;&lt;(layer*2);
00091 }
00092 
00093 <font class="comment">// ***************************************************************************</font>
00094 
<a name="l00095"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c2">00095</a> <font class="keywordtype">void</font> CZoneSymmetrisation::setTileBorderState (uint patch, uint tile, TState state)
00096 {
00097         <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c1">setTileState</a> (patch, tile, 3, state);
00098 }
00099 
00100 <font class="comment">// ***************************************************************************</font>
00101 
<a name="l00102"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c3">00102</a> <font class="keywordtype">void</font> CZoneSymmetrisation::setOrientedTileBorderState (uint patch, uint tile, TState state)
00103 {
00104         <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c1">setTileState</a> (patch, tile, 4, state);
00105 }
00106 
00107 <font class="comment">// ***************************************************************************</font>
00108 
<a name="l00109"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c4">00109</a> <font class="keywordtype">void</font> CZoneSymmetrisation::setOrientedTileCorner (uint patch, uint tile, <font class="keywordtype">bool</font> corner)
00110 {
00111         uint16 &amp;ref = <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#o0">_TilesLayerStates</a>[patch][tile];
00112         ref &amp;= ~(1&lt;&lt;10);
00113         ref |= ((uint16)corner)&lt;&lt;(10);
00114 }
00115 
00116 <font class="comment">// ***************************************************************************</font>
00117 
00118 <font class="comment">/*</font>
00119 <font class="comment"></font>
00120 <font class="comment">REMARKS:</font>
00121 <font class="comment">- I call "isotile" the set of connected tiles in the zone using the same tileset and a continus rotation value.</font>
00122 <font class="comment"></font>
00123 <font class="comment">This method determines the state of each tile in the zone. This state will be used to transform</font>
00124 <font class="comment">the tile during symmetrisation of the zone.</font>
00125 <font class="comment"></font>
00126 <font class="comment">The state can be Regular, Goofy or Nothing.</font>
00127 <font class="comment"></font>
00128 <font class="comment">If the state is Nothing, this tile is in an "isotile" that is not connected to a zone border. No matter the method</font>
00129 <font class="comment">you use to tranform it, it will not influence the neighbor zones.</font>
00130 <font class="comment"></font>
00131 <font class="comment">If the state is Regular, the rotation of this tile after symmetrisation will by given by this formula : tilerot = (4-tilerot)&amp;3</font>
00132 <font class="comment">If the state is Goofy, the rotation of this tile after symmetrisation will by given by this formula : tilerot = (4-tilerot+2)&amp;3</font>
00133 <font class="comment"></font>
00134 <font class="comment">- Getting the state of the tile:</font>
00135 <font class="comment">        - A) We flag all the zone patches as Nothing.</font>
00136 <font class="comment">        - B) We need to select patches having an open edge on the zone border. To do so, we use the snapCell and weldThreshold</font>
00137 <font class="comment">        parameters.</font>
00138 <font class="comment">        - C) Then, for each patches on the zone border, we need to know if they are Goofy or Regular.</font>
00139 <font class="comment"></font>
00140 <font class="comment">                Y</font>
00141 <font class="comment">  </font>
00142 <font class="comment">                /\</font>
00143 <font class="comment">                | </font>
00144 <font class="comment">                |  0     3</font>
00145 <font class="comment">                |   *****</font>
00146 <font class="comment">                |   *   *   This patch is regular</font>
00147 <font class="comment">                |   *   *</font>
00148 <font class="comment">                |   *****</font>
00149 <font class="comment">                |  1     2</font>
00150 <font class="comment">                | </font>
00151 <font class="comment">                |  2     1</font>
00152 <font class="comment">                |   *****</font>
00153 <font class="comment">                |   *   *   This patch is regular</font>
00154 <font class="comment">                |   *   *</font>
00155 <font class="comment">                |   *****</font>
00156 <font class="comment">                |  3     0</font>
00157 <font class="comment">                | </font>
00158 <font class="comment">                |  3     2</font>
00159 <font class="comment">                |   *****</font>
00160 <font class="comment">                |   *   *   This patch is goofy</font>
00161 <font class="comment">                |   *   *</font>
00162 <font class="comment">                |   *****</font>
00163 <font class="comment">                |  0     1</font>
00164 <font class="comment">                | </font>
00165 <font class="comment">                |  1     4</font>
00166 <font class="comment">                |   *****</font>
00167 <font class="comment">                |   *   *   This patch is goofy</font>
00168 <font class="comment">                |   *   *</font>
00169 <font class="comment">                |   *****</font>
00170 <font class="comment">                |  2     3</font>
00171 <font class="comment">                -----------------------------------------&gt; X</font>
00172 <font class="comment"></font>
00173 <font class="comment">        - D) We flag each tiles as Nothing</font>
00174 <font class="comment">        - E) We flag each tile on an opened edge using this formula:</font>
00175 <font class="comment">                - If the patch is not Nothing do</font>
00176 <font class="comment">                        - tileIsGoofy = (patchIsGoofy) XOR ((tileRotation&amp;1) != 0)</font>
00177 <font class="comment">        - F) Then, we propagate the tile A flag across the tiles in the zone following this rules:</font>
00178 <font class="comment">                - If A is not Nothing do</font>
00179 <font class="comment">                        - For each neighbor B of A do</font>
00180 <font class="comment">                                - If B is different from A do</font>
00181 <font class="comment">                                        - If A is Regular (res Goofy), and B is Nothing, B will be Regular (res Goofy)</font>
00182 <font class="comment">                                        - If A is Regular (res Goofy), and B is Goofy (res Regular), -&gt; Error</font>
00183 <font class="comment">                                        - Propagate B</font>
00184 <font class="comment">*/</font>
00185 
<a name="l00186"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a5">00186</a> <font class="keywordtype">bool</font> CZoneSymmetrisation::build (<font class="keyword">const</font> std::vector&lt;CPatchInfo&gt; &amp;patchInfo, <font class="keywordtype">float</font> snapCell, <font class="keywordtype">float</font> weldThreshold, <font class="keyword">const</font> CTileBank &amp;bank, CError &amp;errorDesc, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> &amp;toOriginalSpace)
00187 {
00188         <font class="comment">// * Clear errors</font>
00189         errorDesc.Errors.clear ();
00190 
00191         <font class="comment">// * Build the patches state</font>
00192         
00193         <font class="comment">// A) Resize arrays</font>
00194         <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#o0">_TilesLayerStates</a>.resize (patchInfo.size ());
00195 
00196         <font class="comment">// D) Resize the tile array</font>
00197         uint i;
00198         <font class="keywordflow">for</font> (i=0; i&lt;patchInfo.size (); i++)
00199         {
00200                 <font class="comment">// Ref on the patch</font>
00201                 <font class="keyword">const</font> CPatchInfo &amp;patch = patchInfo[i];
00202                 <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#o0">_TilesLayerStates</a>[i].resize (0);
00203                 <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#o0">_TilesLayerStates</a>[i].resize (patch.OrderS * patch.OrderT, 0);
00204         }
00205 
00206         <font class="comment">// B), C) and E) We need to select patches having an open edge on the zone border. To do so, we use the snapCell and weldThreshold parameters</font>
00207         <font class="keywordflow">for</font> (i=0; i&lt;patchInfo.size (); i++)
00208         {
00209                 <font class="comment">// Ref on the patch</font>
00210                 <font class="keyword">const</font> CPatchInfo &amp;patch = patchInfo[i];
00211 
00212                 <font class="comment">// Does this patch is over a border ?</font>
00213                 <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3">TState</a> patchState;
00214                 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c1">setTileState</a> (patch, i, snapCell, weldThreshold, patchState, toOriginalSpace, bank))
00215                 {
00216                         <font class="comment">// Push an error</font>
00217                         errorDesc.Errors.push_back (<font class="stringliteral">"Patch n�"</font>+toString (i)+<font class="stringliteral">" is invalid"</font>);
00218                 }
00219 
00220                 <font class="comment">// Set the oriented patch state</font>
00221                 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c6">setOrientedTileState</a> (patch, i, snapCell, weldThreshold, patchState, toOriginalSpace, bank))
00222                 {
00223                         <font class="comment">// Push an error</font>
00224                         errorDesc.Errors.push_back (<font class="stringliteral">"Patch n�"</font>+toString (i)+<font class="stringliteral">" is invalid"</font>);
00225                 }
00226         }
00227 
00228         <font class="comment">// F) We flag each tile on an opened edge using this formula</font>
00229         <font class="comment">//      - If the patch is not Nothing do</font>
00230         <font class="comment">//              - tileIsGoofy = (patchIsGoofy) XOR ((tileRotation&amp;1) != 0)</font>
00231         <font class="keywordflow">for</font> (i=0; i&lt;patchInfo.size (); i++)
00232         {
00233                 <font class="comment">// Ref on the patch</font>
00234                 <font class="keyword">const</font> CPatchInfo &amp;patch = patchInfo[i];
00235 
00236                 <font class="comment">// For each tile</font>
00237                 uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
00238                 <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>&lt;patch.OrderT; <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>++)
00239                 {
00240                         <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;patch.OrderS; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>++)
00241                         {
00242                                 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c0">propagateTileState</a> (i, <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, patchInfo, bank, <font class="keyword">false</font>))
00243                                 {
00244                                         <font class="comment">// Push an error</font>
00245                                         errorDesc.Errors.push_back (<font class="stringliteral">"Error during propagation. Topology invalid."</font>);
00246                                         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00247                                 }
00248                         }
00249                 }
00250         }
00251 
00252         <font class="comment">// G) Force all remaining Nothing tiles to Regular</font>
00253         <font class="keywordflow">for</font> (i=0; i&lt;patchInfo.size (); i++)
00254         {
00255                 <font class="comment">// Ref on the patch</font>
00256                 <font class="keyword">const</font> CPatchInfo &amp;patch = patchInfo[i];
00257 
00258                 <font class="comment">// For each tile</font>
00259                 uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
00260                 <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>&lt;patch.OrderT; <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>++)
00261                 {
00262                         <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;patch.OrderS; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>++)
00263                         {
00264                                 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c0">propagateTileState</a> (i, <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, patchInfo, bank, <font class="keyword">true</font>))
00265                                 {
00266                                         <font class="comment">// Push an error</font>
00267                                         errorDesc.Errors.push_back (<font class="stringliteral">"Error during propagation. Topology invalid."</font>);
00268                                         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00269                                 }
00270                         }
00271                 }
00272         }
00273 
00274         <font class="comment">// Returns true if no error</font>
00275         <font class="keywordflow">return</font> errorDesc.Errors.size () == 0;
00276 }
00277 
00278 <font class="comment">// ***************************************************************************</font>
00279 
<a name="l00280"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#f0">00280</a> <font class="keywordtype">bool</font> CZoneSymmetrisation::snapOnGrid (<font class="keywordtype">float</font>&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, <font class="keywordtype">float</font> resolution, <font class="keywordtype">float</font> snap)
00281 {
00282         <font class="comment">// Calc the floor</font>
00283         <font class="keywordtype">float</font> _floor = (float) ( resolution * floor (<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> / resolution) );
00284         <a class="code" href="debug_8h.html#a6">nlassert</a> (_floor&lt;=<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>);
00285 
00286         <font class="comment">// Calc the remainder</font>
00287         <font class="keywordtype">float</font> remainder = <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> - _floor;
00288         <font class="comment">//nlassert ( (remainder&gt;=0) &amp;&amp; (remainder&lt;resolution) );</font>
00289 
00290         <font class="comment">// Check the snape</font>
00291         <font class="keywordflow">if</font> ( remainder &lt;= snap )
00292         {
00293                 <font class="comment">// Flag it</font>
00294                 <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> = _floor;
00295 
00296                 <font class="comment">// Floor is good</font>
00297                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00298         }
00299         <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( (resolution - remainder) &lt;= snap )
00300         {
00301                 <font class="comment">// Flag it</font>
00302                 <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> = _floor + resolution;
00303 
00304                 <font class="comment">// Floor + resolution is good</font>
00305                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00306         }
00307         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00308 }
00309 
00310 <font class="comment">// ***************************************************************************</font>
00311 
<a name="l00312"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c5">00312</a> <font class="keywordtype">bool</font> CZoneSymmetrisation::setTileState (<font class="keyword">const</font> <a class="code" href="structNL3D_1_1CPatchInfo.html">NL3D::CPatchInfo</a> &amp;patch, uint patchId, <font class="keywordtype">float</font> snapCell, <font class="keywordtype">float</font> weldThreshold, TState &amp;state, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> &amp;toOriginalSpace, <font class="keyword">const</font> CTileBank &amp;bank)
00313 {
00314         <font class="comment">// Edges state</font>
00315         <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3">TState</a> edgesState[4] = { <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a>, <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a>, <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a>, <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a> };
00316 
00317         <font class="comment">// Vertices position</font>
00318         sint32 vertPosU[4];
00319         sint32 vertPosV[4];
00320         
00321         <font class="comment">// For each vertices</font>
00322         uint i;
00323         <font class="keywordflow">for</font> (i=0; i&lt;4; i++)
00324         {
00325                 <font class="comment">// Snap the vertex</font>
00326                 CVector original = toOriginalSpace * patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_2">Patch</a>.Vertices[i];
00327                 <font class="keywordtype">float</font> valueU = original.x;
00328                 <font class="keywordtype">float</font> valueV = original.y;
00329 
00330                 <font class="comment">// Snap on U</font>
00331                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#f0">snapOnGrid</a> (valueU, snapCell, weldThreshold))
00332                         vertPosU[i] = (sint32)((valueU+0.5f) / snapCell);
00333                 <font class="keywordflow">else</font>
00334                         vertPosU[i] = 0x80000000;
00335 
00336                 <font class="comment">// Snap on V</font>
00337                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#f0">snapOnGrid</a> (valueV, snapCell, weldThreshold))
00338                         vertPosV[i] = (sint32)((valueV+0.5f) / snapCell);
00339                 <font class="keywordflow">else</font>
00340                         vertPosV[i] = 0x80000000;
00341         }
00342 
00343         <font class="comment">// Patch flags</font>
00344         <font class="keywordtype">bool</font> regular = <font class="keyword">false</font>;
00345         <font class="keywordtype">bool</font> goofy = <font class="keyword">false</font>;
00346         <font class="keywordtype">bool</font> EdgeSnaped[4] = { <font class="keyword">false</font>, <font class="keyword">false</font>, <font class="keyword">false</font>, <font class="keyword">false</font> };
00347 
00348         <font class="comment">// For each edges</font>
00349         <font class="keywordflow">for</font> (i=0; i&lt;4; i++)
00350         {
00351                 <font class="comment">// Vertex snapped and align on a common axis ?</font>
00352                 <font class="keywordflow">if</font> ( (vertPosU[i] != 0x80000000) || (vertPosV[i] != 0x80000000) )
00353                 {
00354                         <font class="comment">// Snapped on U or V ?</font>
00355                         <font class="keywordtype">bool</font> snapU = (vertPosU[i] == vertPosU[(i+1)&amp;3]) &amp;&amp; (vertPosU[i] != 0x80000000);
00356                         <font class="keywordtype">bool</font> snapV = (vertPosV[i] == vertPosV[(i+1)&amp;3]) &amp;&amp; (vertPosV[i] != 0x80000000);
00357                         
00358                         <font class="comment">// If snapped on one, continue</font>
00359                         <font class="keywordflow">if</font> (snapU || snapV)
00360                         {
00361                                 <font class="comment">// If snap on the both, error</font>
00362                                 <font class="keywordflow">if</font> (snapU &amp;&amp; snapV)
00363                                         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00364 
00365                                 <font class="comment">// Is this edge Regular or Goofy ?</font>
00366                                 <font class="keywordflow">if</font> (snapU)
00367                                         edgesState[i] = (i&amp;1)?<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s2">Goofy</a>:<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s1">Regular</a>;
00368                                 <font class="keywordflow">else</font> <font class="comment">// (snapV)</font>
00369                                         edgesState[i] = (i&amp;1)?<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s1">Regular</a>:<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s2">Goofy</a>;
00370 
00371                                 <font class="comment">// Flag the patch</font>
00372                                 <font class="keywordflow">if</font> (edgesState[i] == <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s1">Regular</a>)
00373                                         regular = <font class="keyword">true</font>;
00374                                 <font class="keywordflow">else</font>
00375                                         goofy = <font class="keyword">true</font>;
00376 
00377                                 <font class="comment">// Edge snaped</font>
00378                                 EdgeSnaped[i] = <font class="keyword">true</font>;
00379                         }
00380                 }
00381         }
00382 
00383         <font class="comment">// Goofy and regular ? Error</font>
00384         <font class="keywordflow">if</font> (goofy &amp;&amp; regular)
00385                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00386 
00387         <font class="comment">// Nothing ?</font>
00388         <font class="keywordflow">if</font> ((!goofy) &amp;&amp; (!regular))
00389                 state = <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a>;
00390         <font class="keywordflow">else</font>
00391         {
00392                 <font class="comment">// Not nothing ?</font>
00393                 state = regular?<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s1">Regular</a>:<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s2">Goofy</a>;
00394 
00395                 <font class="comment">// * Set the tiles</font>
00396 
00397                 <font class="comment">// For each edges</font>
00398                 <font class="keywordflow">for</font> (i=0; i&lt;4; i++)
00399                 {
00400                         <font class="comment">// Edge snapped ?</font>
00401                         <font class="keywordflow">if</font> (EdgeSnaped[i])
00402                         {
00403                                 <font class="comment">// For each tiles</font>
00404                                 uint tileCount = ((i&amp;1)!=0)?patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>:patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_4">OrderT</a>;
00405                                 sint currentTile;
00406                                 sint delta;
00407                                 <font class="keywordflow">switch</font> (i)
00408                                 {
00409                                 <font class="keywordflow">case</font> 0:
00410                                         currentTile = 0;
00411                                         delta = patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>;
00412                                         <font class="keywordflow">break</font>;
00413                                 <font class="keywordflow">case</font> 1:
00414                                         currentTile = patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>*(patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_4">OrderT</a>-1);
00415                                         delta = 1;
00416                                         <font class="keywordflow">break</font>;
00417                                 <font class="keywordflow">case</font> 2:
00418                                         currentTile = patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>-1;
00419                                         delta = patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>;
00420                                         <font class="keywordflow">break</font>;
00421                                 <font class="keywordflow">case</font> 3:
00422                                         currentTile = 0;
00423                                         delta = 1;
00424                                         <font class="keywordflow">break</font>;
00425                                 }
00426                                 uint j;
00427                                 <font class="keywordflow">for</font> (j=0; j&lt;tileCount; j++)
00428                                 {
00429                                         <font class="comment">// Set the border state</font>
00430                                         <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c2">setTileBorderState</a> (patchId, currentTile, state);
00431 
00432                                         <font class="comment">// For each layer</font>
00433                                         uint layer;
00434                                         <font class="keywordflow">for</font> (layer=0; layer&lt;3; layer++)
00435                                         {
00436                                                 <font class="comment">// Get the tiles set used here</font>
00437                                                 uint tile = patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z920_0">Tiles</a>[currentTile].Tile[layer];
00438                                                 <font class="keywordflow">if</font> (tile != <a class="code" href="tile__element_8h.html#a12">NL_TILE_ELM_LAYER_EMPTY</a>)
00439                                                 {
00440                                                         <font class="keywordtype">int</font> tileSet;
00441                                                         <font class="keywordtype">int</font> number;
00442                                                         CTileBank::TTileType <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>;
00443                                                         bank.getTileXRef (tile, tileSet, number, <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>);
00444 
00445                                                         <font class="comment">// Set it only if not oriented</font>
00446                                                         <font class="keywordflow">if</font> (!bank.getTileSet (tileSet)-&gt;getOriented ())
00447                                                         {
00448                                                                 <font class="comment">// Set the tile state</font>
00449                                                                 <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c1">setTileState</a> (patchId, currentTile, layer, state);
00450                                                         }
00451                                                 }
00452                                         }
00453 
00454                                         <font class="comment">// Next tile</font>
00455                                         currentTile += delta;
00456                                 }
00457                         }
00458                 }
00459         }
00460 
00461         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00462 }
00463 
00464 <font class="comment">// ***************************************************************************</font>
00465 
<a name="l00466"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c6">00466</a> <font class="keywordtype">bool</font> CZoneSymmetrisation::setOrientedTileState (<font class="keyword">const</font> <a class="code" href="structNL3D_1_1CPatchInfo.html">NL3D::CPatchInfo</a> &amp;patch, uint patchId, <font class="keywordtype">float</font> snapCell, <font class="keywordtype">float</font> weldThreshold, TState &amp;state, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> &amp;toOriginalSpace, <font class="keyword">const</font> CTileBank &amp;bank)
00467 {
00468         <font class="comment">// Edges state</font>
00469         <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3">TState</a> edgesState[4] = { <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a>, <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a>, <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a>, <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a> };
00470 
00471         <font class="comment">// Vertices position</font>
00472         sint32 vertPosU[4];
00473         sint32 vertPosV[4];
00474         
00475         <font class="comment">// For each vertices</font>
00476         uint i;
00477         <font class="keywordflow">for</font> (i=0; i&lt;4; i++)
00478         {
00479                 <font class="comment">// Snap the vertex</font>
00480                 CVector original = toOriginalSpace * patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_2">Patch</a>.Vertices[i];
00481                 <font class="keywordtype">float</font> valueU = original.x;
00482                 <font class="keywordtype">float</font> valueV = original.y;
00483 
00484                 <font class="comment">// Snap on U</font>
00485                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#f0">snapOnGrid</a> (valueU, snapCell, weldThreshold))
00486                         vertPosU[i] = (sint32)((valueU+0.5f) / snapCell);
00487                 <font class="keywordflow">else</font>
00488                         vertPosU[i] = 0x80000000;
00489 
00490                 <font class="comment">// Snap on V</font>
00491                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#f0">snapOnGrid</a> (valueV, snapCell, weldThreshold))
00492                         vertPosV[i] = (sint32)((valueV+0.5f) / snapCell);
00493                 <font class="keywordflow">else</font>
00494                         vertPosV[i] = 0x80000000;
00495         }
00496 
00497         <font class="comment">// Patch flags</font>
00498         <font class="keywordtype">bool</font> regular = <font class="keyword">false</font>;
00499         <font class="keywordtype">bool</font> goofy = <font class="keyword">false</font>;
00500         <font class="keywordtype">bool</font> EdgeSnaped[4] = { <font class="keyword">false</font>, <font class="keyword">false</font>, <font class="keyword">false</font>, <font class="keyword">false</font> };
00501 
00502         <font class="comment">// For each edges</font>
00503         <font class="keywordflow">for</font> (i=0; i&lt;4; i++)
00504         {
00505                 <font class="comment">// Vertex snapped and align on a common axis ?</font>
00506                 <font class="keywordflow">if</font> ( (vertPosU[i] != 0x80000000) || (vertPosV[i] != 0x80000000) )
00507                 {
00508                         <font class="comment">// Snapped on U or V ?</font>
00509                         <font class="keywordtype">bool</font> snapU = (vertPosU[i] == vertPosU[(i+1)&amp;3]) &amp;&amp; (vertPosU[i] != 0x80000000);
00510                         <font class="keywordtype">bool</font> snapV = (vertPosV[i] == vertPosV[(i+1)&amp;3]) &amp;&amp; (vertPosV[i] != 0x80000000);
00511                         
00512                         <font class="comment">// If snapped on one, continue</font>
00513                         <font class="keywordflow">if</font> (snapU || snapV)
00514                         {
00515                                 <font class="comment">// If snap on the both, error</font>
00516                                 <font class="keywordflow">if</font> (snapU &amp;&amp; snapV)
00517                                         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00518 
00519                                 <font class="comment">// Is this edge Regular or Goofy ?</font>
00520                                 edgesState[i] = (i&amp;1)?<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s2">Goofy</a>:<a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s1">Regular</a>;
00521 
00522                                 <font class="comment">// Flag the patch</font>
00523                                 <font class="keywordflow">if</font> (edgesState[i] == <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s1">Regular</a>)
00524                                         regular = <font class="keyword">true</font>;
00525                                 <font class="keywordflow">else</font>
00526                                         goofy = <font class="keyword">true</font>;
00527 
00528                                 <font class="comment">// Edge snaped</font>
00529                                 EdgeSnaped[i] = <font class="keyword">true</font>;
00530                         }
00531                 }
00532         }
00533 
00534         <font class="comment">// * Set the tiles</font>
00535 
00536         <font class="comment">// For each edges</font>
00537         <font class="keywordflow">for</font> (i=0; i&lt;4; i++)
00538         {
00539                 <font class="comment">// Edge snapped ?</font>
00540                 <font class="keywordflow">if</font> (EdgeSnaped[i])
00541                 {
00542                         <font class="comment">// For each tiles</font>
00543                         uint tileCount = ((i&amp;1)!=0)?patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>:patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_4">OrderT</a>;
00544                         sint currentTile;
00545                         sint delta;
00546                         <font class="keywordflow">switch</font> (i)
00547                         {
00548                         <font class="keywordflow">case</font> 0:
00549                                 currentTile = 0;
00550                                 delta = patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>;
00551                                 <font class="keywordflow">break</font>;
00552                         <font class="keywordflow">case</font> 1:
00553                                 currentTile = patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>*(patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_4">OrderT</a>-1);
00554                                 delta = 1;
00555                                 <font class="keywordflow">break</font>;
00556                         <font class="keywordflow">case</font> 2:
00557                                 currentTile = patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>-1;
00558                                 delta = patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>;
00559                                 <font class="keywordflow">break</font>;
00560                         <font class="keywordflow">case</font> 3:
00561                                 currentTile = 0;
00562                                 delta = 1;
00563                                 <font class="keywordflow">break</font>;
00564                         }
00565                         uint j;
00566                         <font class="keywordflow">for</font> (j=0; j&lt;tileCount; j++)
00567                         {
00568                                 <font class="comment">// Set the border state</font>
00569                                 <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c3">setOrientedTileBorderState</a> (patchId, currentTile, edgesState[i]);
00570 
00571                                 <font class="comment">// For each layer</font>
00572                                 uint layer;
00573                                 <font class="keywordflow">for</font> (layer=0; layer&lt;3; layer++)
00574                                 {
00575                                         <font class="comment">// Get the tiles set used here</font>
00576                                         uint tile = patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z920_0">Tiles</a>[currentTile].Tile[layer];
00577                                         <font class="keywordflow">if</font> (tile != <a class="code" href="tile__element_8h.html#a12">NL_TILE_ELM_LAYER_EMPTY</a>)
00578                                         {
00579                                                 <font class="keywordtype">int</font> tileSet;
00580                                                 <font class="keywordtype">int</font> number;
00581                                                 CTileBank::TTileType <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>;
00582                                                 bank.getTileXRef (tile, tileSet, number, <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>);
00583 
00584                                                 <font class="comment">// Set it only if oriented</font>
00585                                                 <font class="keywordflow">if</font> (bank.getTileSet (tileSet)-&gt;getOriented ())
00586                                                 {
00587                                                         <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c1">setTileState</a> (patchId, currentTile, layer, edgesState[i]);
00588                                                 }
00589                                         }
00590                                 }
00591 
00592                                 <font class="comment">// Next tile</font>
00593                                 currentTile += delta;
00594                         }
00595                 }
00596         }
00597         
00598         <font class="comment">// For each corners</font>
00599         <font class="keywordflow">for</font> (i=0; i&lt;4; i++)
00600         {
00601                 <font class="comment">// Corner snapped ?</font>
00602                 uint next = (i+1)&amp;3;
00603                 <font class="keywordflow">if</font> (EdgeSnaped[i] &amp;&amp; EdgeSnaped[next])
00604                 {
00605                         <font class="comment">// Flag tile as corner</font>
00606                         <font class="keywordflow">switch</font> (i)
00607                         {
00608                         <font class="keywordflow">case</font> 0:
00609                                 <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c4">setOrientedTileCorner</a> (patchId, patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>*(patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_4">OrderT</a>-1), <font class="keyword">true</font>);
00610                                 <font class="keywordflow">break</font>;
00611                         <font class="keywordflow">case</font> 1:
00612                                 <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c4">setOrientedTileCorner</a> (patchId, patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>*patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_4">OrderT</a>-1, <font class="keyword">true</font>);
00613                                 <font class="keywordflow">break</font>;
00614                         <font class="keywordflow">case</font> 2:
00615                                 <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c4">setOrientedTileCorner</a> (patchId, patch.<a class="code" href="structNL3D_1_1CPatchInfo.html#z919_3">OrderS</a>-1, <font class="keyword">true</font>);
00616                                 <font class="keywordflow">break</font>;
00617                         <font class="keywordflow">case</font> 3:
00618                                 <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c4">setOrientedTileCorner</a> (patchId, 0, <font class="keyword">true</font>);
00619                                 <font class="keywordflow">break</font>;
00620                         }
00621                 }
00622         }
00623         
00624         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00625 }
00626 
00627 <font class="comment">// ***************************************************************************</font>
00628 
00629 CVector2f <a class="code" href="namespaceNL3D.html#a482">st2uv</a> (sint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, <font class="keyword">const</font> CPatchInfo &amp;patch)
00630 {
00631         <font class="keywordflow">return</font> CVector2f ((((<font class="keywordtype">float</font>)<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>)+0.5f)/(<font class="keywordtype">float</font>)patch.OrderS, (((<font class="keywordtype">float</font>)<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)+0.5f)/(<font class="keywordtype">float</font>)patch.OrderT);
00632 }
00633 
00634 <font class="comment">// ***************************************************************************</font>
00635 
00636 <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a483">uv2st</a> (<font class="keyword">const</font> CVector2f &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a404">in</a>, sint &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, sint &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, <font class="keyword">const</font> CPatchInfo &amp;patch)
00637 {
00638         <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> = (sint)(<a class="code" href="driver__opengl__extension__def_8h.html#a404">in</a>.x*(float)patch.OrderS);
00639         <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a> = (sint)(<a class="code" href="driver__opengl__extension__def_8h.html#a404">in</a>.y*(float)patch.OrderT);
00640 }
00641 
00642 <font class="comment">// ***************************************************************************</font>
00643 
<a name="l00644"></a><a class="code" href="classNL3D_1_1CFillStackNode.html">00644</a> <font class="keyword">class </font>CFillStackNode
00645 {
00646 <font class="keyword">public</font>:
<a name="l00647"></a><a class="code" href="classNL3D_1_1CFillStackNode.html#a0">00647</a>         <a class="code" href="classNL3D_1_1CFillStackNode.html#a0">CFillStackNode</a> (uint16 patch, uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, uint8 rotate, CZoneSymmetrisation::TState     state) { <a class="code" href="classNL3D_1_1CFillStackNode.html#m2">Patch</a> = patch; <a class="code" href="classNL3D_1_1CFillStackNode.html#m0">S</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; <a class="code" href="classNL3D_1_1CFillStackNode.html#m1">T</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>; <a class="code" href="classNL3D_1_1CFillStackNode.html#m3">Edge</a> = 0; <a class="code" href="classNL3D_1_1CFillStackNode.html#m4">Rotate</a> = rotate; <a class="code" href="classNL3D_1_1CFillStackNode.html#m5">State</a> = state; };
<a name="l00648"></a><a class="code" href="classNL3D_1_1CFillStackNode.html#m0">00648</a>         uint16  <a class="code" href="classNL3D_1_1CFillStackNode.html#m0">S</a>;
<a name="l00649"></a><a class="code" href="classNL3D_1_1CFillStackNode.html#m1">00649</a>         uint16  <a class="code" href="classNL3D_1_1CFillStackNode.html#m1">T</a>;
<a name="l00650"></a><a class="code" href="classNL3D_1_1CFillStackNode.html#m2">00650</a>         uint16  <a class="code" href="classNL3D_1_1CFillStackNode.html#m2">Patch</a>;
<a name="l00651"></a><a class="code" href="classNL3D_1_1CFillStackNode.html#m3">00651</a>         uint8   <a class="code" href="classNL3D_1_1CFillStackNode.html#m3">Edge</a>;
<a name="l00652"></a><a class="code" href="classNL3D_1_1CFillStackNode.html#m4">00652</a>         uint8   <a class="code" href="classNL3D_1_1CFillStackNode.html#m4">Rotate</a>;
<a name="l00653"></a><a class="code" href="classNL3D_1_1CFillStackNode.html#m5">00653</a>         CZoneSymmetrisation::TState     <a class="code" href="classNL3D_1_1CFillStackNode.html#m5">State</a>;
00654 };
00655 
00656 <font class="comment">// ***************************************************************************</font>
00657 
<a name="l00658"></a><a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c0">00658</a> <font class="keywordtype">bool</font> CZoneSymmetrisation::propagateTileState (uint patch, uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, <font class="keyword">const</font> std::vector&lt;CPatchInfo&gt; &amp;patchInfo, <font class="keyword">const</font> CTileBank &amp;bank, <font class="keywordtype">bool</font> forceRegular)
00659 {
00660         <font class="comment">// For each layer</font>
00661         uint layer;
00662         <font class="keywordflow">for</font> (layer=0; layer&lt;3; layer++)
00663         {
00664                 <font class="comment">// Get the patch ptr</font>
00665                 <font class="keyword">const</font> CPatchInfo *currentPatchPtr = &amp;(patchInfo[patch]);
00666 
00667                 <font class="comment">// Get the tile index</font>
00668                 uint tile = <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>+<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>*currentPatchPtr-&gt;OrderS;
00669 
00670                 <font class="comment">// Get the tiles set used here</font>
00671                 uint tileIndex = currentPatchPtr-&gt;Tiles[tile].Tile[layer];
00672                 <font class="keywordflow">if</font> (tileIndex != <a class="code" href="tile__element_8h.html#a12">NL_TILE_ELM_LAYER_EMPTY</a>)
00673                 {
00674                         <font class="comment">// Valid tile number ?</font>
00675                         <font class="keywordflow">if</font> (tileIndex &gt;= (uint)bank.getTileCount ())
00676                         {
00677                                 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CZoneSymmetrisation::propagateTileState: Invalid tile index"</font>);
00678                                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00679                         }
00680 
00681                         <font class="comment">// Get the tile set used by this layer</font>
00682                         <font class="keywordtype">int</font> tileSetToPropagate;
00683                         <font class="keywordtype">int</font> number;
00684                         CTileBank::TTileType <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>;
00685                         bank.getTileXRef (tileIndex, tileSetToPropagate, number, <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>);
00686 
00687                         <font class="comment">// Oriented ?</font>
00688                         <font class="keywordtype">bool</font> oriented = bank.getTileSet (tileSetToPropagate)-&gt;getOriented ();
00689 
00690                         <font class="comment">// If oriented, must not be a corner</font>
00691                         <font class="keywordflow">if</font> (!(oriented &amp;&amp; <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a4">getOrientedTileCorner</a> (patch, tile)))
00692                         {
00693                                 <font class="comment">// Current node</font>
00694                                 CFillStackNode currentNode (patch, <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, currentPatchPtr-&gt;Tiles[tile].getTileOrient(layer), <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a1">getTileState</a> (patch, tile, layer));
00695 
00696                                 <font class="comment">// Propagate non-Nothing tiles</font>
00697                                 <font class="keywordflow">if</font> ( (!forceRegular &amp;&amp; (currentNode.State != <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a>)) || (forceRegular &amp;&amp; (currentNode.State == <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a>)) )
00698                                 {
00699                                         <font class="comment">// Force to Regular ?</font>
00700                                         <font class="keywordflow">if</font> (forceRegular)
00701                                         {
00702                                                 <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c1">setTileState</a> (patch, tile, layer, <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s1">Regular</a>);
00703                                                 currentNode.State = <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s1">Regular</a>;
00704                                         }
00705 
00706                                         <font class="comment">// Fill stack</font>
00707                                         vector&lt;CFillStackNode&gt;  stack;
00708                                         stack.push_back (currentNode);
00709 
00710                                         <font class="comment">// While people in the stack</font>
00711                                         <font class="keywordflow">while</font> (!stack.empty ())
00712                                         {               
00713                                                 <font class="comment">// Pop last element</font>
00714                                                 currentNode = stack.back ();
00715                                                 stack.pop_back ();
00716 
00717                                                 <font class="keywordflow">do</font>
00718                                                 {
00719                                                         <font class="comment">// Set current patch pointer</font>
00720                                                         currentPatchPtr = &amp;(patchInfo[currentNode.Patch]);
00721 
00722                                                         <font class="comment">// Get neighbor</font>
00723                                                         CFillStackNode neighborNode (currentNode.Patch, currentNode.S, currentNode.T, currentNode.Rotate, currentNode.State);
00724                                                         <font class="keywordflow">switch</font> (currentNode.Edge)
00725                                                         {
00726                                                         <font class="keywordflow">case</font> 0:
00727                                                                 neighborNode.S--;
00728                                                                 <font class="keywordflow">break</font>;
00729                                                         <font class="keywordflow">case</font> 1:
00730                                                                 neighborNode.T++;
00731                                                                 <font class="keywordflow">break</font>;
00732                                                         <font class="keywordflow">case</font> 2:
00733                                                                 neighborNode.S++;
00734                                                                 <font class="keywordflow">break</font>;
00735                                                         <font class="keywordflow">case</font> 3:
00736                                                                 neighborNode.T--;
00737                                                                 <font class="keywordflow">break</font>;
00738                                                         }
00739 
00740                                                         <font class="comment">// Is still in patch ?</font>
00741                                                         <font class="keywordflow">if</font> ( (neighborNode.S&lt;0) || (neighborNode.S&gt;=patchInfo[currentNode.Patch].OrderS) || (neighborNode.T&lt;0) || (neighborNode.T&gt;=patchInfo[currentNode.Patch].OrderT) )
00742                                                         {
00743                                                                 <font class="comment">// No, found new patch</font>
00744                                                                 uint position;
00745                                                                 <font class="keywordflow">switch</font> (currentNode.Edge)
00746                                                                 {
00747                                                                 <font class="keywordflow">case</font> 0:
00748                                                                         position = neighborNode.T;
00749                                                                         <font class="keywordflow">break</font>;
00750                                                                 <font class="keywordflow">case</font> 1:
00751                                                                         position = neighborNode.S;
00752                                                                         <font class="keywordflow">break</font>;
00753                                                                 <font class="keywordflow">case</font> 2:
00754                                                                         position = patchInfo[currentNode.Patch].OrderT - neighborNode.T - 1;
00755                                                                         <font class="keywordflow">break</font>;
00756                                                                 <font class="keywordflow">case</font> 3:
00757                                                                         position = patchInfo[currentNode.Patch].OrderS - neighborNode.S - 1;
00758                                                                         <font class="keywordflow">break</font>;
00759                                                                 }
00760 
00761                                                                 <font class="comment">// Get next patch</font>
00762                                                                 uint patchOut;
00763                                                                 sint sOut;
00764                                                                 sint tOut;
00765                                                                 <font class="keywordflow">if</font> (patchInfo[currentNode.Patch].getNeighborTile (currentNode.Patch, currentNode.Edge, position, 
00766                                                                         patchOut, sOut, tOut, patchInfo))
00767                                                                 {
00768                                                                         <font class="comment">// Should be another patch</font>
00769                                                                         <a class="code" href="debug_8h.html#a6">nlassert</a> (patchOut != currentNode.Patch);
00770 
00771                                                                         <font class="comment">// Get patch id</font>
00772                                                                         neighborNode.Patch = patchOut;
00773 
00774                                                                         <font class="comment">// Coordinate must be IN the patch</font>
00775                                                                         <a class="code" href="debug_8h.html#a6">nlassert</a> (sOut &gt;= 0);
00776                                                                         <a class="code" href="debug_8h.html#a6">nlassert</a> (tOut &gt;= 0);
00777                                                                         <a class="code" href="debug_8h.html#a6">nlassert</a> (sOut &lt; patchInfo[neighborNode.Patch].OrderS);
00778                                                                         <a class="code" href="debug_8h.html#a6">nlassert</a> (tOut &lt; patchInfo[neighborNode.Patch].OrderT);
00779 
00780                                                                         <font class="comment">// Copy it</font>
00781                                                                         neighborNode.S = sOut;
00782                                                                         neighborNode.T = tOut;
00783 
00784                                                                         <font class="comment">// Find neighbor</font>
00785                                                                         <font class="keyword">const</font> CPatchInfo::CBindInfo &amp;neighborBindInfo = patchInfo[currentNode.Patch].BindEdges[currentNode.Edge];
00786                                                                         uint edgePatch;
00787                                                                         <font class="keywordflow">for</font> (edgePatch=0; edgePatch&lt;(uint)neighborBindInfo.NPatchs; edgePatch++)
00788                                                                         {
00789                                                                                 <font class="keywordflow">if</font> (neighborBindInfo.Next[edgePatch] == neighborNode.Patch)
00790                                                                                         <font class="keywordflow">break</font>;
00791                                                                         }
00792 
00793                                                                         <font class="comment">// Must find one patch</font>
00794                                                                         <a class="code" href="debug_8h.html#a6">nlassert</a> (edgePatch&lt;(uint)neighborBindInfo.NPatchs);
00795 
00796                                                                         <font class="comment">// Rotation</font>
00797                                                                         neighborNode.Rotate = (currentNode.Rotate + 2 + neighborBindInfo.Edge[edgePatch] - currentNode.Edge) &amp; 3;
00798 
00799                                                                         <font class="comment">// Toggle the state ?</font>
00800                                                                         <font class="keywordflow">if</font> ((neighborNode.Rotate ^ currentNode.Rotate) &amp; 1)
00801                                                                         {
00802                                                                                 <font class="comment">// Yes</font>
00803                                                                                 neighborNode.State = (neighborNode.State == <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s1">Regular</a>) ? <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s2">Goofy</a> : <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s1">Regular</a>;
00804                                                                         }
00805                                                                 }
00806                                                                 <font class="keywordflow">else</font>
00807                                                                 {
00808                                                                         <font class="comment">// No propagation, continue</font>
00809                                                                         currentNode.Edge++;
00810                                                                         <font class="keywordflow">continue</font>;
00811                                                                 }
00812                                                         }
00813 
00814                                                         <font class="comment">// Neighbor patch</font>
00815                                                         <font class="keyword">const</font> CPatchInfo *neighborPatchPtr = &amp;(patchInfo[neighborNode.Patch]);
00816 
00817                                                         <font class="comment">// Get the tile index</font>
00818                                                         uint neighborTile = neighborNode.S+neighborNode.T*neighborPatchPtr-&gt;OrderS;
00819                                                         
00820                                                         <font class="comment">// Look for the same tile set in the new tile</font>
00821                                                         uint neighborLayer;
00822                                                         <font class="keywordflow">for</font> (neighborLayer=0; neighborLayer&lt;3; neighborLayer++)
00823                                                         {
00824                                                                 <font class="comment">// Get the tile index</font>
00825                                                                 uint neighborTileIndex = neighborPatchPtr-&gt;Tiles[neighborTile].Tile[neighborLayer];
00826 
00827                                                                 <font class="keywordflow">if</font> (neighborTileIndex != <a class="code" href="tile__element_8h.html#a12">NL_TILE_ELM_LAYER_EMPTY</a>)
00828                                                                 {
00829                                                                         <font class="comment">// Valid tile number ?</font>
00830                                                                         <font class="keywordflow">if</font> (neighborTileIndex &gt;= (uint)bank.getTileCount ())
00831                                                                         {
00832                                                                                 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CZoneSymmetrisation::propagateTileState: Invalid tile index"</font>);
00833                                                                                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00834                                                                         }
00835 
00836                                                                         <font class="comment">// Get tileset</font>
00837                                                                         <font class="keywordtype">int</font> neighborTileSet;
00838                                                                         <font class="keywordtype">int</font> neighborNumber;
00839                                                                         CTileBank::TTileType neighborType;
00840                                                                         bank.getTileXRef (neighborTileIndex, neighborTileSet, neighborNumber, neighborType);
00841 
00842                                                                         <font class="comment">// Same tileset ? Stop!</font>
00843                                                                         <font class="keywordflow">if</font> (    (neighborTileSet == tileSetToPropagate) &amp;&amp; 
00844                                                                                         (neighborNode.Rotate == neighborPatchPtr-&gt;Tiles[neighborTile].getTileOrient(neighborLayer)) )
00845                                                                                 <font class="keywordflow">break</font>;
00846                                                                 }
00847                                                         }
00848 
00849                                                         <font class="comment">// Found ?</font>
00850                                                         <font class="keywordflow">if</font> (neighborLayer&lt;3)
00851                                                         {
00852                                                                 <font class="comment">// If oriented, must not be a corner</font>
00853                                                                 <font class="keywordflow">if</font> (!(oriented &amp;&amp; <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a4">getOrientedTileCorner</a> (neighborNode.Patch, neighborTile)))
00854                                                                 {
00855                                                                         <font class="comment">// Propagate in the new node ?</font>
00856                                                                         <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3">TState</a> neighborState = <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#a1">getTileState</a> (neighborNode.Patch, neighborTile, neighborLayer);
00857                                                                         <font class="keywordflow">if</font> (neighborState == <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#s3s0">Nothing</a>)
00858                                                                         {
00859                                                                                 <font class="comment">// Set the state</font>
00860                                                                                 <a class="code" href="classNL3D_1_1CZoneSymmetrisation.html#c1">setTileState</a> (neighborNode.Patch, neighborTile, neighborLayer, neighborNode.State);
00861 
00862                                                                                 <font class="comment">// Stack current node if some neighbor left to visit</font>
00863                                                                                 <font class="keywordflow">if</font> (currentNode.Edge &lt; 3)
00864                                                                                 {
00865                                                                                         currentNode.Edge++;
00866                                                                                         stack.push_back (currentNode);
00867                                                                                 }
00868 
00869                                                                                 <font class="comment">// Continue with the new node</font>
00870                                                                                 currentNode = neighborNode;
00871                                                                         }
00872                                                                         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (neighborState != neighborNode.State)
00873                                                                         {
00874                                                                                 <font class="comment">// Error, same tile but not same state</font>
00875                                                                                 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CZoneSymmetrisation::propagateTileState: error, find same iso surfaces with different state."</font>);
00876 
00877                                                                                 <font class="comment">// No propagation, continue</font>
00878                                                                                 currentNode.Edge++;
00879                                                                         }
00880                                                                         <font class="keywordflow">else</font>
00881                                                                         {
00882                                                                                 <font class="comment">// No propagation, continue</font>
00883                                                                                 currentNode.Edge++;
00884                                                                         }
00885                                                                 }
00886                                                                 <font class="keywordflow">else</font>
00887                                                                 {
00888                                                                         <font class="comment">// No propagation, continue</font>
00889                                                                         currentNode.Edge++;
00890                                                                 }
00891                                                         }
00892                                                         <font class="keywordflow">else</font>
00893                                                                 <font class="comment">// No propagation, continue</font>
00894                                                                 currentNode.Edge++;
00895                                                 }
00896                                                 <font class="keywordflow">while</font> (currentNode.Edge&lt;4);
00897                                         }
00898                                 }
00899                         }
00900                 }
00901         }
00902 
00903         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00904 }
00905 
00906 <font class="comment">// ***************************************************************************</font>
00907 
00908 } <font class="comment">// NL3D</font>
</pre></div>

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