aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a02875.html
blob: ecbdf9f5f2ceb32d4ff477794918a7ff11d7cc57 (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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>NeL: NL3D::CMeshBlockManager class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex">  <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a>  | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>NL3D::CMeshBlockManager Class Reference</h1><code>#include &lt;<a class="el" href="a05998.html">mesh_block_manager.h</a>&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A class used to render instances sorted by MeshGeom first, then per material, where possible. This allow optimisation because less renderState swapping are needed. WARNING: if you add MeshGeom to 2 different <a class="el" href="a02875.html">CMeshBlockManager</a> at same times, it won't work, and will certainly crashes (not checked/assert).<p>
NB VBHeap part works, even if no User interface use it. It don't give greate performance Add, but will may be used.<p>
<dl compact><dt><b>Author:</b></dt><dd>Lionel Berenguier <p>
Nevrax France </dd></dl>
<dl compact><dt><b>Date:</b></dt><dd>2002 </dd></dl>

<p>

<p>
Definition at line <a class="el" href="a05998.html#l00056">56</a> of file <a class="el" href="a05998.html">mesh_block_manager.h</a>.<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagera0">addInstance</a> (<a class="el" href="a02879.html">IMeshGeom</a> *meshGeom, <a class="el" href="a02873.html">CMeshBaseInstance</a> *inst, float polygonCount)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagera1">CMeshBlockManager</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Constructor.  <a href="#NL3D_1_1CMeshBlockManagera1"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagera2">flush</a> (<a class="el" href="a02434.html">IDriver</a> *drv, <a class="el" href="a03348.html">CScene</a> *scene, <a class="el" href="a03325.html">CRenderTrav</a> *renderTrav)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagera3">~CMeshBlockManager</a> ()</td></tr>

<tr><td colspan="2"><div class="groupHeader">VBHeap part.</div></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagerz453_0">addVBHeap</a> (<a class="el" href="a02434.html">IDriver</a> *drv, <a class="el" href="a04558.html#a15">uint</a> vertexFormat, <a class="el" href="a04558.html#a15">uint</a> maxVertices)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagerz453_1">freeMeshVBHeap</a> (<a class="el" href="a02879.html">IMeshGeom</a> *mesh)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Called by ~IMeshGeom().  <a href="#NL3D_1_1CMeshBlockManagerz453_1"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagerz453_2">releaseVBHeaps</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">release all Heaps =&gt; clear memory of meshs registered.  <a href="#NL3D_1_1CMeshBlockManagerz453_2"></a><br><br></td></tr>
<tr><td colspan=2><br><h2>Private Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef std::map&lt; <a class="el" href="a04558.html#a15">uint</a>, <a class="el" href="a04558.html#a15">uint</a> &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagery0">TVBHeapMap</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Heap Map from vertexFormat to VBHeap Id. NB: do not contains 0th.  <a href="#NL3D_1_1CMeshBlockManagery0"></a><br><br></td></tr>
<tr><td colspan=2><br><h2>Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagerd0">allocateMeshVBHeap</a> (<a class="el" href="a02879.html">IMeshGeom</a> *mesh)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Try to allocate a MeshGeom into a specific Heap.  <a href="#NL3D_1_1CMeshBlockManagerd0"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagerd1">render</a> (<a class="el" href="a02877.html">CVBHeapBlock</a> *hb, <a class="el" href="a02879.html">IMeshGeom</a> *meshGeom, std::vector&lt; <a class="el" href="a02876.html">CInstanceInfo</a> &gt; &amp;rdrInstances)</td></tr>

<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02887.html">CMeshGeomRenderContext</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagerr0">_RenderCtx</a></td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector&lt; <a class="el" href="a02877.html">CVBHeapBlock</a> * &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a></td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagery0">TVBHeapMap</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagerr2">_VBHeapMap</a></td></tr>

</table>
<hr><h2>Member Typedef Documentation</h2>
<a class="anchor" name="NL3D_1_1CMeshBlockManagery0" doxytag="NL3D::CMeshBlockManager::TVBHeapMap" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> typedef std::map&lt;<a class="el" href="a04558.html#a15">uint</a>, <a class="el" href="a04558.html#a15">uint</a>&gt; <a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagery0">NL3D::CMeshBlockManager::TVBHeapMap</a><code> [private]</code>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Heap Map from vertexFormat to VBHeap Id. NB: do not contains 0th. 
<p>

<p>
Definition at line <a class="el" href="a05998.html#l00122">122</a> of file <a class="el" href="a05998.html">mesh_block_manager.h</a>.    </td>
  </tr>
</table>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="NL3D_1_1CMeshBlockManagera1" doxytag="NL3D::CMeshBlockManager::CMeshBlockManager" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> NL3D::CMeshBlockManager::CMeshBlockManager </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Constructor. 
<p>

<p>
Definition at line <a class="el" href="a05997.html#l00044">44</a> of file <a class="el" href="a05997.html">mesh_block_manager.cpp</a>.
<p>
References <a class="el" href="a05998.html#l00137">_RenderCtx</a>, <a class="el" href="a05998.html#l00128">_VBHeapBlocks</a>, <a class="el" href="a06000.html#l00062">NL3D::CMeshGeomRenderContext::Driver</a>, <a class="el" href="a06000.html#l00064">NL3D::CMeshGeomRenderContext::RenderTrav</a>, and <a class="el" href="a06000.html#l00063">NL3D::CMeshGeomRenderContext::Scene</a>.
<p>
<div class="fragment"><pre>00045 {
00046         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr0">_RenderCtx</a>.Driver= NULL;
00047         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr0">_RenderCtx</a>.Scene= NULL;
00048         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr0">_RenderCtx</a>.RenderTrav= NULL;
00049 
00050         <span class="comment">// Allocate at least the 0th heap</span>
00051         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>.resize(1);
00052         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>[0]= <span class="keyword">new</span> CVBHeapBlock;
00053         <span class="comment">// some reserve, avoiding first reallocation.</span>
00054         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>[0]-&gt;RdrInstances.reserve(100);
00055         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>[0]-&gt;RdrMeshGeoms.reserve(100);
00056 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CMeshBlockManagera3" doxytag="NL3D::CMeshBlockManager::~CMeshBlockManager" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> NL3D::CMeshBlockManager::~<a class="el" href="a02875.html">CMeshBlockManager</a> </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a05997.html#l00059">59</a> of file <a class="el" href="a05997.html">mesh_block_manager.cpp</a>.
<p>
References <a class="el" href="a05998.html#l00128">_VBHeapBlocks</a>, and <a class="el" href="a05997.html#l00359">releaseVBHeaps()</a>.
<p>
<div class="fragment"><pre>00060 {
00061         <span class="comment">// must release any user heap.</span>
00062         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerz453_2">releaseVBHeaps</a>();
00063         <span class="comment">// Release the 0th one.</span>
00064         <span class="keyword">delete</span> <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>[0];
00065         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>.clear();
00066 }
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NL3D_1_1CMeshBlockManagera0" doxytag="NL3D::CMeshBlockManager::addInstance" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NL3D::CMeshBlockManager::addInstance </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a02879.html">IMeshGeom</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>meshGeom</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a02873.html">CMeshBaseInstance</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>inst</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float&nbsp;</td>
          <td class="mdname" nowrap> <em>polygonCount</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Add an instance of a MeshGeom to render. Only <a class="el" href="a02873.html">CMeshBaseInstance</a> can be added. For now, only <a class="el" href="a02878.html">CMeshGeom</a> and <a class="el" href="a02892.html">CMeshMRMGeom</a> are known to work.
<p>
Definition at line <a class="el" href="a05997.html#l00069">69</a> of file <a class="el" href="a05997.html">mesh_block_manager.cpp</a>.
<p>
References <a class="el" href="a06000.html#l00231">NL3D::IMeshGeom::_MeshBlockManager</a>, <a class="el" href="a06000.html#l00233">NL3D::IMeshGeom::_MeshVBHeapId</a>, <a class="el" href="a06000.html#l00228">NL3D::IMeshGeom::_RootInstanceId</a>, <a class="el" href="a05998.html#l00128">_VBHeapBlocks</a>, <a class="el" href="a05997.html#l00274">allocateMeshVBHeap()</a>, <a class="el" href="a05998.html#l00098">NL3D::CMeshBlockManager::CInstanceInfo::MBI</a>, <a class="el" href="a05998.html#l00097">NL3D::CMeshBlockManager::CInstanceInfo::MeshGeom</a>, <a class="el" href="a05998.html#l00101">NL3D::CMeshBlockManager::CInstanceInfo::NextInstance</a>, <a class="el" href="a05997.html#l00040">NL3D_MBM_VBHEAP_HEAP_MASK</a>, <a class="el" href="a05998.html#l00099">NL3D::CMeshBlockManager::CInstanceInfo::PolygonCount</a>, <a class="el" href="a05998.html#l00108">NL3D::CMeshBlockManager::CVBHeapBlock::RdrInstances</a>, and <a class="el" href="a05998.html#l00111">NL3D::CMeshBlockManager::CVBHeapBlock::RdrMeshGeoms</a>.
<p>
Referenced by <a class="el" href="a06570.html#l00178">NL3D::CTransformShape::traverseRender()</a>.
<p>
<div class="fragment"><pre>00070 {
00071         <span class="comment">// If the meshGeom has never been added to the manager, may do some precalc</span>
00072         <span class="keywordflow">if</span>(meshGeom-&gt;_MeshBlockManager==NULL)
00073         {
00074                 <span class="comment">// Fill </span>
00075                 meshGeom-&gt;_MeshBlockManager= <span class="keyword">this</span>;
00076                 <span class="comment">// try to fit the meshGeom in one of our VBHeap.</span>
00077                 <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerd0">allocateMeshVBHeap</a>(meshGeom);
00078         }
00079 
00080         <span class="comment">// TestYoyo</span>
00081         <span class="comment">/*extern uint   TEMP_Yoyo_NInstVBHeap;</span>
00082 <span class="comment">        extern uint     TEMP_Yoyo_NInstNoVBHeap;</span>
00083 <span class="comment">        if( meshGeom-&gt;_MeshVBHeapId &amp; NL3D_MBM_VBHEAP_HEAP_MASK )</span>
00084 <span class="comment">                TEMP_Yoyo_NInstVBHeap++; </span>
00085 <span class="comment">        else</span>
00086 <span class="comment">                TEMP_Yoyo_NInstNoVBHeap++;*/</span>
00087         <span class="comment">// End TestYoyo</span>
00088 
00089         <span class="comment">// Choose the HeapBlock to fit in.</span>
00090         CVBHeapBlock    *hb= <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>[meshGeom-&gt;_MeshVBHeapId &amp; <a class="code" href="a04574.html#a3">NL3D_MBM_VBHEAP_HEAP_MASK</a>];
00091 
00092         <span class="comment">// If the mesh geom is not added to this manager, add it.</span>
00093         <span class="keywordflow">if</span>(meshGeom-&gt;_RootInstanceId==-1)
00094         {
00095                 hb-&gt;RdrMeshGeoms.push_back(meshGeom);
00096         }
00097 
00098         <span class="comment">// setup the instance.</span>
00099         CInstanceInfo           instInfo;
00100         instInfo.MeshGeom= meshGeom;
00101         instInfo.MBI= inst;
00102         instInfo.PolygonCount= polygonCount;
00103 
00104         <span class="comment">// link to the head of the list.</span>
00105         instInfo.NextInstance= meshGeom-&gt;_RootInstanceId;
00106         meshGeom-&gt;_RootInstanceId= hb-&gt;RdrInstances.size();
00107 
00108         <span class="comment">// add this instance</span>
00109         hb-&gt;RdrInstances.push_back(instInfo);
00110 
00111 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CMeshBlockManagerz453_0" doxytag="NL3D::CMeshBlockManager::addVBHeap" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> bool NL3D::CMeshBlockManager::addVBHeap </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a02434.html">IDriver</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>drv</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>vertexFormat</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>maxVertices</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Add a Heap for a given vertexFormat. Any meshGeom added with <a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagera0">addInstance()</a> which has this vertex Format may fit in this heap. return false and fail if the heap can't be allocated or if the heap with same vertexFormat still exist.
<p>
Definition at line <a class="el" href="a05997.html#l00393">393</a> of file <a class="el" href="a05997.html">mesh_block_manager.cpp</a>.
<p>
References <a class="el" href="a05998.html#l00128">_VBHeapBlocks</a>, <a class="el" href="a05998.html#l00123">_VBHeapMap</a>, <a class="el" href="a06714.html#l00056">NL3D::CVertexBufferHeap::init()</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05998.html#l00114">NL3D::CMeshBlockManager::CVBHeapBlock::VBHeap</a>.
<p>
<div class="fragment"><pre>00394 {
00395         <span class="comment">// if find an existing vertexFormat, abort.</span>
00396         TVBHeapMap::iterator    it= <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr2">_VBHeapMap</a>.find(vertexFormat);
00397         <span class="comment">// if found, abort</span>
00398         <span class="keywordflow">if</span>( it!=<a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr2">_VBHeapMap</a>.end() )
00399                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00400 
00401         <span class="comment">// create the block</span>
00402         CVBHeapBlock    *hb= <span class="keyword">new</span> CVBHeapBlock;
00403 
00404         <span class="comment">// allocate vertex space</span>
00405         hb-&gt;VBHeap.init(drv, vertexFormat, maxVertices);
00406 
00407         <span class="comment">// add an entry to the array, and the map.</span>
00408         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>.push_back(hb);
00409         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr2">_VBHeapMap</a>[vertexFormat]= <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>.size()-1;
00410 
00411         <span class="keywordflow">return</span> <span class="keyword">true</span>;
00412 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CMeshBlockManagerd0" doxytag="NL3D::CMeshBlockManager::allocateMeshVBHeap" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NL3D::CMeshBlockManager::allocateMeshVBHeap </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a02879.html">IMeshGeom</a> *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>mesh</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [private]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Try to allocate a MeshGeom into a specific Heap. 
<p>

<p>
Definition at line <a class="el" href="a05997.html#l00274">274</a> of file <a class="el" href="a05997.html">mesh_block_manager.cpp</a>.
<p>
References <a class="el" href="a06000.html#l00233">NL3D::IMeshGeom::_MeshVBHeapId</a>, <a class="el" href="a06000.html#l00235">NL3D::IMeshGeom::_MeshVBHeapIndexStart</a>, <a class="el" href="a06000.html#l00237">NL3D::IMeshGeom::_MeshVBHeapNumVertices</a>, <a class="el" href="a05998.html#l00128">_VBHeapBlocks</a>, <a class="el" href="a05998.html#l00123">_VBHeapMap</a>, <a class="el" href="a06714.html#l00125">NL3D::CVertexBufferHeap::allocate()</a>, <a class="el" href="a05998.html#l00116">NL3D::CMeshBlockManager::CVBHeapBlock::AllocatedMeshGeoms</a>, <a class="el" href="a06000.html#l00207">NL3D::IMeshGeom::computeMeshVBHeap()</a>, <a class="el" href="a05998.html#l00118">NL3D::CMeshBlockManager::CVBHeapBlock::FreeIds</a>, <a class="el" href="a06000.html#l00200">NL3D::IMeshGeom::getVBHeapInfo()</a>, <a class="el" href="a06714.html#l00153">NL3D::CVertexBufferHeap::lock()</a>, <a class="el" href="a05997.html#l00038">NL3D_MBM_VBHEAP_MESH_SHIFT</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05981.html#l00096">uint8</a>, <a class="el" href="a06714.html#l00171">NL3D::CVertexBufferHeap::unlock()</a>, and <a class="el" href="a05998.html#l00114">NL3D::CMeshBlockManager::CVBHeapBlock::VBHeap</a>.
<p>
Referenced by <a class="el" href="a05997.html#l00069">addInstance()</a>.
<p>
<div class="fragment"><pre>00275 {
00276         <span class="comment">// Get info from mesh. </span>
00277         <a class="code" href="a04558.html#a15">uint</a> vertexFormat, numVertices;
00278         <span class="comment">// if the mesh do not support VBHeap, quit.</span>
00279         <span class="keywordflow">if</span>( !mesh-&gt;getVBHeapInfo(vertexFormat, numVertices) )
00280                 <span class="keywordflow">return</span>;
00281 
00282         <span class="comment">// In case of ...</span>
00283         <span class="keywordflow">if</span>( numVertices==0 )
00284                 <span class="keywordflow">return</span>;
00285 
00286         <span class="comment">// try to find a VBHeap with this vertexFormat.</span>
00287         TVBHeapMap::iterator    it= <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr2">_VBHeapMap</a>.find(vertexFormat);
00288         <span class="comment">// if not found, abort</span>
00289         <span class="keywordflow">if</span>(it==<a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr2">_VBHeapMap</a>.end())
00290                 <span class="keywordflow">return</span>;
00291 
00292         <span class="comment">// access to this VBHeap.</span>
00293         <a class="code" href="a04558.html#a15">uint</a>    vbHeapId= it-&gt;second;
00294         CVBHeapBlock    *vbHeapBlock= <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>[vbHeapId];
00295         <span class="comment">// try to allocate sapce into the heap. Fail=&gt; abort.</span>
00296         <a class="code" href="a04558.html#a15">uint</a>    indexStart;
00297         <span class="keywordflow">if</span>( !vbHeapBlock-&gt;VBHeap.allocate(numVertices, indexStart) )
00298                 <span class="keywordflow">return</span>;
00299 
00300         <span class="comment">// All is Ok here =&gt; setup infos.</span>
00301         <span class="comment">//==================</span>
00302 
00303         <span class="comment">// Keep track of the mesh =&gt; allocate.</span>
00304         <a class="code" href="a04558.html#a15">uint</a>    meshId;
00305         <span class="comment">// try to get a free id.</span>
00306         <span class="keywordflow">if</span>( !vbHeapBlock-&gt;FreeIds.empty() )
00307         {
00308                 meshId= vbHeapBlock-&gt;FreeIds.back();
00309                 vbHeapBlock-&gt;FreeIds.pop_back();
00310                 vbHeapBlock-&gt;AllocatedMeshGeoms[meshId]= mesh;
00311         }
00312         <span class="comment">// else, must add to the array</span>
00313         <span class="keywordflow">else</span>
00314         {
00315                 meshId= vbHeapBlock-&gt;AllocatedMeshGeoms.size();
00316                 vbHeapBlock-&gt;AllocatedMeshGeoms.push_back(mesh);
00317         }
00318 
00319         <span class="comment">// info for delete in mesh</span>
00320         mesh-&gt;_MeshVBHeapIndexStart= indexStart;
00321         mesh-&gt;_MeshVBHeapId= vbHeapId + (meshId&lt;&lt;<a class="code" href="a04574.html#a1">NL3D_MBM_VBHEAP_MESH_SHIFT</a>);
00322         mesh-&gt;_MeshVBHeapNumVertices= numVertices;
00323 
00324 
00325         <span class="comment">// Fill VB.</span>
00326         <span class="comment">//==================</span>
00327         <a class="code" href="a04558.html#a7">uint8</a>   *dst= vbHeapBlock-&gt;VBHeap.lock(indexStart);
00328         mesh-&gt;computeMeshVBHeap(dst, indexStart);
00329         <span class="comment">// unlock only what vertices have changed (ATI problem)</span>
00330         vbHeapBlock-&gt;VBHeap.unlock(indexStart, indexStart+numVertices);
00331 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CMeshBlockManagera2" doxytag="NL3D::CMeshBlockManager::flush" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NL3D::CMeshBlockManager::flush </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a02434.html">IDriver</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>drv</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a03348.html">CScene</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>scene</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a03325.html">CRenderTrav</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>renderTrav</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Flush the manager and effectively render.
<p>
Definition at line <a class="el" href="a05997.html#l00114">114</a> of file <a class="el" href="a05997.html">mesh_block_manager.cpp</a>.
<p>
References <a class="el" href="a05998.html#l00137">_RenderCtx</a>, <a class="el" href="a05998.html#l00128">_VBHeapBlocks</a>, <a class="el" href="a06714.html#l00179">NL3D::CVertexBufferHeap::activate()</a>, <a class="el" href="a06000.html#l00062">NL3D::CMeshGeomRenderContext::Driver</a>, <a class="el" href="a05788.html#l00056">H_AUTO</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05998.html#l00108">NL3D::CMeshBlockManager::CVBHeapBlock::RdrInstances</a>, <a class="el" href="a05998.html#l00111">NL3D::CMeshBlockManager::CVBHeapBlock::RdrMeshGeoms</a>, <a class="el" href="a05997.html#l00177">render()</a>, <a class="el" href="a06000.html#l00066">NL3D::CMeshGeomRenderContext::RenderThroughVBHeap</a>, <a class="el" href="a06000.html#l00064">NL3D::CMeshGeomRenderContext::RenderTrav</a>, <a class="el" href="a06000.html#l00063">NL3D::CMeshGeomRenderContext::Scene</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05998.html#l00114">NL3D::CMeshBlockManager::CVBHeapBlock::VBHeap</a>.
<p>
Referenced by <a class="el" href="a06329.html#l00089">NL3D::CRenderTrav::traverse()</a>.
<p>
<div class="fragment"><pre>00115 {
00116         <a class="code" href="a04558.html#a15">uint</a>    i,j;
00117 
00118         <a class="code" href="a04365.html#a4">H_AUTO</a>( NL3D_MeshBlockManager );
00119 
00120         <span class="comment">// setup the manager</span>
00121         <a class="code" href="a04199.html#a6">nlassert</a>(drv &amp;&amp; scene &amp;&amp; renderTrav);
00122         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr0">_RenderCtx</a>.Driver= drv;
00123         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr0">_RenderCtx</a>.Scene= scene;
00124         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr0">_RenderCtx</a>.RenderTrav= renderTrav;
00125         
00126         <span class="comment">// render</span>
00127         <span class="comment">//==========</span>
00128 
00129         <span class="comment">// sort by Heap first =&gt; small setup of VBs.</span>
00130         <span class="keywordflow">for</span>(j=0; j&lt;<a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>.size();j++)
00131         {
00132                 CVBHeapBlock    *hb= <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>[j];
00133                 <span class="comment">// if not the special 0th heap, must activate VB.</span>
00134                 <span class="keywordflow">if</span>(j==0)
00135                 {
00136                         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr0">_RenderCtx</a>.RenderThroughVBHeap= <span class="keyword">false</span>;
00137                 }
00138                 <span class="keywordflow">else</span>
00139                 {
00140                         <span class="comment">// set to true =&gt; avoid mesh to setup their own VB.</span>
00141                         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr0">_RenderCtx</a>.RenderThroughVBHeap= <span class="keyword">true</span>;
00142                         <span class="comment">// activate current VB in driver</span>
00143                         hb-&gt;VBHeap.activate();
00144                 }
00145 
00146 
00147                 <span class="comment">// Always sort by MeshGeom, in this heap</span>
00148                 <span class="keywordflow">for</span>(i=0; i&lt;hb-&gt;RdrMeshGeoms.size();i++)
00149                 {
00150                         <span class="comment">// render the meshGeom and his instances</span>
00151                         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerd1">render</a>(hb, hb-&gt;RdrMeshGeoms[i], hb-&gt;RdrInstances);
00152                 }
00153         }
00154 
00155         <span class="comment">// reset.</span>
00156         <span class="comment">//==========</span>
00157 
00158         <span class="comment">// For all vb heaps</span>
00159         <span class="keywordflow">for</span>(j=0; j&lt;<a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>.size();j++)
00160         {
00161                 CVBHeapBlock    *hb= <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>[j];
00162 
00163                 <span class="comment">// Parse all MehsGeoms, and flag them as Not Added to me</span>
00164                 <span class="keywordflow">for</span>(i=0; i&lt;hb-&gt;RdrMeshGeoms.size();i++)
00165                 {
00166                         hb-&gt;RdrMeshGeoms[i]-&gt;_RootInstanceId= -1;
00167                 }
00168 
00169                 <span class="comment">// clear rdr arrays</span>
00170                 hb-&gt;RdrInstances.clear();
00171                 hb-&gt;RdrMeshGeoms.clear();
00172         }
00173 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CMeshBlockManagerz453_1" doxytag="NL3D::CMeshBlockManager::freeMeshVBHeap" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NL3D::CMeshBlockManager::freeMeshVBHeap </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a02879.html">IMeshGeom</a> *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>mesh</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Called by ~IMeshGeom(). 
<p>

<p>
Definition at line <a class="el" href="a05997.html#l00334">334</a> of file <a class="el" href="a05997.html">mesh_block_manager.cpp</a>.
<p>
References <a class="el" href="a06000.html#l00233">NL3D::IMeshGeom::_MeshVBHeapId</a>, <a class="el" href="a06000.html#l00235">NL3D::IMeshGeom::_MeshVBHeapIndexStart</a>, <a class="el" href="a05998.html#l00128">_VBHeapBlocks</a>, <a class="el" href="a05998.html#l00116">NL3D::CMeshBlockManager::CVBHeapBlock::AllocatedMeshGeoms</a>, <a class="el" href="a06714.html#l00142">NL3D::CVertexBufferHeap::free()</a>, <a class="el" href="a05998.html#l00118">NL3D::CMeshBlockManager::CVBHeapBlock::FreeIds</a>, <a class="el" href="a05997.html#l00040">NL3D_MBM_VBHEAP_HEAP_MASK</a>, <a class="el" href="a05997.html#l00039">NL3D_MBM_VBHEAP_MESH_MASK</a>, <a class="el" href="a05997.html#l00038">NL3D_MBM_VBHEAP_MESH_SHIFT</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05998.html#l00114">NL3D::CMeshBlockManager::CVBHeapBlock::VBHeap</a>.
<p>
Referenced by <a class="el" href="a05997.html#l00359">releaseVBHeaps()</a>, and <a class="el" href="a05999.html#l00046">NL3D::IMeshGeom::~IMeshGeom()</a>.
<p>
<div class="fragment"><pre>00335 {
00336         <a class="code" href="a04199.html#a6">nlassert</a>(mesh-&gt;_MeshVBHeapId);
00337 
00338         <span class="comment">// unpack heap and mesh id.</span>
00339         <a class="code" href="a04558.html#a15">uint</a>    vbHeapId= mesh-&gt;_MeshVBHeapId &amp; <a class="code" href="a04574.html#a3">NL3D_MBM_VBHEAP_HEAP_MASK</a>;
00340         <a class="code" href="a04558.html#a15">uint</a>    meshId= (mesh-&gt;_MeshVBHeapId &amp; <a class="code" href="a04574.html#a2">NL3D_MBM_VBHEAP_MESH_MASK</a>) &gt;&gt; <a class="code" href="a04574.html#a1">NL3D_MBM_VBHEAP_MESH_SHIFT</a>;
00341 
00342         <span class="comment">// access to this VBHeap.</span>
00343         CVBHeapBlock    *vbHeapBlock= <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>[vbHeapId];
00344 
00345         <span class="comment">// free VB memory.</span>
00346         vbHeapBlock-&gt;VBHeap.free(mesh-&gt;_MeshVBHeapIndexStart);
00347 
00348         <span class="comment">// free this space</span>
00349         <a class="code" href="a04199.html#a6">nlassert</a>(meshId&lt;vbHeapBlock-&gt;AllocatedMeshGeoms.size());
00350         vbHeapBlock-&gt;AllocatedMeshGeoms[meshId]= NULL;
00351         vbHeapBlock-&gt;FreeIds.push_back(meshId);
00352 
00353         <span class="comment">// reset mesh info.</span>
00354         mesh-&gt;_MeshVBHeapId= 0;
00355         mesh-&gt;_MeshVBHeapIndexStart= 0;
00356 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CMeshBlockManagerz453_2" doxytag="NL3D::CMeshBlockManager::releaseVBHeaps" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NL3D::CMeshBlockManager::releaseVBHeaps </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
release all Heaps =&gt; clear memory of meshs registered. 
<p>

<p>
Definition at line <a class="el" href="a05997.html#l00359">359</a> of file <a class="el" href="a05997.html">mesh_block_manager.cpp</a>.
<p>
References <a class="el" href="a05998.html#l00128">_VBHeapBlocks</a>, <a class="el" href="a05998.html#l00123">_VBHeapMap</a>, <a class="el" href="a05998.html#l00116">NL3D::CMeshBlockManager::CVBHeapBlock::AllocatedMeshGeoms</a>, <a class="el" href="a05997.html#l00334">freeMeshVBHeap()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a05997.html#l00059">~CMeshBlockManager()</a>.
<p>
<div class="fragment"><pre>00360 {
00361         <a class="code" href="a04558.html#a15">uint</a>    i,j;
00362 
00363         <span class="comment">// For all blocks but the 0th</span>
00364         <span class="keywordflow">for</span>(j=1; j&lt;<a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>.size();j++)
00365         {
00366                 CVBHeapBlock    *hb= <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>[j];
00367 
00368                 <span class="comment">// For all allocated mesh of this heap.</span>
00369                 <span class="keywordflow">for</span>(i=0;i&lt;hb-&gt;AllocatedMeshGeoms.size();i++)
00370                 {
00371                         IMeshGeom       *mesh= hb-&gt;AllocatedMeshGeoms[i];
00372                         <span class="comment">// if the mesh exist.</span>
00373                         <span class="keywordflow">if</span>(mesh)
00374                         {
00375                                 <span class="comment">// free his VBHeap Data.</span>
00376                                 <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerz453_1">freeMeshVBHeap</a>(mesh);
00377                                 <a class="code" href="a04199.html#a6">nlassert</a>( hb-&gt;AllocatedMeshGeoms[i] == NULL );
00378                         }
00379                 }
00380 
00381                 <span class="comment">// delete the block. NB: VBHeap auto released</span>
00382                 <span class="keyword">delete</span> hb;
00383         }
00384 
00385         <span class="comment">// erase all blocks but 0th</span>
00386         <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">_VBHeapBlocks</a>.resize(1);
00387 
00388         <span class="comment">// clear the map.</span>
00389         <a class="code" href="a05378.html#a381">contReset</a>(_VBHeapMap);
00390 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CMeshBlockManagerd1" doxytag="NL3D::CMeshBlockManager::render" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NL3D::CMeshBlockManager::render </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a02877.html">CVBHeapBlock</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>hb</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a02879.html">IMeshGeom</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>meshGeom</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>std::vector&lt; <a class="el" href="a02876.html">CInstanceInfo</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>rdrInstances</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [private]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a05997.html#l00177">177</a> of file <a class="el" href="a05997.html">mesh_block_manager.cpp</a>.
<p>
References <a class="el" href="a06000.html#l00235">NL3D::IMeshGeom::_MeshVBHeapIndexStart</a>, <a class="el" href="a06000.html#l00237">NL3D::IMeshGeom::_MeshVBHeapNumVertices</a>, <a class="el" href="a05998.html#l00137">_RenderCtx</a>, <a class="el" href="a06000.html#l00228">NL3D::IMeshGeom::_RootInstanceId</a>, <a class="el" href="a02879.html#NL3D_1_1IMeshGeomz457_0">NL3D::IMeshGeom::activeInstance()</a>, <a class="el" href="a02879.html#NL3D_1_1IMeshGeomz457_1">NL3D::IMeshGeom::beginMesh()</a>, <a class="el" href="a02879.html#NL3D_1_1IMeshGeomz457_3">NL3D::IMeshGeom::endMesh()</a>, <a class="el" href="a02879.html#NL3D_1_1IMeshGeomz457_4">NL3D::IMeshGeom::getNumRdrPassesForInstance()</a>, <a class="el" href="a02879.html#NL3D_1_1IMeshGeomz457_5">NL3D::IMeshGeom::getNumRdrPassesForMesh()</a>, <a class="el" href="a06000.html#l00212">NL3D::IMeshGeom::isActiveInstanceNeedVBFill()</a>, <a class="el" href="a06714.html#l00153">NL3D::CVertexBufferHeap::lock()</a>, <a class="el" href="a05998.html#l00098">NL3D::CMeshBlockManager::CInstanceInfo::MBI</a>, <a class="el" href="a05998.html#l00101">NL3D::CMeshBlockManager::CInstanceInfo::NextInstance</a>, <a class="el" href="a05998.html#l00099">NL3D::CMeshBlockManager::CInstanceInfo::PolygonCount</a>, <a class="el" href="a02879.html#NL3D_1_1IMeshGeomz457_9">NL3D::IMeshGeom::renderPass()</a>, <a class="el" href="a06000.html#l00066">NL3D::CMeshGeomRenderContext::RenderThroughVBHeap</a>, <a class="el" href="a05981.html#l00099">sint32</a>, <a class="el" href="a02879.html#NL3D_1_1IMeshGeomz457_10">NL3D::IMeshGeom::sortPerMaterial()</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a06714.html#l00171">NL3D::CVertexBufferHeap::unlock()</a>, and <a class="el" href="a05998.html#l00114">NL3D::CMeshBlockManager::CVBHeapBlock::VBHeap</a>.
<p>
Referenced by <a class="el" href="a05997.html#l00114">flush()</a>.
<p>
<div class="fragment"><pre>00178 {
00179         <span class="comment">// TestYoyo</span>
00180         <span class="comment">/*extern uint TEMP_Yoyo_NMeshVBHeap;</span>
00181 <span class="comment">        extern uint TEMP_Yoyo_NMeshNoVBHeap;</span>
00182 <span class="comment">        if( _RenderCtx.RenderThroughVBHeap )</span>
00183 <span class="comment">                TEMP_Yoyo_NMeshVBHeap++;</span>
00184 <span class="comment">        else</span>
00185 <span class="comment">                TEMP_Yoyo_NMeshNoVBHeap++;*/</span>
00186         <span class="comment">// End TestYoyo</span>
00187 
00188         <span class="comment">// Start for this mesh.</span>
00189         meshGeom-&gt;beginMesh(_RenderCtx);
00190 
00191 
00192         <span class="comment">// sort per material first?</span>
00193         <span class="keywordflow">if</span>( meshGeom-&gt;sortPerMaterial() )
00194         {
00195                 <span class="comment">// number of renderPasses for this mesh.</span>
00196                 <a class="code" href="a04558.html#a15">uint</a>    numRdrPass= meshGeom-&gt;getNumRdrPassesForMesh();
00197 
00198                 <span class="comment">// for all material.</span>
00199                 <span class="keywordflow">for</span>(<a class="code" href="a04558.html#a15">uint</a> rdrPass=0;rdrPass&lt;numRdrPass;rdrPass++)
00200                 {
00201                         <span class="comment">// for all instance.</span>
00202                         <a class="code" href="a04558.html#a10">sint32</a>  instId= meshGeom-&gt;_RootInstanceId;
00203                         <span class="keywordflow">while</span>( instId!=-1 )
00204                         {
00205                                 CInstanceInfo           &amp;instInfo= rdrInstances[instId];
00206 
00207                                 <span class="comment">// activate this instance</span>
00208                                 meshGeom-&gt;activeInstance(_RenderCtx, instInfo.MBI, instInfo.PolygonCount, NULL);
00209 
00210                                 <span class="comment">// render the pass.</span>
00211                                 meshGeom-&gt;renderPass(_RenderCtx, instInfo.MBI, instInfo.PolygonCount, rdrPass);
00212 
00213                                 <span class="comment">// next instance</span>
00214                                 instId= instInfo.NextInstance;
00215                         }
00216                 }
00217         }
00218         <span class="comment">// else sort per instance first</span>
00219         <span class="keywordflow">else</span>
00220         {
00221                 <span class="comment">// for all instance.</span>
00222                 <a class="code" href="a04558.html#a10">sint32</a>  instId= meshGeom-&gt;_RootInstanceId;
00223                 <span class="keywordflow">while</span>( instId!=-1 )
00224                 {
00225                         CInstanceInfo           &amp;instInfo= rdrInstances[instId];
00226 
00227                         <span class="comment">// If the meshGeom need to change Some VB (geomorphs...)</span>
00228                         <span class="keywordtype">bool</span>    needVBHeapLock= <a class="code" href="a02875.html#NL3D_1_1CMeshBlockManagerr0">_RenderCtx</a>.RenderThroughVBHeap &amp;&amp; meshGeom-&gt;isActiveInstanceNeedVBFill();
00229                         <span class="keywordtype">void</span>    *vbDst= NULL;
00230                         <span class="keywordflow">if</span>(needVBHeapLock)
00231                         {
00232                                 <span class="comment">// Lock the VBHeap</span>
00233                                 vbDst= vbHeapBlock-&gt;VBHeap.lock(meshGeom-&gt;_MeshVBHeapIndexStart);
00234                         }
00235 
00236                         <span class="comment">// activate this instance</span>
00237                         meshGeom-&gt;activeInstance(_RenderCtx, instInfo.MBI, instInfo.PolygonCount, vbDst);
00238 
00239                         <span class="keywordflow">if</span>(needVBHeapLock)
00240                         {
00241                                 <span class="comment">// unlock only what vertices have changed (ATI problem)</span>
00242                                 vbHeapBlock-&gt;VBHeap.unlock(meshGeom-&gt;_MeshVBHeapIndexStart, 
00243                                         meshGeom-&gt;_MeshVBHeapIndexStart + meshGeom-&gt;_MeshVBHeapNumVertices);
00244                         }
00245 
00246                         <span class="comment">// number of renderPasses for this mesh.</span>
00247                         <a class="code" href="a04558.html#a15">uint</a>    numRdrPass= meshGeom-&gt;getNumRdrPassesForInstance(instInfo.MBI);
00248 
00249                         <span class="comment">// for all material.</span>
00250                         <span class="keywordflow">for</span>(<a class="code" href="a04558.html#a15">uint</a> rdrPass=0;rdrPass&lt;numRdrPass;rdrPass++)
00251                         {
00252                                 <span class="comment">// render the pass.</span>
00253                                 meshGeom-&gt;renderPass(_RenderCtx, instInfo.MBI, instInfo.PolygonCount, rdrPass);
00254                         }
00255 
00256                         <span class="comment">// next instance</span>
00257                         instId= instInfo.NextInstance;
00258                 }
00259         }
00260 
00261         <span class="comment">// End for this mesh.</span>
00262         meshGeom-&gt;endMesh(_RenderCtx);
00263 }
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Field Documentation</h2>
<a class="anchor" name="NL3D_1_1CMeshBlockManagerr0" doxytag="NL3D::CMeshBlockManager::_RenderCtx" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a02887.html">CMeshGeomRenderContext</a> <a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagerr0">NL3D::CMeshBlockManager::_RenderCtx</a><code> [private]</code>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a05998.html#l00137">137</a> of file <a class="el" href="a05998.html">mesh_block_manager.h</a>.
<p>
Referenced by <a class="el" href="a05997.html#l00044">CMeshBlockManager()</a>, <a class="el" href="a05997.html#l00114">flush()</a>, and <a class="el" href="a05997.html#l00177">render()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CMeshBlockManagerr1" doxytag="NL3D::CMeshBlockManager::_VBHeapBlocks" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> std::vector&lt;<a class="el" href="a02877.html">CVBHeapBlock</a>*&gt; <a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagerr1">NL3D::CMeshBlockManager::_VBHeapBlocks</a><code> [private]</code>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
List of Heaps. NB: 0th heap is special: contains all meshs which can't fit in any VBHeap.
<p>
Definition at line <a class="el" href="a05998.html#l00128">128</a> of file <a class="el" href="a05998.html">mesh_block_manager.h</a>.
<p>
Referenced by <a class="el" href="a05997.html#l00069">addInstance()</a>, <a class="el" href="a05997.html#l00393">addVBHeap()</a>, <a class="el" href="a05997.html#l00274">allocateMeshVBHeap()</a>, <a class="el" href="a05997.html#l00044">CMeshBlockManager()</a>, <a class="el" href="a05997.html#l00114">flush()</a>, <a class="el" href="a05997.html#l00334">freeMeshVBHeap()</a>, <a class="el" href="a05997.html#l00359">releaseVBHeaps()</a>, and <a class="el" href="a05997.html#l00059">~CMeshBlockManager()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CMeshBlockManagerr2" doxytag="NL3D::CMeshBlockManager::_VBHeapMap" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagery0">TVBHeapMap</a> <a class="el" href="a02875.html#NL3D_1_1CMeshBlockManagerr2">NL3D::CMeshBlockManager::_VBHeapMap</a><code> [private]</code>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a05998.html#l00123">123</a> of file <a class="el" href="a05998.html">mesh_block_manager.h</a>.
<p>
Referenced by <a class="el" href="a05997.html#l00393">addVBHeap()</a>, <a class="el" href="a05997.html#l00274">allocateMeshVBHeap()</a>, and <a class="el" href="a05997.html#l00359">releaseVBHeaps()</a>.    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a05998.html">mesh_block_manager.h</a><li><a class="el" href="a05997.html">mesh_block_manager.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 06:51:48 2004 for NeL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
</a>1.3.6 </small></address>
</body>
</html>