aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/primitive__world__image_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/primitive__world__image_8cpp-source.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'docs/doxygen/nel/primitive__world__image_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/primitive__world__image_8cpp-source.html1560
1 files changed, 1560 insertions, 0 deletions
diff --git a/docs/doxygen/nel/primitive__world__image_8cpp-source.html b/docs/doxygen/nel/primitive__world__image_8cpp-source.html
new file mode 100644
index 00000000..9819f9e2
--- /dev/null
+++ b/docs/doxygen/nel/primitive__world__image_8cpp-source.html
@@ -0,0 +1,1560 @@
+<!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>primitive_world_image.cpp</h1><a href="primitive__world__image_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
+00008 <font class="comment"> *</font>
+00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00013 <font class="comment"> * any later version.</font>
+00014 <font class="comment"></font>
+00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00018 <font class="comment"> * General Public License for more details.</font>
+00019 <font class="comment"></font>
+00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00023 <font class="comment"> * MA 02111-1307, USA.</font>
+00024 <font class="comment"> */</font>
+00025
+00026 <font class="preprocessor">#include "<a class="code" href="stdpacs_8h.html">stdpacs.h</a>"</font>
+00027
+00028 <font class="preprocessor">#include "<a class="code" href="hierarchical__timer_8h.html">nel/misc/hierarchical_timer.h</a>"</font>
+00029
+00030 <font class="preprocessor">#include "<a class="code" href="primitive__world__image_8h.html">pacs/primitive_world_image.h</a>"</font>
+00031 <font class="preprocessor">#include "<a class="code" href="move__primitive_8h.html">pacs/move_primitive.h</a>"</font>
+00032 <font class="preprocessor">#include "<a class="code" href="move__element_8h.html">pacs/move_element.h</a>"</font>
+00033
+00034 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00035
+00036
+00037 <font class="keyword">namespace </font>NLPACS
+00038 {
+00039
+00040 <font class="comment">// ***************************************************************************</font>
+00041
+<a name="l00042"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a0">00042</a> CPrimitiveWorldImage::CPrimitiveWorldImage()
+00043 {
+00044 <font class="comment">// Set to NULL</font>
+00045 <font class="keywordflow">for</font> (uint i=0; i&lt;4; i++)
+00046 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[i]=NULL;
+00047
+00048 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o0">_DynamicFlags</a>=0;
+00049 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>=-FLT_MAX;
+00050 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>=-FLT_MAX;
+00051 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>=-FLT_MAX;
+00052 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>=-FLT_MAX;
+00053 }
+00054
+00055 <font class="comment">// ***************************************************************************</font>
+00056
+<a name="l00057"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a1">00057</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::deleteIt (CMoveContainer &amp;container, uint8 worldImage)
+00058 {
+00059 <font class="comment">// Free the move elements </font>
+00060 <font class="keywordflow">for</font> (uint i=0; i&lt;4; i++)
+00061 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[i])
+00062 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a22">removeMoveElement</a> (i, container, worldImage);
+00063 }
+00064 <font class="comment">// ***************************************************************************</font>
+00065
+<a name="l00066"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a2">00066</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::copy (<font class="keyword">const</font> CPrimitiveWorldImage&amp; source)
+00067 {
+00068 <font class="comment">// Copy</font>
+00069 this-&gt;operator=(source);
+00070
+00071 <font class="comment">// Reset some flags</font>
+00072 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o0">_DynamicFlags</a>&amp;=~<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#u5u2">InModifiedListFlag</a>;
+00073
+00074 <font class="comment">// Pointer into the 4 possibles sorted lists of movable primitives. Must be NULL</font>
+00075 <font class="keywordflow">for</font> (uint i=0; i&lt;4; i++)
+00076 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[i]=NULL;
+00077 }
+00078
+00079 <font class="comment">// ***************************************************************************</font>
+00080
+<a name="l00081"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a35">00081</a> <font class="keywordtype">bool</font> CPrimitiveWorldImage::evalCollision (CPrimitiveWorldImage&amp; other, CCollisionDesc&amp; desc, <font class="keywordtype">double</font> timeMin, <font class="keywordtype">double</font> timeMax, uint32 testTime,
+00082 uint32 maxTestIteration, <font class="keywordtype">double</font> &amp;firstContactTime, <font class="keywordtype">double</font> &amp;lastContactTime, CMovePrimitive&amp; primitive,
+00083 CMovePrimitive&amp; otherPrimitive)
+00084 {
+00085 <font class="comment">// H_AUTO(PACS_PWI_evalCollision_long);</font>
+00086
+00087 <font class="comment">// Mask test</font>
+00088 <font class="keywordflow">if</font> (( (primitive.getCollisionMaskInternal() &amp; otherPrimitive.getOcclusionMaskInternal()) == 0) &amp;&amp;
+00089 ( (primitive.getOcclusionMaskInternal() &amp; otherPrimitive.getCollisionMaskInternal()) == 0))
+00090 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00091
+00092 <font class="comment">// Test time</font>
+00093 <font class="keywordflow">if</font> ( (!primitive.checkTestTime (testTime, maxTestIteration)) || (!otherPrimitive.checkTestTime (testTime, maxTestIteration)) )
+00094 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00095
+00096 <font class="comment">// Clear time min time max</font>
+00097 firstContactTime=FLT_MAX;
+00098 lastContactTime=-FLT_MAX;
+00099
+00100 <font class="comment">// Switch the good test</font>
+00101 <font class="keywordflow">switch</font> (primitive.getPrimitiveTypeInternal())
+00102 {
+00103
+00104 <font class="comment">// Static box over...</font>
+00105 <font class="keywordflow">case</font> UMovePrimitive::_2DOrientedBox:
+00106 {
+00107 <font class="comment">// Switch second type</font>
+00108 <font class="keywordflow">switch</font> (otherPrimitive.getPrimitiveTypeInternal())
+00109 {
+00110
+00111 <font class="comment">// Static box over movable box</font>
+00112 <font class="keywordflow">case</font> UMovePrimitive::_2DOrientedBox:
+00113 <font class="comment">// Make the test</font>
+00114 <font class="keywordflow">return</font> <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a36">evalCollisionOBoverOB</a> (other, desc, timeMin, timeMax, firstContactTime, lastContactTime, primitive, otherPrimitive);
+00115
+00116 <font class="comment">// Static box over movable cylinder</font>
+00117 <font class="keywordflow">case</font> UMovePrimitive::_2DOrientedCylinder:
+00118 <font class="comment">// Make the test</font>
+00119 <font class="keywordflow">return</font> <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a37">evalCollisionOBoverOC</a> (other, desc, timeMin, timeMax, firstContactTime, lastContactTime, primitive, otherPrimitive);
+00120
+00121 <font class="keywordflow">default</font>:
+00122 <font class="comment">// Should not go here</font>
+00123 <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00124 }
+00125 }
+00126
+00127 <font class="comment">// Static box over...</font>
+00128 <font class="keywordflow">case</font> UMovePrimitive::_2DOrientedCylinder:
+00129 {
+00130 <font class="comment">// Switch second type</font>
+00131 <font class="keywordflow">switch</font> (otherPrimitive.getPrimitiveTypeInternal())
+00132 {
+00133
+00134 <font class="comment">// Static box over movable box</font>
+00135 <font class="keywordflow">case</font> UMovePrimitive::_2DOrientedBox:
+00136 {
+00137 <font class="comment">// Make the test</font>
+00138 <font class="keywordtype">bool</font> collid=other.evalCollisionOBoverOC (*<font class="keyword">this</font>, desc, timeMin, timeMax, firstContactTime, lastContactTime, otherPrimitive,
+00139 primitive);
+00140 <font class="keywordflow">if</font> (collid)
+00141 desc.XChgContactNormals ();
+00142 <font class="keywordflow">return</font> collid;
+00143 }
+00144
+00145 <font class="comment">// Static box over movable cylinder</font>
+00146 <font class="keywordflow">case</font> UMovePrimitive::_2DOrientedCylinder:
+00147 <font class="comment">// Make the test</font>
+00148 <font class="keywordflow">return</font> <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a38">evalCollisionOCoverOC</a> (other, desc, timeMin, timeMax, firstContactTime, lastContactTime, primitive, otherPrimitive);
+00149
+00150 <font class="keywordflow">default</font>:
+00151 <font class="comment">// Should not go here</font>
+00152 <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00153 }
+00154 }
+00155
+00156 <font class="keywordflow">default</font>:
+00157 <font class="comment">// Should not go here</font>
+00158 <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00159 }
+00160
+00161 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00162 }
+00163
+00164 <font class="comment">// ***************************************************************************</font>
+00165
+<a name="l00166"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a42">00166</a> <font class="keyword">const</font> <a class="code" href="namespaceNLPACS.html#a0">TCollisionSurfaceDescVector</a> *CPrimitiveWorldImage::evalCollision (CGlobalRetriever &amp;retriever, CCollisionSurfaceTemp&amp; surfaceTemp,
+00167 uint32 testTime, uint32 maxTestIteration, CMovePrimitive&amp; primitive)
+00168 {
+00169 <font class="comment">// H_AUTO(PACS_PWI_evalCollision_short);</font>
+00170
+00171 <font class="comment">// Test time</font>
+00172 <font class="keywordflow">if</font> (!primitive.checkTestTime (testTime, maxTestIteration))
+00173 <font class="keywordflow">return</font> NULL;
+00174
+00175 <font class="comment">// Switch the good test</font>
+00176 <font class="keywordflow">if</font> (primitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedBox)
+00177 {
+00178 <font class="comment">// Local I</font>
+00179 CVector locI ((<font class="keywordtype">float</font>)(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.EdgeDirectionX[0]*primitive.getLength(0)/2.0), (float)(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.EdgeDirectionY[0]*primitive.getLength(1)/2.0), 0);
+00180
+00181 <font class="comment">// Local J</font>
+00182 CVector locJ ((<font class="keywordtype">float</font>)(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.EdgeDirectionX[1]*primitive.getLength(0)/2.0), (float)(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.EdgeDirectionY[1]*primitive.getLength(1)/2.0), 0);
+00183
+00184 <font class="comment">// Test</font>
+00185 <font class="keywordflow">return</font> retriever.testBBoxMove (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a2">getGlobalPos</a> (), <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o4">_DeltaPosition</a>, locI, locJ, surfaceTemp);
+00186 }
+00187 <font class="keywordflow">else</font>
+00188 {
+00189 <font class="comment">// Check</font>
+00190 <a class="code" href="debug_8h.html#a6">nlassert</a> (primitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedCylinder);
+00191
+00192 <font class="comment">// Test</font>
+00193 <font class="comment">//nlinfo ("1) %f %f %f\n", _DeltaPosition.x, _DeltaPosition.y, _DeltaPosition.z);</font>
+00194
+00195 <font class="keywordflow">return</font> retriever.testCylinderMove (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a2">getGlobalPos</a> (), <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o4">_DeltaPosition</a>, primitive.getRadiusInternal(), surfaceTemp);
+00196 }
+00197 }
+00198
+00199 <font class="comment">// ***************************************************************************</font>
+00200
+<a name="l00201"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a43">00201</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::doMove (CGlobalRetriever &amp;retriever, CCollisionSurfaceTemp&amp; surfaceTemp, <font class="keywordtype">double</font> originalMax, <font class="keywordtype">double</font> finalMax, <font class="keywordtype">bool</font> keepZ <font class="comment">/*= false*/</font>)
+00202 {
+00203 <font class="comment">// H_AUTO(PACS_PWI_doMove_long);</font>
+00204
+00205 <font class="comment">// Time to avance</font>
+00206 <font class="keywordtype">double</font> ratio;
+00207 <font class="keywordflow">if</font> (finalMax!=originalMax)
+00208 ratio=(finalMax-<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o2">_InitTime</a>)/(originalMax-<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o2">_InitTime</a>);
+00209 <font class="keywordflow">else</font>
+00210 ratio=1;
+00211
+00212 <font class="comment">// Make the move</font>
+00213 <font class="keywordflow">if</font> (!keepZ)
+00214 {
+00215 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a3">setGlobalPos</a> (retriever.doMove(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a2">getGlobalPos</a>(), <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o4">_DeltaPosition</a>, (float)ratio, surfaceTemp, <font class="keyword">false</font>), retriever);
+00216 }
+00217 <font class="keywordflow">else</font>
+00218 {
+00219 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a4">setGlobalPosKeepZ</a>(retriever.doMove(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a2">getGlobalPos</a>(), <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o4">_DeltaPosition</a>, (float)ratio, surfaceTemp, <font class="keyword">false</font>), retriever);
+00220 }
+00221
+00222
+00223 <font class="comment">// Final position</font>
+00224 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o2">_InitTime</a>=finalMax;
+00225 }
+00226
+00227 <font class="comment">// ***************************************************************************</font>
+00228
+<a name="l00229"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a44">00229</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::doMove (<font class="keywordtype">double</font> timeMax)
+00230 {
+00231 <font class="comment">// H_AUTO(PACS_PWI_doMove_short);</font>
+00232
+00233 <font class="comment">// Make the move</font>
+00234 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a1">setPos</a> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a0">getPos</a> ()+<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>*(timeMax-<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o2">_InitTime</a>));
+00235
+00236 <font class="comment">// Final position</font>
+00237 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o2">_InitTime</a>=timeMax;
+00238 }
+00239
+00240 <font class="comment">// ***************************************************************************</font>
+00241
+<a name="l00242"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a36">00242</a> <font class="keywordtype">bool</font> CPrimitiveWorldImage::evalCollisionOBoverOB (CPrimitiveWorldImage&amp; other, CCollisionDesc&amp; desc, <font class="keywordtype">double</font> timeMin, <font class="keywordtype">double</font> timeMax,
+00243 <font class="keywordtype">double</font> &amp;firstContactTime, <font class="keywordtype">double</font> &amp;lastContactTime, CMovePrimitive&amp; primitive,
+00244 CMovePrimitive&amp; otherPrimitive)
+00245 {
+00246 <font class="comment">// Checks</font>
+00247 <a class="code" href="debug_8h.html#a6">nlassert</a> (primitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedBox);
+00248 <a class="code" href="debug_8h.html#a6">nlassert</a> (otherPrimitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedBox);
+00249
+00250 <font class="comment">// Find a collision</font>
+00251 <font class="keywordtype">bool</font> find=<font class="keyword">false</font>;
+00252
+00253 <font class="comment">// Best time</font>
+00254 desc.ContactTime=FLT_MAX;
+00255
+00256 <font class="comment">// Timemin</font>
+00257 <font class="keywordtype">double</font> _timeMax=-FLT_MAX;
+00258
+00259 <font class="comment">// Check movable points over the edge</font>
+00260 uint pt;
+00261 uint seg;
+00262 <font class="keywordflow">for</font> (pt=0; pt&lt;4; pt++)
+00263 <font class="keywordflow">for</font> (seg=0; seg&lt;4; seg++)
+00264 {
+00265 <font class="comment">// Get collision time of the point over the segment</font>
+00266 CCollisionDesc d;
+00267 <font class="keywordflow">if</font> ( <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a39">evalCollisionPoverS</a> (other, d, pt, seg, primitive, otherPrimitive) )
+00268 {
+00269 <font class="comment">// Find</font>
+00270 find=<font class="keyword">true</font>;
+00271
+00272 <font class="comment">// Best time ?</font>
+00273 <font class="keywordflow">if</font> (d.ContactTime&lt;desc.ContactTime)
+00274 {
+00275 <font class="comment">// This is the new descriptor</font>
+00276 desc=d;
+00277 }
+00278
+00279 <font class="comment">// Best max time ?</font>
+00280 <font class="keywordflow">if</font> (d.ContactTime&gt;_timeMax)
+00281 {
+00282 <font class="comment">// This is the new max time</font>
+00283 _timeMax=d.ContactTime;
+00284 }
+00285 }
+00286 }
+00287
+00288 <font class="comment">// Check static points over the movable box</font>
+00289 <font class="keywordflow">for</font> (pt=0; pt&lt;4; pt++)
+00290 <font class="keywordflow">for</font> (seg=0; seg&lt;4; seg++)
+00291 {
+00292 <font class="comment">// Get collision time of the point over the segment</font>
+00293 CCollisionDesc d;
+00294 <font class="keywordflow">if</font> (other.evalCollisionPoverS (*<font class="keyword">this</font>, d, pt, seg, primitive, otherPrimitive))
+00295 {
+00296 <font class="comment">// Find</font>
+00297 find=<font class="keyword">true</font>;
+00298
+00299 <font class="comment">// Best time ?</font>
+00300 <font class="keywordflow">if</font> (d.ContactTime&lt;desc.ContactTime)
+00301 {
+00302 <font class="comment">// This is the new descriptor</font>
+00303 desc=d;
+00304 }
+00305
+00306 <font class="comment">// Best max time ?</font>
+00307 <font class="keywordflow">if</font> (d.ContactTime&gt;_timeMax)
+00308 {
+00309 <font class="comment">// This is the new max time</font>
+00310 _timeMax=d.ContactTime;
+00311 }
+00312 }
+00313 }
+00314
+00315 <font class="keywordflow">if</font> (find)
+00316 {
+00317 <font class="comment">// First last contact time</font>
+00318 firstContactTime=desc.ContactTime;
+00319 lastContactTime=_timeMax;
+00320
+00321 <font class="comment">// Half time</font>
+00322 <font class="comment">//double halfTime = (_timeMax+desc.ContactTime)/2.0;</font>
+00323
+00324 <font class="comment">// Collision in the past ?</font>
+00325 <font class="comment">//if (timeMin &gt; halfTime)</font>
+00326 <font class="keywordflow">if</font> (timeMin &gt; _timeMax)
+00327 <font class="comment">// yes, abort</font>
+00328 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00329
+00330 <font class="comment">// Collision not in the future ?</font>
+00331 <font class="keywordflow">if</font> (timeMax&gt;desc.ContactTime)
+00332 {
+00333 <font class="comment">// Clamp time</font>
+00334 <font class="keywordflow">if</font> (desc.ContactTime&lt;timeMin)
+00335 desc.ContactTime=timeMin;
+00336
+00337 <font class="comment">// yes, found it</font>
+00338 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00339 }
+00340 }
+00341
+00342 <font class="comment">// No collision found</font>
+00343 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00344 }
+00345
+00346 <font class="comment">// ***************************************************************************</font>
+00347
+<a name="l00348"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a37">00348</a> <font class="keywordtype">bool</font> CPrimitiveWorldImage::evalCollisionOBoverOC (CPrimitiveWorldImage&amp; other, CCollisionDesc&amp; desc, <font class="keywordtype">double</font> timeMin, <font class="keywordtype">double</font> timeMax,
+00349 <font class="keywordtype">double</font> &amp;firstContactTime, <font class="keywordtype">double</font> &amp;lastContactTime, CMovePrimitive&amp; primitive,
+00350 CMovePrimitive&amp; otherPrimitive)
+00351 {
+00352 <font class="comment">// Checks</font>
+00353 <a class="code" href="debug_8h.html#a6">nlassert</a> (primitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedBox);
+00354 <a class="code" href="debug_8h.html#a6">nlassert</a> (otherPrimitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedCylinder);
+00355
+00356 <font class="comment">// Find a collision</font>
+00357 <font class="keywordtype">bool</font> find=<font class="keyword">false</font>;
+00358
+00359 <font class="comment">// Best time</font>
+00360 desc.ContactTime=FLT_MAX;
+00361
+00362 <font class="comment">// time min clip</font>
+00363 <font class="keywordtype">double</font> _timeMax = -FLT_MAX;
+00364
+00365 <font class="comment">// Check movable points over the cylinder</font>
+00366 uint pt;
+00367 <font class="keywordflow">for</font> (pt=0; pt&lt;4; pt++)
+00368 {
+00369 <font class="comment">// Get collision time of the point over the segment</font>
+00370 CCollisionDesc d;
+00371 <font class="keywordtype">double</font> firstContactTime;
+00372 <font class="keywordtype">double</font> lastContactTime;
+00373 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a40">evalCollisionPoverOC</a> (other, d, pt, firstContactTime, lastContactTime, primitive, otherPrimitive))
+00374 {
+00375 <font class="comment">// Found</font>
+00376 find=<font class="keyword">true</font>;
+00377
+00378 <font class="comment">// Best time ?</font>
+00379 <font class="keywordflow">if</font> (firstContactTime&lt;desc.ContactTime)
+00380 {
+00381 <font class="comment">// This is the new descriptor</font>
+00382 desc=d;
+00383 }
+00384
+00385 <font class="comment">// Best max time ?</font>
+00386 <font class="keywordflow">if</font> (lastContactTime&gt;_timeMax)
+00387 {
+00388 <font class="comment">// New max time</font>
+00389 _timeMax=lastContactTime;
+00390 }
+00391 }
+00392 }
+00393
+00394 <font class="comment">// Check static points over the movable box</font>
+00395 uint seg;
+00396 <font class="keywordflow">for</font> (seg=0; seg&lt;4; seg++)
+00397 {
+00398 <font class="comment">// Get collision time of the point over the segment</font>
+00399 CCollisionDesc d;
+00400 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a41">evalCollisionSoverOC</a> (other, d, seg, primitive, otherPrimitive))
+00401 {
+00402 <font class="comment">// Found</font>
+00403 find=<font class="keyword">true</font>;
+00404
+00405 <font class="comment">// Best time ?</font>
+00406 <font class="keywordflow">if</font> (d.ContactTime&lt;desc.ContactTime)
+00407 {
+00408 <font class="comment">// This is the new descriptor</font>
+00409 desc=d;
+00410 }
+00411
+00412 <font class="comment">// Best max time ?</font>
+00413 <font class="keywordflow">if</font> (d.ContactTime&gt;_timeMax)
+00414 {
+00415 <font class="comment">// New max time</font>
+00416 _timeMax=d.ContactTime;
+00417 }
+00418 }
+00419 }
+00420
+00421 <font class="keywordflow">if</font> (find)
+00422 {
+00423 <font class="comment">// First last contact time</font>
+00424 firstContactTime=desc.ContactTime;
+00425 lastContactTime=_timeMax;
+00426
+00427 <font class="comment">// Half time</font>
+00428 <font class="comment">//double halfTime = (_timeMax+desc.ContactTime)/2.0;</font>
+00429
+00430 <font class="comment">// Collision in the past ?</font>
+00431 <font class="comment">//if (timeMin &gt; halfTime)</font>
+00432 <font class="keywordflow">if</font> (timeMin &gt; _timeMax)
+00433 <font class="comment">// yes, abort</font>
+00434 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00435
+00436 <font class="comment">// Collision not in the future ?</font>
+00437 <font class="keywordflow">if</font> (timeMax&gt;desc.ContactTime)
+00438 {
+00439 <font class="comment">// Clamp time</font>
+00440 <font class="keywordflow">if</font> (desc.ContactTime&lt;timeMin)
+00441 desc.ContactTime=timeMin;
+00442
+00443 <font class="comment">// yes, found it</font>
+00444 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00445 }
+00446 }
+00447
+00448 <font class="comment">// No collision found</font>
+00449 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00450 }
+00451
+00452 <font class="comment">// ***************************************************************************</font>
+00453
+<a name="l00454"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a39">00454</a> <font class="keywordtype">bool</font> CPrimitiveWorldImage::evalCollisionPoverS (CPrimitiveWorldImage&amp; other, CCollisionDesc&amp; desc, uint numPoint, uint numSeg,
+00455 CMovePrimitive&amp; primitive, CMovePrimitive&amp; otherPrimitive)
+00456 {
+00457 <font class="comment">// Checks</font>
+00458 <a class="code" href="debug_8h.html#a6">nlassert</a> (primitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedBox);
+00459 <a class="code" href="debug_8h.html#a6">nlassert</a> (otherPrimitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedBox);
+00460
+00461 <font class="comment">// Some constants</font>
+00462 <font class="keyword">const</font> <font class="keywordtype">double</font> normalSegX=other._OBData.EdgeDirectionY[numSeg];
+00463 <font class="keyword">const</font> <font class="keywordtype">double</font> normalSegY=-other._OBData.EdgeDirectionX[numSeg];
+00464
+00465 <font class="comment">// Relative speed</font>
+00466 <font class="keyword">const</font> <font class="keywordtype">double</font> speedX=other._Speed.x-<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>;
+00467 <font class="keyword">const</font> <font class="keywordtype">double</font> speedY=other._Speed.y-<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>;
+00468
+00469 <font class="comment">// Dot product with the plan tangeante</font>
+00470 <font class="keywordtype">double</font> dotProd= speedX*normalSegX + speedY*normalSegY;
+00471 <font class="comment">//if ( dotProd &gt; 0 )</font>
+00472 <font class="keywordflow">if</font> ( dotProd != 0 )
+00473 {
+00474 <font class="comment">// Time of the collision</font>
+00475 <font class="keywordtype">double</font> time= (normalSegX*(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[numPoint] - other._OBData.PointPosX[numSeg]) +
+00476 normalSegY*(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[numPoint] - other._OBData.PointPosY[numSeg])) / dotProd;
+00477
+00478 <font class="comment">// Position of segment point at collision time</font>
+00479 <font class="keyword">const</font> <font class="keywordtype">double</font> segPosX= other._OBData.PointPosX[numSeg] + other._Speed.x*time;
+00480 <font class="keyword">const</font> <font class="keywordtype">double</font> segPosY= other._OBData.PointPosY[numSeg] + other._Speed.y*time;
+00481
+00482 <font class="comment">// Position of the point at collision time</font>
+00483 <font class="keyword">const</font> <font class="keywordtype">double</font> ptPosX= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[numPoint] + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>*time;
+00484 <font class="keyword">const</font> <font class="keywordtype">double</font> ptPosY= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[numPoint] + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>*time;
+00485
+00486 <font class="comment">// Direction of the collision on the segment</font>
+00487 <font class="keyword">const</font> <font class="keywordtype">double</font> dirX= ptPosX - segPosX;
+00488 <font class="keyword">const</font> <font class="keywordtype">double</font> dirY= ptPosY - segPosY;
+00489
+00490 <font class="comment">// Length of this vector</font>
+00491 <font class="keyword">const</font> <font class="keywordtype">double</font> length= dirY*normalSegX - dirX*normalSegY;
+00492
+00493 <font class="comment">// Included ?</font>
+00494 <font class="keywordflow">if</font> ( ( length &gt;= 0 ) &amp;&amp; ( length &lt;= otherPrimitive.getLength(numSeg&amp;1) ) )
+00495 {
+00496 <font class="comment">// 2d Collid checked... Now check height</font>
+00497
+00498 <font class="comment">// Pos Z</font>
+00499 <font class="keyword">const</font> <font class="keywordtype">double</font> pointSegZ=other._3dInitPosition.z;
+00500 <font class="keyword">const</font> <font class="keywordtype">double</font> segPosZ= pointSegZ + other._Speed.z*time;
+00501
+00502 <font class="comment">// Some constants</font>
+00503 <font class="keyword">const</font> <font class="keywordtype">double</font> pointZ=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m2">z</a>;
+00504 <font class="keyword">const</font> <font class="keywordtype">double</font> ptPosZ= pointZ + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m2">z</a>*time;
+00505
+00506 <font class="comment">// Included ?</font>
+00507 <font class="keywordflow">if</font> ( (ptPosZ &lt;= segPosZ + otherPrimitive.getHeightInternal()) &amp;&amp; (ptPosZ + primitive.getHeightInternal() &gt;= segPosZ) )
+00508 {
+00509 <font class="comment">// Ok Collision, fill the result</font>
+00510
+00511 <font class="comment">// Time</font>
+00512 desc.ContactTime=time;
+00513
+00514 <font class="comment">// Position</font>
+00515 desc.ContactPosition.x=ptPosX;
+00516 desc.ContactPosition.y=ptPosY;
+00517 desc.ContactPosition.z=std::max (segPosZ, ptPosZ);
+00518
+00519 <font class="comment">// Seg box normal</font>
+00520 desc.ContactNormal1.x=normalSegX;
+00521 desc.ContactNormal1.y=normalSegY;
+00522 desc.ContactNormal1.z=0;
+00523 desc.ContactNormal0.x=-desc.ContactNormal1.x;
+00524 desc.ContactNormal0.y=-desc.ContactNormal1.y;
+00525 desc.ContactNormal0.z=0;
+00526
+00527 <font class="comment">// End</font>
+00528 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00529 }
+00530 }
+00531 }
+00532
+00533 <font class="comment">// No collision</font>
+00534 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00535 }
+00536
+00537 <font class="comment">// ***************************************************************************</font>
+00538
+00539 <font class="keyword">inline</font> uint <a class="code" href="namespaceNLPACS.html#a29">secondDegree</a> (<font class="keywordtype">double</font> a, <font class="keywordtype">double</font> b, <font class="keywordtype">double</font> c, <font class="keywordtype">double</font>&amp; s0, <font class="keywordtype">double</font>&amp; s1)
+00540 {
+00541 <font class="keywordtype">double</font> d=b*b-4.f*a*c;
+00542 <font class="keywordflow">if</font> (d&gt;0)
+00543 {
+00544 <font class="comment">// sqrt d</font>
+00545 d=(double)sqrt (d);
+00546
+00547 <font class="comment">// 1 / 2a</font>
+00548 a=0.5f/a;
+00549
+00550 <font class="comment">// 2 solutions</font>
+00551 s0 = (-b-d)*a;
+00552 s1 = (-b+d)*a;
+00553
+00554 <font class="keywordflow">return</font> 2;
+00555 }
+00556 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (d&lt;0)
+00557 {
+00558 <font class="comment">// No solution</font>
+00559 <font class="keywordflow">return</font> 0;
+00560 }
+00561 <font class="keywordflow">else</font>
+00562 {
+00563 <font class="comment">// 1 solution</font>
+00564 s0 = -b/(2.f*a);
+00565
+00566 <font class="keywordflow">return</font> 1;
+00567 }
+00568 }
+00569
+00570 <font class="comment">// ***************************************************************************</font>
+00571
+<a name="l00572"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a40">00572</a> <font class="keywordtype">bool</font> CPrimitiveWorldImage::evalCollisionPoverOC (CPrimitiveWorldImage&amp; other, CCollisionDesc&amp; desc, uint numPoint,
+00573 <font class="keywordtype">double</font> &amp;firstContactTime, <font class="keywordtype">double</font> &amp;lastContactTime, CMovePrimitive&amp; primitive,
+00574 CMovePrimitive&amp; otherPrimitive)
+00575 {
+00576 <font class="comment">// Checks</font>
+00577 <a class="code" href="debug_8h.html#a6">nlassert</a> (primitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedBox);
+00578 <a class="code" href="debug_8h.html#a6">nlassert</a> (otherPrimitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedCylinder);
+00579
+00580 <font class="comment">/* Point Equ:</font>
+00581 <font class="comment"> * p(t) = p0 + v0*(t - t0)</font>
+00582 <font class="comment"> *</font>
+00583 <font class="comment"> * Cylinder center Equ:</font>
+00584 <font class="comment"> * p'(t) = p'0 + v'0*(t - t'0)</font>
+00585 <font class="comment"> *</font>
+00586 <font class="comment"> * Find t for this equation:</font>
+00587 <font class="comment"> * R² = Norm² (p(t) - p'(t))</font>
+00588 <font class="comment"> * R² = Norm² ( p0 + v0 ( t - t0 ) - p'0 - v'0 ( t - t'0 ) )</font>
+00589 <font class="comment"> *</font>
+00590 <font class="comment"> * A = p0 - v0*t0 - p'0 + v'0*t'0</font>
+00591 <font class="comment"> * B = (v0 - v'0)</font>
+00592 <font class="comment"> *</font>
+00593 <font class="comment"> * Norm² (B)*t² + 2*(A.B)*t + Norm² (A) - R² = 0</font>
+00594 <font class="comment"> *</font>
+00595 <font class="comment"> * a = Norm² (B)</font>
+00596 <font class="comment"> * b = 2*(A.B)</font>
+00597 <font class="comment"> * c = Norm² (A) - R²</font>
+00598 <font class="comment"> *</font>
+00599 <font class="comment"> * a*t² + b*t + c = 0</font>
+00600 <font class="comment"> */</font>
+00601
+00602 <font class="comment">// Let's go</font>
+00603 <font class="keyword">const</font> <font class="keywordtype">double</font> _Ax = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[numPoint] - other._3dInitPosition.x;
+00604 <font class="keyword">const</font> <font class="keywordtype">double</font> _Ay = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[numPoint] - other._3dInitPosition.y;
+00605 <font class="keyword">const</font> <font class="keywordtype">double</font> _Bx = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a> - other._Speed.x;
+00606 <font class="keyword">const</font> <font class="keywordtype">double</font> _By = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a> - other._Speed.y;
+00607
+00608 <font class="comment">// Eval system</font>
+00609 <font class="keywordtype">double</font> s0, s1;
+00610 <font class="keywordtype">double</font> squareRadius=otherPrimitive.getRadiusInternal()*otherPrimitive.getRadiusInternal();
+00611 uint numSolution=<a class="code" href="namespaceNLPACS.html#a29">secondDegree</a> (_Bx*_Bx+_By*_By, 2.f*(_Ax*_Bx+_Ay*_By), _Ax*_Ax+_Ay*_Ay-squareRadius, s0, s1);
+00612 <font class="keywordflow">if</font> (numSolution!=0)
+00613 {
+00614 <font class="comment">// time</font>
+00615 <font class="keywordtype">double</font> time;
+00616
+00617 <font class="comment">// Collision time</font>
+00618 <font class="keywordflow">if</font> (numSolution==1)
+00619 {
+00620 firstContactTime=s0;
+00621 lastContactTime=s0;
+00622 }
+00623 <font class="keywordflow">else</font>
+00624 {
+00625 <font class="comment">// First and last time</font>
+00626 <font class="keywordflow">if</font> (s0&lt;s1)
+00627 {
+00628 firstContactTime=s0;
+00629 lastContactTime=s1;
+00630 }
+00631 <font class="keywordflow">else</font>
+00632 {
+00633 firstContactTime=s1;
+00634 lastContactTime=s0;
+00635 }
+00636 }
+00637 time=firstContactTime;
+00638
+00639 <font class="comment">// Pos Z</font>
+00640 <font class="keyword">const</font> <font class="keywordtype">double</font> pointCylZ=other._3dInitPosition.z;
+00641 <font class="keyword">const</font> <font class="keywordtype">double</font> cylPosZ= pointCylZ + other._Speed.z*time;
+00642
+00643 <font class="comment">// Some constants</font>
+00644 <font class="keyword">const</font> <font class="keywordtype">double</font> pointZ=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m2">z</a>;
+00645 <font class="keyword">const</font> <font class="keywordtype">double</font> ptPosZ= pointZ + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m2">z</a>*time;
+00646
+00647 <font class="comment">// Z Included ?</font>
+00648 <font class="keywordflow">if</font> ( (ptPosZ &lt;= cylPosZ + otherPrimitive.getHeightInternal()) &amp;&amp; (ptPosZ + primitive.getHeightInternal() &gt;= cylPosZ) )
+00649 {
+00650 <font class="comment">// Ok Collision, fill the result</font>
+00651
+00652 <font class="comment">// Time</font>
+00653 desc.ContactTime=time;
+00654
+00655 <font class="comment">// Point position</font>
+00656 <font class="keyword">const</font> <font class="keywordtype">double</font> ptPosX= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[numPoint] + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>*time;
+00657 <font class="keyword">const</font> <font class="keywordtype">double</font> ptPosY= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[numPoint] + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>*time;
+00658
+00659 <font class="comment">// Cylinder position</font>
+00660 <font class="keyword">const</font> <font class="keywordtype">double</font> cylPosX= other._3dInitPosition.x + other._Speed.x*time;
+00661 <font class="keyword">const</font> <font class="keywordtype">double</font> cylPosY= other._3dInitPosition.y + other._Speed.y*time;
+00662
+00663 <font class="comment">// Position</font>
+00664 desc.ContactPosition.x=ptPosX;
+00665 desc.ContactPosition.y=ptPosY;
+00666 desc.ContactPosition.z=std::max (cylPosZ, ptPosZ);
+00667
+00668 <font class="comment">// Cylinder normal</font>
+00669 desc.ContactNormal1.x=ptPosX-cylPosX;
+00670 desc.ContactNormal1.y=ptPosY-cylPosY;
+00671 desc.ContactNormal1.z=0;
+00672 desc.ContactNormal1.normalize ();
+00673 desc.ContactNormal0.x=-desc.ContactNormal1.x;
+00674 desc.ContactNormal0.y=-desc.ContactNormal1.y;
+00675 desc.ContactNormal0.z=0;
+00676
+00677 <font class="comment">// End</font>
+00678 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00679 }
+00680 }
+00681
+00682 <font class="comment">// No collision</font>
+00683 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00684 }
+00685
+00686 <font class="comment">// ***************************************************************************</font>
+00687
+<a name="l00688"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a41">00688</a> <font class="keywordtype">bool</font> CPrimitiveWorldImage::evalCollisionSoverOC (CPrimitiveWorldImage&amp; other, CCollisionDesc&amp; desc, uint numSeg, CMovePrimitive&amp; primitive,
+00689 CMovePrimitive&amp; otherPrimitive)
+00690 {
+00691 <font class="comment">// Checks</font>
+00692 <a class="code" href="debug_8h.html#a6">nlassert</a> (primitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedBox);
+00693 <a class="code" href="debug_8h.html#a6">nlassert</a> (otherPrimitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedCylinder);
+00694
+00695 <font class="comment">// Some constants</font>
+00696 <font class="keyword">const</font> <font class="keywordtype">double</font> normalSegX=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.EdgeDirectionY[numSeg];
+00697 <font class="keyword">const</font> <font class="keywordtype">double</font> normalSegY=-<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.EdgeDirectionX[numSeg];
+00698
+00699 <font class="comment">// Relative speed</font>
+00700 <font class="keyword">const</font> <font class="keywordtype">double</font> speedX=other._Speed.x-<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>;
+00701 <font class="keyword">const</font> <font class="keywordtype">double</font> speedY=other._Speed.y-<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>;
+00702
+00703 <font class="comment">// Dot product with the plan tangeante</font>
+00704 <font class="keywordtype">double</font> dotProd= speedX*normalSegX + speedY*normalSegY;
+00705 <font class="comment">//if ( dotProd &lt; 0 )</font>
+00706 <font class="keywordflow">if</font> ( dotProd !=0 )
+00707 {
+00708 <font class="comment">// Time of the collision</font>
+00709 <font class="keywordtype">double</font> time= (otherPrimitive.getRadiusInternal() + normalSegX*(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[numSeg] - other._3dInitPosition.x ) +
+00710 normalSegY*(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[numSeg] - other._3dInitPosition.y ) ) / dotProd;
+00711
+00712 <font class="comment">// Position of segment point at collision time</font>
+00713 <font class="keyword">const</font> <font class="keywordtype">double</font> segPosX= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[numSeg] + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>*time;
+00714 <font class="keyword">const</font> <font class="keywordtype">double</font> segPosY= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[numSeg] + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>*time;
+00715
+00716 <font class="comment">// Position of the cylinder at collision time</font>
+00717 <font class="keyword">const</font> <font class="keywordtype">double</font> cylPosX= other._3dInitPosition.x + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>*time;
+00718 <font class="keyword">const</font> <font class="keywordtype">double</font> cylPosY= other._3dInitPosition.y + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>*time;
+00719
+00720 <font class="comment">// Position de contact</font>
+00721 <font class="keyword">const</font> <font class="keywordtype">double</font> contactX= cylPosX - normalSegX*otherPrimitive.getRadiusInternal();
+00722 <font class="keyword">const</font> <font class="keywordtype">double</font> contactY= cylPosY - normalSegY*otherPrimitive.getRadiusInternal();
+00723
+00724 <font class="comment">// Direction of the collision on the segment</font>
+00725 <font class="keyword">const</font> <font class="keywordtype">double</font> dirX= contactX - segPosX;
+00726 <font class="keyword">const</font> <font class="keywordtype">double</font> dirY= contactY - segPosY;
+00727
+00728 <font class="comment">// Length of this vector</font>
+00729 <font class="keyword">const</font> <font class="keywordtype">double</font> length= dirY*normalSegX - dirX*normalSegY;
+00730
+00731 <font class="comment">// Included ?</font>
+00732 <font class="keywordflow">if</font> ( ( length &gt;= 0 ) &amp;&amp; ( length &lt;= primitive.getLength (numSeg&amp;1) ) )
+00733 {
+00734 <font class="comment">// 2d Collid checked... Now check height</font>
+00735
+00736 <font class="comment">// Pos Z</font>
+00737 <font class="keyword">const</font> <font class="keywordtype">double</font> segPosZ= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m2">z</a> + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m2">z</a>*time;
+00738
+00739 <font class="comment">// Some constants</font>
+00740 <font class="keyword">const</font> <font class="keywordtype">double</font> cylPosZ= other._3dInitPosition.z + other._Speed.z*time;
+00741
+00742 <font class="comment">// Included ?</font>
+00743 <font class="keywordflow">if</font> ( (cylPosZ &lt;= segPosZ + primitive.getHeightInternal() ) &amp;&amp; (cylPosZ + otherPrimitive.getHeightInternal() &gt;= segPosZ) )
+00744 {
+00745 <font class="comment">// Ok Collision, fill the result</font>
+00746
+00747 <font class="comment">// Time</font>
+00748 desc.ContactTime=time;
+00749
+00750 <font class="comment">// Position</font>
+00751 desc.ContactPosition.x=contactX;
+00752 desc.ContactPosition.y=contactY;
+00753 desc.ContactPosition.z=std::max (segPosZ, cylPosZ);
+00754
+00755 <font class="comment">// Segment normal</font>
+00756 desc.ContactNormal0.x=normalSegX;
+00757 desc.ContactNormal0.y=normalSegY;
+00758 desc.ContactNormal0.z=0;
+00759
+00760 <font class="comment">// Seg box normal</font>
+00761 desc.ContactNormal1.x=contactX-cylPosX;
+00762 desc.ContactNormal1.y=contactY-cylPosY;
+00763 desc.ContactNormal1.z=0;
+00764 desc.ContactNormal1.normalize ();
+00765
+00766 <font class="comment">// End</font>
+00767 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00768 }
+00769 }
+00770 }
+00771
+00772 <font class="comment">// No collision</font>
+00773 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00774 }
+00775
+00776
+00777 <font class="comment">// ***************************************************************************</font>
+00778
+<a name="l00779"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a38">00779</a> <font class="keywordtype">bool</font> CPrimitiveWorldImage::evalCollisionOCoverOC (CPrimitiveWorldImage&amp; other, CCollisionDesc&amp; desc, <font class="keywordtype">double</font> timeMin, <font class="keywordtype">double</font> timeMax,
+00780 <font class="keywordtype">double</font> &amp;firstContactTime, <font class="keywordtype">double</font> &amp;lastContactTime, CMovePrimitive&amp; primitive,
+00781 CMovePrimitive&amp; otherPrimitive)
+00782 {
+00783 <font class="comment">// Checks</font>
+00784 <a class="code" href="debug_8h.html#a6">nlassert</a> (primitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedCylinder);
+00785 <a class="code" href="debug_8h.html#a6">nlassert</a> (otherPrimitive.getPrimitiveTypeInternal()==UMovePrimitive::_2DOrientedCylinder);
+00786
+00787
+00788 <font class="comment">/* Cylinder0 center equ:</font>
+00789 <font class="comment"> * p(t) = p0 + v0*(t - t0)</font>
+00790 <font class="comment"> *</font>
+00791 <font class="comment"> * Cylinder1 center equ:</font>
+00792 <font class="comment"> * p'(t) = p'0 + v'0*(t - t'0)</font>
+00793 <font class="comment"> *</font>
+00794 <font class="comment"> * Find t for this equation:</font>
+00795 <font class="comment"> * (R + R')² = Norm² (p(t) - p'(t))</font>
+00796 <font class="comment"> * (R + R')² = Norm² ( p0 + v0 ( t - t0 ) - p'0 - v'0 ( t - t'0 ) )</font>
+00797 <font class="comment"> *</font>
+00798 <font class="comment"> * A = p0 - v0*t0 - p'0 + v'0*t'0</font>
+00799 <font class="comment"> * B = (v0 - v'0)</font>
+00800 <font class="comment"> *</font>
+00801 <font class="comment"> * Norm² (B)*t² + 2*(A.B)*t + Norm² (A) - (R + R')² = 0</font>
+00802 <font class="comment"> *</font>
+00803 <font class="comment"> * a = Norm² (B)</font>
+00804 <font class="comment"> * b = 2*(A.B)</font>
+00805 <font class="comment"> * c = Norm² (A) - (R + R')²</font>
+00806 <font class="comment"> *</font>
+00807 <font class="comment"> * a*t² + b*t + c = 0</font>
+00808 <font class="comment"> */</font>
+00809
+00810 <font class="comment">// Let's go</font>
+00811 <font class="keyword">const</font> <font class="keywordtype">double</font> _Ax = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a> - other._3dInitPosition.x;
+00812 <font class="keyword">const</font> <font class="keywordtype">double</font> _Ay = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a> - other._3dInitPosition.y;
+00813 <font class="keyword">const</font> <font class="keywordtype">double</font> _Bx = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a> - other._Speed.x;
+00814 <font class="keyword">const</font> <font class="keywordtype">double</font> _By = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a> - other._Speed.y;
+00815
+00816 <font class="comment">// Eval system</font>
+00817 <font class="keywordtype">double</font> s0, s1;
+00818 <font class="keywordtype">double</font> radiusSquare=primitive.getRadiusInternal()+otherPrimitive.getRadiusInternal();
+00819 radiusSquare*=radiusSquare;
+00820 uint numSolution=<a class="code" href="namespaceNLPACS.html#a29">secondDegree</a> (_Bx*_Bx+_By*_By, 2.f*(_Ax*_Bx+_Ay*_By), _Ax*_Ax+_Ay*_Ay-radiusSquare, s0, s1);
+00821 <font class="keywordflow">if</font> (numSolution!=0)
+00822 {
+00823 <font class="comment">// time</font>
+00824 <font class="keywordtype">double</font> _timeMin, _timeMax;
+00825
+00826 <font class="comment">// Collision time</font>
+00827 <font class="keywordflow">if</font> (numSolution==1)
+00828 {
+00829 _timeMin=s0;
+00830 _timeMax=s0;
+00831 }
+00832 <font class="keywordflow">else</font>
+00833 {
+00834 <font class="comment">// Time min and max</font>
+00835 <font class="keywordflow">if</font> (s0&gt;s1)
+00836 {
+00837 _timeMin=s1;
+00838 _timeMax=s0;
+00839 }
+00840 <font class="keywordflow">else</font>
+00841 {
+00842 _timeMin=s0;
+00843 _timeMax=s1;
+00844 }
+00845 }
+00846
+00847 <font class="comment">// half time</font>
+00848 <font class="comment">//const double halfTime=(_timeMin+_timeMax)/2.0;</font>
+00849
+00850 <font class="comment">// Conatct time</font>
+00851 firstContactTime=_timeMin;
+00852 lastContactTime=_timeMax;
+00853
+00854 <font class="comment">// Clip time</font>
+00855 <font class="keywordflow">if</font> ((timeMin&lt;_timeMax)&amp;&amp;(_timeMin&lt;timeMax))
+00856 {
+00857 <font class="comment">// Some constants</font>
+00858 <font class="keyword">const</font> <font class="keywordtype">double</font> cyl0Time= _timeMin;
+00859 <font class="keyword">const</font> <font class="keywordtype">double</font> pointCyl0Z=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m2">z</a>;
+00860 <font class="keyword">const</font> <font class="keywordtype">double</font> cyl0PosZ= pointCyl0Z + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m2">z</a>*cyl0Time;
+00861
+00862 <font class="comment">// Pos Z</font>
+00863 <font class="keyword">const</font> <font class="keywordtype">double</font> cyl1Time= _timeMin;
+00864 <font class="keyword">const</font> <font class="keywordtype">double</font> pointCyl1Z=other._3dInitPosition.z;
+00865 <font class="keyword">const</font> <font class="keywordtype">double</font> cyl1PosZ= pointCyl1Z + other._Speed.z * cyl1Time;
+00866
+00867 <font class="comment">// Z Included ?</font>
+00868 <font class="keywordflow">if</font> ( (cyl0PosZ &lt;= cyl1PosZ + otherPrimitive.getHeightInternal() ) &amp;&amp; (cyl0PosZ + primitive.getHeightInternal() &gt;= cyl1PosZ) )
+00869 {
+00870 <font class="comment">// Ok Collision, fill the result</font>
+00871
+00872 <font class="comment">// Time</font>
+00873 desc.ContactTime=std::max (_timeMin, timeMin);
+00874
+00875 <font class="comment">// Cylinder 0 position</font>
+00876 <font class="keyword">const</font> <font class="keywordtype">double</font> cyl0PosX= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a> + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>*cyl0Time;
+00877 <font class="keyword">const</font> <font class="keywordtype">double</font> cyl0PosY= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a> + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>*cyl0Time;
+00878
+00879 <font class="comment">// Cylinder 1 position</font>
+00880 <font class="keyword">const</font> <font class="keywordtype">double</font> cyl1PosX= other._3dInitPosition.x + other._Speed.x*cyl1Time;
+00881 <font class="keyword">const</font> <font class="keywordtype">double</font> cyl1PosY= other._3dInitPosition.y + other._Speed.y*cyl1Time;
+00882
+00883 <font class="comment">// First cylinder normal</font>
+00884 desc.ContactNormal0.x= cyl1PosX - cyl0PosX;
+00885 desc.ContactNormal0.y= cyl1PosY - cyl0PosY;
+00886 desc.ContactNormal0.z= 0;
+00887 desc.ContactNormal0.normalize ();
+00888
+00889 <font class="comment">// Contact position</font>
+00890 desc.ContactPosition.x= desc.ContactNormal0.x*primitive.getRadiusInternal() + cyl0PosX;
+00891 desc.ContactPosition.y= desc.ContactNormal0.y*primitive.getRadiusInternal() + cyl0PosY;
+00892 desc.ContactPosition.z= std::max (cyl0PosZ, cyl1PosZ);
+00893
+00894 <font class="comment">// Second cylinder normal</font>
+00895 desc.ContactNormal1.x= -desc.ContactNormal0.x;
+00896 desc.ContactNormal1.y= -desc.ContactNormal0.y;
+00897 desc.ContactNormal1.z= 0;
+00898
+00899 <font class="comment">// End</font>
+00900 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00901 }
+00902 }
+00903 }
+00904
+00905 <font class="comment">// No collision</font>
+00906 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00907 }
+00908
+00909 <font class="comment">// ***************************************************************************</font>
+00910
+<a name="l00911"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a32">00911</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::precalcPos (CMovePrimitive &amp;primitive)
+00912 {
+00913 <font class="comment">// Type of the primitive</font>
+00914 uint <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>=primitive.getPrimitiveTypeInternal();
+00915
+00916 <font class="comment">// Box ?</font>
+00917 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==UMovePrimitive::_2DOrientedBox)
+00918 {
+00919 <font class="comment">// Calc cosinus and sinus</font>
+00920 <font class="keywordtype">double</font> cosinus=(double)cos(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.Orientation);
+00921 <font class="keywordtype">double</font> sinus=(double)sin(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.Orientation);
+00922
+00923 <font class="comment">// Size</font>
+00924 <font class="keywordtype">double</font> halfWidth=primitive.getLength (0)/2;
+00925 <font class="keywordtype">double</font> halfDepth=primitive.getLength (1)/2;
+00926
+00927 <font class="comment">// First point</font>
+00928 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[0]=cosinus*(-halfWidth)-sinus*(-halfDepth)+<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>;
+00929 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[0]=sinus*(-halfWidth)+cosinus*(-halfDepth)+<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>;
+00930
+00931 <font class="comment">// Second point</font>
+00932 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[1]=cosinus*halfWidth-sinus*(-halfDepth)+<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>;
+00933 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[1]=sinus*halfWidth+cosinus*(-halfDepth)+<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>;
+00934
+00935 <font class="comment">// Third point</font>
+00936 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[2]=cosinus*halfWidth-sinus*halfDepth+<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>;
+00937 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[2]=sinus*halfWidth+cosinus*halfDepth+<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>;
+00938
+00939 <font class="comment">// Fourth point</font>
+00940 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[3]=cosinus*(-halfWidth)-sinus*halfDepth+<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>;
+00941 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[3]=sinus*(-halfWidth)+cosinus*halfDepth+<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>;
+00942
+00943 <font class="comment">// Direction</font>
+00944 <font class="keywordtype">double</font> oneOverLength[2]= { 1 / primitive.getLength(0), 1 / primitive.getLength(1) };
+00945
+00946 <font class="comment">// Direction</font>
+00947 uint i;
+00948 <font class="keywordflow">for</font> (i=0; i&lt;4; i++)
+00949 {
+00950 <font class="comment">// Next index</font>
+00951 uint next=(i+1)&amp;3;
+00952 <font class="keywordtype">double</font> oneOver=oneOverLength[i&amp;1];
+00953
+00954 <font class="comment">// New direction</font>
+00955 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.EdgeDirectionX[i]=(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[next] - <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[i])*oneOver;
+00956 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.EdgeDirectionY[i]=(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[next] - <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[i])*oneOver;
+00957 }
+00958 }
+00959 <font class="keywordflow">else</font>
+00960 {
+00961 <font class="comment">// Should be a cylinder</font>
+00962 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==UMovePrimitive::_2DOrientedCylinder);
+00963 }
+00964 }
+00965
+00966 <font class="comment">// ***************************************************************************</font>
+00967
+<a name="l00968"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a34">00968</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::precalcBB (<font class="keywordtype">double</font> beginTime, <font class="keywordtype">double</font> endTime, CMovePrimitive &amp;primitive)
+00969 {
+00970 <font class="comment">// Type of the primitive</font>
+00971 uint <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>=primitive.getPrimitiveTypeInternal();
+00972
+00973 <font class="comment">// Box ?</font>
+00974 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==UMovePrimitive::_2DOrientedBox)
+00975 {
+00976 <font class="comment">// Orientation index</font>
+00977 sint orient= (sint)(256.f*<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.Orientation/(2.f*NLMISC::Pi));
+00978 orient&amp;=0xff;
+00979 orient&gt;&gt;=6;
+00980 <a class="code" href="debug_8h.html#a6">nlassert</a> (orient&gt;=0);
+00981 <a class="code" href="debug_8h.html#a6">nlassert</a> (orient&lt;4);
+00982
+00983 <font class="comment">// Compute coordinates</font>
+00984 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>=FLT_MAX;
+00985 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>=FLT_MAX;
+00986 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>=-FLT_MAX;
+00987 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>=-FLT_MAX;
+00988
+00989 <font class="keywordflow">for</font> (uint i=0; i&lt;4; i++)
+00990 {
+00991 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[i]&lt;<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>)
+00992 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[i];
+00993 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[i]&gt;<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>)
+00994 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosX[i];
+00995 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[i]&lt;<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>)
+00996 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[i];
+00997 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[i]&gt;<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>)
+00998 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o15">_OBData</a>.PointPosY[i];
+00999 }
+01000 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>=<a class="code" href="bit__set_8cpp.html#a0">std::min</a> (std::min (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>, <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>+endTime*<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>), <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>+beginTime*<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>);
+01001 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>=std::max (std::max (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>, <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>+endTime*<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>), <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>+beginTime*<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>);
+01002 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>=<a class="code" href="bit__set_8cpp.html#a0">std::min</a> (std::min (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>, <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>+endTime*<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>), <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>+beginTime*<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>);
+01003 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>=std::max (std::max (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>, <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>+endTime*<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>), <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>+beginTime*<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>);
+01004
+01005 <font class="comment">/* </font>
+01006 <font class="comment"> // This code is faster but buggy.. </font>
+01007 <font class="comment"> _BBXMin= _OBData.PointPosX[minX[orient]] + _Speed.x*beginTime;</font>
+01008 <font class="comment"> _BBXMin= std::min (_BBXMin, _OBData.PointPosX[minX[orient]] + _Speed.x*endTime);</font>
+01009 <font class="comment"></font>
+01010 <font class="comment"> _BBYMin= _OBData.PointPosY[minY[orient]] + _Speed.y*beginTime;</font>
+01011 <font class="comment"> _BBYMin= std::min (_BBYMin, _OBData.PointPosY[minY[orient]] + _Speed.y*endTime);</font>
+01012 <font class="comment"></font>
+01013 <font class="comment"> _BBXMax= _OBData.PointPosX[maxX[orient]] + _Speed.x*beginTime;</font>
+01014 <font class="comment"> _BBXMax= std::max (_BBXMax, _OBData.PointPosX[maxX[orient]] + _Speed.x*endTime);</font>
+01015 <font class="comment"></font>
+01016 <font class="comment"> _BBYMax= _OBData.PointPosY[maxY[orient]] + _Speed.y*beginTime;</font>
+01017 <font class="comment"> _BBYMax= std::max (_BBYMax, _OBData.PointPosY[maxY[orient]] + _Speed.y*endTime);*/</font>
+01018 }
+01019 <font class="keywordflow">else</font>
+01020 {
+01021 <font class="comment">// Should be a cylinder</font>
+01022 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==UMovePrimitive::_2DOrientedCylinder);
+01023
+01024 <font class="comment">// Compute X coordinates</font>
+01025 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a> + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>*beginTime;
+01026 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a> + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m0">x</a>*endTime;
+01027 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>&gt;<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>)
+01028 {
+01029 <font class="keywordtype">double</font> tmp=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>;
+01030 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>;
+01031 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>=tmp;
+01032 }
+01033 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>-=primitive.getRadiusInternal();
+01034 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>+=primitive.getRadiusInternal();
+01035
+01036 <font class="comment">// Compute Y coordinates</font>
+01037 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a> + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>*beginTime;
+01038 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a> + <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#m1">y</a>*endTime;
+01039 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>&gt;<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>)
+01040 {
+01041 <font class="keywordtype">double</font> tmp=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>;
+01042 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>;
+01043 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>=tmp;
+01044 }
+01045 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o7">_BBYMin</a>-=primitive.getRadiusInternal();
+01046 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o9">_BBYMax</a>+=primitive.getRadiusInternal();
+01047 }
+01048
+01049 <font class="comment">// Delta position</font>
+01050 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o4">_DeltaPosition</a>=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>*(endTime-beginTime);
+01051 }
+01052
+01053 <font class="comment">// ***************************************************************************</font>
+01054
+<a name="l01055"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a23">01055</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::addMoveElement (CMoveCell&amp; cell, uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <font class="keywordtype">double</font> centerX, <font class="keywordtype">double</font> centerY, CMovePrimitive *primitive,
+01056 CMoveContainer &amp;container, uint8 worldImage)
+01057 {
+01058 <font class="comment">// Find a free place</font>
+01059 uint slot;
+01060 <font class="keywordflow">for</font> (slot=0; slot&lt;4; slot++)
+01061 {
+01062 <font class="comment">// Empty ?</font>
+01063 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]==NULL)
+01064 {
+01065 <font class="comment">// Primitive center</font>
+01066 <font class="keywordtype">double</font> cx=(<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>+<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o8">_BBXMax</a>)/2.f;
+01067
+01068 <font class="comment">// Allocate move element</font>
+01069 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]=container.allocateMoveElement ();
+01070 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]-&gt;Primitive=primitive;
+01071 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]-&gt;X=<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
+01072 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]-&gt;Y=<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+01073
+01074 <font class="comment">// Insert in left or right ?</font>
+01075 <font class="keywordflow">if</font> (cx&lt;centerX)
+01076 <font class="comment">// In the left</font>
+01077 cell.linkFirstX (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]);
+01078 <font class="keywordflow">else</font>
+01079 <font class="comment">// In the right</font>
+01080 cell.linkLastX (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]);
+01081
+01082 <font class="comment">/*// Insert in left or right ?</font>
+01083 <font class="comment"> if (cy&lt;centerY)</font>
+01084 <font class="comment"> // In the left</font>
+01085 <font class="comment"> cell.linkFirstY (_MoveElement[slot]);</font>
+01086 <font class="comment"> else</font>
+01087 <font class="comment"> // In the right</font>
+01088 <font class="comment"> cell.linkLastY (_MoveElement[slot]);*/</font>
+01089
+01090 <font class="comment">// Move it</font>
+01091 cell.updateSortedLists (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot], worldImage);
+01092
+01093 <font class="comment">// End</font>
+01094 <font class="keywordflow">break</font>;
+01095 }
+01096 }
+01097 }
+01098
+01099 <font class="comment">// ***************************************************************************</font>
+01100
+01101 <font class="keywordtype">void</font> CPrimitiveWorldImage::addMoveElementendOfList (CMoveCell&amp; cell, uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, CMovePrimitive *primitive,
+01102 CMoveContainer &amp;container)
+01103 {
+01104 <font class="comment">// Find a free place</font>
+01105 uint slot;
+01106 <font class="keywordflow">for</font> (slot=0; slot&lt;4; slot++)
+01107 {
+01108 <font class="comment">// Empty ?</font>
+01109 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]==NULL)
+01110 {
+01111 <font class="comment">// Allocate move element</font>
+01112 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]=container.allocateMoveElement ();
+01113 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]-&gt;Primitive=primitive;
+01114 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]-&gt;X=<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
+01115 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]-&gt;Y=<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+01116
+01117 <font class="comment">// In the right</font>
+01118 cell.linkLastX (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[slot]);
+01119
+01120 <font class="comment">// End</font>
+01121 <font class="keywordflow">break</font>;
+01122 }
+01123 }
+01124 }
+01125
+01126 <font class="comment">// ***************************************************************************</font>
+01127
+<a name="l01128"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a22">01128</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::removeMoveElement (uint i, CMoveContainer &amp;container, uint8 worldImage)
+01129 {
+01130 <font class="comment">// Check</font>
+01131 <a class="code" href="debug_8h.html#a6">nlassert</a> ((i&gt;=0)||(i&lt;4));
+01132 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[i]!=NULL);
+01133
+01134 <font class="comment">// Unlink the element</font>
+01135 container.unlinkMoveElement (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[i], worldImage);
+01136
+01137 <font class="comment">// Free the move element</font>
+01138 container.freeMoveElement (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[i]);
+01139
+01140 <font class="comment">// Set to NULL</font>
+01141 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[i]=NULL;
+01142 }
+01143
+01144 <font class="comment">// ***************************************************************************</font>
+01145
+<a name="l01146"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a26">01146</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::checkSortedList (uint8 worldImage)
+01147 {
+01148 <font class="comment">// For the 4 elements</font>
+01149 <font class="keywordflow">for</font> (uint i=0; i&lt;4; i++)
+01150 {
+01151 <font class="comment">// element here ?</font>
+01152 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[i])
+01153 {
+01154 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[i]-&gt;PreviousX)
+01155 <a class="code" href="debug_8h.html#a7">nlassertonce</a> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[i]-&gt;PreviousX-&gt;Primitive-&gt;getWorldImage(worldImage)-&gt;_BBXMin &lt;= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o6">_BBXMin</a>);
+01156 <font class="keywordflow">if</font> (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o17">_MoveElement</a>[i]-&gt;NextX)
+01157 <a class="code" href="debug_8h.html#a7">nlassertonce</a> (_BBXMin &lt;= _MoveElement[i]-&gt;NextX-&gt;Primitive-&gt;getWorldImage(worldImage)-&gt;_BBXMin);
+01158 }
+01159 }
+01160 }
+01161
+01162 <font class="comment">// ***************************************************************************</font>
+01163
+<a name="l01164"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a45">01164</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::reaction (CPrimitiveWorldImage&amp; second, <font class="keyword">const</font> CCollisionDesc&amp; desc, CGlobalRetriever* retriever,
+01165 CCollisionSurfaceTemp&amp; surfaceTemp, <font class="keywordtype">bool</font> collision, CMovePrimitive &amp;primitive,
+01166 CMovePrimitive &amp;otherPrimitive, CMoveContainer *container, uint8 worldImage, uint8 secondWorldImage,
+01167 <font class="keywordtype">bool</font> secondConst)
+01168 {
+01169 <font class="comment">// H_AUTO(PACS_PWI_reaction_long);</font>
+01170
+01171 <font class="comment">// TODO: reaction for no collision must be made on the full deltaTime not only to CollisionTime</font>
+01172
+01173 <font class="comment">// Get the two reaction codes</font>
+01174 UMovePrimitive::TReaction firstReaction=primitive.getReactionTypeInternal();
+01175 UMovePrimitive::TReaction secondReaction=otherPrimitive.getReactionTypeInternal();
+01176
+01177 <font class="comment">// Overide collsion </font>
+01178 collision = collision &amp;&amp; (primitive.isObstacle ()) &amp;&amp; (otherPrimitive.isObstacle ());
+01179
+01180 <font class="comment">// Get the two mass</font>
+01181 <font class="keywordtype">float</font> mass0 = primitive.getMass ();
+01182 <font class="keywordtype">float</font> mass1 = otherPrimitive.getMass ();
+01183
+01184 <font class="comment">// Energy sum</font>
+01185 <font class="keywordtype">double</font> projSpeed0 = desc.ContactNormal1 * <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>;
+01186 <font class="keywordtype">double</font> projSpeed1 = desc.ContactNormal0 * second._Speed;
+01187 <font class="keywordtype">double</font> energySum = (- mass0 * projSpeed0 - mass1 * projSpeed1 ) / 2.0;
+01188
+01189 <font class="comment">// Old position</font>
+01190 CVectorD collisionPosition=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a>;
+01191 collisionPosition+=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>*desc.ContactTime;
+01192
+01193 <font class="comment">// Calc new speed</font>
+01194 CVectorD newSpeed;
+01195
+01196 <font class="comment">// Obstacle ?</font>
+01197 <font class="keywordflow">if</font> ( (!collision) || (firstReaction==UMovePrimitive::DoNothing) )
+01198 newSpeed=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>;
+01199 <font class="keywordflow">else</font>
+01200 {
+01201 <font class="keywordflow">switch</font> (firstReaction)
+01202 {
+01203 <font class="keywordflow">case</font> UMovePrimitive::Slide:
+01204 <font class="comment">// Remove projected speed</font>
+01205 newSpeed=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a> - projSpeed0 * desc.ContactNormal1;
+01206
+01207 <font class="comment">// Reflexion speed</font>
+01208 newSpeed+=( primitive.getAttenuation()*energySum / mass0 ) * desc.ContactNormal1;
+01209 <font class="keywordflow">break</font>;
+01210 <font class="keywordflow">case</font> UMovePrimitive::Reflexion:
+01211 <font class="comment">// Remove projected speed</font>
+01212 newSpeed=<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a> - projSpeed0 * desc.ContactNormal1;
+01213
+01214 <font class="comment">// Reflexion speed</font>
+01215 newSpeed+=( primitive.getAttenuation()*energySum / mass0 ) * desc.ContactNormal1;
+01216 <font class="keywordflow">break</font>;
+01217 <font class="keywordflow">case</font> UMovePrimitive::Stop:
+01218 newSpeed.<a class="code" href="classNLMISC_1_1CVectorD.html#z346_0">set</a> (0,0,0);
+01219 <font class="keywordflow">break</font>;
+01220 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
+01221 }
+01222 }
+01223
+01224 <font class="comment">// Set new speed</font>
+01225 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a8">setSpeed</a> (newSpeed, container, &amp;primitive, worldImage);
+01226
+01227 <font class="comment">// New position at t=0</font>
+01228 <font class="keywordflow">if</font> (retriever)
+01229 {
+01230 <font class="comment">// Make a domove in the Ben data</font>
+01231 <font class="keywordtype">double</font> deltaDist= <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o4">_DeltaPosition</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#z345_2">norm</a>();
+01232 <font class="keywordtype">double</font> deltaTime;
+01233 <font class="keywordflow">if</font>(deltaDist&lt;0.000001)
+01234 deltaTime= 0;
+01235 <font class="keywordflow">else</font>
+01236 deltaTime=(collisionPosition-<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a0">getPos</a> ()).norm()/deltaDist;
+01237 <a class="code" href="debug_8h.html#a6">nlassert</a> (deltaTime&gt;=0);
+01238 <a class="code" href="debug_8h.html#a6">nlassert</a> (deltaTime&lt;=1);
+01239
+01240 UGlobalPosition newPosition = retriever-&gt;doMove (<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a2">getGlobalPos</a> (), <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o4">_DeltaPosition</a>,
+01241 (float)deltaTime, surfaceTemp, <font class="keyword">true</font>);
+01242
+01243 <font class="comment">// Set the new position</font>
+01244 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a3">setGlobalPos</a> (newPosition, *retriever);
+01245
+01246 <font class="comment">// Position at t=0</font>
+01247 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a> = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a0">getPos</a>() - newSpeed * desc.ContactTime;
+01248
+01249 <font class="comment">// New init time</font>
+01250 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o2">_InitTime</a> = desc.ContactTime;
+01251 }
+01252 <font class="keywordflow">else</font>
+01253 {
+01254 <font class="comment">// No retriever used</font>
+01255 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a1">setPos</a> (collisionPosition);
+01256
+01257 <font class="comment">// Position at t=0</font>
+01258 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a> = collisionPosition - newSpeed * desc.ContactTime;
+01259
+01260 <font class="comment">// New init time</font>
+01261 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o2">_InitTime</a> = desc.ContactTime;
+01262 }
+01263
+01264 <font class="comment">// Dirt pos</font>
+01265 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a29">dirtPos</a> (container, &amp;primitive, worldImage);
+01266
+01267 <font class="comment">// ****** Second object</font>
+01268
+01269 <font class="comment">// Is second object in a static world ?</font>
+01270 <font class="keywordflow">if</font> (!secondConst)
+01271 {
+01272 <font class="comment">// Old position</font>
+01273 collisionPosition=second._3dInitPosition;
+01274 collisionPosition+=second._Speed * desc.ContactTime;
+01275
+01276 <font class="comment">// Obstacle ?</font>
+01277 <font class="keywordflow">if</font> ( (!collision) || (secondReaction==UMovePrimitive::DoNothing) )
+01278 newSpeed=second._Speed;
+01279 <font class="keywordflow">else</font>
+01280 {
+01281 <font class="keywordflow">switch</font> (secondReaction)
+01282 {
+01283 <font class="keywordflow">case</font> UMovePrimitive::Slide:
+01284 <font class="comment">// Remove projected speed</font>
+01285 newSpeed=second._Speed - projSpeed1 * desc.ContactNormal0;
+01286
+01287 <font class="comment">// Reflexion speed</font>
+01288 newSpeed+=( otherPrimitive.getAttenuation()*energySum / mass1 ) * desc.ContactNormal1;
+01289 <font class="keywordflow">break</font>;
+01290 <font class="keywordflow">case</font> UMovePrimitive::Reflexion:
+01291 <font class="comment">// Remove projected speed</font>
+01292 newSpeed=second._Speed - projSpeed1 * desc.ContactNormal0;
+01293
+01294 <font class="comment">// Reflexion speed</font>
+01295 newSpeed+=( otherPrimitive.getAttenuation()*energySum / mass1 ) * desc.ContactNormal0;
+01296 <font class="keywordflow">break</font>;
+01297 <font class="keywordflow">case</font> UMovePrimitive::Stop:
+01298 newSpeed.set (0,0,0);
+01299 <font class="keywordflow">break</font>;
+01300 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
+01301 }
+01302 }
+01303
+01304 <font class="comment">// Set new speed</font>
+01305 second.setSpeed (newSpeed, container, &amp;otherPrimitive, secondWorldImage);
+01306
+01307 <font class="comment">// New position at t=0</font>
+01308 <font class="keywordflow">if</font> (retriever)
+01309 {
+01310 <font class="comment">// Make a domove in the Ben data</font>
+01311 <font class="keywordtype">double</font> deltaDist= second._DeltaPosition.norm();
+01312 <font class="keywordtype">double</font> deltaTime;
+01313 <font class="keywordflow">if</font>(deltaDist==0)
+01314 deltaTime= 0;
+01315 <font class="keywordflow">else</font>
+01316 deltaTime=(collisionPosition-second._Position.getPos ()).norm()/deltaDist;
+01317 <a class="code" href="namespaceNLMISC.html#a215">clamp</a> (deltaTime, 0.0, 1.0);
+01318
+01319 UGlobalPosition newPosition = retriever-&gt;doMove (second._Position.getGlobalPos (), second._DeltaPosition,
+01320 (float)deltaTime, surfaceTemp, <font class="keyword">true</font>);
+01321
+01322 <font class="comment">// Set the new position</font>
+01323 second._Position.setGlobalPos (newPosition, *retriever);
+01324
+01325 <font class="comment">// Position at t=0</font>
+01326 second._3dInitPosition = second._Position.getPos() - newSpeed * desc.ContactTime;
+01327
+01328 <font class="comment">// New init time</font>
+01329 second._InitTime = desc.ContactTime;
+01330 }
+01331 <font class="keywordflow">else</font>
+01332 {
+01333 <font class="comment">// No retriever used</font>
+01334 second._Position.setPos (collisionPosition);
+01335
+01336 <font class="comment">// Position at t=0</font>
+01337 second._3dInitPosition = collisionPosition - newSpeed * desc.ContactTime;
+01338
+01339 <font class="comment">// New init time</font>
+01340 second._InitTime = desc.ContactTime;
+01341 }
+01342
+01343 <font class="comment">// Dirt pos</font>
+01344 second.dirtPos (container, &amp;otherPrimitive, secondWorldImage);
+01345 }
+01346 }
+01347
+01348 <font class="comment">// ***************************************************************************</font>
+01349
+<a name="l01350"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a46">01350</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::reaction (<font class="keyword">const</font> CCollisionSurfaceDesc&amp; surfaceDesc, <font class="keyword">const</font> UGlobalPosition&amp; globalPosition,
+01351 CGlobalRetriever&amp; retriever, <font class="keywordtype">double</font> ratio, <font class="keywordtype">double</font> dt, CMovePrimitive &amp;primitive, CMoveContainer &amp;container,
+01352 uint8 worldImage)
+01353 {
+01354 <font class="comment">// H_AUTO(PACS_PWI_reaction_short);</font>
+01355
+01356 <font class="comment">// Reaction type</font>
+01357 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>=primitive.getReactionTypeInternal();
+01358
+01359 <font class="comment">// Reaction to the collision: copy the CGlobalRetriever::CGlobalPosition</font>
+01360 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a3">setGlobalPos</a> (globalPosition, retriever);
+01361
+01362 <font class="comment">// Relfexion or slide ?</font>
+01363 <font class="keywordflow">if</font> ((<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==UMovePrimitive::Reflexion)||(<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==UMovePrimitive::Slide))
+01364 {
+01365 <font class="comment">// Slide ?</font>
+01366 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==UMovePrimitive::Slide)
+01367 {
+01368 <font class="comment">// Project last delta on plane of collision.</font>
+01369 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>-= surfaceDesc.ContactNormal*(surfaceDesc.ContactNormal*<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>-<a class="code" href="move__primitive_8h.html#a0">NELPACS_DIST_BACK</a>/(dt-surfaceDesc.ContactTime));
+01370 }
+01371
+01372 <font class="comment">// Reflexion ?</font>
+01373 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==UMovePrimitive::Reflexion)
+01374 {
+01375 <font class="comment">// Project last delta on plane of collision.</font>
+01376 <font class="keywordtype">double</font> speedProj=surfaceDesc.ContactNormal*<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>;
+01377 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>-=surfaceDesc.ContactNormal*(speedProj+speedProj*primitive.getAttenuation()-<a class="code" href="move__primitive_8h.html#a0">NELPACS_DIST_BACK</a>/(dt-surfaceDesc.ContactTime));
+01378 }
+01379 }
+01380 <font class="keywordflow">else</font>
+01381 {
+01382 <font class="comment">// Stop ?</font>
+01383 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>==UMovePrimitive::Stop)
+01384 {
+01385 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>.<a class="code" href="classNLMISC_1_1CVectorD.html#z346_0">set</a> (0,0,0);
+01386 }
+01387 }
+01388
+01389 <font class="comment">// Contact time</font>
+01390 <font class="keywordtype">double</font> contactTime=surfaceDesc.ContactTime;
+01391
+01392 <font class="comment">// Init position</font>
+01393 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a> = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a0">getPos</a>() - <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a> * contactTime;
+01394
+01395 <font class="comment">// Set contactTime</font>
+01396 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o2">_InitTime</a>=contactTime;
+01397
+01398 <font class="comment">// Dirt pos</font>
+01399 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a29">dirtPos</a> (&amp;container, &amp;primitive, worldImage);
+01400 }
+01401
+01402 <font class="comment">// ***************************************************************************</font>
+01403
+<a name="l01404"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a3">01404</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::setGlobalPosition (<font class="keyword">const</font> UGlobalPosition&amp; pos, CMoveContainer&amp; container, CMovePrimitive &amp;primitive, uint8 worldImage)
+01405 {
+01406 <font class="comment">// Cast type</font>
+01407 <a class="code" href="debug_8h.html#a6">nlassert</a> (dynamic_cast&lt;const CMoveContainer*&gt;(&amp;container));
+01408 <font class="keyword">const</font> CMoveContainer *cont=(<font class="keyword">const</font> CMoveContainer*)&amp;container;
+01409
+01410 <font class="comment">// Use the global retriever ?</font>
+01411 <a class="code" href="debug_8h.html#a6">nlassert</a> (cont-&gt;getGlobalRetriever());
+01412
+01413 <font class="comment">// Get the pos</font>
+01414 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a3">setGlobalPos</a> (pos, *cont-&gt;getGlobalRetriever());
+01415
+01416 <font class="comment">// Precalc some values</font>
+01417 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a> = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a0">getPos</a> ();
+01418 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o2">_InitTime</a> = 0;
+01419
+01420 <font class="comment">// Speed NULL</font>
+01421 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>=CVector::Null;
+01422
+01423 <font class="comment">// Dirt BB</font>
+01424 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a29">dirtPos</a> (&amp;container, &amp;primitive, worldImage);
+01425 }
+01426
+01427 <font class="comment">// ***************************************************************************</font>
+01428
+<a name="l01429"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a4">01429</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::setGlobalPosition (<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVectorD.html">NLMISC::CVectorD</a>&amp; pos, CMoveContainer&amp; container, CMovePrimitive &amp;primitive, uint8 worldImage, <font class="keywordtype">bool</font> keepZ <font class="comment">/*= false*/</font>)
+01430 {
+01431 <font class="comment">// Cast type</font>
+01432 <a class="code" href="debug_8h.html#a6">nlassert</a> (dynamic_cast&lt;const CMoveContainer*&gt;(&amp;container));
+01433 <font class="keyword">const</font> CMoveContainer *cont=(<font class="keyword">const</font> CMoveContainer*)&amp;container;
+01434
+01435 <font class="comment">// Get the retriever</font>
+01436 CGlobalRetriever *retriever=cont-&gt;getGlobalRetriever();
+01437
+01438 <font class="comment">// Use a global retriever</font>
+01439 <font class="keywordflow">if</font> (retriever)
+01440 {
+01441 <font class="comment">// Get a cvector</font>
+01442 <font class="comment">// CVector vect=pos; // better with CVectorD</font>
+01443
+01444 <font class="comment">// Get global position</font>
+01445 UGlobalPosition globalPosition=retriever-&gt;retrievePosition (pos);
+01446
+01447 <font class="keywordflow">if</font> (keepZ)
+01448 {
+01449 globalPosition.LocalPosition.Estimation.z = (float) pos.<a class="code" href="classNLMISC_1_1CVectorD.html#m2">z</a>;
+01450 }
+01451 <font class="comment">// Set global position</font>
+01452 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a3">setGlobalPos</a> (globalPosition, *retriever);
+01453 }
+01454 <font class="keywordflow">else</font>
+01455 {
+01456 <font class="comment">// Set the position</font>
+01457 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a1">setPos</a> (pos);
+01458 }
+01459
+01460 <font class="comment">// Precalc some values</font>
+01461 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a> = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a0">getPos</a> ();
+01462 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o2">_InitTime</a> = 0;
+01463
+01464 <font class="comment">// Speed NULL</font>
+01465 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o5">_Speed</a>=CVector::Null;
+01466
+01467 <font class="comment">// Dirt BB</font>
+01468 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a29">dirtPos</a> (&amp;container, &amp;primitive, worldImage);
+01469 }
+01470
+01471 <font class="comment">// ***************************************************************************</font>
+01472
+<a name="l01473"></a><a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a7">01473</a> <font class="keywordtype">void</font> CPrimitiveWorldImage::move (<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVectorD.html">NLMISC::CVectorD</a>&amp; speed, CMoveContainer&amp; container, CMovePrimitive &amp;primitive, uint8 worldImage)
+01474 {
+01475 <font class="comment">// New speed</font>
+01476 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a8">setSpeed</a> (speed, &amp;container, &amp;primitive, worldImage);
+01477
+01478 <font class="comment">// Set initial position</font>
+01479 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o3">_3dInitPosition</a> = <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o1">_Position</a>.<a class="code" href="classNLPACS_1_1CPrimitiveWorldImage_1_1CPosition.html#a0">getPos</a> ();
+01480
+01481 <font class="comment">// Set initial time</font>
+01482 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#o2">_InitTime</a> = 0;
+01483
+01484 <font class="comment">// Dirt BB</font>
+01485 <a class="code" href="classNLPACS_1_1CPrimitiveWorldImage.html#a29">dirtPos</a> (&amp;container, &amp;primitive, worldImage);
+01486 }
+01487
+01488 <font class="comment">// ***************************************************************************</font>
+01489
+01490
+01491 } <font class="comment">// NLPACS</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>