aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/patch__noise_8cpp-source.html
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/patch__noise_8cpp-source.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'docs/doxygen/nel/patch__noise_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/patch__noise_8cpp-source.html1037
1 files changed, 1037 insertions, 0 deletions
diff --git a/docs/doxygen/nel/patch__noise_8cpp-source.html b/docs/doxygen/nel/patch__noise_8cpp-source.html
new file mode 100644
index 00000000..80a4d798
--- /dev/null
+++ b/docs/doxygen/nel/patch__noise_8cpp-source.html
@@ -0,0 +1,1037 @@
+<!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_noise.cpp</h1><a href="patch__noise_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
+00008 <font class="comment"> *</font>
+00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00013 <font class="comment"> * any later version.</font>
+00014 <font class="comment"></font>
+00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00018 <font class="comment"> * General Public License for more details.</font>
+00019 <font class="comment"></font>
+00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00023 <font class="comment"> * MA 02111-1307, USA.</font>
+00024 <font class="comment"> */</font>
+00025
+00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
+00027
+00028
+00029 <font class="preprocessor">#include "<a class="code" href="patch_8h.html">3d/patch.h</a>"</font>
+00030 <font class="preprocessor">#include "<a class="code" href="tessellation_8h.html">3d/tessellation.h</a>"</font>
+00031 <font class="preprocessor">#include "<a class="code" href="bezier__patch_8h.html">3d/bezier_patch.h</a>"</font>
+00032 <font class="preprocessor">#include "<a class="code" href="src_23d_2zone_8h.html">3d/zone.h</a>"</font>
+00033 <font class="preprocessor">#include "<a class="code" href="landscape_8h.html">3d/landscape.h</a>"</font>
+00034 <font class="preprocessor">#include "<a class="code" href="vector_8h.html">nel/misc/vector.h</a>"</font>
+00035 <font class="preprocessor">#include "<a class="code" href="common_8h.html">nel/misc/common.h</a>"</font>
+00036 <font class="preprocessor">#include "<a class="code" href="tile__noise__map_8h.html">3d/tile_noise_map.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="keyword">using</font> <font class="keyword">namespace </font>std;
+00039 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00040
+00041
+00042 <font class="keyword">namespace </font>NL3D
+00043 {
+00044
+00045
+00046 <font class="comment">// ***************************************************************************</font>
+00047
+00048
+00049 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00050 <font class="preprocessor"></font>
+00051 <font class="comment">/* This floor works only for floor with noise, because floor/ceil are only made on decimal coordinates:</font>
+00052 <font class="comment"> sTile =1.25 .... NB: because of difference of mapping (rare case), we may have sometimes values with</font>
+00053 <font class="comment"> precision &lt; 1/4 (eg 1.125). Just use f*256 to compute the floor.</font>
+00054 <font class="comment"></font>
+00055 <font class="comment"> NB: using a fastFloor() (fistp changing the controlfp() is not very a good idea here, because </font>
+00056 <font class="comment"> computeNoise() are not "packed", so change on controlFp() would bee to frequent... </font>
+00057 <font class="comment"> And also because we need either floor() or ceil() here.</font>
+00058 <font class="comment">*/</font>
+00059 <font class="keyword">inline</font> sint <a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(<font class="keywordtype">float</font> f)
+00060 {
+00061 <font class="comment">// build a fixed 24:8.</font>
+00062 sint a;
+00063 f*=256;
+00064
+00065 <font class="comment">// fast ftol. work if no decimal.</font>
+00066 _asm
+00067 {
+00068 fld f
+00069 fistp a
+00070 }
+00071
+00072 <font class="comment">// floor.</font>
+00073 a&gt;&gt;=8;
+00074
+00075 <font class="keywordflow">return</font> a;
+00076 }
+00077
+00078
+00079 <font class="keyword">inline</font> sint <a class="code" href="namespaceNL3D.html#a394">noiseCeil</a>(<font class="keywordtype">float</font> f)
+00080 {
+00081 <font class="comment">// build a fixed 24:8.</font>
+00082 sint a;
+00083 f*=256;
+00084
+00085 <font class="comment">// fast ftol. work if no decimal.</font>
+00086 _asm
+00087 {
+00088 fld f
+00089 fistp a
+00090 }
+00091
+00092 <font class="comment">// ceil.</font>
+00093 a+=255;
+00094 a&gt;&gt;=8;
+00095
+00096 <font class="keywordflow">return</font> a;
+00097 }
+00098
+00099
+00100 <font class="keyword">inline</font> <font class="keywordtype">float</font> <a class="code" href="namespaceNL3D.html#a391">noiseFloorF</a>(<font class="keywordtype">float</font> f)
+00101 {
+00102 <font class="keywordflow">return</font> (float)<a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(f);
+00103 }
+00104 <font class="keyword">inline</font> <font class="keywordtype">float</font> <a class="code" href="namespaceNL3D.html#a392">noiseCeilF</a>(<font class="keywordtype">float</font> f)
+00105 {
+00106 <font class="keywordflow">return</font> (float)<a class="code" href="namespaceNL3D.html#a394">noiseCeil</a>(f);
+00107 }
+00108
+00109
+00110 <font class="preprocessor">#else</font>
+00111 <font class="preprocessor"></font>
+00112
+00113 <font class="keyword">inline</font> <font class="keywordtype">float</font> <a class="code" href="namespaceNL3D.html#a391">noiseFloorF</a>(<font class="keywordtype">float</font> f)
+00114 {
+00115 <font class="keywordflow">return</font> (float)floor(f);
+00116 }
+00117 <font class="keyword">inline</font> <font class="keywordtype">float</font> <a class="code" href="namespaceNL3D.html#a392">noiseCeilF</a>(<font class="keywordtype">float</font> f)
+00118 {
+00119 <font class="keywordflow">return</font> (float)ceil(f);
+00120 }
+00121
+00122 <font class="keyword">inline</font> sint <a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(<font class="keywordtype">float</font> f)
+00123 {
+00124 <font class="keywordflow">return</font> (sint)floor(f);
+00125 }
+00126 <font class="keyword">inline</font> sint <a class="code" href="namespaceNL3D.html#a394">noiseCeil</a>(<font class="keywordtype">float</font> f)
+00127 {
+00128 <font class="keywordflow">return</font> (sint)ceil(f);
+00129 }
+00130
+00131 <font class="preprocessor">#endif</font>
+00132 <font class="preprocessor"></font>
+00133
+00134
+00135 <font class="comment">// ***************************************************************************</font>
+<a name="l00136"></a><a class="code" href="classNL3D_1_1CPatch.html#z685_0">00136</a> <font class="keywordtype">float</font> CPatch::computeDisplaceRawInteger(sint ts, sint tt, sint ms, sint mt)<font class="keyword"> const</font>
+00137 <font class="keyword"></font>{
+00138 <font class="comment">// Choose the noiseMap.</font>
+00139 <font class="comment">// ===============================</font>
+00140 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(ts, 0, <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>-1);
+00141 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(tt, 0, <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>-1);
+00142
+00143 uint tileId= tt*<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a> + ts;
+00144 <font class="comment">// Get the tile for pass0. This is the principal tile, and this one tells what noise to take.</font>
+00145 sint tileNumber= <a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[tileId].Tile[0];
+00146 <font class="comment">// Get the subNoise from tileElement.</font>
+00147 uint tileSubNoise= <a class="code" href="classNL3D_1_1CPatch.html#m4">Tiles</a>[tileId].getTileSubNoise();
+00148
+00149 <font class="comment">// retrieve the wanted noiseMap.</font>
+00150 CTileNoiseMap *noiseMap;
+00151 noiseMap = <a class="code" href="classNL3D_1_1CPatch.html#a5">getZone</a>()-&gt;getLandscape()-&gt;TileBank.getTileNoiseMap (tileNumber, tileSubNoise);
+00152
+00153
+00154 <font class="comment">// Sample the noiseMap with (s,t).</font>
+00155 <font class="comment">// ===============================</font>
+00156
+00157 <font class="comment">// sample from map.</font>
+00158 sint8 pix= noiseMap-&gt;Pixels[mt*<a class="code" href="tile__noise__map_8h.html#a1">NL3D_TILE_NOISE_MAP_SIZE</a> + ms];
+00159
+00160 <font class="comment">// normalize.</font>
+00161 <font class="keywordflow">return</font> (float)pix * (<a class="code" href="patch_8h.html#a11">NL3D_NOISE_MAX</a> / 127.f);
+00162 }
+00163
+00164
+00165 <font class="comment">// ***************************************************************************</font>
+<a name="l00166"></a><a class="code" href="classNL3D_1_1CPatch.html#z685_1">00166</a> <font class="keywordtype">void</font> CPatch::computeDisplaceRawCoordinates(<font class="keywordtype">float</font> sTile, <font class="keywordtype">float</font> tTile, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>,
+00167 sint &amp;ts, sint &amp;tt, sint &amp;ms, sint &amp;mt)<font class="keyword"> const</font>
+00168 <font class="keyword"></font>{
+00169 <font class="comment">// Choose the noiseMap.</font>
+00170 <font class="comment">// ===============================</font>
+00171 <font class="comment">// Compute coordinate in the patch.</font>
+00172 ts= <a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(sTile);
+00173 tt= <a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(tTile);
+00174
+00175
+00176 <font class="comment">// Sample the noiseMap with (s,t).</font>
+00177 <font class="comment">// ===============================</font>
+00178
+00179 <font class="comment">// scale the map.</font>
+00180 <font class="keywordtype">float</font> u= <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> * <a class="code" href="tile__noise__map_8h.html#a0">NL3D_TILE_NOISE_MAP_TILE_FACTOR</a>;
+00181 <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a> * <a class="code" href="tile__noise__map_8h.html#a0">NL3D_TILE_NOISE_MAP_TILE_FACTOR</a>;
+00182
+00183 <font class="comment">// Speed rotation.</font>
+00184 CUV uv;
+00185 <font class="keywordflow">switch</font>(<a class="code" href="classNL3D_1_1CPatch.html#z668_2">NoiseRotation</a> &amp; 3)
+00186 {
+00187 <font class="keywordflow">case</font> 0:
+00188 uv.U= u;
+00189 uv.V= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+00190 <font class="keywordflow">break</font>;
+00191 <font class="keywordflow">case</font> 1:
+00192 uv.U= <a class="code" href="tile__noise__map_8h.html#a1">NL3D_TILE_NOISE_MAP_SIZE</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+00193 uv.V= u;
+00194 <font class="keywordflow">break</font>;
+00195 <font class="keywordflow">case</font> 2:
+00196 uv.U= <a class="code" href="tile__noise__map_8h.html#a1">NL3D_TILE_NOISE_MAP_SIZE</a>-u;
+00197 uv.V= <a class="code" href="tile__noise__map_8h.html#a1">NL3D_TILE_NOISE_MAP_SIZE</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+00198 <font class="keywordflow">break</font>;
+00199 <font class="keywordflow">case</font> 3:
+00200 uv.U= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+00201 uv.V= <a class="code" href="tile__noise__map_8h.html#a1">NL3D_TILE_NOISE_MAP_SIZE</a>-u;
+00202 <font class="keywordflow">break</font>;
+00203 }
+00204
+00205 <font class="comment">// direct map (no bilinear, no round, the case where s,t &lt; 1/4 of a tile is very rare).</font>
+00206 ms= <a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(uv.U);
+00207 mt= <a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(uv.V);
+00208
+00209 <font class="comment">// Manage Tiling (add NL3D_TILE_NOISE_MAP_SIZE*1 should be sufficient, but take margin).</font>
+00210 ms= (ms + (<a class="code" href="tile__noise__map_8h.html#a1">NL3D_TILE_NOISE_MAP_SIZE</a>*256)) &amp; (<a class="code" href="tile__noise__map_8h.html#a1">NL3D_TILE_NOISE_MAP_SIZE</a>-1);
+00211 mt= (mt + (<a class="code" href="tile__noise__map_8h.html#a1">NL3D_TILE_NOISE_MAP_SIZE</a>*256)) &amp; (<a class="code" href="tile__noise__map_8h.html#a1">NL3D_TILE_NOISE_MAP_SIZE</a>-1);
+00212 }
+00213
+00214
+00215
+00216 <font class="comment">// ***************************************************************************</font>
+<a name="l00217"></a><a class="code" href="classNL3D_1_1CPatch.html#z685_2">00217</a> <font class="keywordtype">float</font> CPatch::computeDisplaceRaw(<font class="keywordtype">float</font> sTile, <font class="keywordtype">float</font> tTile, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)<font class="keyword"> const</font>
+00218 <font class="keyword"></font>{
+00219 sint ts,tt,ms,mt;
+00220 <a class="code" href="classNL3D_1_1CPatch.html#z685_1">computeDisplaceRawCoordinates</a>(sTile, tTile, <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>, ts, tt, ms, mt);
+00221 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#z685_0">computeDisplaceRawInteger</a>(ts, tt, ms, mt);
+00222
+00223 }
+00224
+00225 <font class="comment">// ***************************************************************************</font>
+00226 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a395">computeDisplaceBilinear</a>(<font class="keywordtype">float</font> sTile, <font class="keywordtype">float</font> tTile,
+00227 <font class="keywordtype">float</font> &amp;sInc, <font class="keywordtype">float</font> &amp;tInc, <font class="keywordtype">float</font> &amp;sa, <font class="keywordtype">float</font> &amp;ta, <font class="keywordtype">float</font> &amp;sa1, <font class="keywordtype">float</font> &amp;ta1)
+00228 {
+00229 <font class="keywordtype">float</font> sDecimal= sTile-<a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(sTile);
+00230 <font class="keywordtype">float</font> tDecimal= tTile-<a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(tTile);
+00231 <font class="keywordtype">float</font> sDist, tDist;
+00232
+00233 <font class="comment">// Do a bilinear centered on 0.5, 0.5.</font>
+00234
+00235 <font class="comment">// Compute increment, according to position against center.</font>
+00236 <font class="keywordflow">if</font>(sDecimal&gt;=0.5)
+00237 sInc= 1;
+00238 <font class="keywordflow">else</font>
+00239 sInc= -1;
+00240 <font class="keywordflow">if</font>(tDecimal&gt;=0.5)
+00241 tInc= 1;
+00242 <font class="keywordflow">else</font>
+00243 tInc= -1;
+00244
+00245 <font class="comment">// Compute weight factor.</font>
+00246 sDist= (float)fabs(0.5 - sDecimal); <font class="comment">// s distance from center.</font>
+00247 tDist= (float)fabs(0.5 - tDecimal); <font class="comment">// t distance from center.</font>
+00248 sa= 1-sDist;
+00249 ta= 1-tDist;
+00250 sa1= 1-sa;
+00251 ta1= 1-ta;
+00252 }
+00253
+00254
+00255 <font class="comment">// ***************************************************************************</font>
+<a name="l00256"></a><a class="code" href="classNL3D_1_1CPatch.html#z685_4">00256</a> <font class="keywordtype">float</font> CPatch::computeDisplaceInteriorSmooth(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)<font class="keyword"> const</font>
+00257 <font class="keyword"></font>{
+00258 <font class="keywordtype">float</font> sTile= <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00259 <font class="keywordtype">float</font> tTile= <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+00260 <font class="keywordtype">float</font> ret;
+00261
+00262 <font class="comment">// compute bi-linear weight factors.</font>
+00263 <font class="keywordtype">float</font> sInc, tInc, sa, ta, sa1, ta1;
+00264 <a class="code" href="namespaceNL3D.html#a395">computeDisplaceBilinear</a>(sTile, tTile, sInc, tInc, sa, ta, sa1, ta1);
+00265
+00266
+00267 <font class="comment">// NB: to have smooth transition, must keep the same (s,t), so we do a transition with the noise tile of </font>
+00268 <font class="comment">// our neigbhor, but under us.</font>
+00269
+00270 <font class="comment">// speed up, using just one computeDisplaceRawCoordinates(), and multiple computeDisplaceRawInteger().</font>
+00271 sint ts,tt,ms,mt;
+00272 <a class="code" href="classNL3D_1_1CPatch.html#z685_1">computeDisplaceRawCoordinates</a>(sTile, tTile, <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>, ts, tt, ms, mt);
+00273
+00274 sint sIncInt= (sint) sInc;
+00275 sint tIncInt= (sint) tInc;
+00276 ret = <a class="code" href="classNL3D_1_1CPatch.html#z685_0">computeDisplaceRawInteger</a>(ts, tt, ms,mt) * sa * ta;
+00277 ret+= <a class="code" href="classNL3D_1_1CPatch.html#z685_0">computeDisplaceRawInteger</a>(ts+sIncInt, tt, ms,mt) * sa1 * ta;
+00278 ret+= <a class="code" href="classNL3D_1_1CPatch.html#z685_0">computeDisplaceRawInteger</a>(ts, tt+tIncInt, ms,mt) * sa * ta1;
+00279 ret+= <a class="code" href="classNL3D_1_1CPatch.html#z685_0">computeDisplaceRawInteger</a>(ts+sIncInt, tt+tIncInt, ms,mt) * sa1 * ta1;
+00280
+00281 <font class="keywordflow">return</font> ret;
+00282 }
+00283
+00284
+00285 <font class="comment">// ***************************************************************************</font>
+<a name="l00286"></a><a class="code" href="classNL3D_1_1CPatch.html#z685_5">00286</a> <font class="keywordtype">float</font> CPatch::computeDisplaceEdgeSmooth(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, sint8 smoothBorderX, sint8 smoothBorderY)<font class="keyword"> const</font>
+00287 <font class="keyword"></font>{
+00288 <font class="keywordtype">float</font> sTile= <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00289 <font class="keywordtype">float</font> tTile= <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+00290 CBindInfo bindInfo;
+00291 uint edge=0;
+00292
+00293 <font class="comment">// only one must be not null</font>
+00294 <a class="code" href="debug_8h.html#a6">nlassert</a>( (smoothBorderX==0) != (smoothBorderY==0) );
+00295
+00296
+00297 <font class="comment">// Get the edge against we must share displace.</font>
+00298 <font class="keywordflow">if</font>(smoothBorderX==-1) edge=0;
+00299 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderY==1) edge=1;
+00300 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderX==1) edge=2;
+00301 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderY==-1) edge=3;
+00302 <font class="keywordflow">else</font> <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00303
+00304 <font class="comment">// Build the bindInfo against this edge.</font>
+00305 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edge, bindInfo);
+00306
+00307 <font class="comment">// Fast reject: if no neighbor, just do a simple computeDisplaceInteriorSmooth.</font>
+00308 <font class="keywordflow">if</font>(!bindInfo.Zone)
+00309 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#z685_4">computeDisplaceInteriorSmooth</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>);
+00310 <font class="comment">// else, look for result in neighborhood.</font>
+00311 <font class="keywordflow">else</font>
+00312 {
+00313 <font class="keywordtype">float</font> ret;
+00314
+00315
+00316 <font class="comment">// compute bi-linear weight factors.</font>
+00317 <font class="keywordtype">float</font> sInc, tInc, sa, ta, sa1, ta1;
+00318 <a class="code" href="namespaceNL3D.html#a395">computeDisplaceBilinear</a>(sTile, tTile, sInc, tInc, sa, ta, sa1, ta1);
+00319 <font class="comment">// Manage limit case: if bilinear has not chosen the good direction (because of floor and orientation).</font>
+00320 <font class="comment">// eg on Right edge: This case arise if sDecimal==0, so if sa==sa1==0.5f. result is that</font>
+00321 <font class="comment">// smoothBorderX is != than sInc on right border. same reasoning with downBorder (smoothBorderY=1).</font>
+00322
+00323 <font class="comment">// NO NEED TO DO HERE, because sInc or tInc is not used if it is bad (smoothBorder? used instead).</font>
+00324 <font class="comment">// and no need to correct sa, sa1, because in this case they are both equal to 0.5.</font>
+00325
+00326
+00327 <font class="comment">// compute Neighboring info.</font>
+00328 CPatchUVLocator uvLocator;
+00329 uvLocator.build(<font class="keyword">this</font>, edge, bindInfo);
+00330
+00331 <font class="comment">/* NB: there is floor problems with neighbors:</font>
+00332 <font class="comment"> - difference of orientation =&gt; uv.v=1. This point to the 1th tile. But this is not the same, if</font>
+00333 <font class="comment"> v goes to up, or goes to down.</font>
+00334 <font class="comment"> - if multiple bind, problem at limit (eg a bind 1/2 on edge 0 with OrdertT=8, when uv.v= 4).</font>
+00335 <font class="comment"> because, selection of the patch is dependent of orientation too.</font>
+00336 <font class="comment"> To avoid them, just take center of (sTile, tTile) to remove ambiguity.</font>
+00337 <font class="comment"> This works because computeDisplaceRaw() use sTile, tTile to get the noiseMap, so the decimal part is not </font>
+00338 <font class="comment"> used.</font>
+00339 <font class="comment"></font>
+00340 <font class="comment"> Notice that we do this AFTER computeDisplaceBilinear() of course.</font>
+00341 <font class="comment"> */</font>
+00342 sTile= <a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(sTile) + 0.5f;
+00343 tTile= <a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(tTile) + 0.5f;
+00344 <font class="comment">// If we were exactly on the superior edge, prec compute is false... so correct this here.</font>
+00345 <font class="keywordflow">if</font>(sTile&gt;<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>) sTile--;
+00346 <font class="keywordflow">if</font>(tTile&gt;<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>) tTile--;
+00347
+00348
+00349 <font class="comment">// Bilinear across an edge (enjoy!!).</font>
+00350 CVector2f stTileIn, stIn;
+00351 CVector2f stTileOut, stOut;
+00352 <a class="code" href="classNL3D_1_1CPatch.html#a0">CPatch</a> *patchOut;
+00353 uint patchId;
+00354
+00355
+00356 <font class="comment">// if vertical edge.</font>
+00357 <font class="keywordflow">if</font>(smoothBorderX!=0)
+00358 {
+00359 <font class="comment">// compute contribution of our patch.</font>
+00360 ret = <a class="code" href="classNL3D_1_1CPatch.html#z685_2">computeDisplaceRaw</a>(sTile,tTile, <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>) * sa * ta;
+00361 ret+= <a class="code" href="classNL3D_1_1CPatch.html#z685_2">computeDisplaceRaw</a>(sTile,tTile+tInc, <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>) * sa * ta1;
+00362
+00363 <font class="comment">// compute contribution of next(s) patchs.</font>
+00364
+00365 <font class="comment">// contribution of next at tTile.</font>
+00366 <font class="comment">// Keep the same coordinate.</font>
+00367 stIn.set(<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>);
+00368 <font class="comment">// But look for the neighbor noise tile.</font>
+00369 stTileIn.set(sTile+smoothBorderX, tTile);
+00370 <font class="comment">// change basis: find the s,t on the neighbor patch.</font>
+00371 patchId= uvLocator.selectPatch(stTileIn);
+00372 uvLocator.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00373 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00374 <font class="comment">// Compute displace, and bi-linear on the neighbor patch.</font>
+00375 ret+= patchOut-&gt;computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa1 * ta;
+00376
+00377 <font class="comment">// contribution of next at tTile+tInc (same reasoning).</font>
+00378 stIn.set(<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>);
+00379 stTileIn.set(sTile+smoothBorderX, tTile+tInc);
+00380 patchId= uvLocator.selectPatch(stTileIn);
+00381 uvLocator.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00382 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00383 ret+= patchOut-&gt;computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa1 * ta1;
+00384
+00385 }
+00386 <font class="comment">// else if horizontal edge.</font>
+00387 <font class="keywordflow">else</font>
+00388 {
+00389 <font class="comment">// same reasoning as above.</font>
+00390
+00391 <font class="comment">// compute contribution of our patch.</font>
+00392 ret = <a class="code" href="classNL3D_1_1CPatch.html#z685_2">computeDisplaceRaw</a>(sTile, tTile, <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>) * sa * ta;
+00393 ret+= <a class="code" href="classNL3D_1_1CPatch.html#z685_2">computeDisplaceRaw</a>(sTile+sInc,tTile, <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>) * sa1 * ta;
+00394
+00395 <font class="comment">// compute contribution of next(s) patchs.</font>
+00396 <font class="comment">// contribution of next at tTile.</font>
+00397 stIn.set(<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>);
+00398 stTileIn.set(sTile, tTile+smoothBorderY);
+00399 patchId= uvLocator.selectPatch(stTileIn);
+00400 uvLocator.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00401 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00402 ret+= patchOut-&gt;computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa * ta1;
+00403
+00404 <font class="comment">// contribution of next at tTile+tInc (same reasoning).</font>
+00405 stIn.set(<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>);
+00406 stTileIn.set(sTile+sInc, tTile+smoothBorderY);
+00407 patchId= uvLocator.selectPatch(stTileIn);
+00408 uvLocator.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00409 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00410 ret+= patchOut-&gt;computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa1 * ta1;
+00411 }
+00412
+00413 <font class="keywordflow">return</font> ret;
+00414 }
+00415
+00416 }
+00417
+00418
+00419 <font class="comment">// ***************************************************************************</font>
+<a name="l00420"></a><a class="code" href="classNL3D_1_1CPatch.html#z685_3">00420</a> <font class="keywordtype">float</font> CPatch::computeDisplaceRawOnNeighbor(<font class="keywordtype">float</font> sTile, <font class="keywordtype">float</font> tTile, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)<font class="keyword"> const</font>
+00421 <font class="keyword"></font>{
+00422 sint edge= -1;
+00423
+00424 <font class="comment">// look on what neighbor patch we must find the value (if any).</font>
+00425 <font class="keywordflow">if</font>(sTile&lt;0) edge=0;
+00426 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(tTile&gt;<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>) edge=1;
+00427 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(sTile&gt;<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>) edge=2;
+00428 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(tTile&lt;0) edge=3;
+00429
+00430 <font class="comment">// If the location is In the patch, just return normal value.</font>
+00431 <font class="keywordflow">if</font>(edge==-1)
+00432 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#z685_2">computeDisplaceRaw</a>(sTile, tTile, <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>);
+00433 <font class="comment">// else must find on neighbor.</font>
+00434 <font class="keywordflow">else</font>
+00435 {
+00436 CBindInfo bindInfo;
+00437 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edge, bindInfo);
+00438
+00439 <font class="comment">// Fast reject: if no neighbor on the edge, just do a simple computeDisplaceRaw()</font>
+00440 <font class="keywordflow">if</font>(!bindInfo.Zone)
+00441 {
+00442 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#z685_2">computeDisplaceRaw</a>(sTile, tTile, <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>);
+00443 }
+00444 <font class="comment">// else must find on neighbor.</font>
+00445 <font class="keywordflow">else</font>
+00446 {
+00447 CPatchUVLocator uvLocator;
+00448 uvLocator.build(<font class="keyword">this</font>, edge, bindInfo);
+00449
+00450 CVector2f stTileIn, stIn;
+00451 CVector2f stTileOut, stOut;
+00452 <a class="code" href="classNL3D_1_1CPatch.html#a0">CPatch</a> *patchOut;
+00453 uint patchId;
+00454
+00455 <font class="comment">// look on neighbor. same reasoning as in computeDisplaceEdgeSmooth();</font>
+00456 stIn.set(<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>);
+00457 stTileIn.set(sTile, tTile);
+00458 patchId= uvLocator.selectPatch(stTileIn);
+00459 uvLocator.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00460 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00461 <font class="keywordflow">return</font> patchOut-&gt;computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y);
+00462 }
+00463
+00464 }
+00465 }
+00466
+00467
+00468 <font class="comment">// ***************************************************************************</font>
+<a name="l00469"></a><a class="code" href="classNL3D_1_1CPatch.html#z685_6">00469</a> <font class="keywordtype">float</font> CPatch::computeDisplaceCornerSmooth(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, sint8 smoothBorderX, sint8 smoothBorderY)<font class="keyword"> const</font>
+00470 <font class="keyword"></font>{
+00471 <font class="comment">// compute the value across the corner (enjoy!!)</font>
+00472 <font class="comment">// NB: Only corners with Edges==4 and corners on a bind are correclty supported.</font>
+00473 <font class="comment">// ignore problems with corner which nbEdges!=4, because Blend of normals blend to 0 on corner (see computenoise()).</font>
+00474
+00475 <font class="keywordtype">float</font> sTile= <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00476 <font class="keywordtype">float</font> tTile= <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+00477 CBindInfo bindInfoX;
+00478 CBindInfo bindInfoY;
+00479 uint edgeX=0;
+00480 uint edgeY=0;
+00481
+00482 <font class="comment">// both must be not null</font>
+00483 <a class="code" href="debug_8h.html#a6">nlassert</a>( (smoothBorderX!=0) &amp;&amp; (smoothBorderY!=0) );
+00484
+00485
+00486 <font class="comment">// Get the edge against we must share displace.</font>
+00487 <font class="keywordflow">if</font>(smoothBorderX==-1) edgeX=0;
+00488 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderX==1) edgeX=2;
+00489 <font class="keywordflow">else</font> <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00490 <font class="keywordflow">if</font>(smoothBorderY==1) edgeY=1;
+00491 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderY==-1) edgeY=3;
+00492 <font class="keywordflow">else</font> <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00493
+00494 <font class="comment">// Build the bindInfo against those 2 edge.</font>
+00495 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edgeX, bindInfoX);
+00496 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edgeY, bindInfoY);
+00497
+00498 <font class="comment">// Fast reject: if no neighbor on one of the edge, just do a simple computeDisplaceInteriorSmooth.</font>
+00499 <font class="keywordflow">if</font>(!bindInfoX.Zone || !bindInfoY.Zone)
+00500 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPatch.html#z685_4">computeDisplaceInteriorSmooth</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>);
+00501 <font class="keywordflow">else</font>
+00502 {
+00503 <font class="keywordtype">float</font> ret;
+00504
+00505
+00506 <font class="comment">// compute bi-linear weight factors.</font>
+00507 <font class="keywordtype">float</font> sInc, tInc, sa, ta, sa1, ta1;
+00508 <a class="code" href="namespaceNL3D.html#a395">computeDisplaceBilinear</a>(sTile, tTile, sInc, tInc, sa, ta, sa1, ta1);
+00509 <font class="comment">// Manage limit case: if bilinear has not chosen the good direction (because of floor and orientation).</font>
+00510 <font class="comment">// eg on Right edge: This case arise if sDecimal==0, so if sa==sa1==0.5f. result is that</font>
+00511 <font class="comment">// smoothBorderX is != than sInc on right border. same reasoning with downBorder (smoothBorderY=1).</font>
+00512
+00513 <font class="comment">// NO NEED TO DO HERE, because sInc or tInc are not used at all.</font>
+00514
+00515
+00516
+00517 <font class="comment">// compute Neighboring info.</font>
+00518 CPatchUVLocator uvLocatorX;
+00519 CPatchUVLocator uvLocatorY;
+00520 uvLocatorX.build(<font class="keyword">this</font>, edgeX, bindInfoX);
+00521 uvLocatorY.build(<font class="keyword">this</font>, edgeY, bindInfoY);
+00522
+00523
+00524 <font class="comment">/* NB: see floor problems note in computeDisplaceEdgeSmooth();</font>
+00525 <font class="comment"> */</font>
+00526 sTile= <a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(sTile) + 0.5f;
+00527 tTile= <a class="code" href="namespaceNL3D.html#a393">noiseFloor</a>(tTile) + 0.5f;
+00528 <font class="comment">// If we were exactly on the superior edge, prec compute is false... so correct this here.</font>
+00529 <font class="keywordflow">if</font>(sTile&gt;<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>) sTile--;
+00530 <font class="keywordflow">if</font>(tTile&gt;<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>) tTile--;
+00531
+00532
+00533 <font class="comment">// Bilinear across a corner.</font>
+00534 CVector2f stTileIn, stIn;
+00535 CVector2f stTileOut, stOut;
+00536 <a class="code" href="classNL3D_1_1CPatch.html#a0">CPatch</a> *patchOut;
+00537 uint patchId;
+00538
+00539
+00540 <font class="comment">// compute contribution of our patch.</font>
+00541 ret = <a class="code" href="classNL3D_1_1CPatch.html#z685_2">computeDisplaceRaw</a>(sTile,tTile, <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>) * sa * ta;
+00542
+00543 <font class="comment">// compute contribution of the patch on the left/right side. same reasoning as in computeDisplaceEdgeSmooth();</font>
+00544 stIn.set(<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>);
+00545 stTileIn.set(sTile+smoothBorderX, tTile);
+00546 patchId= uvLocatorX.selectPatch(stTileIn);
+00547 uvLocatorX.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00548 uvLocatorX.locateUV(stIn, patchId, patchOut, stOut);
+00549 ret+= patchOut-&gt;computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa1 * ta;
+00550
+00551
+00552 <font class="comment">// compute contribution of the patch on the up/down side. same reasoning as in computeDisplaceEdgeSmooth();</font>
+00553 stIn.set(<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>);
+00554 stTileIn.set(sTile, tTile+smoothBorderY);
+00555 patchId= uvLocatorY.selectPatch(stTileIn);
+00556 uvLocatorY.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00557 uvLocatorY.locateUV(stIn, patchId, patchOut, stOut);
+00558 ret+= patchOut-&gt;computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa * ta1;
+00559
+00560
+00561 <font class="comment">/* compute contribution of the patch adjacent to me.</font>
+00562 <font class="comment"> There is multiple case to consider here. Take example with corner=0 (ie smBdX=smBdY=-1):</font>
+00563 <font class="comment"> - if we are a normal corner with 4 edges, take the result from the left patch of our top patch.</font>
+00564 <font class="comment"> - if the corner is on a bind Edge, the top patch may be the bigger patch, so don't take the result</font>
+00565 <font class="comment"> from his neighbor (of course).</font>
+00566 <font class="comment"> - if we are a normal corner with N!=4 edges, just do same thing than if N==4. this is false but don't bother.</font>
+00567 <font class="comment"></font>
+00568 <font class="comment"> To solve smoothly cases 1 and 2, use computeDisplaceRawOnNeighbor().</font>
+00569 <font class="comment"> This method, if nessecary, look on his neighbor to compute the value.</font>
+00570 <font class="comment"> */</font>
+00571 stIn.set(<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>);
+00572 stTileIn.set(sTile+smoothBorderX, tTile+smoothBorderY);
+00573 <font class="comment">// look on our "top" patch (this is arbitrary).</font>
+00574 patchId= uvLocatorY.selectPatch(stTileIn);
+00575 uvLocatorY.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00576 uvLocatorY.locateUV(stIn, patchId, patchOut, stOut);
+00577 ret+= patchOut-&gt;computeDisplaceRawOnNeighbor(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa1 * ta1;
+00578
+00579
+00580 <font class="keywordflow">return</font> ret;
+00581 }
+00582
+00583 }
+00584
+00585 <font class="comment">// ***************************************************************************</font>
+<a name="l00586"></a><a class="code" href="classNL3D_1_1CPatch.html#z685_7">00586</a> CVector CPatch::computeNormalEdgeSmooth(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, sint8 smoothBorderX, sint8 smoothBorderY)<font class="keyword"> const</font>
+00587 <font class="keyword"></font>{
+00588 CBindInfo bindInfo;
+00589 uint edge=0;
+00590 CBezierPatch *bpatch;
+00591 bpatch= <a class="code" href="classNL3D_1_1CPatch.html#a45">unpackIntoCache</a>();
+00592
+00593 <font class="comment">// only one must be not null</font>
+00594 <a class="code" href="debug_8h.html#a6">nlassert</a>( (smoothBorderX==0) != (smoothBorderY==0) );
+00595
+00596
+00597 <font class="comment">// Get the edge against we must share displace.</font>
+00598 <font class="keywordflow">if</font>(smoothBorderX==-1) edge=0;
+00599 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderY==1) edge=1;
+00600 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderX==1) edge=2;
+00601 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderY==-1) edge=3;
+00602 <font class="keywordflow">else</font> <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00603
+00604 <font class="comment">// If the edge is smoothed, blend with neighbor.</font>
+00605 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#a40">getSmoothFlag</a>(edge))
+00606 {
+00607 <font class="comment">// Build the bindInfo against this edge.</font>
+00608 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edge, bindInfo);
+00609
+00610 <font class="comment">// Fast reject: if no neighbor, just do a simple computeDisplaceInteriorSmooth.</font>
+00611 <font class="keywordflow">if</font>(!bindInfo.Zone)
+00612 <font class="keywordflow">return</font> bpatch-&gt;evalNormal(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>/<a class="code" href="classNL3D_1_1CPatch.html#a6">getOrderS</a>(), <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>/<a class="code" href="classNL3D_1_1CPatch.html#a7">getOrderT</a>());
+00613 <font class="keywordflow">else</font>
+00614 {
+00615 CVector r0, r1;
+00616
+00617 <font class="comment">// Compute our contribution.</font>
+00618 r0= bpatch-&gt;evalNormal(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>/<a class="code" href="classNL3D_1_1CPatch.html#a6">getOrderS</a>(), <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>/<a class="code" href="classNL3D_1_1CPatch.html#a7">getOrderT</a>());
+00619
+00620 <font class="comment">// Compute the coordinate on the border of the edge, and the coef of the blend.</font>
+00621 <font class="keywordtype">float</font> se=<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00622 <font class="keywordtype">float</font> te=<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+00623 <font class="keywordtype">float</font> coef=0.0;
+00624 <font class="keywordflow">if</font>(smoothBorderX==-1) se= <a class="code" href="namespaceNL3D.html#a391">noiseFloorF</a>(se), coef=<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>-se;
+00625 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderX==1) se= <a class="code" href="namespaceNL3D.html#a392">noiseCeilF</a>(se), coef=se-<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00626 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderY==-1) te= <a class="code" href="namespaceNL3D.html#a391">noiseFloorF</a>(te), coef=<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>-te;
+00627 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderY==1) te= <a class="code" href="namespaceNL3D.html#a392">noiseCeilF</a>(te), coef=te-<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+00628 coef= 0.5f + coef*0.5f;
+00629
+00630 <font class="comment">// Compute contribution of the normal on the neighbor, on the border of the edge.</font>
+00631 CPatchUVLocator uvLocator;
+00632 CVector2f stIn, stOut;
+00633 <a class="code" href="classNL3D_1_1CPatch.html#a0">CPatch</a> *patchOut;
+00634 uint patchId;
+00635
+00636 uvLocator.build(<font class="keyword">this</font>, edge, bindInfo);
+00637 stIn.set(se, te);
+00638 patchId= uvLocator.selectPatch(stIn);
+00639 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00640
+00641 bpatch= patchOut-&gt;unpackIntoCache();
+00642 r1= bpatch-&gt;evalNormal(stOut.x/patchOut-&gt;getOrderS(), stOut.y/patchOut-&gt;getOrderT());
+00643
+00644 <font class="comment">// NB: don't bother problems with bind 1/X and the choice of the patch, because bind are C1, so normal is C0.</font>
+00645
+00646 <font class="comment">// Blend 2 result. For speed optim, don't normalize.</font>
+00647 <font class="keywordflow">return</font> r0*coef + r1*(1-coef);
+00648 }
+00649 }
+00650 <font class="comment">// else blend with vector Null.</font>
+00651 <font class="keywordflow">else</font>
+00652 {
+00653 <font class="comment">// compute coef.</font>
+00654 <font class="keywordtype">float</font> se=<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00655 <font class="keywordtype">float</font> te=<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+00656 <font class="keywordtype">float</font> coef=0.0;
+00657 <font class="keywordflow">if</font>(smoothBorderX==-1) se= <a class="code" href="namespaceNL3D.html#a391">noiseFloorF</a>(se), coef=<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>-se;
+00658 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderX==1) se= <a class="code" href="namespaceNL3D.html#a392">noiseCeilF</a>(se), coef=se-<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00659 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderY==-1) te= <a class="code" href="namespaceNL3D.html#a391">noiseFloorF</a>(te), coef=<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>-te;
+00660 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderY==1) te= <a class="code" href="namespaceNL3D.html#a392">noiseCeilF</a>(te), coef=te-<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+00661
+00662 <font class="comment">// Compute our contribution.</font>
+00663 CVector r0;
+00664 r0= bpatch-&gt;evalNormal(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>/<a class="code" href="classNL3D_1_1CPatch.html#a6">getOrderS</a>(), <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>/<a class="code" href="classNL3D_1_1CPatch.html#a7">getOrderT</a>());
+00665
+00666 <font class="comment">// Blend with 0.</font>
+00667 <font class="keywordflow">return</font> r0*coef;
+00668 }
+00669 }
+00670
+00671
+00672 <font class="comment">// ***************************************************************************</font>
+<a name="l00673"></a><a class="code" href="classNL3D_1_1CPatch.html#z685_9">00673</a> CVector CPatch::computeNormalOnNeighbor(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, uint edgeExclude)<font class="keyword"> const</font>
+00674 <font class="keyword"></font>{
+00675 sint edge= -1;
+00676
+00677 <font class="comment">// look on what neighbor patch we must find the value (if any).</font>
+00678 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;1 &amp;&amp; edgeExclude!=0) edge=0;
+00679 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>&gt;<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>-1 &amp;&amp; edgeExclude!=1) edge=1;
+00680 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&gt;<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>-1 &amp;&amp; edgeExclude!=2) edge=2;
+00681 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>&lt;1 &amp;&amp; edgeExclude!=3) edge=3;
+00682
+00683
+00684 <font class="comment">// If the location is In the patch, just return normal value. (case of a bind 1/X).</font>
+00685 <font class="keywordflow">if</font>(edge==-1)
+00686 {
+00687 CBezierPatch *bpatch= <a class="code" href="classNL3D_1_1CPatch.html#a45">unpackIntoCache</a>();
+00688 <font class="keywordflow">return</font> bpatch-&gt;evalNormal(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>/<a class="code" href="classNL3D_1_1CPatch.html#a6">getOrderS</a>(), <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>/<a class="code" href="classNL3D_1_1CPatch.html#a7">getOrderT</a>());
+00689 }
+00690 <font class="comment">// else must find on neighbor.</font>
+00691 <font class="keywordflow">else</font>
+00692 {
+00693 CBindInfo bindInfo;
+00694 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edge, bindInfo);
+00695
+00696 <font class="comment">// Fast reject: if no neighbor on the edge, just do a simple computeDisplaceRaw()</font>
+00697 <font class="keywordflow">if</font>(!bindInfo.Zone)
+00698 {
+00699 CBezierPatch *bpatch= <a class="code" href="classNL3D_1_1CPatch.html#a45">unpackIntoCache</a>();
+00700 <font class="keywordflow">return</font> bpatch-&gt;evalNormal(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>/<a class="code" href="classNL3D_1_1CPatch.html#a6">getOrderS</a>(), <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>/<a class="code" href="classNL3D_1_1CPatch.html#a7">getOrderT</a>());
+00701 }
+00702 <font class="comment">// else must find on neighbor.</font>
+00703 <font class="keywordflow">else</font>
+00704 {
+00705 CPatchUVLocator uvLocator;
+00706 uvLocator.build(<font class="keyword">this</font>, edge, bindInfo);
+00707
+00708 CVector2f stIn;
+00709 CVector2f stOut;
+00710 <a class="code" href="classNL3D_1_1CPatch.html#a0">CPatch</a> *patchOut;
+00711 uint patchId;
+00712
+00713 <font class="comment">// look on neighbor. same reasoning as in computeDisplaceEdgeSmooth();</font>
+00714 stIn.set(<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>);
+00715 patchId= uvLocator.selectPatch(stIn);
+00716 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00717 CBezierPatch *bpatch= patchOut-&gt;unpackIntoCache();
+00718 <font class="keywordflow">return</font> bpatch-&gt;evalNormal(stOut.x/patchOut-&gt;getOrderS(), stOut.y/patchOut-&gt;getOrderT());
+00719 }
+00720
+00721 }
+00722 }
+00723
+00724
+00725 <font class="comment">// ***************************************************************************</font>
+<a name="l00726"></a><a class="code" href="classNL3D_1_1CPatch.html#z685_8">00726</a> CVector CPatch::computeNormalCornerSmooth(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, sint8 smoothBorderX, sint8 smoothBorderY)<font class="keyword"> const</font>
+00727 <font class="keyword"></font>{
+00728 CBindInfo bindInfoX;
+00729 CBindInfo bindInfoY;
+00730 uint edgeX=0;
+00731 uint edgeY=0;
+00732 uint corner;
+00733 CBezierPatch *bpatch;
+00734 bpatch= <a class="code" href="classNL3D_1_1CPatch.html#a45">unpackIntoCache</a>();
+00735
+00736 <font class="comment">// both must be not null</font>
+00737 <a class="code" href="debug_8h.html#a6">nlassert</a>( (smoothBorderX!=0) &amp;&amp; (smoothBorderY!=0) );
+00738
+00739
+00740 <font class="comment">// Get the edge against we must share displace.</font>
+00741 <font class="keywordflow">if</font>(smoothBorderX==-1) edgeX=0;
+00742 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderX==1) edgeX=2;
+00743 <font class="keywordflow">else</font> <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00744 <font class="keywordflow">if</font>(smoothBorderY==1) edgeY=1;
+00745 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothBorderY==-1) edgeY=3;
+00746 <font class="keywordflow">else</font> <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00747
+00748 <font class="comment">// Get the corner against we must share displace.</font>
+00749 <font class="keywordflow">if</font>(smoothBorderX==-1)
+00750 {
+00751 <font class="keywordflow">if</font>(smoothBorderY==-1) corner=0;
+00752 <font class="keywordflow">else</font> corner=1;
+00753 }
+00754 <font class="keywordflow">else</font>
+00755 {
+00756 <font class="keywordflow">if</font>(smoothBorderY==-1) corner=3;
+00757 <font class="keywordflow">else</font> corner=2;
+00758 }
+00759
+00760 <font class="comment">// If this corner is smoothed, blend with 4 neighbors patchs.</font>
+00761 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CPatch.html#z668_1">getCornerSmoothFlag</a>(corner))
+00762 {
+00763 <font class="comment">// Build the bindInfo against the 2 edge.</font>
+00764 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edgeX, bindInfoX);
+00765 <a class="code" href="classNL3D_1_1CPatch.html#a13">getBindNeighbor</a>(edgeY, bindInfoY);
+00766
+00767 <font class="comment">// Fast reject: if no neighbor, just do a simple computeDisplaceInteriorSmooth.</font>
+00768 <font class="keywordflow">if</font>(!bindInfoX.Zone || !bindInfoY.Zone)
+00769 <font class="keywordflow">return</font> bpatch-&gt;evalNormal(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>/<a class="code" href="classNL3D_1_1CPatch.html#a6">getOrderS</a>(), <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>/<a class="code" href="classNL3D_1_1CPatch.html#a7">getOrderT</a>());
+00770 <font class="keywordflow">else</font>
+00771 {
+00772 CVector ret;
+00773
+00774
+00775 <font class="comment">// Compute the coordinate on the border of the edge, and the coef of the blend.</font>
+00776 <font class="keywordtype">float</font> se=<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00777 <font class="keywordtype">float</font> te=<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+00778 <font class="keywordtype">float</font> coefX;
+00779 <font class="keywordtype">float</font> coefY;
+00780 <font class="keywordflow">if</font>(smoothBorderX==-1) se= <a class="code" href="namespaceNL3D.html#a391">noiseFloorF</a>(se), coefX=<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>-se;
+00781 <font class="keywordflow">else</font> se= <a class="code" href="namespaceNL3D.html#a392">noiseCeilF</a>(se), coefX=se-<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00782 <font class="keywordflow">if</font>(smoothBorderY==-1) te= <a class="code" href="namespaceNL3D.html#a391">noiseFloorF</a>(te), coefY=<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>-te;
+00783 <font class="keywordflow">else</font> te= <a class="code" href="namespaceNL3D.html#a392">noiseCeilF</a>(te), coefY=te-<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+00784 coefX= 0.5f + coefX*0.5f;
+00785 coefY= 0.5f + coefY*0.5f;
+00786
+00787
+00788 <font class="comment">// Compute our contribution.</font>
+00789 ret= bpatch-&gt;evalNormal(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>/<a class="code" href="classNL3D_1_1CPatch.html#a6">getOrderS</a>(), <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>/<a class="code" href="classNL3D_1_1CPatch.html#a7">getOrderT</a>()) *coefX*coefY;
+00790
+00791
+00792 <font class="comment">// compute Neighboring info.</font>
+00793 CPatchUVLocator uvLocatorX;
+00794 CPatchUVLocator uvLocatorY;
+00795 CVector2f stIn, stOut;
+00796 <a class="code" href="classNL3D_1_1CPatch.html#a0">CPatch</a> *patchOut;
+00797 uint patchId;
+00798
+00799 uvLocatorX.build(<font class="keyword">this</font>, edgeX, bindInfoX);
+00800 uvLocatorY.build(<font class="keyword">this</font>, edgeY, bindInfoY);
+00801
+00802 <font class="comment">// Patch on our X side.</font>
+00803 stIn.set(se, te);
+00804 patchId= uvLocatorX.selectPatch(stIn);
+00805 uvLocatorX.locateUV(stIn, patchId, patchOut, stOut);
+00806 bpatch= patchOut-&gt;unpackIntoCache();
+00807 ret+= bpatch-&gt;evalNormal(stOut.x/patchOut-&gt;getOrderS(), stOut.y/patchOut-&gt;getOrderT()) *(1-coefX)*coefY;
+00808
+00809 <font class="comment">// Patch on our Y side.</font>
+00810 stIn.set(se, te);
+00811 patchId= uvLocatorY.selectPatch(stIn);
+00812 uvLocatorY.locateUV(stIn, patchId, patchOut, stOut);
+00813 bpatch= patchOut-&gt;unpackIntoCache();
+00814 ret+= bpatch-&gt;evalNormal(stOut.x/patchOut-&gt;getOrderS(), stOut.y/patchOut-&gt;getOrderT()) *coefX*(1-coefY);
+00815
+00816 <font class="comment">/* compute contribution of the patch adjacent to me.</font>
+00817 <font class="comment"> Same reasoning as in computeDisplaceCornerSmooth().</font>
+00818 <font class="comment"> */</font>
+00819 stIn.set(se, te);
+00820 patchId= uvLocatorY.selectPatch(stIn);
+00821 uvLocatorY.locateUV(stIn, patchId, patchOut, stOut);
+00822 <font class="comment">// Because we compute the normal exactly on the edge, we must inform this method not to take us as neighbor.</font>
+00823 <font class="comment">// ugly but simpler.</font>
+00824 ret+= patchOut-&gt;computeNormalOnNeighbor(stOut.x, stOut.y, bindInfoY.Edge[patchId]) *(1-coefX)*(1-coefY);
+00825
+00826 <font class="keywordflow">return</font> ret;
+00827 }
+00828 }
+00829 <font class="comment">// else must blend with 0.</font>
+00830 <font class="keywordflow">else</font>
+00831 {
+00832 <font class="comment">// compute coef.</font>
+00833 <font class="keywordtype">float</font> se=<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00834 <font class="keywordtype">float</font> te=<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+00835 <font class="keywordtype">float</font> coefX;
+00836 <font class="keywordtype">float</font> coefY;
+00837 <font class="keywordflow">if</font>(smoothBorderX==-1) se= <a class="code" href="namespaceNL3D.html#a391">noiseFloorF</a>(se), coefX=<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>-se;
+00838 <font class="keywordflow">else</font> se= <a class="code" href="namespaceNL3D.html#a392">noiseCeilF</a>(se), coefX=se-<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00839 <font class="keywordflow">if</font>(smoothBorderY==-1) te= <a class="code" href="namespaceNL3D.html#a391">noiseFloorF</a>(te), coefY=<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>-te;
+00840 <font class="keywordflow">else</font> te= <a class="code" href="namespaceNL3D.html#a392">noiseCeilF</a>(te), coefY=te-<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+00841
+00842
+00843 <font class="comment">// To have smooth continuities with smooth on edge (if any), we must do this.</font>
+00844 CVector rx, ry;
+00845 <font class="comment">// Compute a smooth with my X neighbor.</font>
+00846 rx= <a class="code" href="classNL3D_1_1CPatch.html#z685_7">computeNormalEdgeSmooth</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>, smoothBorderX, 0);
+00847 <font class="comment">// Compute a smooth with my Y neighbor.</font>
+00848 ry= <a class="code" href="classNL3D_1_1CPatch.html#z685_7">computeNormalEdgeSmooth</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>, 0, smoothBorderY);
+00849
+00850 <font class="comment">// Blend the 2 result.</font>
+00851 <font class="keywordflow">if</font>(coefY + coefX&gt;0)
+00852 {
+00853 <font class="comment">// This the weight used to blend to 0.</font>
+00854 <font class="keywordtype">float</font> maxCoef= max(coefY, coefX);
+00855 <font class="comment">// This the weight used to blend beetween rx and ry.</font>
+00856 <font class="keywordtype">float</font> ooSum= 1.0f / (coefY + coefX);
+00857 <font class="keywordtype">float</font> blendCoefX= coefX * ooSum;
+00858 <font class="keywordtype">float</font> blendCoefY= coefY * ooSum;
+00859
+00860 <font class="keywordflow">return</font> maxCoef* (rx*blendCoefY + ry*blendCoefX);
+00861 }
+00862 <font class="keywordflow">else</font>
+00863 {
+00864 <font class="keywordflow">return</font> CVector::Null;
+00865 }
+00866 }
+00867 }
+00868
+00869
+00870
+00871 <font class="comment">// ***************************************************************************</font>
+<a name="l00872"></a><a class="code" href="classNL3D_1_1CPatch.html#z685_10">00872</a> <font class="keywordtype">void</font> CPatch::computeNoise(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>, CVector &amp;displace)<font class="keyword"> const</font>
+00873 <font class="keyword"></font>{
+00874 <font class="keywordtype">float</font> so= <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>*<a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>;
+00875 <font class="keywordtype">float</font> to= <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>*<a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>;
+00876
+00877
+00878 <font class="comment">// Pre-Compute Border Smothing.</font>
+00879 <font class="comment">//=========================</font>
+00880 <font class="comment">// If we are on a border, flag it.</font>
+00881 sint8 smoothNormalBorderX= 0;
+00882 sint8 smoothNormalBorderY= 0;
+00883 <font class="comment">// NB: because OrderS and OrderT &gt;=2, smoothNormalBorderX=-1 and smoothNormalBorderX=1 are exclusive (as smoothNormalBorderY).</font>
+00884 <font class="keywordflow">if</font>(so &lt; 1) smoothNormalBorderX= -1;
+00885 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(so &gt; <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>-1) smoothNormalBorderX= 1;
+00886 <font class="keywordflow">if</font>(to &lt; 1) smoothNormalBorderY= -1;
+00887 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(to &gt; <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>-1) smoothNormalBorderY= 1;
+00888
+00889 <font class="keywordtype">bool</font> smoothNormalEdge= (smoothNormalBorderX!=0) != (smoothNormalBorderY!=0);
+00890 <font class="keywordtype">bool</font> smoothNormalCorner= (smoothNormalBorderX!=0) &amp;&amp; (smoothNormalBorderY!=0);
+00891
+00892
+00893 <font class="comment">// Do same thing, but to know if we must compute a displace on an interior, on an edge or on a corner.</font>
+00894 sint8 smoothDisplaceBorderX= 0;
+00895 sint8 smoothDisplaceBorderY= 0;
+00896 <font class="comment">// NB: because OrderS and OrderT &gt;=2, smoothBorderX=-1 and smoothBorderX=1 are exclusive (as smoothBorderY).</font>
+00897 <font class="keywordflow">if</font>(so &lt; 0.5) smoothDisplaceBorderX= -1;
+00898 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(so &gt; <a class="code" href="classNL3D_1_1CPatch.html#o2">OrderS</a>-0.5) smoothDisplaceBorderX= 1;
+00899 <font class="keywordflow">if</font>(to &lt; 0.5) smoothDisplaceBorderY= -1;
+00900 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(to &gt; <a class="code" href="classNL3D_1_1CPatch.html#o3">OrderT</a>-0.5) smoothDisplaceBorderY= 1;
+00901
+00902 <font class="keywordtype">bool</font> smoothDisplaceEdge= (smoothDisplaceBorderX!=0) != (smoothDisplaceBorderY!=0);
+00903 <font class="keywordtype">bool</font> smoothDisplaceCorner= (smoothDisplaceBorderX!=0) &amp;&amp; (smoothDisplaceBorderY!=0);
+00904
+00905
+00906 <font class="comment">// Compute Displace value.</font>
+00907 <font class="comment">//=========================</font>
+00908 <font class="keywordtype">float</font> displaceValue;
+00909
+00910 <font class="keywordflow">if</font>(smoothDisplaceCorner)
+00911 displaceValue= <a class="code" href="classNL3D_1_1CPatch.html#z685_6">computeDisplaceCornerSmooth</a>(so, to, smoothDisplaceBorderX, smoothDisplaceBorderY);
+00912 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothDisplaceEdge)
+00913 displaceValue= <a class="code" href="classNL3D_1_1CPatch.html#z685_5">computeDisplaceEdgeSmooth</a>(so, to, smoothDisplaceBorderX, smoothDisplaceBorderY);
+00914 <font class="keywordflow">else</font>
+00915 displaceValue= <a class="code" href="classNL3D_1_1CPatch.html#z685_4">computeDisplaceInteriorSmooth</a>(so, to);
+00916
+00917
+00918
+00919 <font class="comment">// Compute Displace normal.</font>
+00920 <font class="comment">//=========================</font>
+00921
+00922 <font class="comment">// Evaluate the normal.</font>
+00923 CVector displaceNormal;
+00924
+00925
+00926 <font class="comment">// smooth on edges and on corners.</font>
+00927 <font class="keywordflow">if</font>(smoothNormalCorner)
+00928 displaceNormal= <a class="code" href="classNL3D_1_1CPatch.html#z685_8">computeNormalCornerSmooth</a>(so, to, smoothNormalBorderX, smoothNormalBorderY);
+00929 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(smoothNormalEdge)
+00930 displaceNormal= <a class="code" href="classNL3D_1_1CPatch.html#z685_7">computeNormalEdgeSmooth</a>(so, to, smoothNormalBorderX, smoothNormalBorderY);
+00931 <font class="keywordflow">else</font>
+00932 {
+00933 <font class="comment">// unpack...</font>
+00934 CBezierPatch *bpatch= <a class="code" href="classNL3D_1_1CPatch.html#a45">unpackIntoCache</a>();
+00935 <font class="comment">// eval.</font>
+00936 displaceNormal= bpatch-&gt;evalNormal(<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>);
+00937 }
+00938
+00939
+00940
+00941 <font class="comment">// Final result.</font>
+00942 <font class="comment">//=========================</font>
+00943 displace= displaceNormal * displaceValue;
+00944 }
+00945
+00946
+00947
+00948 <font class="comment">// ***************************************************************************</font>
+<a name="l00949"></a><a class="code" href="classNL3D_1_1CPatch.html#z668_0">00949</a> <font class="keywordtype">void</font> CPatch::setCornerSmoothFlag(uint corner, <font class="keywordtype">bool</font> smooth)
+00950 {
+00951 <a class="code" href="debug_8h.html#a6">nlassert</a>(corner&lt;=3);
+00952 uint mask= 1&lt;&lt;corner;
+00953 <font class="keywordflow">if</font>(smooth)
+00954 <a class="code" href="classNL3D_1_1CPatch.html#z668_3">_CornerSmoothFlag</a>|= mask;
+00955 <font class="keywordflow">else</font>
+00956 <a class="code" href="classNL3D_1_1CPatch.html#z668_3">_CornerSmoothFlag</a>&amp;= ~mask;
+00957 }
+00958
+00959 <font class="comment">// ***************************************************************************</font>
+<a name="l00960"></a><a class="code" href="classNL3D_1_1CPatch.html#z668_1">00960</a> <font class="keywordtype">bool</font> CPatch::getCornerSmoothFlag(uint corner)<font class="keyword"> const</font>
+00961 <font class="keyword"></font>{
+00962 <a class="code" href="debug_8h.html#a6">nlassert</a>(corner&lt;=3);
+00963 uint mask= 1&lt;&lt;corner;
+00964 <font class="keywordflow">return</font> (<a class="code" href="classNL3D_1_1CPatch.html#z668_3">_CornerSmoothFlag</a>&amp; mask)!=0;
+00965 }
+00966
+00967
+00968 } <font class="comment">// NL3D</font>
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>