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
|
<!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> <A CLASS=uplinks HREF=><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><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="/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>
<!-- 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> </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:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>tess_face_priority_list.cpp</h1><a href="tess__face__priority__list_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00007 <font class="comment">/* Copyright, 2001 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 <font class="preprocessor">#include "<a class="code" href="tess__face__priority__list_8h.html">3d/tess_face_priority_list.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font>
00030 <font class="preprocessor">#include <math.h></font>
00031 <font class="preprocessor">#include "<a class="code" href="tessellation_8h.html">3d/tessellation.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="fast__floor_8h.html">3d/fast_floor.h</a>"</font>
00033
00034
00035 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00036 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00037
00038 <font class="keyword">namespace </font>NL3D
00039 {
00040
00041 <font class="comment">// ***************************************************************************</font>
00042 <font class="comment">// ***************************************************************************</font>
00043 <font class="comment">// CTessFacePListNode</font>
00044 <font class="comment">// ***************************************************************************</font>
00045 <font class="comment">// ***************************************************************************</font>
00046
00047
00048 <font class="comment">// ***************************************************************************</font>
<a name="l00049"></a><a class="code" href="classNL3D_1_1CTessFacePListNode.html#a4">00049</a> <font class="keywordtype">void</font> CTessFacePListNode::linkInPList(CTessFacePListNode &root)
00050 {
00051 <font class="comment">// unlink old list from me.</font>
00052 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o0">_PrecTessFaceInPList</a>->_NextTessFaceInPList= <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o1">_NextTessFaceInPList</a>;
00053 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o1">_NextTessFaceInPList</a>->_PrecTessFaceInPList= <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o0">_PrecTessFaceInPList</a>;
00054
00055 <font class="comment">// link me to the list.</font>
00056 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o0">_PrecTessFaceInPList</a>= &root;
00057 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o1">_NextTessFaceInPList</a>= root._NextTessFaceInPList;
00058 <font class="comment">// link the list to me.</font>
00059 root._NextTessFaceInPList->_PrecTessFaceInPList= <font class="keyword">this</font>;
00060 root._NextTessFaceInPList= <font class="keyword">this</font>;
00061 <font class="comment">/*</font>
00062 <font class="comment"> NB if list was empty (this, this), then</font>
00063 <font class="comment"> _PrecTessFaceInPList= &root</font>
00064 <font class="comment"> _NextTessFaceInPList= root._NextTessFaceInPList= &root !</font>
00065 <font class="comment"> root._NextTessFaceInPList->_PrecTessFaceInPList= this; => root._PrecTessFaceInPList= this</font>
00066 <font class="comment"> root._NextTessFaceInPList= this</font>
00067 <font class="comment"> */</font>
00068 }
00069
00070 <font class="comment">// ***************************************************************************</font>
<a name="l00071"></a><a class="code" href="classNL3D_1_1CTessFacePListNode.html#a5">00071</a> <font class="keywordtype">void</font> CTessFacePListNode::unlinkInPList()
00072 {
00073 <font class="comment">/*</font>
00074 <font class="comment"> NB: if this node was empty (this, this), this is a No-Op.</font>
00075 <font class="comment"> If this node was the last of a list, then the root correctly get (&root, &root) after this.</font>
00076 <font class="comment"> */</font>
00077 <font class="comment">// unlink old list from me.</font>
00078 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o0">_PrecTessFaceInPList</a>->_NextTessFaceInPList= <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o1">_NextTessFaceInPList</a>;
00079 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o1">_NextTessFaceInPList</a>->_PrecTessFaceInPList= <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o0">_PrecTessFaceInPList</a>;
00080
00081 <font class="comment">// reset to empty node.</font>
00082 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o0">_PrecTessFaceInPList</a>= <font class="keyword">this</font>;
00083 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o1">_NextTessFaceInPList</a>= <font class="keyword">this</font>;
00084 }
00085
00086
00087 <font class="comment">// ***************************************************************************</font>
<a name="l00088"></a><a class="code" href="classNL3D_1_1CTessFacePListNode.html#a6">00088</a> <font class="keywordtype">void</font> CTessFacePListNode::appendPList(CTessFacePListNode &root)
00089 {
00090 <font class="comment">// If list to append is not empty.</font>
00091 <font class="keywordflow">if</font>( root._NextTessFaceInPList != &root )
00092 {
00093 <font class="comment">// If we are empty.</font>
00094 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o1">_NextTessFaceInPList</a>==<font class="keyword">this</font> )
00095 {
00096 <font class="comment">// link the appendList to the root.</font>
00097 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o0">_PrecTessFaceInPList</a>= root._PrecTessFaceInPList;
00098 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o1">_NextTessFaceInPList</a>= root._NextTessFaceInPList;
00099 <font class="comment">// link the root to the appendList.</font>
00100 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o0">_PrecTessFaceInPList</a>->_NextTessFaceInPList= <font class="keyword">this</font>;
00101 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o1">_NextTessFaceInPList</a>->_PrecTessFaceInPList= <font class="keyword">this</font>;
00102 }
00103 <font class="comment">// else bind first-last in the interval prec-next.</font>
00104 <font class="keywordflow">else</font>
00105 {
00106 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#a0">CTessFacePListNode</a> *first= root._NextTessFaceInPList;
00107 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#a0">CTessFacePListNode</a> *last= root._PrecTessFaceInPList;
00108 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#a0">CTessFacePListNode</a> *prec= <font class="keyword">this</font>;
00109 <a class="code" href="classNL3D_1_1CTessFacePListNode.html#a0">CTessFacePListNode</a> *next= <a class="code" href="classNL3D_1_1CTessFacePListNode.html#o1">_NextTessFaceInPList</a>;
00110 <font class="comment">// insert the appendList in our list.</font>
00111 next->_PrecTessFaceInPList= last;
00112 prec->_NextTessFaceInPList= first;
00113 <font class="comment">// insert our list in the appendList.</font>
00114 last->_NextTessFaceInPList= next;
00115 first->_PrecTessFaceInPList= prec;
00116 }
00117
00118 <font class="comment">// clear input list.</font>
00119 root._PrecTessFaceInPList= &root;
00120 root._NextTessFaceInPList= &root;
00121 }
00122 }
00123
00124
00125
00126 <font class="comment">// ***************************************************************************</font>
00127 <font class="comment">// ***************************************************************************</font>
00128 <font class="comment">// CTessFacePriorityList</font>
00129 <font class="comment">// ***************************************************************************</font>
00130 <font class="comment">// ***************************************************************************</font>
00131
00132
00133 <font class="comment">// ***************************************************************************</font>
<a name="l00134"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList.html#a0">00134</a> CTessFacePriorityList::CTessFacePriorityList()
00135 {
00136 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o1">_OODistStep</a>= 1;
00137 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>= 0;
00138 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o3">_MaskEntries</a>= 0;
00139 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o4">_EntryModStart</a>= 0;
00140 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o5">_NumQuadrant</a>= 0;
00141 }
00142
00143 <font class="comment">// ***************************************************************************</font>
<a name="l00144"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList.html#a1">00144</a> CTessFacePriorityList::~CTessFacePriorityList()
00145 {
00146 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#a3">clear</a>();
00147 }
00148
00149 <font class="comment">// ***************************************************************************</font>
<a name="l00150"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList.html#a2">00150</a> <font class="keywordtype">void</font> CTessFacePriorityList::init(<font class="keywordtype">float</font> distStep, uint numEntries, <font class="keywordtype">float</font> distMaxMod, uint numQuadrant)
00151 {
00152 uint i;
00153 <a class="code" href="debug_8h.html#a6">nlassert</a>(distStep>0);
00154 <a class="code" href="debug_8h.html#a6">nlassert</a>(numEntries>0 && <a class="code" href="namespaceNLMISC.html#a225">isPowerOf2</a>(numEntries));
00155 <a class="code" href="debug_8h.html#a6">nlassert</a>(distMaxMod<1);
00156 <a class="code" href="debug_8h.html#a6">nlassert</a>(numQuadrant==0 || (numQuadrant>=4 && <a class="code" href="namespaceNLMISC.html#a225">isPowerOf2</a>(numQuadrant)) );
00157
00158 <font class="comment">// clear the prioriy list before.</font>
00159 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#a3">clear</a>();
00160
00161 <font class="comment">// setup</font>
00162 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o1">_OODistStep</a>= 1.0f / distStep;
00163 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>= numEntries;
00164 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o3">_MaskEntries</a>= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>-1;
00165 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o4">_EntryModStart</a>= (uint)ceil(distMaxMod * <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>);
00166 <a class="code" href="namespaceNLMISC.html#a215">NLMISC::clamp</a>(<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o4">_EntryModStart</a>, 0U, <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>-1);
00167 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o5">_NumQuadrant</a>= numQuadrant;
00168
00169 <font class="comment">// Build the Rolling tables.</font>
00170 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>.resize(1+<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o5">_NumQuadrant</a>);
00171 <font class="keywordflow">for</font>(i=0;i<<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>.size();i++)
00172 {
00173 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>[i].init(<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>);
00174 <font class="comment">// setup the quadrant direction. NB: 0 not used since "Direction less rolling table"</font>
00175 <font class="keywordflow">if</font>(i>=1)
00176 {
00177 uint idx= i-1;
00178 <font class="comment">// split evenly the plane with direction.</font>
00179 <font class="keywordtype">float</font> angle= float(2*<a class="code" href="namespaceNLMISC.html#a7">Pi</a>*idx)/<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o5">_NumQuadrant</a>;
00180 CMatrix mat;
00181 mat.rotateZ(angle);
00182 <font class="comment">// setup the vector</font>
00183 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>[i].QuadrantDirection= mat.getJ();
00184 }
00185 }
00186
00187 <font class="comment">// Build Quarter Selection. In is in CCW order. Out: see selectQuadrant()</font>
00188 <font class="keyword">const</font> uint quarterLut[4]= {1,3,2,0};
00189 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o6">_MaskQuadrant</a>= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o5">_NumQuadrant</a>-1;
00190 <font class="keywordflow">for</font>(i=0;i<4;i++)
00191 {
00192 <font class="comment">// Re-Order for faster ASM acces. see selectQuadrant()</font>
00193 uint idx= quarterLut[i];
00194 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o7">_QuarterQuadrantStart</a>[idx]= i*<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o5">_NumQuadrant</a>/4;
00195 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o8">_QuarterQuadrantEnd</a>[idx]= 1+ (i+1)*<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o5">_NumQuadrant</a>/4;
00196 }
00197
00198 }
00199
00200 <font class="comment">// ***************************************************************************</font>
<a name="l00201"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList.html#a3">00201</a> <font class="keywordtype">void</font> CTessFacePriorityList::clear()
00202 {
00203 <font class="comment">// just clear all the rolling tables.</font>
00204 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>.clear();
00205 }
00206
00207
00208 <font class="comment">// ***************************************************************************</font>
<a name="l00209"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList.html#a4">00209</a> uint CTessFacePriorityList::selectQuadrant(<font class="keyword">const</font> CVector &direction)
00210 {
00211 <font class="comment">// if numQuadrants=0, ret 0.</font>
00212 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o5">_NumQuadrant</a>==0)
00213 <font class="keywordflow">return</font> 0;
00214
00215
00216 <font class="comment">// select the quarter.</font>
00217 uint quarterId;
00218 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
00219 <font class="preprocessor"></font> __asm
00220 {
00221 mov esi, direction
00222 mov eax, [esi]direction.y
00223 mov ebx, [esi]direction.x
00224 <font class="comment">// read the sign</font>
00225 and eax, 0x80000000
00226 and ebx, 0x80000000
00227 <font class="comment">// set the bit</font>
00228 shr eax, 30
00229 shr ebx, 31
00230 <font class="comment">// assemble</font>
00231 or eax, ebx
00232 mov quarterId, eax
00233 }
00234 <font class="preprocessor">#else</font>
00235 <font class="preprocessor"></font> <font class="keywordflow">if</font>(direction.y>0)
00236 {
00237 <font class="keywordflow">if</font>(direction.x>0) quarterId= 0;
00238 <font class="keywordflow">else</font> quarterId= 1;
00239 }
00240 <font class="keywordflow">else</font>
00241 {
00242 <font class="keywordflow">if</font>(direction.x>0) quarterId= 2;
00243 <font class="keywordflow">else</font> quarterId= 3;
00244 }
00245 <font class="preprocessor">#endif</font>
00246 <font class="preprocessor"></font>
00247 <font class="comment">// Run only the quadrants of the associated quarter.</font>
00248 uint quadrantStart= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o7">_QuarterQuadrantStart</a>[quarterId];
00249 uint quadrantEnd= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o8">_QuarterQuadrantEnd</a>[quarterId];
00250
00251
00252 <font class="comment">// For all quadrants of the quarter, return the best direction</font>
00253 <font class="keywordtype">float</font> bestDirPs= -FLT_MAX;
00254 uint bestQuadrant= 0;
00255 <font class="keywordflow">for</font>(uint i=quadrantStart;i<quadrantEnd;i++)
00256 {
00257 <font class="comment">// get the quadrant Id. Must mask for last (0). And Start at 1 in the _RollingTables.</font>
00258 uint quadrantId= (i&<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o6">_MaskQuadrant</a>)+1;
00259 <font class="comment">// Test with this quadrant</font>
00260 <font class="keywordtype">float</font> ps= direction*<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>[i].QuadrantDirection;
00261 <font class="keywordflow">if</font>(ps>bestDirPs)
00262 {
00263 bestDirPs= ps;
00264 bestQuadrant= i;
00265 }
00266 }
00267
00268 <font class="keywordflow">return</font> bestQuadrant;
00269 }
00270
00271
00272 <font class="comment">// ***************************************************************************</font>
<a name="l00273"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList.html#a6">00273</a> <font class="keywordtype">void</font> CTessFacePriorityList::insert(uint quadrantId, <font class="keywordtype">float</font> distance, CTessFace *<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>)
00274 {
00275 <font class="comment">// plist must be inited.</font>
00276 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>>0 && quadrantId<<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>.size());
00277
00278 <font class="comment">// First, setup in our basis.</font>
00279 distance*= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o1">_OODistStep</a>;
00280
00281 <font class="comment">// Insert int the good quadrant</font>
00282 CRollingTable &rollTable= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>[quadrantId];
00283
00284 <font class="comment">// Then, look where we must insert it.</font>
00285 sint idInsert;
00286 <font class="keywordflow">if</font>(distance<=0)
00287 idInsert= 0;
00288 <font class="keywordflow">else</font>
00289 {
00290 <font class="comment">// Must insert so we can't miss it when a shift occurs (=> floor).</font>
00291 idInsert= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(distance + rollTable.Remainder);
00292 }
00293 idInsert= std::max(0, idInsert);
00294
00295 <font class="comment">// Manage Mod.</font>
00296 <font class="comment">// If the element to insert must be inserted at distance > distMax.</font>
00297 <font class="keywordflow">if</font>(idInsert>(sint)<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o3">_MaskEntries</a>)
00298 {
00299 <font class="comment">// Compute number of entries to apply the mod.</font>
00300 uint nMod= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a> - <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o4">_EntryModStart</a>;
00301 <font class="comment">// Of how many entries are we too far.</font>
00302 idInsert= idInsert - <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o3">_MaskEntries</a>;
00303 <font class="comment">// Then loop in the interval [_EntryModStart, _NEntries[.</font>
00304 idInsert= idInsert % nMod;
00305 idInsert= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o4">_EntryModStart</a> + idInsert;
00306 }
00307
00308 <font class="comment">// insert in the Roll Table.</font>
00309 rollTable.insertInRollTable(idInsert, <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>);
00310 }
00311
00312
00313 <font class="comment">// ***************************************************************************</font>
<a name="l00314"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList.html#a7">00314</a> <font class="keywordtype">void</font> CTessFacePriorityList::shift(<font class="keyword">const</font> CVector &direction, CTessFacePListNode &pulledElements)
00315 {
00316 <font class="comment">// plist must be inited.</font>
00317 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>>0);
00318
00319 pulledElements.unlinkInPList();
00320
00321 <font class="comment">// Shift all the rolling tables</font>
00322 <font class="keywordflow">for</font>(uint i=0;i<<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>.size();i++)
00323 {
00324 CRollingTable &rollTable= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>[i];
00325 <font class="keywordtype">float</font> shiftDistance;
00326
00327 <font class="comment">// if quadrant 0, Direction less => get distance with Euler norm.</font>
00328 <font class="keywordflow">if</font>(i==0)
00329 {
00330 shiftDistance= direction.norm();
00331 }
00332 <font class="comment">// Else compute the effective distance we run to the plane.</font>
00333 <font class="keywordflow">else</font>
00334 {
00335 shiftDistance= direction*rollTable.QuadrantDirection;
00336 <font class="comment">// For now, just clamp, but may be interesting to shift Back the rolling table !!</font>
00337 shiftDistance= max(0.f, shiftDistance);
00338 }
00339
00340 <font class="comment">// First, setup in our basis.</font>
00341 shiftDistance*= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o1">_OODistStep</a>;
00342
00343 <font class="comment">// at least, fill OUT with elements of entry 0.</font>
00344 <font class="comment">// For all elements of the entry 0 of , pull them, and insert in result list.</font>
00345 pulledElements.appendPList(rollTable.getRollTableEntry(0));
00346
00347 <font class="comment">// shift.</font>
00348 rollTable.Remainder+= shiftDistance;
00349 <font class="comment">// If Remainder>=1, it means that we must shift the rolling table, and get elements deleted.</font>
00350 uint entryShift= (uint)floor(rollTable.Remainder);
00351 rollTable.Remainder= rollTable.Remainder - entryShift;
00352
00353 <font class="comment">// shift full array??</font>
00354 <font class="keywordflow">if</font>( entryShift >= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>)
00355 {
00356 entryShift= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>;
00357 <font class="comment">// The entire array is pulled, _Remainder should get a good value.</font>
00358 rollTable.Remainder= 0;
00359 }
00360
00361 <font class="comment">// If some real shift, do it.</font>
00362 rollTable.shiftEntries(entryShift, pulledElements);
00363 }
00364 }
00365
00366
00367 <font class="comment">// ***************************************************************************</font>
<a name="l00368"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList.html#a8">00368</a> <font class="keywordtype">void</font> CTessFacePriorityList::shiftAll(CTessFacePListNode &pulledElements)
00369 {
00370 <font class="comment">// plist must be inited.</font>
00371 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>>0);
00372
00373 pulledElements.unlinkInPList();
00374
00375 <font class="comment">// Do it for all rolling tables.</font>
00376 <font class="keywordflow">for</font>(uint i=0;i<<a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>.size();i++)
00377 {
00378 <font class="comment">// The entire array is pulled, _Remainder should get a good value.</font>
00379 uint entryShift= <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#o2">_NEntries</a>;
00380 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>[i].Remainder= 0;
00381
00382 <font class="comment">// shift the entire array.</font>
00383 <a class="code" href="classNL3D_1_1CTessFacePriorityList.html#z818_0">_RollingTables</a>[i].shiftEntries(entryShift, pulledElements);
00384 }
00385 }
00386
00387
00388 <font class="comment">// ***************************************************************************</font>
00389 <font class="comment">// ***************************************************************************</font>
00390 <font class="comment">// Rolling table.</font>
00391 <font class="comment">// ***************************************************************************</font>
00392 <font class="comment">// ***************************************************************************</font>
00393
00394 <font class="comment">// ***************************************************************************</font>
<a name="l00395"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#a0">00395</a> CTessFacePriorityList::CRollingTable::CRollingTable()
00396 {
00397 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o1">_EntryStart</a>= 0;
00398 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o2">_NEntries</a>= 0;
00399 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o3">_MaskEntries</a>= 0;
00400 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#m1">Remainder</a>= 0;
00401 }
00402
00403 <font class="comment">// ***************************************************************************</font>
<a name="l00404"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#a1">00404</a> CTessFacePriorityList::CRollingTable::~CRollingTable()
00405 {
00406 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#a6">clearRollTable</a>();
00407 }
00408
00409
00410 <font class="comment">// ***************************************************************************</font>
<a name="l00411"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#a2">00411</a> <font class="keywordtype">void</font> CTessFacePriorityList::CRollingTable::init(uint numEntries)
00412 {
00413 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o1">_EntryStart</a>= 0;
00414 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o2">_NEntries</a>= numEntries;
00415 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o3">_MaskEntries</a>= <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o2">_NEntries</a>-1;
00416 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#m1">Remainder</a>= 0;
00417 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o0">_Entries</a>.resize(numEntries);
00418 }
00419
00420
00421 <font class="comment">// ***************************************************************************</font>
<a name="l00422"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#a3">00422</a> <font class="keywordtype">void</font> CTessFacePriorityList::CRollingTable::insertInRollTable(uint entry, CTessFace *<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>)
00423 {
00424 CTessFacePListNode &root= <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o0">_Entries</a>[ (entry + <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o1">_EntryStart</a>) & <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o3">_MaskEntries</a> ];
00425
00426 <font class="comment">// Insert into list.</font>
00427 <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>->linkInPList(root);
00428 }
00429
00430 <font class="comment">// ***************************************************************************</font>
<a name="l00431"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#a4">00431</a> CTessFacePListNode &CTessFacePriorityList::CRollingTable::getRollTableEntry(uint entry)
00432 {
00433 CTessFacePListNode &root= <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o0">_Entries</a>[ (entry + <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o1">_EntryStart</a>) & <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o3">_MaskEntries</a> ];
00434 <font class="keywordflow">return</font> root;
00435 }
00436
00437 <font class="comment">// ***************************************************************************</font>
<a name="l00438"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#c0">00438</a> <font class="keywordtype">void</font> CTessFacePriorityList::CRollingTable::clearRollTableEntry(uint entry)
00439 {
00440 CTessFacePListNode &root= <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o0">_Entries</a>[ (entry + <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o1">_EntryStart</a>) & <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o3">_MaskEntries</a> ];
00441
00442 <font class="comment">// clear all the list.</font>
00443 <font class="keywordflow">while</font>( root.nextInPList() != &root )
00444 {
00445 <font class="comment">// unlink from list</font>
00446 CTessFacePListNode *node= root.nextInPList();
00447 node->unlinkInPList();
00448 }
00449 }
00450
00451 <font class="comment">// ***************************************************************************</font>
<a name="l00452"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#a5">00452</a> <font class="keywordtype">void</font> CTessFacePriorityList::CRollingTable::shiftRollTable(uint shiftEntry)
00453 {
00454 <font class="comment">// delete all elements shifted.</font>
00455 <font class="keywordflow">for</font>(uint i=0; i<shiftEntry; i++)
00456 {
00457 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#c0">clearRollTableEntry</a>(i);
00458 }
00459 <font class="comment">// shift to right the ptr of entries.</font>
00460 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o1">_EntryStart</a>+= shiftEntry;
00461 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o1">_EntryStart</a>= <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o1">_EntryStart</a> & <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o3">_MaskEntries</a>;
00462 }
00463
00464 <font class="comment">// ***************************************************************************</font>
<a name="l00465"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#a6">00465</a> <font class="keywordtype">void</font> CTessFacePriorityList::CRollingTable::clearRollTable()
00466 {
00467 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o2">_NEntries</a>; i++)
00468 {
00469 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#c0">clearRollTableEntry</a>(i);
00470 }
00471 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#o1">_EntryStart</a>= 0;
00472 <font class="comment">// For convenience only (not really usefull).</font>
00473 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#m1">Remainder</a>= 0;
00474 }
00475
00476 <font class="comment">// ***************************************************************************</font>
<a name="l00477"></a><a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#a7">00477</a> <font class="keywordtype">void</font> CTessFacePriorityList::CRollingTable::shiftEntries(uint entryShift, CTessFacePListNode &pulledElements)
00478 {
00479 <font class="keywordflow">if</font>(entryShift>0)
00480 {
00481 <font class="comment">// before shifting the roll Table, fill pulledElements.</font>
00482 <font class="keywordflow">for</font>(uint i=0; i<entryShift; i++)
00483 {
00484 <font class="comment">// For all elements of the ith entry, pull them and isnert in result list.</font>
00485 pulledElements.appendPList(<a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#a4">getRollTableEntry</a>(i));
00486 }
00487
00488 <font class="comment">// shift the roll Table. lists are already empty.</font>
00489 <a class="code" href="classNL3D_1_1CTessFacePriorityList_1_1CRollingTable.html#a5">shiftRollTable</a>(entryShift);
00490 }
00491 }
00492
00493
00494
00495
00496 } <font class="comment">// NL3D</font>
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|