aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/patch__lightmap_8cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/patch__lightmap_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/patch__lightmap_8cpp-source.html2061
1 files changed, 2061 insertions, 0 deletions
diff --git a/docs/doxygen/nel/patch__lightmap_8cpp-source.html b/docs/doxygen/nel/patch__lightmap_8cpp-source.html
new file mode 100644
index 00000000..5acad7e2
--- /dev/null
+++ b/docs/doxygen/nel/patch__lightmap_8cpp-source.html
@@ -0,0 +1,2061 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.14 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>patch_lightmap.cpp</h1><a href="patch__lightmap_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
+00008 <font class="comment"> *</font>
+00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00013 <font class="comment"> * any later version.</font>
+00014 <font class="comment"></font>
+00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00018 <font class="comment"> * General Public License for more details.</font>
+00019 <font class="comment"></font>
+00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00023 <font class="comment"> * MA 02111-1307, USA.</font>
+00024 <font class="comment"> */</font>
+00025
+00026
+00027 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
+00028
+00029
+00030 <font class="preprocessor">#include "<a class="code" href="patch_8h.html">3d/patch.h</a>"</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="bezier__patch_8h.html">3d/bezier_patch.h</a>"</font>
+00033 <font class="preprocessor">#include "<a class="code" href="src_23d_2zone_8h.html">3d/zone.h</a>"</font>
+00034 <font class="preprocessor">#include "<a class="code" href="landscape_8h.html">3d/landscape.h</a>"</font>
+00035 <font class="preprocessor">#include "<a class="code" href="vector_8h.html">nel/misc/vector.h</a>"</font>
+00036 <font class="preprocessor">#include "<a class="code" href="common_8h.html">nel/misc/common.h</a>"</font>
+00037 <font class="preprocessor">#include "<a class="code" href="patchuv__locator_8h.html">3d/patchuv_locator.h</a>"</font>
+00038 <font class="preprocessor">#include "<a class="code" href="vegetable__manager_8h.html">3d/vegetable_manager.h</a>"</font>
+00039 <font class="preprocessor">#include "<a class="code" href="fast__floor_8h.html">3d/fast_floor.h</a>"</font>
+00040 <font class="preprocessor">#include "<a class="code" href="light__influence__interpolator_8h.html">3d/light_influence_interpolator.h</a>"</font>
+00041 <font class="preprocessor">#include "<a class="code" href="patchdlm__context_8h.html">3d/patchdlm_context.h</a>"</font>
+00042 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00043 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00044
+00045
+00046 <font class="keyword">namespace </font>NL3D
+00047 {
+00048
+00049
+00050 <font class="comment">// ***************************************************************************</font>
+00051 <font class="comment">// Precalc table used to decompress shadow map</font>
+00052 <font class="comment">// NB: if you want to change thoses values, see unpackLumelBlock, cause hardcoded.</font>
+00053 <font class="keyword">static</font> <font class="keyword">const</font> uint <a class="code" href="namespaceNL3D.html#a173">NL3DDecompressLumelFactor0Case0</a>[8]=
+00054 {
+00055 7, 0, 6, 5, 4, 3, 2, 1
+00056 };
+00057 <font class="keyword">static</font> <font class="keyword">const</font> uint <a class="code" href="namespaceNL3D.html#a174">NL3DDecompressLumelFactor1Case0</a>[8]=
+00058 {
+00059 0, 7, 1, 2, 3, 4, 5, 6
+00060 };
+00061 <font class="keyword">static</font> <font class="keyword">const</font> uint <a class="code" href="namespaceNL3D.html#a175">NL3DDecompressLumelFactor0Case1</a>[6]=
+00062 {
+00063 5, 0, 4, 3, 2, 1,
+00064 };
+00065 <font class="keyword">static</font> <font class="keyword">const</font> uint <a class="code" href="namespaceNL3D.html#a176">NL3DDecompressLumelFactor1Case1</a>[6]=
+00066 {
+00067 0, 5, 1, 2, 3, 4,
+00068 };
+00069 <font class="comment">// ***************************************************************************</font>
+<a name="l00070"></a><a class="code" href="classNL3D_1_1CPatch.html#c2">00070</a> <font class="keywordtype">void</font> CPatch::unpackLumelBlock (uint8 *dest, <font class="keyword">const</font> uint8 *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>)
+00071 {
+00072 <font class="comment">// Take the two alpha values</font>
+00073 uint alpha0=<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[0];
+00074 uint alpha1=<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[1];
+00075
+00076 <font class="comment">// precompute the 8 possible values, for each possible code.</font>
+00077 <font class="comment">// ------------------</font>
+00078 uint8 values[8];
+00079 <font class="comment">// Case 0</font>
+00080 <font class="keywordflow">if</font> (alpha0&gt;alpha1)
+00081 {
+00082 <font class="comment">// unrolled, and hardcoded for faster compute</font>
+00083 values[0]= alpha0;
+00084 values[1]= alpha1;
+00085 values[2]= (uint8) ( (alpha0*219 + alpha1*37 ) &gt;&gt;8 ) ; <font class="comment">// 6*256/7</font>
+00086 values[3]= (uint8) ( (alpha0*183 + alpha1*73 ) &gt;&gt;8 ) ; <font class="comment">// 5*256/7</font>
+00087 values[4]= (uint8) ( (alpha0*146 + alpha1*110) &gt;&gt;8 ) ; <font class="comment">// 4*256/7</font>
+00088 values[5]= (uint8) ( (alpha0*110 + alpha1*146) &gt;&gt;8 ) ; <font class="comment">// 3*256/7</font>
+00089 values[6]= (uint8) ( (alpha0*73 + alpha1*183) &gt;&gt;8 ) ; <font class="comment">// 2*256/7</font>
+00090 values[7]= (uint8) ( (alpha0*37 + alpha1*219) &gt;&gt;8 ) ; <font class="comment">// 1*256/7</font>
+00091 }
+00092 <font class="comment">// Case 1</font>
+00093 <font class="keywordflow">else</font>
+00094 {
+00095 <font class="comment">// unrolled, and hardcoded for faster compute</font>
+00096 values[0]= alpha0;
+00097 values[1]= alpha1;
+00098 values[2]= (uint8) ( (alpha0*205 + alpha1*51 ) &gt;&gt;8 ) ; <font class="comment">// 4*256/5</font>
+00099 values[3]= (uint8) ( (alpha0*154 + alpha1*102) &gt;&gt;8 ) ; <font class="comment">// 3*256/5</font>
+00100 values[4]= (uint8) ( (alpha0*102 + alpha1*154) &gt;&gt;8 ) ; <font class="comment">// 2*256/5</font>
+00101 values[5]= (uint8) ( (alpha0*51 + alpha1*205) &gt;&gt;8 ) ; <font class="comment">// 1*256/5</font>
+00102 values[6]= 0;
+00103 values[7]= 255;
+00104 }
+00105
+00106
+00107 <font class="comment">// For each pixel, set the value according to the code</font>
+00108 <font class="comment">// ------------------</font>
+00109 uint block8Pixs[2];
+00110 <font class="comment">// Split the 48 bits data in 2 24 bits pass.</font>
+00111 block8Pixs[0]= ((uint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[2]&lt;&lt;16) + ((uint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[3]&lt;&lt;8) + ((uint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[4]) ;
+00112 block8Pixs[1]= ((uint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[5]&lt;&lt;16) + ((uint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[6]&lt;&lt;8) + ((uint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[7]) ;
+00113
+00114 <font class="comment">// write all lumels</font>
+00115 <font class="keywordflow">for</font>(uint i=0; i&lt;2; i++)
+00116 {
+00117 uint blockPix= block8Pixs[i];
+00118 <font class="comment">// parse the 8 pixs, and write seq to dest</font>
+00119 <font class="keywordflow">for</font>(uint n=8; n&gt;0; n--, dest++)
+00120 {
+00121 uint code= (blockPix&gt;&gt;21)&amp;0x7;
+00122
+00123 <font class="comment">// read LUT, and store</font>
+00124 *dest= values[code];
+00125
+00126 <font class="comment">// shift the block</font>
+00127 blockPix&lt;&lt;= 3;
+00128 }
+00129 }
+00130
+00131 }
+00132
+00133 <font class="comment">// ***************************************************************************</font>
+00134 <font class="keyword">inline</font> uint8 <a class="code" href="namespaceNL3D.html#a386">getUnpackLumelBlock</a> (<font class="keyword">const</font> uint8 *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, uint pixel)
+00135 {
+00136 <font class="comment">// Offset of the bit</font>
+00137 pixel*=3;
+00138 uint <a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>=(pixel&gt;&gt;3)+2;
+00139 uint bits=pixel&amp;7;
+00140
+00141 <font class="comment">// Uncompress 16 codes</font>
+00142 uint code;
+00143
+00144 <font class="comment">// Get the code</font>
+00145 <font class="keywordflow">if</font> (bits&lt;=5)
+00146 code=(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>]&gt;&gt;(5-bits))&amp;0x7;
+00147 <font class="keywordflow">else</font>
+00148 code= ( (<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>]&lt;&lt;(bits-5)) | (<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>+1]&gt;&gt;(13-bits)) )&amp;0x7;
+00149
+00150 <font class="comment">// Case 0</font>
+00151 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[0]&gt;<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[1])
+00152 {
+00153 <font class="comment">// Decompress the data</font>
+00154 <font class="keywordflow">return</font> (uint8)((<a class="code" href="namespaceNL3D.html#a173">NL3DDecompressLumelFactor0Case0</a>[code]*<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[0]+<a class="code" href="namespaceNL3D.html#a174">NL3DDecompressLumelFactor1Case0</a>[code]*<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[1])/7);
+00155 }
+00156 <font class="comment">// Case 1</font>
+00157 <font class="keywordflow">else</font>
+00158 {
+00159 <font class="comment">// Decompress the data</font>
+00160 <font class="keywordflow">if</font> (code&lt;6)
+00161 <font class="keywordflow">return</font> (uint8)((<a class="code" href="namespaceNL3D.html#a175">NL3DDecompressLumelFactor0Case1</a>[code]*<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[0]+<a class="code" href="namespaceNL3D.html#a176">NL3DDecompressLumelFactor1Case1</a>[code]*<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[1])/5);
+00162 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (code==6)
+00163 <font class="keywordflow">return</font> 0;
+00164 <font class="keywordflow">else</font>
+00165 <font class="keywordflow">return</font> 255;
+00166 }
+00167 }
+00168
+00169 <font class="comment">// ***************************************************************************</font>
+<a name="l00170"></a><a class="code" href="classNL3D_1_1CPatch.html#a34">00170</a> <font class="keywordtype">void</font> CPatch::unpackShadowMap (uint8 *pLumelDest)
+00171 {
+00172 <font class="comment">// Input of compresed data</font>
+00173 uint8 *compressedData=&amp;<a class="code" href="classNL3D_1_1CPatch.html#m3">CompressedLumels</a>[0];
+00174
+00175 <font class="comment">// Number of lumel by lines</font>
+00176 uint lumelCount=<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>;
+00177
+00178 <font class="comment">// Number of block in a line</font>
+00179 <a class="code" href="debug_8h.html#a6">nlassert</a> ((lumelCount&amp;0x3)==0);
+00180 uint numLumelBlock=lumelCount&gt;&gt;2;
+00181
+00182 <font class="comment">// Number of line</font>
+00183 uint lineCount=<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>;
+00184
+00185 <font class="comment">// Number of block line</font>
+00186 <a class="code" href="debug_8h.html#a6">nlassert</a> ((lineCount&amp;0x3)==0);
+00187 uint numLineBlock=lineCount&gt;&gt;2;
+00188
+00189 <font class="comment">// Destination lumel block size</font>
+00190 uint lumelDestBlockSize=4;
+00191
+00192 <font class="comment">// Destination lumel line block size</font>
+00193 uint lumelDestLineBlockSize=lumelCount*lumelDestBlockSize;
+00194
+00195 <font class="comment">// Each line block</font>
+00196 <font class="keywordflow">for</font> (uint lineBlock=0; lineBlock&lt;numLineBlock; lineBlock++)
+00197 {
+00198 uint countVx4=16;
+00199
+00200 <font class="comment">// Block pointer</font>
+00201 uint8 *blockLine=pLumelDest;
+00202
+00203 <font class="comment">// Each lumel block</font>
+00204 <font class="keywordflow">for</font> (uint lumelBlock=0; lumelBlock&lt;numLumelBlock; lumelBlock++)
+00205 {
+00206 <font class="comment">// *** Unpack the block</font>
+00207 uint countU=4;
+00208
+00209 <font class="comment">// Destination lumel</font>
+00210 uint8 *blockDest=blockLine;
+00211
+00212 <font class="comment">// Temp block</font>
+00213 uint8 block[4*4];
+00214
+00215 <font class="comment">// Block unpacking...</font>
+00216 <a class="code" href="classNL3D_1_1CPatch.html#c2">unpackLumelBlock</a> (block, compressedData);
+00217
+00218 <font class="comment">// Copy the lumels</font>
+00219 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&lt;countVx4; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>+=4)
+00220 {
+00221 <font class="keywordflow">for</font> (uint u=0; u&lt;countU; u++)
+00222 {
+00223 <font class="comment">// Copy the lumel</font>
+00224 blockDest[u]=block[<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>+u];
+00225 }
+00226
+00227 <font class="comment">// Next line</font>
+00228 blockDest+=lumelCount;
+00229 }
+00230
+00231 <font class="comment">// Next source block</font>
+00232 compressedData+=<a class="code" href="patch_8h.html#a8">NL_BLOCK_LUMEL_COMPRESSED_SIZE</a>;
+00233
+00234 <font class="comment">// Next block on the line</font>
+00235 blockLine+=lumelDestBlockSize;
+00236 }
+00237
+00238 <font class="comment">// Next line of block</font>
+00239 pLumelDest+=lumelDestLineBlockSize;
+00240 }
+00241 }
+00242
+00243 <font class="comment">// ***************************************************************************</font>
+<a name="l00244"></a><a class="code" href="classNL3D_1_1CPatch.html#c1">00244</a> uint CPatch::evalLumelBlock (<font class="keyword">const</font> uint8 *original, <font class="keyword">const</font> uint8 *unCompressed, uint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)
+00245 {
+00246 <font class="comment">// Sum</font>
+00247 uint sum=0;
+00248
+00249 <font class="comment">// Eval error for each..</font>
+00250 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&lt;<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>++)
+00251 <font class="keywordflow">for</font> (uint u=0; u&lt;<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>; u++)
+00252 {
+00253 sum += abs((sint)original[<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>*4+u]-(sint)unCompressed[<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>*4+u]);
+00254 }
+00255
+00256 <font class="comment">// return the sum</font>
+00257 <font class="keywordflow">return</font> sum;
+00258 }
+00259
+00260 <font class="comment">// ***************************************************************************</font>
+<a name="l00261"></a><a class="code" href="classNL3D_1_1CPatch.html#c0">00261</a> <font class="keywordtype">void</font> CPatch::packLumelBlock (uint8 *dest, <font class="keyword">const</font> uint8 *source, uint8 alpha0, uint8 alpha1)
+00262 {
+00263 <font class="comment">// Precalc the height values..</font>
+00264 uint8 <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>[8];
+00265
+00266 <font class="comment">// For each value</font>
+00267 uint i;
+00268 <font class="keywordflow">for</font> (i=0; i&lt;8; i++)
+00269 {
+00270 <font class="comment">// Case 0 or 1 ?</font>
+00271 <font class="keywordflow">if</font> (alpha0&gt;alpha1)
+00272 <font class="comment">// Case 0</font>
+00273 <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>[i]=(<a class="code" href="namespaceNL3D.html#a173">NL3DDecompressLumelFactor0Case0</a>[i]*alpha0+<a class="code" href="namespaceNL3D.html#a174">NL3DDecompressLumelFactor1Case0</a>[i]*alpha1)/7;
+00274 <font class="keywordflow">else</font>
+00275 {
+00276 <font class="keywordflow">if</font> (i&lt;6)
+00277 <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>[i]=(<a class="code" href="namespaceNL3D.html#a175">NL3DDecompressLumelFactor0Case1</a>[i]*alpha0+<a class="code" href="namespaceNL3D.html#a176">NL3DDecompressLumelFactor1Case1</a>[i]*alpha1)/5;
+00278 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (i==6)
+00279 <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>[i]=0;
+00280 <font class="keywordflow">else</font>
+00281 <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>[i]=255;
+00282 }
+00283 }
+00284
+00285 <font class="comment">// Store alpha value</font>
+00286 dest[0]=alpha0;
+00287 dest[1]=alpha1;
+00288
+00289 <font class="comment">// Clear dest codes</font>
+00290 <font class="keywordflow">for</font> (i=0; i&lt;6; i++)
+00291 {
+00292 <font class="comment">// Clear the code</font>
+00293 dest[2+i]=0;
+00294 }
+00295
+00296 <font class="comment">// For each original select the best</font>
+00297 uint codeOffset=2;
+00298 sint codeShift=5;
+00299 <font class="keywordflow">for</font> (i=0; i&lt;16; i++)
+00300 {
+00301 <font class="comment">// Best dist and code</font>
+00302 uint bestDist=10000;
+00303 uint8 bestCode=0;
+00304
+00305 <font class="comment">// Calc distance</font>
+00306 <font class="keywordflow">for</font> (uint code=0; code&lt;8; code++)
+00307 {
+00308 <font class="comment">// Distance from original value</font>
+00309 uint dist=abs ((sint)(source[i])-(sint)(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>[code]));
+00310
+00311 <font class="comment">// The best ?</font>
+00312 <font class="keywordflow">if</font> (dist&lt;bestDist)
+00313 {
+00314 <font class="comment">// New best</font>
+00315 bestDist=dist;
+00316 bestCode=code;
+00317 }
+00318
+00319 <font class="comment">// Perfect, stop searching</font>
+00320 <font class="keywordflow">if</font> (dist==0)
+00321 <font class="keywordflow">break</font>;
+00322 }
+00323
+00324 <font class="comment">// Store the best</font>
+00325 <font class="keywordflow">if</font> (codeShift&gt;=0)
+00326 dest[codeOffset]|=bestCode&lt;&lt;codeShift;
+00327 <font class="keywordflow">else</font>
+00328 {
+00329 dest[codeOffset]|=bestCode&gt;&gt;(-codeShift);
+00330 dest[codeOffset+1]|=bestCode&lt;&lt;(8+codeShift);
+00331 }
+00332
+00333
+00334 <font class="comment">// Next shift</font>
+00335 codeShift-=3;
+00336 <font class="keywordflow">if</font> (codeShift&lt;=-3)
+00337 {
+00338 codeOffset++;
+00339 codeShift+=8;
+00340 }
+00341 }
+00342 }
+00343
+00344 <font class="comment">// ***************************************************************************</font>
+<a name="l00345"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_17">00345</a> <font class="keywordtype">void</font> CPatch::getTileTileColors(uint ts, uint tt, CRGBA corners[4])
+00346 {
+00347 <font class="keywordflow">for</font>(sint i=0;i&lt;4;i++)
+00348 {
+00349 CTileColor &amp;tcol= <a class="code" href="classNL3D_1_1CPatch.html#m5">TileColors</a>[ (tt+(i&gt;&gt;1))*(<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>+1) + (ts+(i&amp;1)) ];
+00350 CRGBA &amp;col= corners[i];
+00351 col.set565 (tcol.Color565);
+00352 }
+00353 }
+00354
+00355
+00356 <font class="comment">// ***************************************************************************</font>
+00357 <font class="comment">// bilinear at center of the pixels. x E [0, 3], y E [0, 3].</font>
+00358 <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a387">bilinearColor</a>(CRGBA corners[4], uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, uint &amp;R, uint &amp;G, uint &amp;B)
+00359 {
+00360 <font class="comment">// Fast bilinear and modulate. </font>
+00361 <font class="comment">// \todo yoyo: TODO_OPTIMIZE: should be ASMed later. (MMX...)</font>
+00362 <font class="comment">// hardcoded for 4 pixels.</font>
+00363 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>==4);
+00364
+00365 <font class="comment">// expand to be on center of pixel=&gt; 1,3,5 or 7.</font>
+00366 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;&lt;1)+1;
+00367 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;&lt;1)+1;
+00368 uint x1= 8-<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
+00369 uint y1= 8-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+00370
+00371 <font class="comment">// compute weight factors.</font>
+00372 uint xy= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+00373 uint x1y= x1*<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+00374 uint xy1= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*y1;
+00375 uint x1y1= x1*y1;
+00376
+00377 <font class="comment">// bilinear</font>
+00378 <font class="comment">// pix left top.</font>
+00379 R = corners[0].R * x1y1;
+00380 G = corners[0].G * x1y1;
+00381 B = corners[0].B * x1y1;
+00382 <font class="comment">// pix right top.</font>
+00383 R+= corners[1].R * xy1;
+00384 G+= corners[1].G * xy1;
+00385 B+= corners[1].B * xy1;
+00386 <font class="comment">// pix left bottom.</font>
+00387 R+= corners[2].R * x1y;
+00388 G+= corners[2].G * x1y;
+00389 B+= corners[2].B * x1y;
+00390 <font class="comment">// pix right bottom.</font>
+00391 R+= corners[3].R * xy;
+00392 G+= corners[3].G * xy;
+00393 B+= corners[3].B * xy;
+00394
+00395 }
+00396
+00397
+00398 <font class="comment">// ***************************************************************************</font>
+00399 <font class="comment">// bilinear at center of the pixels. x E [0, 3], y E [0, 3].</font>
+00400 <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a388">bilinearColorAndModulate</a>(CRGBA corners[4], uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, CRGBA &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>)
+00401 {
+00402 uint R,G,B;
+00403 <a class="code" href="namespaceNL3D.html#a387">bilinearColor</a>(corners, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, R, G, B);
+00404
+00405 <font class="comment">// modulate with input.</font>
+00406 R*= <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.R;
+00407 G*= <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.G;
+00408 B*= <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.B;
+00409
+00410 <font class="comment">// result.</font>
+00411 <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.R= R &gt;&gt; 14;
+00412 <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.G= G &gt;&gt; 14;
+00413 <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.B= B &gt;&gt; 14;
+00414 }
+00415
+00416
+00417 <font class="comment">// ***************************************************************************</font>
+00418 <font class="comment">// bilinear at center of the pixels. x E [0, 3], y E [0, 3].</font>
+00419 <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a389">bilinearColorAndAdd</a>(CRGBA corners[4], uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, CRGBA &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>)
+00420 {
+00421 uint R,G,B;
+00422 <a class="code" href="namespaceNL3D.html#a387">bilinearColor</a>(corners, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, R, G, B);
+00423
+00424 <font class="comment">// add with input.</font>
+00425 R= (R&gt;&gt;6) + <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.R;
+00426 G= (G&gt;&gt;6) + <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.G;
+00427 B= (B&gt;&gt;6) + <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.B;
+00428 R= <a class="code" href="bit__set_8cpp.html#a0">min</a>(R, 255U);
+00429 G= <a class="code" href="bit__set_8cpp.html#a0">min</a>(G, 255U);
+00430 B= <a class="code" href="bit__set_8cpp.html#a0">min</a>(B, 255U);
+00431
+00432 <font class="comment">// result.</font>
+00433 <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.R= R;
+00434 <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.G= G;
+00435 <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>.B= B;
+00436 }
+00437
+00438
+00439
+00440 <font class="comment">// ***************************************************************************</font>
+<a name="l00441"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_14">00441</a> <font class="keywordtype">void</font> CPatch::modulateTileLightmapWithTileColors(uint ts, uint tt, CRGBA *dest, uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>)
+00442 {
+00443 <font class="comment">// Get the tileColors around this tile</font>
+00444 CRGBA corners[4];
+00445 <a class="code" href="classNL3D_1_1CPatch.html#z682_17">getTileTileColors</a>(ts, tt, corners);
+00446
+00447 <font class="comment">// For all lumel, bilinear.</font>
+00448 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+00449 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+00450 {
+00451 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+00452 {
+00453 <font class="comment">// compute this pixel, and modulate</font>
+00454 <a class="code" href="namespaceNL3D.html#a388">bilinearColorAndModulate</a>(corners, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, dest[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>]);
+00455 }
+00456 }
+00457 }
+00458
+00459
+00460 <font class="comment">// ***************************************************************************</font>
+<a name="l00461"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_15">00461</a> <font class="keywordtype">void</font> CPatch::modulateTileLightmapEdgeWithTileColors(uint ts, uint tt, uint edge, CRGBA *dest, uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, <font class="keywordtype">bool</font> inverse)
+00462 {
+00463 <font class="comment">// Get the tileColors around this tile</font>
+00464 CRGBA corners[4];
+00465 <a class="code" href="classNL3D_1_1CPatch.html#z682_17">getTileTileColors</a>(ts, tt, corners);
+00466
+00467 <font class="comment">// get coordinate according to edge.</font>
+00468 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;
+00469 <font class="keywordflow">switch</font>(edge)
+00470 {
+00471 <font class="keywordflow">case</font> 0: <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= 0; <font class="keywordflow">break</font>;
+00472 <font class="keywordflow">case</font> 1: <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1; <font class="keywordflow">break</font>;
+00473 <font class="keywordflow">case</font> 2: <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1; <font class="keywordflow">break</font>;
+00474 <font class="keywordflow">case</font> 3: <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= 0; <font class="keywordflow">break</font>;
+00475 };
+00476
+00477 <font class="comment">// For all lumel of the edge, bilinear.</font>
+00478 uint i;
+00479 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; i++)
+00480 {
+00481 <font class="comment">// if vertical edge</font>
+00482 <font class="keywordflow">if</font>( (edge&amp;1)==0 ) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= i;
+00483 <font class="comment">// else horizontal edge</font>
+00484 <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= i;
+00485
+00486 <font class="comment">// manage inverse.</font>
+00487 uint where;
+00488 <font class="keywordflow">if</font>(inverse) where= (<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1)-i;
+00489 <font class="keywordflow">else</font> where= i;
+00490 <font class="comment">// compute this pixel, and modulate</font>
+00491 <a class="code" href="namespaceNL3D.html#a388">bilinearColorAndModulate</a>(corners, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, dest[where*<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>]);
+00492 }
+00493 }
+00494
+00495
+00496 <font class="comment">// ***************************************************************************</font>
+<a name="l00497"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_16">00497</a> <font class="keywordtype">void</font> CPatch::modulateTileLightmapPixelWithTileColors(uint ts, uint tt, uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, CRGBA *dest)
+00498 {
+00499 <font class="comment">// Get the tileColors around this tile</font>
+00500 CRGBA corners[4];
+00501 <a class="code" href="classNL3D_1_1CPatch.html#z682_17">getTileTileColors</a>(ts, tt, corners);
+00502
+00503 <font class="comment">// compute this pixel, and modulate</font>
+00504 <a class="code" href="namespaceNL3D.html#a388">bilinearColorAndModulate</a>(corners, <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, *dest);
+00505 }
+00506
+00507
+00508
+00509 <font class="comment">// ***************************************************************************</font>
+<a name="l00510"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_8">00510</a> <font class="keywordtype">void</font> CPatch::computeTileLightmapAutomatic(uint ts, uint tt, CRGBA *dest, uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>)
+00511 {
+00512 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+00513 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+00514 {
+00515 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+00516 {
+00517 <font class="comment">// compute this pixel.</font>
+00518 <a class="code" href="classNL3D_1_1CPatch.html#z682_10">computeTileLightmapPixelAutomatic</a>(ts, tt, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, dest+ <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>);
+00519 }
+00520 }
+00521 }
+00522
+00523 <font class="comment">// ***************************************************************************</font>
+<a name="l00524"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_9">00524</a> <font class="keywordtype">void</font> CPatch::computeTileLightmapEdgeAutomatic(uint ts, uint tt, uint edge, CRGBA *dest, uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, <font class="keywordtype">bool</font> inverse)
+00525 {
+00526 <font class="comment">// get coordinate according to edge.</font>
+00527 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;
+00528 <font class="keywordflow">switch</font>(edge)
+00529 {
+00530 <font class="keywordflow">case</font> 0: <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= 0; <font class="keywordflow">break</font>;
+00531 <font class="keywordflow">case</font> 1: <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1; <font class="keywordflow">break</font>;
+00532 <font class="keywordflow">case</font> 2: <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1; <font class="keywordflow">break</font>;
+00533 <font class="keywordflow">case</font> 3: <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= 0; <font class="keywordflow">break</font>;
+00534 };
+00535
+00536 uint i;
+00537 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; i++)
+00538 {
+00539 <font class="comment">// if vertical edge</font>
+00540 <font class="keywordflow">if</font>( (edge&amp;1)==0 ) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= i;
+00541 <font class="comment">// else horizontal edge</font>
+00542 <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= i;
+00543
+00544 <font class="comment">// manage inverse.</font>
+00545 uint where;
+00546 <font class="keywordflow">if</font>(inverse) where= (<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1)-i;
+00547 <font class="keywordflow">else</font> where= i;
+00548 <font class="comment">// compute this pixel.</font>
+00549 <a class="code" href="classNL3D_1_1CPatch.html#z682_10">computeTileLightmapPixelAutomatic</a>(ts, tt, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, dest+ where*<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>);
+00550 }
+00551 }
+00552
+00553 <font class="comment">// ***************************************************************************</font>
+<a name="l00554"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_10">00554</a> <font class="keywordtype">void</font> CPatch::computeTileLightmapPixelAutomatic(uint ts, uint tt, uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, CRGBA *dest)
+00555 {
+00556 <font class="keywordtype">float</font> u,<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+00557 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">float</font> lumelSize= 1.f/<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>;
+00558
+00559 <font class="comment">// use 3 computeVertex to compute a normal. This is slow....</font>
+00560 CVector p0, p1 ,p2;
+00561 <font class="comment">// 1st vert. Top-left of the lumel.</font>
+00562 u= (ts + <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>*lumelSize )/<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>;
+00563 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= (tt + <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>*lumelSize )/<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>;
+00564 p0= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(u, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
+00565 <font class="comment">// 2nd vert. Bottom-left of the lumel.</font>
+00566 u= (ts + <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>*lumelSize )/<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>;
+00567 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= (tt + (<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>+1)*lumelSize )/<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>;
+00568 p1= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(u, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
+00569 <font class="comment">// 3rd vert. Center-Right of the lumel.</font>
+00570 u= (ts + (<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>+1)*lumelSize )/<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>;
+00571 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= (tt + (<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>+0.5f)*lumelSize )/<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>;
+00572 p2= <a class="code" href="classNL3D_1_1CPatch.html#a16">computeVertex</a>(u, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
+00573
+00574 <font class="comment">// the normal.</font>
+00575 CVector normal;
+00576 normal= (p1-p0)^(p2-p0);
+00577 normal.normalize();
+00578
+00579 <font class="comment">// lighting.</font>
+00580 <font class="keywordtype">float</font> c= -normal*<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;getAutomaticLightDir();
+00581 c= max(c, 0.f);
+00582 sint ic;
+00583
+00584 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00585 <font class="preprocessor"></font> <font class="comment">// FastFloor using fistp. Don't care convention.</font>
+00586 <font class="keywordtype">float</font> fc= c*256;
+00587 _asm
+00588 {
+00589 fld fc
+00590 fistp ic
+00591 }
+00592 <font class="preprocessor">#else</font>
+00593 <font class="preprocessor"></font> ic= (sint)floor(c*256);
+00594 <font class="preprocessor">#endif</font>
+00595 <font class="preprocessor"></font> <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(ic, 0, 255);
+00596
+00597 <font class="comment">// ambiant/diffuse lighting.</font>
+00598 *dest= <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;getStaticLight()[ic];
+00599 }
+00600
+00601
+00602 <font class="comment">// ***************************************************************************</font>
+<a name="l00603"></a><a class="code" href="classNL3D_1_1CPatch.html#z686_3">00603</a> <font class="keywordtype">void</font> CPatch::getTileLumelmapPrecomputed(uint ts, uint tt, uint8 *dest, uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>)
+00604 {
+00605 <font class="comment">// Unpack the lumels</font>
+00606 uint8 buffer[<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>];
+00607 <a class="code" href="classNL3D_1_1CPatch.html#c2">unpackLumelBlock</a> (buffer, &amp;(<a class="code" href="classNL3D_1_1CPatch.html#m3">CompressedLumels</a>[(ts + (tt*<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>))*<a class="code" href="patch_8h.html#a8">NL_BLOCK_LUMEL_COMPRESSED_SIZE</a>]));
+00608
+00609 <font class="comment">// Retrun it</font>
+00610 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+00611 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+00612 {
+00613 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+00614 {
+00615 <font class="comment">// lumel</font>
+00616 dest[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>]= buffer[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;&lt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>)];
+00617 }
+00618 }
+00619 }
+00620
+00621
+00622 <font class="comment">// ***************************************************************************</font>
+<a name="l00623"></a><a class="code" href="classNL3D_1_1CPatch.html#z686_4">00623</a> <font class="keywordtype">void</font> CPatch::getTileLumelmapPixelPrecomputed(uint ts, uint tt, uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, uint8 &amp;dest)<font class="keyword"> const</font>
+00624 <font class="keyword"></font>{
+00625 <font class="comment">// Return the lumel</font>
+00626 dest= <a class="code" href="namespaceNL3D.html#a386">getUnpackLumelBlock</a> (&amp;(<a class="code" href="classNL3D_1_1CPatch.html#m3">CompressedLumels</a>[(ts + (tt*<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>))*<a class="code" href="patch_8h.html#a8">NL_BLOCK_LUMEL_COMPRESSED_SIZE</a>]), <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>+(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>&lt;&lt;2));
+00627 }
+00628
+00629
+00630 <font class="comment">// ***************************************************************************</font>
+<a name="l00631"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_11">00631</a> <font class="keywordtype">void</font> CPatch::computeTileLightmapPrecomputed(uint ts, uint tt, CRGBA *dest, uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>)
+00632 {
+00633 <font class="comment">// Lumel table</font>
+00634 <font class="keyword">const</font> CRGBA* colorTable=<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a> ()-&gt;getStaticLight ();
+00635 <font class="comment">// Unpack the lumels</font>
+00636 uint8 buffer[<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>];
+00637 <a class="code" href="classNL3D_1_1CPatch.html#c2">unpackLumelBlock</a> (buffer, &amp;(<a class="code" href="classNL3D_1_1CPatch.html#m3">CompressedLumels</a>[(ts + (tt*<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>))*<a class="code" href="patch_8h.html#a8">NL_BLOCK_LUMEL_COMPRESSED_SIZE</a>]));
+00638
+00639 <font class="comment">// Retrun it</font>
+00640 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+00641 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+00642 {
+00643 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+00644 {
+00645 <font class="comment">// lumel</font>
+00646 dest[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>]=colorTable[buffer[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;&lt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>)]];
+00647 }
+00648 }
+00649 }
+00650
+00651 <font class="comment">// ***************************************************************************</font>
+00652
+00653 <font class="keyword">static</font> uint <a class="code" href="namespaceNL3D.html#a177">NL3DPixelStartLumel</a>[4]={0, 4*3, 3, 0};
+00654 <font class="keyword">static</font> uint <a class="code" href="namespaceNL3D.html#a178">NL3DDeltaLumel</a>[4]={4, 1, 4, 1};
+00655
+00656 <font class="comment">// ***************************************************************************</font>
+<a name="l00657"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_12">00657</a> <font class="keywordtype">void</font> CPatch::computeTileLightmapEdgePrecomputed(uint ts, uint tt, uint edge, CRGBA *dest, uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, <font class="keywordtype">bool</font> inverse)
+00658 {
+00659 <font class="comment">// Lumel table</font>
+00660 <font class="keyword">const</font> CRGBA* colorTable=<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a> ()-&gt;getStaticLight ();
+00661
+00662 <font class="comment">// Witch corner to start ?</font>
+00663 uint pixel=<a class="code" href="namespaceNL3D.html#a177">NL3DPixelStartLumel</a>[edge];
+00664 uint delta=<a class="code" href="namespaceNL3D.html#a178">NL3DDeltaLumel</a>[edge];
+00665
+00666 <font class="comment">// For each lumels</font>
+00667 <font class="keyword">const</font> uint8 *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>=&amp;(<a class="code" href="classNL3D_1_1CPatch.html#m3">CompressedLumels</a>[(ts + (tt*<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>))*<a class="code" href="patch_8h.html#a8">NL_BLOCK_LUMEL_COMPRESSED_SIZE</a>]);
+00668 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
+00669 <font class="keywordflow">if</font> (inverse)
+00670 {
+00671 uint inverseStride=<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>*(4-1);
+00672 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;4; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+00673 {
+00674 <font class="comment">// lumel</font>
+00675 dest[inverseStride-<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>]=colorTable[<a class="code" href="namespaceNL3D.html#a386">getUnpackLumelBlock</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, pixel)];
+00676 pixel+=delta;
+00677 }
+00678 }
+00679 <font class="keywordflow">else</font>
+00680 {
+00681 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;4; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+00682 {
+00683 <font class="comment">// lumel</font>
+00684 dest[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>]=colorTable[<a class="code" href="namespaceNL3D.html#a386">getUnpackLumelBlock</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, pixel)];
+00685 pixel+=delta;
+00686 }
+00687 }
+00688 }
+00689
+00690 <font class="comment">// ***************************************************************************</font>
+<a name="l00691"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_13">00691</a> <font class="keywordtype">void</font> CPatch::computeTileLightmapPixelPrecomputed(uint ts, uint tt, uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, CRGBA *dest)
+00692 {
+00693 <font class="comment">// Lumel table</font>
+00694 <font class="keyword">const</font> CRGBA* colorTable=<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a> ()-&gt;getStaticLight ();
+00695
+00696 <font class="comment">// Return the lumel</font>
+00697 *dest=colorTable[<a class="code" href="namespaceNL3D.html#a386">getUnpackLumelBlock</a> (&amp;(<a class="code" href="classNL3D_1_1CPatch.html#m3">CompressedLumels</a>[(ts + (tt*<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>))*<a class="code" href="patch_8h.html#a8">NL_BLOCK_LUMEL_COMPRESSED_SIZE</a>]), <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>+(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>&lt;&lt;2))];
+00698 }
+00699
+00700
+00701
+00702 <font class="comment">// ***************************************************************************</font>
+<a name="l00703"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_5">00703</a> <font class="keywordtype">void</font> CPatch::computeTileLightmap(uint ts, uint tt, CRGBA *dest, uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>)
+00704 {
+00705 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;getAutomaticLighting())
+00706 <a class="code" href="classNL3D_1_1CPatch.html#z682_8">computeTileLightmapAutomatic</a>(ts, tt, dest, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>);
+00707 <font class="keywordflow">else</font>
+00708 {
+00709 <a class="code" href="classNL3D_1_1CPatch.html#z682_11">computeTileLightmapPrecomputed</a>(ts, tt, dest, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>);
+00710 <font class="comment">// Add the inlufence of TLI.</font>
+00711 <a class="code" href="classNL3D_1_1CPatch.html#z682_20">addTileLightmapWithTLI</a>(ts, tt, dest, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>);
+00712 }
+00713
+00714 <font class="comment">// modulate dest with tileColors (at center of lumels).</font>
+00715 <a class="code" href="classNL3D_1_1CPatch.html#z682_14">modulateTileLightmapWithTileColors</a>(ts, tt, dest, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>);
+00716 }
+00717 <font class="comment">// ***************************************************************************</font>
+<a name="l00718"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_6">00718</a> <font class="keywordtype">void</font> CPatch::computeTileLightmapEdge(uint ts, uint tt, uint edge, CRGBA *dest, uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, <font class="keywordtype">bool</font> inverse)
+00719 {
+00720 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;getAutomaticLighting())
+00721 <a class="code" href="classNL3D_1_1CPatch.html#z682_9">computeTileLightmapEdgeAutomatic</a>(ts, tt, edge, dest, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, inverse);
+00722 <font class="keywordflow">else</font>
+00723 {
+00724 <a class="code" href="classNL3D_1_1CPatch.html#z682_12">computeTileLightmapEdgePrecomputed</a>(ts, tt, edge, dest, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, inverse);
+00725 <font class="comment">// Add the inlufence of TLI.</font>
+00726 <a class="code" href="classNL3D_1_1CPatch.html#z682_21">addTileLightmapEdgeWithTLI</a>(ts, tt, edge, dest, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, inverse);
+00727 }
+00728
+00729 <font class="comment">// modulate dest with tileColors (at center of lumels).</font>
+00730 <a class="code" href="classNL3D_1_1CPatch.html#z682_15">modulateTileLightmapEdgeWithTileColors</a>(ts, tt, edge, dest, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, inverse);
+00731 }
+00732
+00733
+00734 <font class="comment">// ***************************************************************************</font>
+<a name="l00735"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_7">00735</a> <font class="keywordtype">void</font> CPatch::computeTileLightmapPixel(uint ts, uint tt, uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, CRGBA *dest)
+00736 {
+00737 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;getAutomaticLighting())
+00738 <a class="code" href="classNL3D_1_1CPatch.html#z682_10">computeTileLightmapPixelAutomatic</a>(ts, tt, <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, dest);
+00739 <font class="keywordflow">else</font>
+00740 {
+00741 <a class="code" href="classNL3D_1_1CPatch.html#z682_13">computeTileLightmapPixelPrecomputed</a>(ts, tt, <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, dest);
+00742 <font class="comment">// Add the inlufence of TLI.</font>
+00743 <a class="code" href="classNL3D_1_1CPatch.html#z682_22">addTileLightmapPixelWithTLI</a>(ts, tt, <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, dest);
+00744 }
+00745
+00746 <font class="comment">// modulate dest with tileColors (at center of lumels).</font>
+00747 <a class="code" href="classNL3D_1_1CPatch.html#z682_16">modulateTileLightmapPixelWithTileColors</a>(ts, tt, <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, dest);
+00748 }
+00749
+00750
+00751 <font class="comment">// ***************************************************************************</font>
+<a name="l00752"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_4">00752</a> <font class="keywordtype">void</font> CPatch::computeTileLightmapPixelAroundCorner(<font class="keyword">const</font> CVector2f &amp;stIn, CRGBA *dest, <font class="keywordtype">bool</font> lookAround)
+00753 {
+00754 <font class="keywordtype">bool</font> mustLookOnNeighbor= <font class="keyword">false</font>;
+00755
+00756 <font class="comment">// Get the Uv, in [0,Order?*NL_LUMEL_BY_TILE] basis (ie lumel basis).</font>
+00757 sint u, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+00758 u= (sint)floor(stIn.x*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>);
+00759 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= (sint)floor(stIn.y*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>);
+00760
+00761 <font class="comment">// if allowed, try to go on neighbor patch.</font>
+00762 <font class="keywordflow">if</font>(lookAround)
+00763 {
+00764 <font class="comment">// try to know if we must go on a neighbor patch (maybe false with bind X/1).</font>
+00765 <font class="keywordflow">if</font>( u&lt;0 || u&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a> || v&lt;0 || v&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>)
+00766 mustLookOnNeighbor= <font class="keyword">true</font>;
+00767 }
+00768
+00769
+00770 <font class="comment">// If we must get (if possible) the pixel in the current patch, do it.</font>
+00771 <font class="keywordflow">if</font>(!mustLookOnNeighbor)
+00772 {
+00773 <font class="comment">// if out this patch, abort.</font>
+00774 <font class="keywordflow">if</font>( u&lt;0 || u&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a> || v&lt;0 || v&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>)
+00775 <font class="keywordflow">return</font>;
+00776 <font class="keywordflow">else</font>
+00777 {
+00778 <font class="comment">// get this pixel.</font>
+00779 <a class="code" href="classNL3D_1_1CPatch.html#z682_7">computeTileLightmapPixel</a>(u&gt;&gt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&gt;&gt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>, u&amp;(<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1), <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&amp;(<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1), dest);
+00780 }
+00781 }
+00782 <font class="comment">// else get from the best neighbor patch.</font>
+00783 <font class="keywordflow">else</font>
+00784 {
+00785 <font class="comment">// choose against which edge we must find the pixel.</font>
+00786 uint edge=0;
+00787 <font class="keywordflow">if</font>(u&lt;0) edge=0;
+00788 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>) edge=1;
+00789 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(u&gt;=<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>) edge=2;
+00790 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&lt;0) edge=3;
+00791
+00792 <font class="comment">// retrieve info on neighbor.</font>
+00793 CBindInfo bindInfo;
+00794 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edge, bindInfo);
+00795
+00796 <font class="comment">// if neighbor present.</font>
+00797 <font class="keywordflow">if</font>(bindInfo.Zone)
+00798 {
+00799 CVector2f stOut;
+00800 <a class="code" href="classNL3D_1_1CPatch.html#a0">CPatch</a> *patchOut;
+00801 uint patchId;
+00802
+00803 <font class="comment">// Ok, search uv on this patch.</font>
+00804 CPatchUVLocator uvLocator;
+00805 uvLocator.build(<font class="keyword">this</font>, edge, bindInfo);
+00806 patchId= uvLocator.selectPatch(stIn);
+00807 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00808
+00809 <font class="comment">// retry only one time, so at next call, must find the data IN htis patch (else abort).</font>
+00810 patchOut-&gt;computeTileLightmapPixelAroundCorner(stOut, dest, <font class="keyword">false</font>);
+00811 }
+00812 }
+00813 }
+00814
+00815
+00816 <font class="comment">// ***************************************************************************</font>
+<a name="l00817"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_3">00817</a> <font class="keywordtype">void</font> CPatch::computeNearBlockLightmap(uint uts, uint utt, CRGBA *lightText)
+00818 {
+00819 sint ts= uts;
+00820 sint tt= utt;
+00821
+00822 <font class="comment">// hardcoded for 10x10.</font>
+00823 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>==10);
+00824 CRGBA *dest;
+00825 uint edge;
+00826 uint corner;
+00827
+00828 <font class="comment">// Compute center of the TessBlock: the 2x2 tiles.</font>
+00829 <font class="comment">//=================</font>
+00830 <font class="comment">// compute tile 0,0 of the tessBlock. must decal of 1 pixel.</font>
+00831 dest= lightText+<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>+1;
+00832 <a class="code" href="classNL3D_1_1CPatch.html#z682_5">computeTileLightmap</a>(ts, tt, dest, <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>);
+00833 <font class="comment">// compute tile 1,0 of the tessBlock. must decal of 1 pixel.</font>
+00834 dest= lightText + <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a> + <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>+1 ;
+00835 <a class="code" href="classNL3D_1_1CPatch.html#z682_5">computeTileLightmap</a>(ts+1, tt, dest, <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>);
+00836 <font class="comment">// compute tile 0,1 of the tessBlock. must decal of 1 pixel.</font>
+00837 dest= lightText + <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a> + <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>+1 ;
+00838 <a class="code" href="classNL3D_1_1CPatch.html#z682_5">computeTileLightmap</a>(ts, tt+1, dest, <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>);
+00839 <font class="comment">// compute tile 1,1 of the tessBlock. must decal of 1 pixel.</font>
+00840 dest= lightText + <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a> + <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a> + <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>+1 ;
+00841 <a class="code" href="classNL3D_1_1CPatch.html#z682_5">computeTileLightmap</a>(ts+1, tt+1, dest, <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>);
+00842
+00843
+00844 <font class="comment">// Compute edges of the TessBlock.</font>
+00845 <font class="comment">//=================</font>
+00846 <font class="keywordtype">bool</font> edgeBorder[4];
+00847 <font class="comment">// where are we on a border of a patch??</font>
+00848 edgeBorder[0]= ( ts==0 );
+00849 edgeBorder[1]= ( tt == <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>-2 );
+00850 edgeBorder[2]= ( ts == <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>-2 );
+00851 edgeBorder[3]= ( tt==0 );
+00852
+00853 <font class="comment">// For all edges.</font>
+00854 <font class="keywordflow">for</font>(edge=0; edge&lt;4; edge++)
+00855 {
+00856 <font class="comment">// compute dest info.</font>
+00857 <font class="comment">//==============</font>
+00858 <font class="comment">// Are we on a vertical edge or horizontal edge??</font>
+00859 uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>= (edge&amp;1)==0? <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a> : 1;
+00860
+00861 <font class="comment">// must compute on which tile we must find info.</font>
+00862 sint decalS=0;
+00863 sint decalT=0;
+00864 <font class="comment">// and must compute ptr, where we store the result of the edge.</font>
+00865 <font class="keywordflow">switch</font>(edge)
+00866 {
+00867 <font class="keywordflow">case</font> 0: decalS=-1; dest= lightText + 0 + <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>; <font class="keywordflow">break</font>;
+00868 <font class="keywordflow">case</font> 1: decalT= 2; dest= lightText + 1 + (<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>-1)*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>; <font class="keywordflow">break</font>;
+00869 <font class="keywordflow">case</font> 2: decalS= 2; dest= lightText + (<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>-1) + <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>; <font class="keywordflow">break</font>;
+00870 <font class="keywordflow">case</font> 3: decalT=-1; dest= lightText + 1; <font class="keywordflow">break</font>;
+00871 };
+00872
+00873 <font class="comment">// compute the second tile dest info.</font>
+00874 CRGBA *dest2;
+00875 sint decalS2;
+00876 sint decalT2;
+00877 <font class="comment">// if vertical edge.</font>
+00878 <font class="keywordflow">if</font>((edge&amp;1)==0)
+00879 {
+00880 <font class="comment">// Next Y tile.</font>
+00881 dest2= dest + <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>;
+00882 decalS2= decalS;
+00883 decalT2= decalT+1;
+00884 }
+00885 <font class="keywordflow">else</font>
+00886 {
+00887 <font class="comment">// Next X tile.</font>
+00888 dest2= dest + <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>;
+00889 decalS2= decalS+1;
+00890 decalT2= decalT;
+00891 }
+00892
+00893
+00894 <font class="comment">// If we are not on a border of a patch, just compute on the interior of the patch.</font>
+00895 <font class="comment">//==============</font>
+00896 <font class="keywordflow">if</font>(!edgeBorder[edge])
+00897 {
+00898 <font class="comment">// find the result on the mirrored border of us. First tile.</font>
+00899 <a class="code" href="classNL3D_1_1CPatch.html#z682_6">computeTileLightmapEdge</a>(ts+decalS, tt+decalT, (edge+2)&amp;3, dest, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, <font class="keyword">false</font>);
+00900
+00901 <font class="comment">// find the result on the mirrored border of us. Second Tile.</font>
+00902 <a class="code" href="classNL3D_1_1CPatch.html#z682_6">computeTileLightmapEdge</a>(ts+decalS2, tt+decalT2, (edge+2)&amp;3, dest2, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, <font class="keyword">false</font>);
+00903
+00904 }
+00905 <font class="comment">// else, slightly complicated, must find the result on neighbor patch(s).</font>
+00906 <font class="comment">//==============</font>
+00907 <font class="keywordflow">else</font>
+00908 {
+00909 CPatchUVLocator uvLocator;
+00910 CBindInfo bindInfo;
+00911 bindInfo.Zone= NULL;
+00912
+00913 <font class="comment">// if smmothed edge, search the neighbor.</font>
+00914 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#a40">getSmoothFlag</a>(edge))
+00915 {
+00916 <font class="comment">// Build the bindInfo against this edge.</font>
+00917 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edge, bindInfo);
+00918
+00919 <font class="comment">// if ok, build the uv info against this edge.</font>
+00920 <font class="keywordflow">if</font>(bindInfo.Zone)
+00921 {
+00922 uvLocator.build(<font class="keyword">this</font>, edge, bindInfo);
+00923 <font class="comment">// if there is not same tile order across the edge, invalidate the smooth.</font>
+00924 <font class="comment">// This is rare, so don't bother.</font>
+00925 <font class="keywordflow">if</font>(!uvLocator.sameEdgeOrder())
+00926 bindInfo.Zone= NULL;
+00927 }
+00928 }
+00929
+00930
+00931 <font class="comment">// Fast reject: if no neighbor, or if not smoothed, or if edge order pb, just copy from my interior.</font>
+00932 <font class="keywordflow">if</font>(!bindInfo.Zone)
+00933 {
+00934 CRGBA *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>=0;
+00935 <font class="keywordflow">switch</font>(edge)
+00936 {
+00937 <font class="keywordflow">case</font> 0: <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= dest + 1; <font class="keywordflow">break</font>;
+00938 <font class="keywordflow">case</font> 1: <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= dest - <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>; <font class="keywordflow">break</font>;
+00939 <font class="keywordflow">case</font> 2: <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= dest - 1; <font class="keywordflow">break</font>;
+00940 <font class="keywordflow">case</font> 3: <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= dest + <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>; <font class="keywordflow">break</font>;
+00941 };
+00942
+00943 <font class="comment">// fill the NL_LUMEL_BY_TILE*2 (8) pixels.</font>
+00944 <font class="keywordflow">for</font>(uint n=<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>*2; n&gt;0; n--, <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>+=<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, dest+=<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>)
+00945 *dest= *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>;
+00946 }
+00947 <font class="comment">// else, ok, get from neighbor.</font>
+00948 <font class="keywordflow">else</font>
+00949 {
+00950 CVector2f stIn, stOut;
+00951 <a class="code" href="classNL3D_1_1CPatch.html#a0">CPatch</a> *patchOut;
+00952 uint patchId;
+00953 uint edgeOut;
+00954 <font class="keywordtype">bool</font> inverse;
+00955
+00956 <font class="comment">// First Tile.</font>
+00957 <font class="comment">//=========</font>
+00958 <font class="comment">// to remove floor pbs, take the center of the wanted tile.</font>
+00959 stIn.set(ts+decalS + 0.5f, tt+decalT + 0.5f);
+00960 patchId= uvLocator.selectPatch(stIn);
+00961 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00962 <font class="comment">// must find what edge on neighbor to compute, and if we must inverse (swap) result.</font>
+00963 <font class="comment">// easy: the edge of the tile is the edge of the patch where we are binded.</font>
+00964 edgeOut= bindInfo.Edge[patchId];
+00965 <font class="comment">// edge0 is oriented in T increasing order. edge1 is oriented in S increasing order.</font>
+00966 <font class="comment">// edge2 is oriented in T decreasing order. edge3 is oriented in S decreasing order.</font>
+00967 <font class="comment">// inverse is true if same sens on both edges (because of mirroring, sens should be different).</font>
+00968 inverse= (edge&gt;&gt;1)==(edgeOut&gt;&gt;1);
+00969 <font class="comment">// compute the lightmap on the edge of the neighbor.</font>
+00970 patchOut-&gt;computeTileLightmapEdge((sint)floor(stOut.x), (sint)floor(stOut.y), edgeOut, dest, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, inverse);
+00971
+00972 <font class="comment">// Second Tile.</font>
+00973 <font class="comment">//=========</font>
+00974 <font class="comment">// same reasoning.</font>
+00975 stIn.set(ts+decalS2 + 0.5f, tt+decalT2 + 0.5f);
+00976 patchId= uvLocator.selectPatch(stIn);
+00977 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00978 edgeOut= bindInfo.Edge[patchId];
+00979 inverse= (edge&gt;&gt;1)==(edgeOut&gt;&gt;1);
+00980 patchOut-&gt;computeTileLightmapEdge((sint)floor(stOut.x), (sint)floor(stOut.y), edgeOut, dest2, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, inverse);
+00981 }
+00982
+00983 }
+00984 }
+00985
+00986
+00987 <font class="comment">// Compute corners of the TessBlock.</font>
+00988 <font class="comment">//=================</font>
+00989 <font class="keywordtype">bool</font> cornerOnPatchEdge[4];
+00990 <font class="keywordtype">bool</font> cornerOnPatchCorner[4];
+00991 <font class="comment">// where are we on a edge border of a patch??</font>
+00992 cornerOnPatchEdge[0]= edgeBorder[3] != edgeBorder[0];
+00993 cornerOnPatchEdge[1]= edgeBorder[0] != edgeBorder[1];
+00994 cornerOnPatchEdge[2]= edgeBorder[1] != edgeBorder[2];
+00995 cornerOnPatchEdge[3]= edgeBorder[2] != edgeBorder[3];
+00996 <font class="comment">// where are we on a corner border of a patch??</font>
+00997 cornerOnPatchCorner[0]= edgeBorder[3] &amp;&amp; edgeBorder[0];
+00998 cornerOnPatchCorner[1]= edgeBorder[0] &amp;&amp; edgeBorder[1];
+00999 cornerOnPatchCorner[2]= edgeBorder[1] &amp;&amp; edgeBorder[2];
+01000 cornerOnPatchCorner[3]= edgeBorder[2] &amp;&amp; edgeBorder[3];
+01001
+01002 <font class="comment">// For all corners.</font>
+01003 <font class="keywordflow">for</font>(corner=0; corner&lt;4; corner++)
+01004 {
+01005 <font class="comment">// compute dest info.</font>
+01006 <font class="comment">//==============</font>
+01007 <font class="comment">// must compute on which tile we must find info.</font>
+01008 sint decalS=0;
+01009 sint decalT=0;
+01010 <font class="comment">// and must compute ptr, where we store the result of the corner.</font>
+01011 <font class="keywordflow">switch</font>(corner)
+01012 {
+01013 <font class="keywordflow">case</font> 0: decalS=-1; decalT=-1; dest= lightText + 0 + 0; <font class="keywordflow">break</font>;
+01014 <font class="keywordflow">case</font> 1: decalS=-1; decalT= 2; dest= lightText + 0 + (<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>-1)*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>; <font class="keywordflow">break</font>;
+01015 <font class="keywordflow">case</font> 2: decalS= 2; decalT= 2; dest= lightText + (<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>-1) + (<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>-1)*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>; <font class="keywordflow">break</font>;
+01016 <font class="keywordflow">case</font> 3: decalS= 2; decalT=-1; dest= lightText + (<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>-1) + 0; <font class="keywordflow">break</font>;
+01017 };
+01018
+01019
+01020 <font class="comment">// If we are not on a border of a patch, just compute on the interior of the patch.</font>
+01021 <font class="comment">//==============</font>
+01022 <font class="comment">// if the corner is IN the patch.</font>
+01023 <font class="keywordflow">if</font>(!cornerOnPatchCorner[corner] &amp;&amp; !cornerOnPatchEdge[corner])
+01024 {
+01025 <font class="comment">// what pixel to read.</font>
+01026 uint subS, subT;
+01027 <font class="keywordflow">if</font>(decalS==-1) subS= <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1;
+01028 <font class="keywordflow">else</font> subS= 0;
+01029 <font class="keywordflow">if</font>(decalT==-1) subT= <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1;
+01030 <font class="keywordflow">else</font> subT= 0;
+01031
+01032 <font class="comment">// find the result on the corner of the neighbor tile.</font>
+01033 <a class="code" href="classNL3D_1_1CPatch.html#z682_7">computeTileLightmapPixel</a>(ts+decalS, tt+decalT, subS, subT, dest);
+01034 }
+01035 <font class="keywordflow">else</font>
+01036 {
+01037 <font class="comment">// By default, fill the corner with our interior corner. Because other methods may fail.</font>
+01038 CRGBA *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>=0;
+01039 <font class="keywordflow">switch</font>(corner)
+01040 {
+01041 <font class="keywordflow">case</font> 0: <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= dest + 1 + <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>; <font class="keywordflow">break</font>;
+01042 <font class="keywordflow">case</font> 1: <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= dest + 1 - <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>; <font class="keywordflow">break</font>;
+01043 <font class="keywordflow">case</font> 2: <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= dest - 1 - <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>; <font class="keywordflow">break</font>;
+01044 <font class="keywordflow">case</font> 3: <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= dest - 1 + <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>; <font class="keywordflow">break</font>;
+01045 };
+01046
+01047 <font class="comment">// fill the pixel.</font>
+01048 *dest= *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>;
+01049
+01050 <font class="comment">// get the coordinate of the corner, in our [0,Order] basis. get it at the center of the pixel.</font>
+01051 CBindInfo bindInfo;
+01052 CPatchUVLocator uvLocator;
+01053 CVector2f stIn, stOut;
+01054 <a class="code" href="classNL3D_1_1CPatch.html#a0">CPatch</a> *patchOut;
+01055 uint patchId;
+01056 <font class="keywordtype">float</font> decX, decY;
+01057 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">float</font> lumelSize= 1.f/<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>;
+01058 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">float</font> semiLumelSize= 0.5f*lumelSize;
+01059
+01060 <font class="keywordflow">if</font>(decalS==-1) decX= - semiLumelSize;
+01061 <font class="keywordflow">else</font> decX= 2+ semiLumelSize;
+01062 <font class="keywordflow">if</font>(decalT==-1) decY= - semiLumelSize;
+01063 <font class="keywordflow">else</font> decY= 2+ semiLumelSize;
+01064 stIn.set( ts+decX, tt+decY);
+01065
+01066
+01067 <font class="comment">// if the corner is on One edge only of the patch.</font>
+01068 <font class="keywordflow">if</font>(cornerOnPatchEdge[corner])
+01069 {
+01070 <font class="comment">// find the edge where to read this corner: hard edge after or before this corner.</font>
+01071 <font class="keywordflow">if</font>(edgeBorder[corner]) edge= corner;
+01072 <font class="keywordflow">else</font> edge= (corner+4-1) &amp; 3;
+01073
+01074 <font class="comment">// if this edge is smoothed, find on neighbor.</font>
+01075 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#a40">getSmoothFlag</a>(edge))
+01076 {
+01077 <font class="comment">// retrieve neigbhor info.</font>
+01078 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edge, bindInfo);
+01079
+01080 <font class="comment">// if neighbor present.</font>
+01081 <font class="keywordflow">if</font>(bindInfo.Zone)
+01082 {
+01083 <font class="comment">// Ok, search uv on this patch.</font>
+01084 uvLocator.build(<font class="keyword">this</font>, edge, bindInfo);
+01085 patchId= uvLocator.selectPatch(stIn);
+01086 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+01087
+01088 <font class="comment">// Get the Uv, in [0,Order?*NL_LUMEL_BY_TILE] basis (ie lumel basis), and get from neighbor patch</font>
+01089 sint u, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+01090 u= (sint)floor(stOut.x*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>);
+01091 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= (sint)floor(stOut.y*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>);
+01092 patchOut-&gt;computeTileLightmapPixel(u&gt;&gt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&gt;&gt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>, u&amp;(<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1), <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&amp;(<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1), dest);
+01093 }
+01094 }
+01095 <font class="comment">// else we must still smooth with our lumel on this patch, so get it from neighbor on edge.</font>
+01096 <font class="keywordflow">else</font>
+01097 {
+01098 <font class="comment">// first, clamp to our patch (recenter on the previous pixel)</font>
+01099 <font class="keywordflow">if</font>(stIn.x&lt;0) stIn.x+= lumelSize;
+01100 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(stIn.x&gt;<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>) stIn.x-= lumelSize;
+01101 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(stIn.y&lt;0) stIn.y+= lumelSize;
+01102 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(stIn.y&gt;<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>) stIn.y-= lumelSize;
+01103
+01104 <font class="comment">// Get the Uv, in [0,Order?*NL_LUMEL_BY_TILE] basis (ie lumel basis), and get from this patch</font>
+01105 sint u, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+01106 u= (sint)floor(stIn.x*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>);
+01107 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= (sint)floor(stIn.y*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>);
+01108 <a class="code" href="classNL3D_1_1CPatch.html#z682_7">computeTileLightmapPixel</a>(u&gt;&gt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&gt;&gt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>, u&amp;(<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1), <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&amp;(<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1), dest);
+01109 }
+01110 }
+01111 <font class="comment">// else it is on a corner of the patch.</font>
+01112 <font class="keywordflow">else</font>
+01113 {
+01114 <font class="comment">// if the corner of the patch (same as tile corner) is smoothed, find on neighbor</font>
+01115 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#z668_1">getCornerSmoothFlag</a>(corner))
+01116 {
+01117 <font class="comment">// retrieve neigbhor info. NB: use edgeId=corner, (corner X is the start of the edge X)it works.</font>
+01118 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(corner, bindInfo);
+01119
+01120 <font class="comment">// if neighbor present.</font>
+01121 <font class="keywordflow">if</font>(bindInfo.Zone)
+01122 {
+01123 <font class="comment">// Ok, search uv on this patch.</font>
+01124 uvLocator.build(<font class="keyword">this</font>, corner, bindInfo);
+01125 patchId= uvLocator.selectPatch(stIn);
+01126 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+01127
+01128 <font class="comment">// same reasoning as in computeDisplaceCornerSmooth(), must find the pixel on the neighbor </font>
+01129 <font class="comment">// of our neighbor. But the current corner may be a corner on a bind X/1. All is managed by doing</font>
+01130 <font class="comment">// this way.</font>
+01131 patchOut-&gt;computeTileLightmapPixelAroundCorner(stOut, dest, <font class="keyword">true</font>);
+01132 }
+01133 }
+01134 }
+01135 }
+01136
+01137 }
+01138
+01139
+01140 }
+01141
+01142
+01143 <font class="comment">// ***************************************************************************</font>
+<a name="l01144"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_0">01144</a> <font class="keywordtype">void</font> CPatch::getTileLightMap(uint ts, uint tt, CPatchRdrPass *&amp;rdrpass)
+01145 {
+01146 <font class="comment">// TessBlocks must have been allocated.</font>
+01147 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size()!=0);
+01148
+01149 <font class="comment">// get what tessBlock to use.</font>
+01150 uint numtb, numtm;
+01151 <a class="code" href="classNL3D_1_1CPatch.html#c35">computeTbTm</a>(numtb, numtm, ts, tt);
+01152 CTessBlock &amp;tessBlock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb];
+01153
+01154 <font class="comment">// If the lightmap Id has not been computed, compute it.</font>
+01155 <font class="keywordflow">if</font>(tessBlock.LightMapRefCount==0)
+01156 {
+01157 <font class="comment">// Compute the lightmap texture, with help of TileColors, with neighboring info etc...</font>
+01158 CRGBA lightText[<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>];
+01159 <a class="code" href="classNL3D_1_1CPatch.html#z682_3">computeNearBlockLightmap</a>(ts&amp;(~1), tt&amp;(~1), lightText);
+01160
+01161 <font class="comment">// Create a rdrPass with this texture, donlod to Driver etc...</font>
+01162 tessBlock.LightMapId= <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;Landscape-&gt;getTileLightMap(lightText, rdrpass);
+01163
+01164 <font class="comment">// store this rdrpass ptr.</font>
+01165 tessBlock.LightMapRdrPass= rdrpass;
+01166 }
+01167
+01168 <font class="comment">// We are using this 2x2 tiles lightmap.</font>
+01169 tessBlock.LightMapRefCount++;
+01170
+01171
+01172 <font class="comment">// get the rdrpass ptr of the tessBlock lightmap</font>
+01173 rdrpass= tessBlock.LightMapRdrPass;
+01174 }
+01175
+01176
+01177 <font class="comment">// ***************************************************************************</font>
+<a name="l01178"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_1">01178</a> <font class="keywordtype">void</font> CPatch::getTileLightMapUvInfo(uint ts, uint tt, CVector &amp;uvScaleBias)
+01179 {
+01180 <font class="comment">// TessBlocks must have been allocated.</font>
+01181 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size()!=0);
+01182
+01183 <font class="comment">// get what tessBlock to use.</font>
+01184 uint numtb, numtm;
+01185 <a class="code" href="classNL3D_1_1CPatch.html#c35">computeTbTm</a>(numtb, numtm, ts, tt);
+01186 CTessBlock &amp;tessBlock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb];
+01187
+01188 <font class="comment">// Get the uvScaleBias for the tile 0,0 of the block.</font>
+01189 <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;Landscape-&gt;getTileLightMapUvInfo(tessBlock.LightMapId, uvScaleBias);
+01190
+01191 <font class="comment">// Must increment the bias, for the good tile in the 2x2 block Lightmap.</font>
+01192 uint tsDec= ts &amp; 1;
+01193 uint ttDec= tt &amp; 1;
+01194 uvScaleBias.x+= tsDec * uvScaleBias.z;
+01195 uvScaleBias.y+= ttDec * uvScaleBias.z;
+01196 }
+01197
+01198
+01199 <font class="comment">// ***************************************************************************</font>
+<a name="l01200"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_2">01200</a> <font class="keywordtype">void</font> CPatch::releaseTileLightMap(uint ts, uint tt)
+01201 {
+01202 <font class="comment">// TessBlocks must have been allocated.</font>
+01203 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size()!=0);
+01204
+01205 <font class="comment">// get what tessBlock to use.</font>
+01206 uint numtb, numtm;
+01207 <a class="code" href="classNL3D_1_1CPatch.html#c35">computeTbTm</a>(numtb, numtm, ts, tt);
+01208 CTessBlock &amp;tessBlock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numtb];
+01209
+01210 <font class="comment">// If no more tileMaterial use this lightmap, release it.</font>
+01211 <a class="code" href="debug_8h.html#a6">nlassert</a>(tessBlock.LightMapRefCount&gt;0);
+01212 tessBlock.LightMapRefCount--;
+01213 <font class="keywordflow">if</font>(tessBlock.LightMapRefCount==0)
+01214 {
+01215 <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;Landscape-&gt;releaseTileLightMap(tessBlock.LightMapId);
+01216 }
+01217 }
+01218
+01219 <font class="comment">// ***************************************************************************</font>
+<a name="l01220"></a><a class="code" href="classNL3D_1_1CPatch.html#a35">01220</a> <font class="keywordtype">void</font> CPatch::packShadowMap (<font class="keyword">const</font> uint8 *pLumelSrc)
+01221 {
+01222 <font class="comment">// Number of lumel by lines</font>
+01223 uint lumelCount=<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>;
+01224
+01225 <font class="comment">// Number of block in a line</font>
+01226 <a class="code" href="debug_8h.html#a6">nlassert</a> ((lumelCount&amp;0x3)==0);
+01227 uint numLumelBlock=lumelCount&gt;&gt;2;
+01228
+01229 <font class="comment">// Number of line</font>
+01230 uint lineCount=<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>;
+01231
+01232 <font class="comment">// Number of block line</font>
+01233 <a class="code" href="debug_8h.html#a6">nlassert</a> ((lineCount&amp;0x3)==0);
+01234 uint numLineBlock=lineCount&gt;&gt;2;
+01235
+01236 <font class="comment">// Resize the compressed buffer</font>
+01237 <a class="code" href="classNL3D_1_1CPatch.html#m3">CompressedLumels</a>.resize (numLumelBlock*numLineBlock*<a class="code" href="patch_8h.html#a8">NL_BLOCK_LUMEL_COMPRESSED_SIZE</a>);
+01238
+01239 <font class="comment">// Input of compresed data</font>
+01240 uint8 *compressedData=&amp;<a class="code" href="classNL3D_1_1CPatch.html#m3">CompressedLumels</a>[0];
+01241
+01242 <font class="comment">// Each line block</font>
+01243 <font class="keywordflow">for</font> (uint lineBlock=0; lineBlock&lt;numLineBlock; lineBlock++)
+01244 {
+01245 <font class="comment">// Block pointer</font>
+01246 <font class="keyword">const</font> uint8 *blockLine=pLumelSrc;
+01247
+01248 <font class="comment">// Each lumel block</font>
+01249 <font class="keywordflow">for</font> (uint lumelBlock=0; lumelBlock&lt;numLumelBlock; lumelBlock++)
+01250 {
+01251 <font class="comment">// *** Unpack the block</font>
+01252 uint countU;
+01253
+01254 <font class="comment">// Last block ?</font>
+01255 <font class="keywordflow">if</font> (lumelBlock==numLumelBlock-1)
+01256 countU=lumelCount&amp;3;
+01257 <font class="keywordflow">else</font>
+01258 countU=4;
+01259
+01260 <font class="comment">// Destination lumel</font>
+01261 <font class="keyword">const</font> uint8 *blockSrc=blockLine;
+01262
+01263 <font class="comment">// Temp block</font>
+01264 uint8 originalBlock[4*4];
+01265
+01266 <font class="comment">// Copy the lumels in the bloc</font>
+01267 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>++)
+01268 {
+01269 <font class="keywordflow">for</font> (uint u=0; u&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; u++)
+01270 {
+01271 <font class="comment">// Copy the lumel</font>
+01272 originalBlock[(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&lt;&lt;2)+u]=blockSrc[u];
+01273 }
+01274
+01275 <font class="comment">// Next line</font>
+01276 blockSrc+=lumelCount;
+01277 }
+01278
+01279 <font class="comment">// Get min and max alpha</font>
+01280 uint8 alphaMin=255;
+01281 uint8 alphaMax=0;
+01282
+01283 <font class="comment">// Scan</font>
+01284 <font class="keywordflow">for</font> (uint i=0; i&lt;16; i++)
+01285 {
+01286 <font class="comment">// Min ?</font>
+01287 <font class="keywordflow">if</font> (originalBlock[i]&lt;alphaMin)
+01288 alphaMin=originalBlock[i];
+01289 <font class="keywordflow">if</font> (originalBlock[i]&gt;alphaMax)
+01290 alphaMax=originalBlock[i];
+01291 }
+01292
+01293 <font class="comment">// *** Try to compress by 2 methods</font>
+01294
+01295 <font class="comment">// Blcok uncompressed</font>
+01296 uint8 uncompressedBlock[4*4];
+01297
+01298 <font class="comment">// Pack the block</font>
+01299 <a class="code" href="classNL3D_1_1CPatch.html#c0">packLumelBlock</a> (compressedData, originalBlock, alphaMin, alphaMax);
+01300
+01301 <font class="comment">// Unpack the block</font>
+01302 <a class="code" href="classNL3D_1_1CPatch.html#c2">unpackLumelBlock</a> (uncompressedBlock, compressedData);
+01303
+01304 <font class="comment">// Eval error</font>
+01305 uint firstMethod=<a class="code" href="classNL3D_1_1CPatch.html#c1">evalLumelBlock</a> (originalBlock, uncompressedBlock, <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>, <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>);
+01306
+01307 <font class="comment">// second compression</font>
+01308 uint8 secondCompressedBlock[<a class="code" href="patch_8h.html#a8">NL_BLOCK_LUMEL_COMPRESSED_SIZE</a>];
+01309 <a class="code" href="classNL3D_1_1CPatch.html#c0">packLumelBlock</a> (secondCompressedBlock, originalBlock, alphaMax, alphaMin);
+01310
+01311 <font class="comment">// Unpack the block</font>
+01312 <a class="code" href="classNL3D_1_1CPatch.html#c2">unpackLumelBlock</a> (uncompressedBlock, secondCompressedBlock);
+01313
+01314 <font class="comment">// Eval error</font>
+01315 uint secondMethod=<a class="code" href="classNL3D_1_1CPatch.html#c1">evalLumelBlock</a> (originalBlock, uncompressedBlock, <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>, <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>);
+01316
+01317 <font class="comment">// Second best ?</font>
+01318 <font class="keywordflow">if</font> (secondMethod&lt;firstMethod)
+01319 {
+01320 <font class="comment">// Copy compressed data</font>
+01321 memcpy (compressedData, secondCompressedBlock, <a class="code" href="patch_8h.html#a8">NL_BLOCK_LUMEL_COMPRESSED_SIZE</a>);
+01322 }
+01323
+01324 <font class="comment">// Next source block</font>
+01325 compressedData+=<a class="code" href="patch_8h.html#a8">NL_BLOCK_LUMEL_COMPRESSED_SIZE</a>;
+01326
+01327 <font class="comment">// Next block on the line</font>
+01328 blockLine+=4;
+01329 }
+01330
+01331 <font class="comment">// Next line of block</font>
+01332 pLumelSrc+=lumelCount*4;
+01333 }
+01334 }
+01335
+01336 <font class="comment">// ***************************************************************************</font>
+<a name="l01337"></a><a class="code" href="classNL3D_1_1CPatch.html#a36">01337</a> <font class="keywordtype">void</font> CPatch::resetCompressedLumels ()
+01338 {
+01339 <font class="comment">// Number of lumel by lines</font>
+01340 uint lumelCount=<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>;
+01341
+01342 <font class="comment">// Number of block in a line</font>
+01343 <a class="code" href="debug_8h.html#a6">nlassert</a> ((lumelCount&amp;0x3)==0);
+01344 uint numLumelBlock=lumelCount&gt;&gt;2;
+01345
+01346 <font class="comment">// Number of line</font>
+01347 uint lineCount=<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>;
+01348
+01349 <font class="comment">// Number of block line</font>
+01350 <a class="code" href="debug_8h.html#a6">nlassert</a> ((lineCount&amp;0x3)==0);
+01351 uint numLineBlock=lineCount&gt;&gt;2;
+01352
+01353 <font class="comment">// Size of the lumel array</font>
+01354 uint size=numLineBlock*numLumelBlock*8;
+01355
+01356 <font class="comment">// 4 bits per lumel</font>
+01357 <a class="code" href="classNL3D_1_1CPatch.html#m3">CompressedLumels</a>.resize (size);
+01358
+01359 <font class="comment">// No line have shadows.</font>
+01360 memset (&amp;<a class="code" href="classNL3D_1_1CPatch.html#m3">CompressedLumels</a>[0], 0, size);
+01361 }
+01362
+01363
+01364 <font class="comment">// ***************************************************************************</font>
+01365 <font class="comment">// ***************************************************************************</font>
+01366 <font class="comment">// Functions (C/ASM).</font>
+01367 <font class="comment">// ***************************************************************************</font>
+01368 <font class="comment">// ***************************************************************************</font>
+01369
+01370
+01371 <font class="comment">// ***************************************************************************</font>
+<a name="l01372"></a><a class="code" href="patch__lightmap_8cpp.html#a0">01372</a> <font class="preprocessor">#define a00 tex[0]</font>
+<a name="l01373"></a><a class="code" href="patch__lightmap_8cpp.html#a1">01373</a> <font class="preprocessor"></font><font class="preprocessor">#define a10 tex[1]</font>
+<a name="l01374"></a><a class="code" href="patch__lightmap_8cpp.html#a2">01374</a> <font class="preprocessor"></font><font class="preprocessor">#define a20 tex[2]</font>
+<a name="l01375"></a><a class="code" href="patch__lightmap_8cpp.html#a3">01375</a> <font class="preprocessor"></font><font class="preprocessor">#define a30 tex[3]</font>
+<a name="l01376"></a><a class="code" href="patch__lightmap_8cpp.html#a4">01376</a> <font class="preprocessor"></font><font class="preprocessor">#define a40 tex[4]</font>
+01377 <font class="preprocessor"></font>
+<a name="l01378"></a><a class="code" href="patch__lightmap_8cpp.html#a5">01378</a> <font class="preprocessor">#define a01 tex[5]</font>
+<a name="l01379"></a><a class="code" href="patch__lightmap_8cpp.html#a6">01379</a> <font class="preprocessor"></font><font class="preprocessor">#define a11 tex[6]</font>
+<a name="l01380"></a><a class="code" href="patch__lightmap_8cpp.html#a7">01380</a> <font class="preprocessor"></font><font class="preprocessor">#define a21 tex[7]</font>
+<a name="l01381"></a><a class="code" href="patch__lightmap_8cpp.html#a8">01381</a> <font class="preprocessor"></font><font class="preprocessor">#define a31 tex[8]</font>
+<a name="l01382"></a><a class="code" href="patch__lightmap_8cpp.html#a9">01382</a> <font class="preprocessor"></font><font class="preprocessor">#define a41 tex[9]</font>
+01383 <font class="preprocessor"></font>
+<a name="l01384"></a><a class="code" href="patch__lightmap_8cpp.html#a10">01384</a> <font class="preprocessor">#define a02 tex[10]</font>
+<a name="l01385"></a><a class="code" href="patch__lightmap_8cpp.html#a11">01385</a> <font class="preprocessor"></font><font class="preprocessor">#define a12 tex[11]</font>
+<a name="l01386"></a><a class="code" href="patch__lightmap_8cpp.html#a12">01386</a> <font class="preprocessor"></font><font class="preprocessor">#define a22 tex[12]</font>
+<a name="l01387"></a><a class="code" href="patch__lightmap_8cpp.html#a13">01387</a> <font class="preprocessor"></font><font class="preprocessor">#define a32 tex[13]</font>
+<a name="l01388"></a><a class="code" href="patch__lightmap_8cpp.html#a14">01388</a> <font class="preprocessor"></font><font class="preprocessor">#define a42 tex[14]</font>
+01389 <font class="preprocessor"></font>
+<a name="l01390"></a><a class="code" href="patch__lightmap_8cpp.html#a15">01390</a> <font class="preprocessor">#define a03 tex[15]</font>
+<a name="l01391"></a><a class="code" href="patch__lightmap_8cpp.html#a16">01391</a> <font class="preprocessor"></font><font class="preprocessor">#define a13 tex[16]</font>
+<a name="l01392"></a><a class="code" href="patch__lightmap_8cpp.html#a17">01392</a> <font class="preprocessor"></font><font class="preprocessor">#define a23 tex[17]</font>
+<a name="l01393"></a><a class="code" href="patch__lightmap_8cpp.html#a18">01393</a> <font class="preprocessor"></font><font class="preprocessor">#define a33 tex[18]</font>
+<a name="l01394"></a><a class="code" href="patch__lightmap_8cpp.html#a19">01394</a> <font class="preprocessor"></font><font class="preprocessor">#define a43 tex[19]</font>
+01395 <font class="preprocessor"></font>
+<a name="l01396"></a><a class="code" href="patch__lightmap_8cpp.html#a20">01396</a> <font class="preprocessor">#define a04 tex[20]</font>
+<a name="l01397"></a><a class="code" href="patch__lightmap_8cpp.html#a21">01397</a> <font class="preprocessor"></font><font class="preprocessor">#define a14 tex[21]</font>
+<a name="l01398"></a><a class="code" href="patch__lightmap_8cpp.html#a22">01398</a> <font class="preprocessor"></font><font class="preprocessor">#define a24 tex[22]</font>
+<a name="l01399"></a><a class="code" href="patch__lightmap_8cpp.html#a23">01399</a> <font class="preprocessor"></font><font class="preprocessor">#define a34 tex[23]</font>
+<a name="l01400"></a><a class="code" href="patch__lightmap_8cpp.html#a24">01400</a> <font class="preprocessor"></font><font class="preprocessor">#define a44 tex[24]</font>
+01401 <font class="preprocessor"></font>
+01402 <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a390">NL3D_bilinearTileLightMap</a>(CRGBA *tex)
+01403 {
+01404 <font class="comment">// Fast bilinear of a 5x5 tile.</font>
+01405 <font class="comment">// Corners must be set.</font>
+01406 <font class="comment">// Later: pass it to ASM.</font>
+01407
+01408 <font class="comment">// Fill first column 0 and column 4.</font>
+01409 <a class="code" href="patch__lightmap_8cpp.html#a10">a02</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a0">a00</a>, <a class="code" href="patch__lightmap_8cpp.html#a20">a04</a>);
+01410 <a class="code" href="patch__lightmap_8cpp.html#a5">a01</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a0">a00</a>, <a class="code" href="patch__lightmap_8cpp.html#a10">a02</a>);
+01411 <a class="code" href="patch__lightmap_8cpp.html#a15">a03</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a10">a02</a>, <a class="code" href="patch__lightmap_8cpp.html#a20">a04</a>);
+01412 <a class="code" href="patch__lightmap_8cpp.html#a14">a42</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a4">a40</a>, <a class="code" href="patch__lightmap_8cpp.html#a24">a44</a>);
+01413 <a class="code" href="patch__lightmap_8cpp.html#a9">a41</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a4">a40</a>, <a class="code" href="patch__lightmap_8cpp.html#a14">a42</a>);
+01414 <a class="code" href="patch__lightmap_8cpp.html#a19">a43</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a14">a42</a>, <a class="code" href="patch__lightmap_8cpp.html#a24">a44</a>);
+01415
+01416 <font class="comment">// Fill Line 0.</font>
+01417 <a class="code" href="patch__lightmap_8cpp.html#a2">a20</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a0">a00</a>, <a class="code" href="patch__lightmap_8cpp.html#a4">a40</a>);
+01418 <a class="code" href="patch__lightmap_8cpp.html#a1">a10</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a0">a00</a>, <a class="code" href="patch__lightmap_8cpp.html#a2">a20</a>);
+01419 <a class="code" href="patch__lightmap_8cpp.html#a3">a30</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a2">a20</a>, <a class="code" href="patch__lightmap_8cpp.html#a4">a40</a>);
+01420
+01421 <font class="comment">// Fill Line 1.</font>
+01422 <a class="code" href="patch__lightmap_8cpp.html#a7">a21</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a5">a01</a>, <a class="code" href="patch__lightmap_8cpp.html#a9">a41</a>);
+01423 <a class="code" href="patch__lightmap_8cpp.html#a6">a11</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a5">a01</a>, <a class="code" href="patch__lightmap_8cpp.html#a7">a21</a>);
+01424 <a class="code" href="patch__lightmap_8cpp.html#a8">a31</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a7">a21</a>, <a class="code" href="patch__lightmap_8cpp.html#a9">a41</a>);
+01425
+01426 <font class="comment">// Fill Line 2. </font>
+01427 <a class="code" href="patch__lightmap_8cpp.html#a12">a22</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a10">a02</a>, <a class="code" href="patch__lightmap_8cpp.html#a14">a42</a>);
+01428 <a class="code" href="patch__lightmap_8cpp.html#a11">a12</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a10">a02</a>, <a class="code" href="patch__lightmap_8cpp.html#a12">a22</a>);
+01429 <a class="code" href="patch__lightmap_8cpp.html#a13">a32</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a12">a22</a>, <a class="code" href="patch__lightmap_8cpp.html#a14">a42</a>);
+01430
+01431 <font class="comment">// Fill Line 3. </font>
+01432 <a class="code" href="patch__lightmap_8cpp.html#a17">a23</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a15">a03</a>, <a class="code" href="patch__lightmap_8cpp.html#a19">a43</a>);
+01433 <a class="code" href="patch__lightmap_8cpp.html#a16">a13</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a15">a03</a>, <a class="code" href="patch__lightmap_8cpp.html#a17">a23</a>);
+01434 <a class="code" href="patch__lightmap_8cpp.html#a18">a33</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a17">a23</a>, <a class="code" href="patch__lightmap_8cpp.html#a19">a43</a>);
+01435
+01436 <font class="comment">// Fill Line 4. </font>
+01437 <a class="code" href="patch__lightmap_8cpp.html#a22">a24</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a20">a04</a>, <a class="code" href="patch__lightmap_8cpp.html#a24">a44</a>);
+01438 <a class="code" href="patch__lightmap_8cpp.html#a21">a14</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a20">a04</a>, <a class="code" href="patch__lightmap_8cpp.html#a22">a24</a>);
+01439 <a class="code" href="patch__lightmap_8cpp.html#a23">a34</a>.avg2(<a class="code" href="patch__lightmap_8cpp.html#a22">a24</a>, <a class="code" href="patch__lightmap_8cpp.html#a24">a44</a>);
+01440
+01441 }
+01442
+01443
+01444 <font class="comment">// ***************************************************************************</font>
+01445 <font class="comment">// ***************************************************************************</font>
+01446 <font class="comment">// Lightmap get interface.</font>
+01447 <font class="comment">// ***************************************************************************</font>
+01448 <font class="comment">// ***************************************************************************</font>
+01449
+01450
+01451 <font class="comment">// ***************************************************************************</font>
+<a name="l01452"></a><a class="code" href="classNL3D_1_1CPatch.html#z671_0">01452</a> uint8 CPatch::getLumel(<font class="keyword">const</font> CUV &amp;uv)<font class="keyword"> const</font>
+01453 <font class="keyword"></font>{
+01454 <font class="comment">// compute tile coord and lumel coord.</font>
+01455 sint ts, tt;
+01456 <font class="comment">// get in lumel coord.</font>
+01457 sint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= (<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&lt;&lt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>);
+01458 sint h= (<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>&lt;&lt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>);
+01459 <font class="comment">// fastFloor: use a precision of 256 to avoid doing OptFastFloorBegin.</font>
+01460 <font class="comment">// add 128, to round and get cneter of lumel.</font>
+01461 ts= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(uv.U* (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>&lt;&lt;8) + 128); ts&gt;&gt;=8;
+01462 tt= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(uv.V* (h&lt;&lt;8) + 128); tt&gt;&gt;=8;
+01463 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(ts, 0, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>-1);
+01464 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(tt, 0, h-1);
+01465 <font class="comment">// get the lumel</font>
+01466 uint8 ret;
+01467 <a class="code" href="classNL3D_1_1CPatch.html#z686_4">getTileLumelmapPixelPrecomputed</a>(ts&gt;&gt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>, tt&gt;&gt;<a class="code" href="patch_8h.html#a6">NL_LUMEL_BY_TILE_SHIFT</a>,
+01468 ts&amp;(<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1), tt&amp;(<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1), ret);
+01469
+01470 <font class="keywordflow">return</font> ret;
+01471 }
+01472
+01473
+01474 <font class="comment">// ***************************************************************************</font>
+01475 <font class="comment">// ***************************************************************************</font>
+01476 <font class="comment">// TileLightInfluences</font>
+01477 <font class="comment">// ***************************************************************************</font>
+01478 <font class="comment">// ***************************************************************************</font>
+01479
+01480
+01481 <font class="comment">// ***************************************************************************</font>
+<a name="l01482"></a><a class="code" href="classNL3D_1_1CPatch.html#z675_0">01482</a> <font class="keywordtype">void</font> CPatch::resetTileLightInfluences()
+01483 {
+01484 <font class="comment">// Fill default.</font>
+01485 <a class="code" href="classNL3D_1_1CPatch.html#m6">TileLightInfluences</a>.resize((<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>/2 +1) * (<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>/2 +1));
+01486 <font class="comment">// Disable All light influence on all points</font>
+01487 <font class="keywordflow">for</font>(uint i=0;i &lt;<a class="code" href="classNL3D_1_1CPatch.html#m6">TileLightInfluences</a>.size(); i++)
+01488 {
+01489 <font class="comment">// Disable all light influence on this point.</font>
+01490 <a class="code" href="classNL3D_1_1CPatch.html#m6">TileLightInfluences</a>[i].Light[0]= 0xFF;
+01491 }
+01492 }
+01493
+01494
+01495 <font class="comment">// ***************************************************************************</font>
+<a name="l01496"></a><a class="code" href="classNL3D_1_1CPatch.html#z671_1">01496</a> <font class="keywordtype">void</font> CPatch::appendTileLightInfluences(<font class="keyword">const</font> CUV &amp;uv,
+01497 std::vector&lt;CPointLightInfluence&gt; &amp;pointLightList)<font class="keyword"> const</font>
+01498 <font class="keyword"></font>{
+01499 <font class="comment">// Compute TLI coord for BiLinear.</font>
+01500 sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+01501 <font class="comment">// There is (OrderS/2+1) * (OrderT/2+1) tileLightInfluences (TLI).</font>
+01502 sint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= (<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;&gt;1);
+01503 sint h= (<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>&gt;&gt;1);
+01504 sint wTLI= <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>+1;
+01505 <font class="comment">// fastFloor: use a precision of 256 to avoid doing OptFastFloorBegin.</font>
+01506 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(uv.U * (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>&lt;&lt;8));
+01507 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(uv.V * (h&lt;&lt;8));
+01508 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, 0, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>&lt;&lt;8);
+01509 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, 0, h&lt;&lt;8);
+01510 <font class="comment">// compute the TLI coord, and the subCoord for bilinear.</font>
+01511 sint xTLI,yTLI, xSub, ySub;
+01512 xTLI= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&gt;&gt;8; <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(xTLI, 0, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>-1);
+01513 yTLI= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&gt;&gt;8; <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(yTLI, 0, h-1);
+01514 <font class="comment">// Hence, xSub and ySub range is [0, 256].</font>
+01515 xSub= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - (xTLI&lt;&lt;8);
+01516 ySub= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - (yTLI&lt;&lt;8);
+01517
+01518
+01519 <font class="comment">// Use a CLightInfluenceInterpolator to biLinear light influence</font>
+01520 CLightInfluenceInterpolator interp;
+01521 <font class="comment">// Must support only 2 light per TLI.</font>
+01522 <a class="code" href="debug_8h.html#a6">nlassert</a>(CTileLightInfluence::NumLightPerCorner==2);
+01523 <a class="code" href="debug_8h.html#a6">nlassert</a>(CLightInfluenceInterpolator::NumLightPerCorner==2);
+01524 <font class="comment">// Get ref on array of PointLightNamed.</font>
+01525 CPointLightNamed *zonePointLights= NULL;
+01526 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CPatch.html#a5">getZone</a>()-&gt;_PointLightArray.getPointLights().size() &gt;0 )
+01527 {
+01528 <font class="comment">// const_cast, because will only change _IdInfluence, and </font>
+01529 <font class="comment">// also because CLightingManager will call appendLightedModel()</font>
+01530 zonePointLights= const_cast&lt;CPointLightNamed*&gt;(&amp;(<a class="code" href="classNL3D_1_1CPatch.html#a5">getZone</a>()-&gt;_PointLightArray.getPointLights()[0]));
+01531 }
+01532 <font class="comment">// For 4 corners.</font>
+01533 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;2;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+01534 {
+01535 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;2;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+01536 {
+01537 <font class="comment">// get ref on TLI, and on corner.</font>
+01538 <font class="keyword">const</font> CTileLightInfluence &amp;tli= <a class="code" href="classNL3D_1_1CPatch.html#m6">TileLightInfluences</a>[ (yTLI+<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)*wTLI + xTLI+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> ];
+01539 CLightInfluenceInterpolator::CCorner &amp;corner= interp.Corners[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*2 + <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>];
+01540 <font class="comment">// For all lights</font>
+01541 uint lid;
+01542 <font class="keywordflow">for</font>(lid= 0; lid&lt;CTileLightInfluence::NumLightPerCorner; lid++)
+01543 {
+01544 <font class="comment">// get the id of the light in the zone</font>
+01545 uint tliLightId= tli.Light[lid];
+01546 <font class="comment">// If empty id, stop</font>
+01547 <font class="keywordflow">if</font>(tliLightId==0xFF)
+01548 <font class="keywordflow">break</font>;
+01549 <font class="keywordflow">else</font>
+01550 {
+01551 <font class="comment">// Set pointer of the light in the corner</font>
+01552 corner.Lights[lid]= zonePointLights + tliLightId;
+01553 }
+01554 }
+01555 <font class="comment">// Reset Empty slots.</font>
+01556 <font class="keywordflow">for</font>(; lid&lt;CTileLightInfluence::NumLightPerCorner; lid++)
+01557 {
+01558 <font class="comment">// set to NULL</font>
+01559 corner.Lights[lid]= NULL;
+01560 }
+01561 }
+01562 }
+01563 <font class="comment">// interpolate.</font>
+01564 interp.interpolate(pointLightList, xSub/256.f, ySub/256.f);
+01565 }
+01566
+01567
+01568 <font class="comment">// ***************************************************************************</font>
+01569 CRGBA CPatch::getCurrentTLIColor(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)<font class="keyword"> const</font>
+01570 <font class="keyword"></font>{
+01571 CRGBA ret;
+01572 ret= CRGBA::Black;
+01573
+01574 <font class="comment">// if at least the zone has pointLights, add them.</font>
+01575 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CPatch.html#a5">getZone</a>()-&gt;_PointLightArray.getPointLights().size() &gt;0 )
+01576 {
+01577 <font class="keyword">const</font> CPointLightNamed *zonePointLights;
+01578 zonePointLights= (&amp;(<a class="code" href="classNL3D_1_1CPatch.html#a5">getZone</a>()-&gt;_PointLightArray.getPointLights()[0]));
+01579
+01580 uint wTLI= (<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;&gt;1)+1;
+01581
+01582 <font class="keyword">const</font> CTileLightInfluence &amp;tli= <a class="code" href="classNL3D_1_1CPatch.html#m6">TileLightInfluences</a>[ <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*wTLI + <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>];
+01583 <font class="keywordflow">for</font>(uint lid=0;lid&lt;CTileLightInfluence::NumLightPerCorner;lid++)
+01584 {
+01585 <font class="comment">// Not influenced by a pointLight?, stop</font>
+01586 <font class="keywordflow">if</font>(tli.Light[lid]==0xFF)
+01587 <font class="keywordflow">break</font>;
+01588 <font class="comment">// Append the influence of this pointLight. </font>
+01589 CRGBA lightCol= zonePointLights[tli.Light[lid]].getDiffuse();
+01590 <font class="comment">// modulate with landscape Material.</font>
+01591 lightCol.modulateFromColorRGBOnly(lightCol, <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;getPointLightDiffuseMaterial() );
+01592 <font class="comment">// modulate with precomputed diffuse factor</font>
+01593 lightCol.modulateFromuiRGBOnly(lightCol, tli.getDiffuseLightFactor(lid) );
+01594 <font class="comment">// add to the corner</font>
+01595 ret.addRGBOnly(ret, lightCol);
+01596 }
+01597 }
+01598
+01599 <font class="keywordflow">return</font> ret;
+01600 }
+01601
+01602
+01603 <font class="comment">// ***************************************************************************</font>
+<a name="l01604"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_19">01604</a> <font class="keywordtype">void</font> CPatch::getCurrentTileTLIColors(uint ts, uint tt, <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> corners[4])
+01605 {
+01606 <font class="comment">// Get ref on array of PointLightNamed.</font>
+01607 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CPatch.html#a5">getZone</a>()-&gt;_PointLightArray.getPointLights().size() &gt;0 )
+01608 {
+01609 <font class="comment">// get coord of the tessBlock</font>
+01610 uint tbs= ts&gt;&gt;1;
+01611 uint tbt= tt&gt;&gt;1;
+01612 <font class="comment">// get tile id local to tessBlock.</font>
+01613 uint tls= ts-(tbs&lt;&lt;1);
+01614 uint tlt= tt-(tbt&lt;&lt;1);
+01615
+01616 <font class="comment">// For each corner of the tessBlock, compute lighting with pointLights.</font>
+01617 CRGBA tbCorners[4];
+01618 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;2;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+01619 {
+01620 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;2;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+01621 {
+01622 CRGBA &amp;cornerCol= tbCorners[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*2+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>];
+01623 cornerCol= getCurrentTLIColor(tbs+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, tbt+<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
+01624 }
+01625 }
+01626
+01627 <font class="comment">// Then biLinear to tile Level (tessBlock==2x2 tiles).</font>
+01628 CRGBA tbEdges[4];
+01629 CRGBA tbMiddle;
+01630 <font class="comment">// left.</font>
+01631 tbEdges[0].avg2RGBOnly(tbCorners[0], tbCorners[2]);
+01632 <font class="comment">// bottom</font>
+01633 tbEdges[1].avg2RGBOnly(tbCorners[2], tbCorners[3]);
+01634 <font class="comment">// right</font>
+01635 tbEdges[2].avg2RGBOnly(tbCorners[1], tbCorners[3]);
+01636 <font class="comment">// up</font>
+01637 tbEdges[3].avg2RGBOnly(tbCorners[0], tbCorners[1]);
+01638 <font class="comment">// middle.</font>
+01639 tbMiddle.avg2RGBOnly(tbEdges[0], tbEdges[2]);
+01640
+01641 <font class="comment">// just copy result according to tile pos in tessBlock.</font>
+01642 <font class="keywordflow">if</font>(tlt==0)
+01643 {
+01644 <font class="keywordflow">if</font>(tls==0)
+01645 {
+01646 corners[0]= tbCorners[0];
+01647 corners[1]= tbEdges[3];
+01648 corners[2]= tbEdges[0];
+01649 corners[3]= tbMiddle;
+01650 }
+01651 <font class="keywordflow">else</font>
+01652 {
+01653 corners[0]= tbEdges[3];
+01654 corners[1]= tbCorners[1];
+01655 corners[2]= tbMiddle;
+01656 corners[3]= tbEdges[2];
+01657 }
+01658 }
+01659 <font class="keywordflow">else</font>
+01660 {
+01661 <font class="keywordflow">if</font>(tls==0)
+01662 {
+01663 corners[0]= tbEdges[0];
+01664 corners[1]= tbMiddle;
+01665 corners[2]= tbCorners[2];
+01666 corners[3]= tbEdges[1];
+01667 }
+01668 <font class="keywordflow">else</font>
+01669 {
+01670 corners[0]= tbMiddle;
+01671 corners[1]= tbEdges[2];
+01672 corners[2]= tbEdges[1];
+01673 corners[3]= tbCorners[3];
+01674 }
+01675 }
+01676 }
+01677 <font class="keywordflow">else</font>
+01678 {
+01679 <font class="comment">// Just fill with 0s.</font>
+01680 corners[0]= CRGBA::Black;
+01681 corners[1]= CRGBA::Black;
+01682 corners[2]= CRGBA::Black;
+01683 corners[3]= CRGBA::Black;
+01684 }
+01685 }
+01686
+01687 <font class="comment">// ***************************************************************************</font>
+<a name="l01688"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_20">01688</a> <font class="keywordtype">void</font> CPatch::addTileLightmapWithTLI(uint ts, uint tt, <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *dest, uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>)
+01689 {
+01690 <font class="comment">// compute colors ar corners of the tile.</font>
+01691 CRGBA corners[4];
+01692 <a class="code" href="classNL3D_1_1CPatch.html#z682_19">getCurrentTileTLIColors</a>(ts, tt, corners);
+01693
+01694 <font class="comment">// Bilinear accross the tile, and add to dest.</font>
+01695 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+01696 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+01697 {
+01698 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+01699 {
+01700 <font class="comment">// compute this pixel, and add</font>
+01701 <a class="code" href="namespaceNL3D.html#a389">bilinearColorAndAdd</a>(corners, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, dest[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>]);
+01702 }
+01703 }
+01704 }
+01705
+01706 <font class="comment">// ***************************************************************************</font>
+<a name="l01707"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_21">01707</a> <font class="keywordtype">void</font> CPatch::addTileLightmapEdgeWithTLI(uint ts, uint tt, uint edge, <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *dest, uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>, <font class="keywordtype">bool</font> inverse)
+01708 {
+01709 <font class="comment">// compute colors ar corners of the tile.</font>
+01710 CRGBA corners[4];
+01711 <a class="code" href="classNL3D_1_1CPatch.html#z682_19">getCurrentTileTLIColors</a>(ts, tt, corners);
+01712
+01713 <font class="comment">// get coordinate according to edge.</font>
+01714 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;
+01715 <font class="keywordflow">switch</font>(edge)
+01716 {
+01717 <font class="keywordflow">case</font> 0: <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= 0; <font class="keywordflow">break</font>;
+01718 <font class="keywordflow">case</font> 1: <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1; <font class="keywordflow">break</font>;
+01719 <font class="keywordflow">case</font> 2: <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= <a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1; <font class="keywordflow">break</font>;
+01720 <font class="keywordflow">case</font> 3: <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= 0; <font class="keywordflow">break</font>;
+01721 };
+01722
+01723 <font class="comment">// For all lumel of the edge, bilinear.</font>
+01724 uint i;
+01725 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>; i++)
+01726 {
+01727 <font class="comment">// if vertical edge</font>
+01728 <font class="keywordflow">if</font>( (edge&amp;1)==0 ) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= i;
+01729 <font class="comment">// else horizontal edge</font>
+01730 <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= i;
+01731
+01732 <font class="comment">// manage inverse.</font>
+01733 uint where;
+01734 <font class="keywordflow">if</font>(inverse) where= (<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>-1)-i;
+01735 <font class="keywordflow">else</font> where= i;
+01736 <font class="comment">// compute this pixel, and modulate</font>
+01737 <a class="code" href="namespaceNL3D.html#a389">bilinearColorAndAdd</a>(corners, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, dest[where*<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>]);
+01738 }
+01739 }
+01740
+01741 <font class="comment">// ***************************************************************************</font>
+<a name="l01742"></a><a class="code" href="classNL3D_1_1CPatch.html#z682_22">01742</a> <font class="keywordtype">void</font> CPatch::addTileLightmapPixelWithTLI(uint ts, uint tt, uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *dest)
+01743 {
+01744 <font class="comment">// compute colors ar corners of the tile.</font>
+01745 CRGBA corners[4];
+01746 <a class="code" href="classNL3D_1_1CPatch.html#z682_19">getCurrentTileTLIColors</a>(ts, tt, corners);
+01747
+01748 <font class="comment">// compute this pixel, and modulate</font>
+01749 <a class="code" href="namespaceNL3D.html#a389">bilinearColorAndAdd</a>(corners, <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, *dest);
+01750 }
+01751
+01752
+01753 <font class="comment">// ***************************************************************************</font>
+<a name="l01754"></a><a class="code" href="classNL3D_1_1CPatch.html#z671_2">01754</a> <font class="keywordtype">void</font> CPatch::computeCurrentTLILightmap(<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *array)<font class="keyword"> const</font>
+01755 <font class="keyword"></font>{
+01756 <font class="comment">// Size of TileLightInfluences</font>
+01757 uint wTLI= (<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;&gt;1)+1;
+01758 uint hTLI= (<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>&gt;&gt;1)+1;
+01759 <font class="comment">// colros at corners of tiles size.</font>
+01760 uint wTC= <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>+1;
+01761 uint wTCx2= wTC*2;
+01762 uint hTC= <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>+1;
+01763 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+01764
+01765 <font class="comment">// Compute TLI colors at each corner of each TessBlocks.</font>
+01766 <font class="comment">//=============</font>
+01767 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;hTLI;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+01768 {
+01769 <font class="comment">// store every 2 tiles corners.</font>
+01770 CRGBA *dst= array + <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*2*wTC;
+01771 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;wTLI;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+01772 {
+01773 *dst= getCurrentTLIColor(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
+01774 <font class="comment">// skip 2 tiles corners.</font>
+01775 dst++;
+01776 dst++;
+01777 }
+01778 }
+01779
+01780 <font class="comment">// Compute TLI colors at each corner of each Tiles.</font>
+01781 <font class="comment">//=============</font>
+01782
+01783 <font class="comment">// Compute corner at middle of vertical TessBlock edges.</font>
+01784 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;hTC-1;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+=2)
+01785 {
+01786 CRGBA *dst= array + <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*wTC;
+01787 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;wTC;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+=2)
+01788 {
+01789 <font class="comment">// Average midlle with cur and next.</font>
+01790 (dst+wTC)-&gt;avg2RGBOnly(*dst, *(dst + wTCx2) );
+01791
+01792 <font class="comment">// skip 2 tiles corners.</font>
+01793 dst++;
+01794 dst++;
+01795 }
+01796 }
+01797
+01798 <font class="comment">// Compute corner at middle of horizontal TessBlock edges, and at middle of TessBlock.</font>
+01799 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;hTC;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+01800 {
+01801 CRGBA *dst= array + <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*wTC;
+01802 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;wTC-1;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+=2)
+01803 {
+01804 <font class="comment">// Average midlle with cur and next.</font>
+01805 (dst+1)-&gt;avg2RGBOnly(*dst, *(dst+2));
+01806
+01807 <font class="comment">// skip 2 tiles corners.</font>
+01808 dst++;
+01809 dst++;
+01810 }
+01811 }
+01812
+01813
+01814 }
+01815
+01816
+01817
+01818 <font class="comment">// ***************************************************************************</font>
+01819 <font class="comment">// ***************************************************************************</font>
+01820 <font class="comment">// UpdateLighting.</font>
+01821 <font class="comment">// ***************************************************************************</font>
+01822 <font class="comment">// ***************************************************************************</font>
+01823
+01824
+01825 <font class="comment">// ***************************************************************************</font>
+<a name="l01826"></a><a class="code" href="classNL3D_1_1CPatch.html#z676_0">01826</a> <font class="keywordtype">void</font> CPatch::linkBeforeNearUL(CPatch *patchNext)
+01827 {
+01828 <a class="code" href="debug_8h.html#a6">nlassert</a>(patchNext);
+01829
+01830 <font class="comment">// first, unlink others from me. NB: works even if _ULNearPrec==_ULNearNext==this.</font>
+01831 <a class="code" href="classNL3D_1_1CPatch.html#z687_1">_ULNearNext</a>-&gt;_ULNearPrec= <a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>;
+01832 <a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>-&gt;_ULNearNext= <a class="code" href="classNL3D_1_1CPatch.html#z687_1">_ULNearNext</a>;
+01833 <font class="comment">// link to igNext.</font>
+01834 <a class="code" href="classNL3D_1_1CPatch.html#z687_1">_ULNearNext</a>= patchNext;
+01835 <a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>= patchNext-&gt;_ULNearPrec;
+01836 <font class="comment">// link others to me.</font>
+01837 <a class="code" href="classNL3D_1_1CPatch.html#z687_1">_ULNearNext</a>-&gt;_ULNearPrec= <font class="keyword">this</font>;
+01838 <a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>-&gt;_ULNearNext= <font class="keyword">this</font>;
+01839 }
+01840
+01841
+01842 <font class="comment">// ***************************************************************************</font>
+<a name="l01843"></a><a class="code" href="classNL3D_1_1CPatch.html#z676_1">01843</a> <font class="keywordtype">void</font> CPatch::unlinkNearUL()
+01844 {
+01845 <font class="comment">// first, unlink others from me. NB: works even if _ULNearPrec==_ULNearNext==this.</font>
+01846 <a class="code" href="classNL3D_1_1CPatch.html#z687_1">_ULNearNext</a>-&gt;_ULNearPrec= <a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>;
+01847 <a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>-&gt;_ULNearNext= <a class="code" href="classNL3D_1_1CPatch.html#z687_1">_ULNearNext</a>;
+01848 <font class="comment">// reset</font>
+01849 <a class="code" href="classNL3D_1_1CPatch.html#z687_0">_ULNearPrec</a>= <font class="keyword">this</font>;
+01850 <a class="code" href="classNL3D_1_1CPatch.html#z687_1">_ULNearNext</a>= <font class="keyword">this</font>;
+01851 }
+01852
+01853
+01854 <font class="comment">// ***************************************************************************</font>
+<a name="l01855"></a><a class="code" href="classNL3D_1_1CPatch.html#z676_4">01855</a> uint CPatch::updateTessBlockLighting(uint numTb)
+01856 {
+01857 <font class="comment">// TessBlocks must have been allocated and tessBlockId must be ok.</font>
+01858 <a class="code" href="debug_8h.html#a6">nlassert</a>(numTb&lt;<a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>.size());
+01859
+01860 <font class="comment">// compute tessBlock coordinate</font>
+01861 uint tbWidth= <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>&gt;&gt;1;
+01862 uint ts= numTb&amp;(tbWidth-1);
+01863 uint tt= numTb/tbWidth;
+01864 <font class="comment">// expand to tile coordinate.</font>
+01865 ts*= 2;
+01866 tt*= 2;
+01867
+01868 <font class="comment">// get what tessBlock to use.</font>
+01869 CTessBlock &amp;tessBlock= <a class="code" href="classNL3D_1_1CPatch.html#z678_1">TessBlocks</a>[numTb];
+01870
+01871 <font class="comment">// If the lightmap Id has not been computed, quit</font>
+01872 <font class="keywordflow">if</font>(tessBlock.LightMapRefCount==0)
+01873 <font class="keywordflow">return</font> 0;
+01874 <font class="keywordflow">else</font>
+01875 {
+01876 <font class="comment">// Recompute the lightmap texture, with help of TileColors, with neighboring info etc...</font>
+01877 CRGBA lightText[<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>];
+01878 <a class="code" href="classNL3D_1_1CPatch.html#z682_3">computeNearBlockLightmap</a>(ts&amp;(~1), tt&amp;(~1), lightText);
+01879
+01880 <font class="comment">// donlod this texture to Driver etc...</font>
+01881 <a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>-&gt;Landscape-&gt;refillTileLightMap(tessBlock.LightMapId, lightText);
+01882
+01883 <font class="comment">// return number of pixels computed.</font>
+01884 <font class="keywordflow">return</font> <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>;
+01885 }
+01886 }
+01887
+01888
+01889 <font class="comment">// ***************************************************************************</font>
+01890 <font class="comment">// ***************************************************************************</font>
+01891 <font class="comment">// ***************************************************************************</font>
+01892 <font class="comment">// ***************************************************************************</font>
+01893
+01894
+01895 <font class="comment">// ***************************************************************************</font>
+<a name="l01896"></a><a class="code" href="classNL3D_1_1CPatch.html#z688_0">01896</a> <font class="keywordtype">void</font> CPatch::addRefDLMContext()
+01897 {
+01898 <font class="comment">// the patch must be compiled.</font>
+01899 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>);
+01900
+01901 <font class="comment">// if 0, create the context.</font>
+01902 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#z688_3">_DLMContextRefCount</a>==0)
+01903 {
+01904 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>==NULL);
+01905 <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>= <font class="keyword">new</font> CPatchDLMContext;
+01906 <font class="comment">// init now the context.</font>
+01907 <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>-&gt;generate(<font class="keyword">this</font>, <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;getTextureDLM(), <a class="code" href="classNL3D_1_1CPatch.html#a4">getLandscape</a>()-&gt;getPatchDLMContextList());
+01908
+01909 <font class="comment">// If the patch is visible, it may have Far Vertices created, </font>
+01910 <font class="comment">// hence, we must refill them with good DLM Uvs.</font>
+01911 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>)
+01912 {
+01913 <font class="comment">// setup DLM Uv with new _DLMContext</font>
+01914 <a class="code" href="classNL3D_1_1CPatch.html#z673_8">fillVBFarsDLMUvOnly</a>();
+01915 }
+01916 }
+01917
+01918 <font class="comment">// incRef.</font>
+01919 <a class="code" href="classNL3D_1_1CPatch.html#z688_3">_DLMContextRefCount</a>++;
+01920 }
+01921
+01922 <font class="comment">// ***************************************************************************</font>
+<a name="l01923"></a><a class="code" href="classNL3D_1_1CPatch.html#z688_1">01923</a> <font class="keywordtype">void</font> CPatch::decRefDLMContext(uint count)
+01924 {
+01925 <font class="comment">// the patch must be compiled.</font>
+01926 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#o0">Zone</a>);
+01927 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z688_3">_DLMContextRefCount</a>&gt;0);
+01928
+01929 <font class="comment">// dec Ref.</font>
+01930 <a class="code" href="classNL3D_1_1CPatch.html#z688_3">_DLMContextRefCount</a>-= count;
+01931 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z688_3">_DLMContextRefCount</a>&gt;=0);
+01932
+01933 <font class="comment">// If 0, delete the context.</font>
+01934 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#z688_3">_DLMContextRefCount</a>==0)
+01935 {
+01936 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>;
+01937 <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>= NULL;
+01938
+01939 <font class="comment">// If the patch is visible, it may have Far Vertices created, </font>
+01940 <font class="comment">// hence, we must reset their DLM Uvs (to point to black pixel)</font>
+01941 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>)
+01942 {
+01943 <font class="comment">// setup DLM Uv with new _DLMContext</font>
+01944 <a class="code" href="classNL3D_1_1CPatch.html#z673_8">fillVBFarsDLMUvOnly</a>();
+01945 }
+01946 }
+01947 }
+01948
+01949
+01950 <font class="comment">// ***************************************************************************</font>
+<a name="l01951"></a><a class="code" href="classNL3D_1_1CPatch.html#z677_0">01951</a> <font class="keywordtype">void</font> CPatch::beginDLMLighting()
+01952 {
+01953 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>);
+01954
+01955 <font class="comment">// Must bkup prec pointLightCount in OldPointLightCount, and reset CurPointLightCount</font>
+01956 <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>-&gt;OldPointLightCount= <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>-&gt;CurPointLightCount;
+01957 <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>-&gt;CurPointLightCount= 0;
+01958
+01959 <font class="comment">// clear lighting, only if patch is visible</font>
+01960 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>)
+01961 <font class="comment">// NB: no-op if src is already full black.</font>
+01962 <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>-&gt;clearLighting();
+01963
+01964 }
+01965
+01966 <font class="comment">// ***************************************************************************</font>
+<a name="l01967"></a><a class="code" href="classNL3D_1_1CPatch.html#z677_1">01967</a> <font class="keywordtype">void</font> CPatch::processDLMLight(CPatchDLMPointLight &amp;pl)
+01968 {
+01969 <font class="comment">// add reference to currentLight, creating DLMContext if needed</font>
+01970 <a class="code" href="classNL3D_1_1CPatch.html#z688_0">addRefDLMContext</a>();
+01971
+01972 <font class="comment">// add curLight counter</font>
+01973 <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>-&gt;CurPointLightCount++;
+01974
+01975 <font class="comment">// compute lighting, only if patch is visible</font>
+01976 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CPatch.html#o26">RenderClipped</a>)
+01977 <a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>-&gt;addPointLightInfluence(pl);
+01978 }
+01979
+01980 <font class="comment">// ***************************************************************************</font>
+<a name="l01981"></a><a class="code" href="classNL3D_1_1CPatch.html#z677_2">01981</a> <font class="keywordtype">void</font> CPatch::endDLMLighting()
+01982 {
+01983 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>);
+01984
+01985 <font class="comment">// delete reference from old pointLight influences, at prec render() pass. _DLMContext may be deleted here,</font>
+01986 <font class="comment">// if no more lights use it, and if the patch is not in Near.</font>
+01987 <a class="code" href="classNL3D_1_1CPatch.html#z688_1">decRefDLMContext</a>(<a class="code" href="classNL3D_1_1CPatch.html#z688_2">_DLMContext</a>-&gt;OldPointLightCount);
+01988 }
+01989
+01990
+01991 } <font class="comment">// NL3D</font>
+01992
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>