From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a03333.html | 2676 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2676 insertions(+) create mode 100644 docs/doxygen/nel/a03333.html (limited to 'docs/doxygen/nel/a03333.html') diff --git a/docs/doxygen/nel/a03333.html b/docs/doxygen/nel/a03333.html new file mode 100644 index 00000000..f9d2d623 --- /dev/null +++ b/docs/doxygen/nel/a03333.html @@ -0,0 +1,2676 @@ + + +NeL: NLPACS::CRetrieverInstance class Reference + + + +
+

NLPACS::CRetrieverInstance Class Reference

#include <retriever_instance.h> +

+


Detailed Description

+An instance of a local retriever. It defines a physical/geographic zone of landscape.
Author:
Benjamin Legros

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 56 of file retriever_instance.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

 CRetrieverInstance ()
 Default constructor.

void forceBorderChainLink (uint border, uint frontInstance, uint frontBorder, uint frontChain, uint frontSurface)
 Forces border chain link.

const NLMISC::CAABBoxgetBBox () const
 Returns the bbox of the instance (using the translation and orientation of the retriever).

CLink getBorderChainLink (uint n) const
 Gets the id of the nth neighbor chain on the given edge.

const std::vector< CLink > & getBorderChainLinks () const
 Gets the ids of the neighbor chains on the given edge.

NLMISC::CVectorD getDoubleGlobalPosition (const NLMISC::CVector &localPosition) const
 Computes the position (as double) in the global axis from a local position (in the retriever axis).

NLMISC::CVector getGlobalPosition (const NLMISC::CVector &localPosition) const
 Computes the position in the global axis from a local position (in the retriever axis).

uint8 getInstanceEdge (uint8 retrieverEdge) const
 Returns the number of the edge on the instance corresponding to the edge on the retriever.

sint32 getInstanceId () const
 Returns the id of this instance.

NLMISC::CVector getLocalPosition (const NLMISC::CVectorD &globalPosition) const
 Computes the position in the local axis of the retriever from a global position.

NLMISC::CVector getLocalPosition (const NLMISC::CVector &globalPosition) const
 Computes the position in the local axis of the retriever from a global position.

sint32 getNeighbor (uint n) const
 Gets the id of the neighbor on the edge.

std::vector< sint32getNeighbors () const
 Gets the neighbors.

uint8 getOrientation () const
 Returns the orientation of the instance in relation to the retriever.

NLMISC::CVector getOrigin () const
 Returns the origin translation of this instance.

uint8 getRetrieverEdge (uint8 instanceEdge) const
 Returns the number of the edge on the retriever corresponding to the edge on the instance.

sint32 getRetrieverId () const
 Returns the id of the retriever associated to this instance.

CLocalRetriever::EType getType () const
 Returns the type of the instance.

void init (const CLocalRetriever &retriever)
 Inits the instance (after a serial for instance.).

void initEdgeQuad (CGlobalRetriever &gr)
void link (CRetrieverInstance &neighbor, const std::vector< CLocalRetriever > &retrievers)
 Links the instance to a given neighbor on the given edge.

void linkEdgeQuad (CGlobalRetriever &gr)
 link the edge quad of the interior with the the landscape instances

void make (sint32 instanceId, sint32 retrieverId, const CLocalRetriever &retriever, uint8 orientation, const NLMISC::CVector &origin)
 Builds the instance.

void reset ()
 Resets the instance. This doesn't affect any neighboring instances...

void resetBorderChainLinks (const std::vector< uint > &links)
 Resets border chains links.

void resetLinks ()
 Resets links of the instance. This doesn't affect any neighboring instances...

void resetLinks (uint32 id)
 Resets links to the given instance. This doesn't affect any neighbor.

void retrievePosition (const NLMISC::CVectorD &estimated, const CLocalRetriever &retriever, CCollisionSurfaceTemp &cst, bool sortByDistance=true) const
void retrievePosition (const NLMISC::CVector &estimated, const CLocalRetriever &retriever, CCollisionSurfaceTemp &cst, bool sortByDistance=true) const
void serial (NLMISC::IStream &f)
 Serialises this CRetrieverInstance.

void snap (ULocalPosition &position, const CLocalRetriever &retriever) const
void snapToInteriorGround (ULocalPosition &position, const CLocalRetriever &retriever) const
 For the interior instances, snaps the point to the ground.

void unlink (std::vector< CRetrieverInstance > &instances)
 Unlinks the instance. The neighbor instance are AFFECTED.

Collision part
void testExteriorCollision (CCollisionSurfaceTemp &cst, const NLMISC::CAABBox &bboxMoveLocal, const NLMISC::CVector2f &transBase, const CLocalRetriever &localRetriever) const

Static Public Member Functions

Vector Snapping.
void snapVector (CVector2f &v)
void snapVector (CVector &v)

Protected Attributes

sint32 _InstanceId
 The id of this instance.

std::vector< CAStarNodeInfo_NodesInformation
sint32 _RetrieverId
 The id of the retrievable surface pattern.

CLocalRetriever::EType _Type
 The type of the instance (see CLocalRetriever::_Type).

Instance displacement.
NLMISC::CAABBox _BBox
 The BBox of the instance.

uint8 _Orientation
 The BBox of the instance.

NLMISC::CVector _Origin
 The BBox of the instance.

Instance linkage.
std::vector< CLink_BorderChainLinks
 The neighbor chains on the border.

std::vector< sint32_Neighbors
 The instance ids of the neighbors.

Interior instance coolision management.
CEdgeQuad _ExteriorEdgeQuad

Friends

class CGlobalRetriever
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NLPACS::CRetrieverInstance::CRetrieverInstance  ) 
+
+ + + + + +
+   + + +

+Default constructor. +

+ +

+Definition at line 36 of file retriever_instance.cpp. +

+References reset(). +

+

00037 {
+00038         reset();
+00039 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NLPACS::CRetrieverInstance::forceBorderChainLink uint  border,
uint  frontInstance,
uint  frontBorder,
uint  frontChain,
uint  frontSurface
[inline]
+
+ + + + + +
+   + + +

+Forces border chain link. +

+ +

+Definition at line 192 of file retriever_instance.h. +

+References _BorderChainLinks, _InstanceId, border, nlwarning, and uint. +

+

00193         {
+00194                 if (border >= _BorderChainLinks.size())
+00195                 {
+00196                         nlwarning("forceBorderChainLink(): couldn't force border %d on instance %d, doesn't exist!", border, _InstanceId);
+00197                         return;
+00198                 }
+00199 
+00200                 if (_BorderChainLinks[border].Instance != 0xffff ||
+00201                         _BorderChainLinks[border].BorderChainId != 0xffff ||
+00202                         _BorderChainLinks[border].ChainId != 0xffff ||
+00203                         _BorderChainLinks[border].SurfaceId != 0xffff)
+00204                 {
+00205                         nlwarning("forceBorderChainLink(): forces border %d on instance %d whereas link is initialised yet, incoherences may appear!", border, _InstanceId);
+00206                 }
+00207 
+00208                 _BorderChainLinks[border].Instance = frontInstance;
+00209                 _BorderChainLinks[border].BorderChainId = frontBorder;
+00210                 _BorderChainLinks[border].ChainId = frontChain;
+00211                 _BorderChainLinks[border].SurfaceId = frontSurface;
+00212         }
+
+

+ + + + +
+ + + + + + + + + +
const NLMISC::CAABBox& NLPACS::CRetrieverInstance::getBBox  )  const [inline]
+
+ + + + + +
+   + + +

+Returns the bbox of the instance (using the translation and orientation of the retriever). +

+ +

+Definition at line 220 of file retriever_instance.h. +

+Referenced by NLPACS::CGlobalRetriever::makeInstance(), NLPACS::CGlobalRetriever::makeLinks(), and NLPACS::CGlobalRetriever::testPosition(). +

+

00220 { return _BBox; }
+
+

+ + + + +
+ + + + + + + + + + +
CLink NLPACS::CRetrieverInstance::getBorderChainLink uint  n  )  const [inline]
+
+ + + + + +
+   + + +

+Gets the id of the nth neighbor chain on the given edge. +

+ +

+Definition at line 188 of file retriever_instance.h. +

+References _BorderChainLinks, and uint. +

+Referenced by NLPACS::CGlobalRetriever::check(), NLPACS::CGlobalRetriever::findAStarPath(), and NLPACS::CGlobalRetriever::findCollisionChains(). +

+

00188 { return _BorderChainLinks[n]; }
+
+

+ + + + +
+ + + + + + + + + +
const std::vector<CLink>& NLPACS::CRetrieverInstance::getBorderChainLinks  )  const [inline]
+
+ + + + + +
+   + + +

+Gets the ids of the neighbor chains on the given edge. +

+ +

+Definition at line 186 of file retriever_instance.h. +

+References _BorderChainLinks. +

+Referenced by NLPACS::CGlobalRetriever::check(). +

+

00186 { return _BorderChainLinks; }
+
+

+ + + + +
+ + + + + + + + + + +
CVectorD NLPACS::CRetrieverInstance::getDoubleGlobalPosition const NLMISC::CVector localPosition  )  const
+
+ + + + + +
+   + + +

+Computes the position (as double) in the global axis from a local position (in the retriever axis). +

+ +

+Definition at line 610 of file retriever_instance.cpp. +

+References _Orientation, _Origin, nlerror, nlwarning, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. +

+

00611 {
+00612         switch (_Orientation)
+00613         {
+00614         default:
+00615                 nlwarning("in NLPACS::CRetrieverInstance::getLocalPosition()");
+00616                 nlerror("unexpected orientation value (%d)", _Orientation);
+00617         case 0:
+00618                 return CVectorD(+(double)localPosition.x+(double)_Origin.x, +(double)localPosition.y+(double)_Origin.y, (double)localPosition.z+(double)_Origin.z );
+00619                 break;
+00620         case 1:
+00621                 return CVectorD(-(double)localPosition.y+(double)_Origin.x, +(double)localPosition.x+(double)_Origin.y, (double)localPosition.z+(double)_Origin.z );
+00622                 break;
+00623         case 2:
+00624                 return CVectorD(-(double)localPosition.x+(double)_Origin.x, -(double)localPosition.y+(double)_Origin.y, (double)localPosition.z+(double)_Origin.z );
+00625                 break;
+00626         case 3:
+00627                 return CVectorD(+(double)localPosition.y+(double)_Origin.x, -(double)localPosition.x+(double)_Origin.y, (double)localPosition.z+(double)_Origin.z );
+00628                 break;
+00629         }
+00630 }
+
+

+ + + + +
+ + + + + + + + + + +
CVector NLPACS::CRetrieverInstance::getGlobalPosition const NLMISC::CVector localPosition  )  const
+
+ + + + + +
+   + + +

+Computes the position in the global axis from a local position (in the retriever axis). +

+ +

+Definition at line 588 of file retriever_instance.cpp. +

+References _Orientation, _Origin, nlerror, nlwarning, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. +

+

00589 {
+00590         switch (_Orientation)
+00591         {
+00592         default:
+00593                 nlwarning("in NLPACS::CRetrieverInstance::getLocalPosition()");
+00594                 nlerror("unexpected orientation value (%d)", _Orientation);
+00595         case 0:
+00596                 return CVector(+localPosition.x+_Origin.x, +localPosition.y+_Origin.y, localPosition.z+_Origin.z );
+00597                 break;
+00598         case 1:
+00599                 return CVector(-localPosition.y+_Origin.x, +localPosition.x+_Origin.y, localPosition.z+_Origin.z );
+00600                 break;
+00601         case 2:
+00602                 return CVector(-localPosition.x+_Origin.x, -localPosition.y+_Origin.y, localPosition.z+_Origin.z );
+00603                 break;
+00604         case 3:
+00605                 return CVector(+localPosition.y+_Origin.x, -localPosition.x+_Origin.y, localPosition.z+_Origin.z );
+00606                 break;
+00607         }
+00608 }
+
+

+ + + + +
+ + + + + + + + + + +
uint8 NLPACS::CRetrieverInstance::getInstanceEdge uint8  retrieverEdge  )  const [inline]
+
+ + + + + +
+   + + +

+Returns the number of the edge on the instance corresponding to the edge on the retriever. +

+ +

+Definition at line 215 of file retriever_instance.h. +

+References _Orientation, and uint8. +

+

00215 { return (retrieverEdge+_Orientation)%4; }
+
+

+ + + + +
+ + + + + + + + + +
sint32 NLPACS::CRetrieverInstance::getInstanceId  )  const [inline]
+
+ + + + + +
+   + + +

+Returns the id of this instance. +

+ +

+Definition at line 170 of file retriever_instance.h. +

+References _InstanceId, and sint32. +

+Referenced by NLPACS::CGlobalRetriever::buildInstance(), NLPACS::CGlobalRetriever::check(), NLPACS::CGlobalRetriever::makeInstance(), and NLPACS::CGlobalRetriever::makeLinks(). +

+

00170 { return _InstanceId; }
+
+

+ + + + +
+ + + + + + + + + + +
CVector NLPACS::CRetrieverInstance::getLocalPosition const NLMISC::CVectorD globalPosition  )  const
+
+ + + + + +
+   + + +

+Computes the position in the local axis of the retriever from a global position. +

+ +

+Definition at line 566 of file retriever_instance.cpp. +

+References _Orientation, _Origin, nlerror, nlwarning, NLMISC::CVector::x, NLMISC::CVectorD::x, NLMISC::CVector::y, NLMISC::CVectorD::y, NLMISC::CVector::z, and NLMISC::CVectorD::z. +

+

00567 {
+00568         switch (_Orientation)
+00569         {
+00570         default:
+00571                 nlwarning("in NLPACS::CRetrieverInstance::getLocalPosition()");
+00572                 nlerror("unexpected orientation value (%d)", _Orientation);
+00573         case 0:
+00574                 return CVector((float)(+globalPosition.x-_Origin.x), (float)(+globalPosition.y-_Origin.y), (float)(globalPosition.z-_Origin.z));
+00575                 break;
+00576         case 1:
+00577                 return CVector((float)(+globalPosition.y-_Origin.y), (float)(-globalPosition.x+_Origin.x), (float)(globalPosition.z-_Origin.z));
+00578                 break;
+00579         case 2:
+00580                 return CVector((float)(-globalPosition.x+_Origin.x), (float)(-globalPosition.y+_Origin.y), (float)(globalPosition.z-_Origin.z));
+00581                 break;
+00582         case 3:
+00583                 return CVector((float)(-globalPosition.y+_Origin.y), (float)(+globalPosition.x-_Origin.x), (float)(globalPosition.z-_Origin.z));
+00584                 break;
+00585         }
+00586 }
+
+

+ + + + +
+ + + + + + + + + + +
CVector NLPACS::CRetrieverInstance::getLocalPosition const NLMISC::CVector globalPosition  )  const
+
+ + + + + +
+   + + +

+Computes the position in the local axis of the retriever from a global position. +

+ +

+Definition at line 544 of file retriever_instance.cpp. +

+References _Orientation, _Origin, nlerror, nlwarning, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. +

+Referenced by retrievePosition(), and NLPACS::CGlobalRetriever::retrievePosition(). +

+

00545 {
+00546         switch (_Orientation)
+00547         {
+00548         default:
+00549                 nlwarning("in NLPACS::CRetrieverInstance::getLocalPosition()");
+00550                 nlerror("unexpected orientation value (%d)", _Orientation);
+00551         case 0:
+00552                 return CVector(+globalPosition.x-_Origin.x, +globalPosition.y-_Origin.y, globalPosition.z-_Origin.z);
+00553                 break;
+00554         case 1:
+00555                 return CVector(+globalPosition.y-_Origin.y, -globalPosition.x+_Origin.x, globalPosition.z-_Origin.z);
+00556                 break;
+00557         case 2:
+00558                 return CVector(-globalPosition.x+_Origin.x, -globalPosition.y+_Origin.y, globalPosition.z-_Origin.z);
+00559                 break;
+00560         case 3:
+00561                 return CVector(-globalPosition.y+_Origin.y, +globalPosition.x-_Origin.x, globalPosition.z-_Origin.z);
+00562                 break;
+00563         }
+00564 }
+
+

+ + + + +
+ + + + + + + + + + +
sint32 NLPACS::CRetrieverInstance::getNeighbor uint  n  )  const [inline]
+
+ + + + + +
+   + + +

+Gets the id of the neighbor on the edge. +

+ +

+Definition at line 183 of file retriever_instance.h. +

+References _Neighbors, sint32, and uint. +

+

00183 { return _Neighbors[n]; }
+
+

+ + + + +
+ + + + + + + + + +
std::vector<sint32> NLPACS::CRetrieverInstance::getNeighbors  )  const [inline]
+
+ + + + + +
+   + + +

+Gets the neighbors. +

+ +

+Definition at line 181 of file retriever_instance.h. +

+References _Neighbors. +

+

00181 { return _Neighbors; }
+
+

+ + + + +
+ + + + + + + + + +
uint8 NLPACS::CRetrieverInstance::getOrientation  )  const [inline]
+
+ + + + + +
+   + + +

+Returns the orientation of the instance in relation to the retriever. +

+ +

+Definition at line 174 of file retriever_instance.h. +

+References _Orientation, and uint8. +

+

00174 { return _Orientation; }
+
+

+ + + + +
+ + + + + + + + + +
NLMISC::CVector NLPACS::CRetrieverInstance::getOrigin  )  const [inline]
+
+ + + + + +
+   + + +

+Returns the origin translation of this instance. +

+ +

+Definition at line 176 of file retriever_instance.h. +

+References _Origin. +

+Referenced by NLPACS::CEdgeQuad::build(), NLPACS::CGlobalRetriever::doMove(), NLPACS::CGlobalRetriever::findCollisionChains(), NLPACS::CGlobalRetriever::getBorders(), NLPACS::CGlobalRetriever::testBBoxMove(), NLPACS::CGlobalRetriever::testBBoxRot(), NLPACS::CGlobalRetriever::testCollisionWithCollisionChains(), NLPACS::CGlobalRetriever::testCylinderMove(), NLPACS::CGlobalRetriever::testMovementWithCollisionChains(), and NLPACS::CGlobalRetriever::testPosition(). +

+

00176 { return _Origin; }
+
+

+ + + + +
+ + + + + + + + + + +
uint8 NLPACS::CRetrieverInstance::getRetrieverEdge uint8  instanceEdge  )  const [inline]
+
+ + + + + +
+   + + +

+Returns the number of the edge on the retriever corresponding to the edge on the instance. +

+ +

+Definition at line 217 of file retriever_instance.h. +

+References _Orientation, and uint8. +

+

00217 { return (instanceEdge+4-_Orientation)%4; }
+
+

+ + + + +
+ + + + + + + + + +
sint32 NLPACS::CRetrieverInstance::getRetrieverId  )  const [inline]
+
+ + + + + +
+   + + +

+Returns the id of the retriever associated to this instance. +

+ +

+Definition at line 172 of file retriever_instance.h. +

+References _RetrieverId, and sint32. +

+Referenced by NLPACS::CGlobalRetriever::buildInstance(), NLPACS::CGlobalRetriever::check(), NLPACS::CGlobalRetriever::findAStarPath(), NLPACS::CGlobalRetriever::findCollisionChains(), NLPACS::CGlobalRetriever::getBorders(), NLPACS::CGlobalRetriever::getMaterial(), NLPACS::CGlobalRetriever::getMeanHeight(), NLPACS::CGlobalRetriever::getSurfaceById(), NLPACS::CGlobalRetriever::isWaterPosition(), NLPACS::CGlobalRetriever::makeInstance(), NLPACS::CGlobalRetriever::makeLinks(), NLPACS::CGlobalRetriever::retrievePosition(), NLPACS::CGlobalRetriever::testCollisionWithCollisionChains(), NLPACS::CGlobalRetriever::testMovementWithCollisionChains(), and NLPACS::CGlobalRetriever::testPosition(). +

+

00172 { return _RetrieverId; }
+
+

+ + + + +
+ + + + + + + + + + +
CLocalRetriever::EType NLPACS::CRetrieverInstance::getType void   )  const [inline]
+
+ + + + + +
+   + + +

+Returns the type of the instance. +

+ +

+Definition at line 178 of file retriever_instance.h. +

+Referenced by NLPACS::CGlobalRetriever::check(), NLPACS::CGlobalRetriever::findCollisionChains(), and NLPACS::CGlobalRetriever::retrievePosition(). +

+

00178 { return _Type; }
+
+

+ + + + +
+ + + + + + + + + + +
void NLPACS::CRetrieverInstance::init const CLocalRetriever retriever  ) 
+
+ + + + + +
+   + + +

+Inits the instance (after a serial for instance.). +

+ +

+Definition at line 89 of file retriever_instance.cpp. +

+References _BorderChainLinks, NLPACS::CLocalRetriever::getBorderChains(), NLPACS::CLocalRetriever::getType(), and NLPACS::CLocalRetriever::isLoaded(). +

+Referenced by make(). +

+

00090 {
+00091         if (!retriever.isLoaded())
+00092                 return;
+00093 /*
+00094         _NodesInformation.resize(retriever.getSurfaces().size());
+00095         uint    i;
+00096 
+00097         // Resets _NodesInformation for later pathfinding graph annotation.
+00098         for (i=0; i<_NodesInformation.size(); ++i)
+00099         {
+00100                 CVector pos = getGlobalPosition(retriever.getSurfaces()[i].getCenter());
+00101                 _NodesInformation[i].Position = CVector2f(pos.x, pos.y);
+00102         }
+00103 */
+00104 
+00105         _Type = retriever.getType();
+00106         _BorderChainLinks.resize(retriever.getBorderChains().size());
+00107 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLPACS::CRetrieverInstance::initEdgeQuad CGlobalRetriever gr  ) 
+
+ + + + + +
+   + + +

+Inits the edgequad (only for Interior instances, and only after all the landscape instances have been built. +

+Definition at line 139 of file retriever_instance.cpp. +

+References _ExteriorEdgeQuad, _InstanceId, _RetrieverId, NLPACS::CEdgeQuad::build(), NLPACS::CLocalRetriever::getExteriorMesh(), NLPACS::CGlobalRetriever::getInternalCST(), NLPACS::CGlobalRetriever::getRetriever(), NLPACS::CLocalRetriever::getType(), and nlerror. +

+Referenced by NLPACS::CGlobalRetriever::makeInstance(). +

+

00140 {
+00141         const CLocalRetriever   &lr = gr.getRetriever(_RetrieverId);
+00142 
+00143         if (lr.getType() != CLocalRetriever::Interior)
+00144         {
+00145                 nlerror("Attempt to init the edgequad of instance %d whereas local retriever %d is not interior", _InstanceId, _RetrieverId);
+00146         }
+00147 
+00148         // build the edge quad
+00149         _ExteriorEdgeQuad.build(lr.getExteriorMesh(), gr, gr.getInternalCST(),_InstanceId);
+00150 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLPACS::CRetrieverInstance::link CRetrieverInstance neighbor,
const std::vector< CLocalRetriever > &  retrievers
+
+ + + + + +
+   + + +

+Links the instance to a given neighbor on the given edge. +

+ +

+

Todo:
Compute real position using _Orientation
+ +

+Definition at line 194 of file retriever_instance.cpp. +

+References _BorderChainLinks, _InstanceId, _Neighbors, _Origin, _RetrieverId, NLPACS::CLocalRetriever::getBorderChains(), NLPACS::CLocalRetriever::getChains(), NLPACS::CLocalRetriever::getStartVector(), NLPACS::CLocalRetriever::getStopVector(), sint, uint, and uint16. +

+Referenced by NLPACS::CGlobalRetriever::makeLinks(). +

+

00196 {
+00197         uint    i, j;
+00198         for (i=0; i<_Neighbors.size(); ++i)
+00199                 if (_Neighbors[i] == neighbor._InstanceId)
+00200                         return;
+00201 
+00202         const CLocalRetriever                                           &retriever = retrievers[_RetrieverId];
+00203         const CLocalRetriever                                           &nRetriever = retrievers[neighbor._RetrieverId];
+00204 
+00205         const vector<CChain>                                            &chains = retriever.getChains(),
+00206                                                                                                 &nChains = nRetriever.getChains();
+00207         const vector<uint16>                                            &borderChains = retriever.getBorderChains(),
+00208                                                                                                 &nBorderChains = nRetriever.getBorderChains();
+00209 
+00210         vector< pair<CVector,CVector> >                         chainTips,
+00211                                                                                                 nChainTips;
+00212 
+00213         _BorderChainLinks.resize(borderChains.size());
+00214         neighbor._BorderChainLinks.resize(nBorderChains.size());
+00215 
+00216 /*
+00217         for (i=0; i<borderChains.size(); ++i)
+00218                 chainTips.push_back(make_pair(retriever.getTip(chains[borderChains[i]].getStartTip()).Point,
+00219                                                                           retriever.getTip(chains[borderChains[i]].getStopTip()).Point));
+00220 */
+00221         for (i=0; i<borderChains.size(); ++i)
+00222                 chainTips.push_back(make_pair(retriever.getStartVector(borderChains[i]),
+00223                                                                           retriever.getStopVector(borderChains[i])));
+00224 
+00226 
+00227         CVector translation = neighbor._Origin - _Origin;
+00228 /*
+00229         for (i=0; i<nBorderChains.size(); ++i)
+00230                 nChainTips.push_back(make_pair(nRetriever.getTip(nChains[nBorderChains[i]].getStartTip()).Point+translation,
+00231                                                                            nRetriever.getTip(nChains[nBorderChains[i]].getStopTip()).Point+translation));
+00232 */
+00233         for (i=0; i<nBorderChains.size(); ++i)
+00234                 nChainTips.push_back(make_pair(nRetriever.getStartVector(nBorderChains[i])+translation,
+00235                                                                            nRetriever.getStopVector(nBorderChains[i])+translation));
+00236 
+00237         for (i=0; i<borderChains.size(); ++i)
+00238         {
+00239                 // if the chain is already linked, just step
+00240                 if (_BorderChainLinks[i].Instance != 0xFFFF || _BorderChainLinks[i].BorderChainId != 0xFFFF ||
+00241                         _BorderChainLinks[i].ChainId != 0xFFFF || _BorderChainLinks[i].SurfaceId != 0xFFFF)
+00242                         continue;
+00243 
+00244                 float   bestDist = 1.0f;
+00245                 sint    best = -1;
+00246 
+00247                 for (j=0; j<nBorderChains.size(); ++j)
+00248                 {
+00249                         if (neighbor._BorderChainLinks[j].Instance != 0xFFFF || neighbor._BorderChainLinks[j].BorderChainId != 0xFFFF ||
+00250                                 neighbor._BorderChainLinks[j].ChainId != 0xFFFF || neighbor._BorderChainLinks[j].SurfaceId != 0xFFFF)
+00251                                 continue;
+00252 
+00253                         float   d = (chainTips[i].first-nChainTips[j].second).norm()+(chainTips[i].second-nChainTips[j].first).norm();
+00254                         if (d < bestDist)
+00255                         {
+00256                                 bestDist = d;
+00257                                 best = j;
+00258                         }
+00259                 }
+00260 
+00261                 // if no best match, just don't link
+00262                 if (bestDist > 1.0e-1f || best == -1)
+00263                         continue;
+00264 
+00265                 _BorderChainLinks[i].Instance = (uint16)neighbor._InstanceId;
+00266                 _BorderChainLinks[i].BorderChainId = (uint16)best;
+00267                 _BorderChainLinks[i].ChainId = nBorderChains[_BorderChainLinks[i].BorderChainId];
+00268                 _BorderChainLinks[i].SurfaceId = (uint16)nChains[_BorderChainLinks[i].ChainId].getLeft();
+00269 
+00270                 neighbor._BorderChainLinks[best].Instance = (uint16)_InstanceId;
+00271                 neighbor._BorderChainLinks[best].BorderChainId = (uint16)i;
+00272                 neighbor._BorderChainLinks[best].ChainId = borderChains[neighbor._BorderChainLinks[best].BorderChainId];
+00273                 neighbor._BorderChainLinks[best].SurfaceId = (uint16)chains[neighbor._BorderChainLinks[best].ChainId].getLeft();
+00274         }
+00275 
+00276         _Neighbors.push_back(neighbor._InstanceId);
+00277         neighbor._Neighbors.push_back(_InstanceId);
+00278 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLPACS::CRetrieverInstance::linkEdgeQuad CGlobalRetriever gr  ) 
+
+ + + + + +
+   + + +

+link the edge quad of the interior with the the landscape instances +

+ +

+Definition at line 152 of file retriever_instance.cpp. +

+References _BorderChainLinks, _ExteriorEdgeQuad, _InstanceId, _RetrieverId, NLPACS::CRetrieverInstance::CLink::BorderChainId, NLPACS::CExteriorMesh::CLink::BorderChainId, NLPACS::CRetrieverInstance::CLink::ChainId, NLPACS::CExteriorMesh::CLink::ChainId, NLPACS::CExteriorMesh::getEdge(), NLPACS::CEdgeQuad::getEdgeEntries(), NLPACS::CLocalRetriever::getExteriorMesh(), NLPACS::CExteriorMesh::getLink(), NLPACS::CGlobalRetriever::getRetriever(), NLPACS::CRetrieverInstance::CLink::Instance, NLPACS::CExteriorMesh::CEdge::Link, nlwarning, NLPACS::CRetrieverInstance::CLink::SurfaceId, NLPACS::CExteriorMesh::CLink::SurfaceId, uint, and uint16. +

+Referenced by NLPACS::CGlobalRetriever::makeLinks(). +

+

00153 {
+00154         const CLocalRetriever                           &lr = gr.getRetriever(_RetrieverId);
+00155         const CExteriorMesh                                     &em = lr.getExteriorMesh();
+00156 
+00157         const vector<CExteriorEdgeEntry>        &ee = _ExteriorEdgeQuad.getEdgeEntries();
+00158 
+00159         // here we fill (partially) the _BorderChainLinks table
+00160         uint    i;
+00161         for (i=0; i<ee.size(); ++i)
+00162         {
+00163                 const CExteriorMesh::CEdge      &edge = em.getEdge(ee[i].EdgeId);
+00164                 if (edge.Link != -1)
+00165                 {
+00166                         const CExteriorMesh::CLink              &link = em.getLink(edge.Link);
+00167 
+00168                         if (link.SurfaceId != 0xFFFF && link.ChainId != 0xFFFF && link.BorderChainId != 0xFFFF)
+00169                         {
+00170                                 CRetrieverInstance::CLink       &borderLink = _BorderChainLinks[link.BorderChainId];
+00171                                 borderLink.ChainId = 0xFFFF;            // no opposite chain
+00172                                 borderLink.BorderChainId = 0xFFFF;      // idem
+00173                                 if ((borderLink.Instance == 0xFFFF && borderLink.SurfaceId == 0xFFFF) ||
+00174                                         (borderLink.Instance == (uint16)(ee[i].Exterior.RetrieverInstanceId) &&
+00175                                          borderLink.SurfaceId == (uint16)(ee[i].Exterior.SurfaceId) ))
+00176                                 {
+00177                                         borderLink.Instance = (uint16)(ee[i].Exterior.RetrieverInstanceId);
+00178                                         borderLink.SurfaceId = (uint16)(ee[i].Exterior.SurfaceId);
+00179                                 }
+00180                                 else
+00181                                 {
+00182                                         nlwarning("Instance %d, borderLink %d: link already set to inst=%d, surf=%d, try to set to inst=%d, surf=%d",
+00183                                                                 _InstanceId, link.BorderChainId, borderLink.Instance, borderLink.SurfaceId, 
+00184                                                                 (uint16)(ee[i].Exterior.RetrieverInstanceId), (uint16)(ee[i].Exterior.SurfaceId));
+00185                                 }
+00186                         }
+00187                 }
+00188         }
+00189 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NLPACS::CRetrieverInstance::make sint32  instanceId,
sint32  retrieverId,
const CLocalRetriever retriever,
uint8  orientation,
const NLMISC::CVector origin
+
+ + + + + +
+   + + +

+Builds the instance. +

+ +

+Definition at line 109 of file retriever_instance.cpp. +

+References _InstanceId, _Orientation, _Origin, _RetrieverId, NLPACS::CLocalRetriever::getBBox(), NLMISC::CAABBox::getCenter(), NLMISC::CAABBox::getHalfSize(), init(), nlerror, nlwarning, NLMISC::CAABBox::setCenter(), NLMISC::CAABBox::setHalfSize(), sint32, uint8, NLMISC::CVector::x, and NLMISC::CVector::y. +

+Referenced by NLPACS::CGlobalRetriever::makeInstance(). +

+

00111 {
+00112         if (_InstanceId != -1 || _RetrieverId != -1)
+00113         {
+00114                 nlwarning("in call to NLPACS::CRetrieverInstance::make");
+00115                 nlwarning("_InstanceId=%d _RetrieverId=%d _Orientation=%d", _InstanceId, _RetrieverId, _Orientation);
+00116                 nlwarning("instanceId=%d retrieverId=%d orientation=%d", instanceId, retrieverId, orientation);
+00117                 nlerror("Retriever instance %d has already been set", _InstanceId);
+00118         }
+00119         
+00120         _InstanceId = instanceId;
+00121         _RetrieverId = retrieverId;
+00122         _Orientation = (orientation%4);
+00123         _Origin = origin;
+00124 
+00125         _BBox = retriever.getBBox();
+00126         _BBox.setCenter(_BBox.getCenter()+_Origin);
+00127 
+00128         if (_Orientation == 1 || _Orientation == 3)
+00129         {
+00130                 CVector hs = _BBox.getHalfSize();
+00131                 std::swap(hs.x, hs.y);
+00132                 _BBox.setHalfSize(hs);
+00133         }
+00134 
+00135         init(retriever);
+00136 }
+
+

+ + + + +
+ + + + + + + + + +
void NLPACS::CRetrieverInstance::reset  ) 
+
+ + + + + +
+   + + +

+Resets the instance. This doesn't affect any neighboring instances... +

+ +

+Definition at line 72 of file retriever_instance.cpp. +

+References _BorderChainLinks, _ExteriorEdgeQuad, _InstanceId, _NodesInformation, _Orientation, _Origin, _RetrieverId, NLPACS::CEdgeQuad::clear(), and resetLinks(). +

+Referenced by CRetrieverInstance(). +

+

00073 {
+00074         // WARNING !!
+00075         // this is a HARD reset !
+00076         // only the instance i reset, no care about neighbors !!
+00077         _NodesInformation.clear();
+00078         _InstanceId = -1;
+00079         _RetrieverId = -1;
+00080         _Orientation = 0;
+00081         _Origin = CVector::Null;
+00082         _Type = CLocalRetriever::Landscape;
+00083         _BorderChainLinks.clear();
+00084         _ExteriorEdgeQuad.clear();
+00085 
+00086         resetLinks();
+00087 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLPACS::CRetrieverInstance::resetBorderChainLinks const std::vector< uint > &  links  ) 
+
+ + + + + +
+   + + +

+Resets border chains links. +

+ +

+Definition at line 772 of file retriever_instance.cpp. +

+References _BorderChainLinks, and uint. +

+

00773 {
+00774         uint    i;
+00775         for (i=0; i<links.size(); ++i)
+00776         {
+00777                 if (links[i] >= _BorderChainLinks.size())
+00778                         _BorderChainLinks.resize(links[i]+1);
+00779 
+00780                 _BorderChainLinks[links[i]].reset();
+00781         }
+00782 }
+
+

+ + + + +
+ + + + + + + + + +
void NLPACS::CRetrieverInstance::resetLinks  ) 
+
+ + + + + +
+   + + +

+Resets links of the instance. This doesn't affect any neighboring instances... +

+ +

+Definition at line 42 of file retriever_instance.cpp. +

+References _BorderChainLinks, _ExteriorEdgeQuad, _Neighbors, NLPACS::CEdgeQuad::removeLinks(), and uint. +

+Referenced by reset(), and unlink(). +

+

00043 {
+00044         uint    i;
+00045         // WARNING !!
+00046         // this is a HARD reset !
+00047         // only the instance i reset, no care about neighbors !!
+00048         for (i=0; i<_Neighbors.size(); ++i)
+00049                 _Neighbors[i] = -1;
+00050         _BorderChainLinks.clear();
+00051 
+00052         _ExteriorEdgeQuad.removeLinks();
+00053 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLPACS::CRetrieverInstance::resetLinks uint32  id  ) 
+
+ + + + + +
+   + + +

+Resets links to the given instance. This doesn't affect any neighbor. +

+ +

+Definition at line 55 of file retriever_instance.cpp. +

+References _BorderChainLinks, _ExteriorEdgeQuad, _Neighbors, NLPACS::CEdgeQuad::removeLinks(), sint32, uint, uint16, and uint32. +

+

00056 {
+00057         vector<sint32>::iterator        rit;
+00058         for (rit=_Neighbors.begin(); rit!=_Neighbors.end(); )
+00059                 if (*rit == (sint32)id)
+00060                         rit = _Neighbors.erase(rit);
+00061                 else
+00062                         ++rit;
+00063 
+00064         uint    i;
+00065         for (i=0; i<_BorderChainLinks.size(); ++i)
+00066                 if (_BorderChainLinks[i].Instance == (uint16)id)
+00067                         _BorderChainLinks[i].reset();
+00068 
+00069         _ExteriorEdgeQuad.removeLinks(id);
+00070 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NLPACS::CRetrieverInstance::retrievePosition const NLMISC::CVectorD estimated,
const CLocalRetriever retriever,
CCollisionSurfaceTemp cst,
bool  sortByDistance = true
const
+
+ + + + + +
+   + + +

+Retrieves the position in the instance from an estimated position (double instead.) WARNING: the estimated position is a GLOBAL position, and the returned position is a LOCAL position (to the retriever). +

+Definition at line 387 of file retriever_instance.cpp. +

+References _InstanceId, NLPACS::ULocalPosition::Estimation, getLocalPosition(), NLPACS::CRetrievableSurface::getQuantHeight(), NLPACS::CLocalRetriever::getSurface(), nlerror, nlwarning, NLPACS::CCollisionSurfaceTemp::OutCounter, NLPACS::CCollisionSurfaceTemp::PossibleSurfaces, NLPACS::CLocalRetriever::retrievePosition(), NLPACS::CLocalRetriever::snapToInteriorGround(), NLPACS::CCollisionSurfaceTemp::SortedSurfaces, NLPACS::ULocalPosition::Surface, NLPACS::CCollisionSurfaceTemp::SurfaceLUT, uint, uint16, NLMISC::CVectorD::x, NLMISC::CVectorD::y, NLMISC::CVectorD::z, and NLMISC::CVector::z. +

+

00388 {
+00389         CVector                                                 localEstimated;
+00390 
+00391 //      nldebug("PACS: retrievePosition in instance %d (retriever %d)", _InstanceId, _RetrieverId);
+00392 
+00393         // get local coordinates
+00394         localEstimated = getLocalPosition(estimated);
+00395         // Yoyo: must snap vector.
+00396         CRetrieverInstance::snapVector(localEstimated);
+00397 
+00398         // fills _RetrieveTable by retrievingPosition.
+00399         retriever.retrievePosition(localEstimated, cst);
+00400 
+00401         uint    i, surf;
+00402 /*      sint    bestSurf = -1;
+00403         sint    lastSurf = -1;
+00404         float   bestDistance = 1.0e10f;
+00405         float   bestHeight;*/
+00406         bool    found = false;
+00407 
+00408         switch (_Type)
+00409         {
+00410         case CLocalRetriever::Landscape:
+00411                 // for landscape
+00412                 for (i=0; i<cst.PossibleSurfaces.size(); ++i)
+00413                 {
+00414                         surf = cst.PossibleSurfaces[i];
+00415 
+00416 //                      nldebug("PACS: surface %d: count %d", surf, cst.SurfaceLUT[surf].Counter);
+00417 
+00418                         // if the surface contains the estimated position.
+00419                         if (cst.SurfaceLUT[surf].Counter == 2)
+00420                         {
+00421                                 float                   meanHeight;
+00422 /*
+00423                                 const CQuadLeaf *leaf;
+00424 
+00425                                 // search in the surface's quad tree for the actual height
+00426                                 leaf = retriever.getSurfaces()[surf].getQuadTree().getLeaf(localEstimated);
+00427                                 // if there is no acceptable leaf, just give up
+00428                                 if (leaf != NULL)
+00429                                 {
+00430                                         meanHeight = leaf->getMaxHeight();
+00431                                         //meanHeight = retriever.getSurfaces()[surf].getQuadTree().getInterpZ(localEstimated);
+00432 
+00433                                         // if it is closer to the estimation than the previous remembered...
+00434                                         found = true;
+00435                                         float   distance = (float)fabs(localEstimated.z-meanHeight);
+00436                                         cst.SortedSurfaces.push_back(CCollisionSurfaceTemp::CDistanceSurface(distance, (uint16)surf, (uint16)_InstanceId, cst.SurfaceLUT[surf].FoundCloseEdge));
+00437                                 }
+00438 */
+00439 
+00440                                 meanHeight = retriever.getSurface(surf).getQuantHeight()*2.0f + 1.0f;
+00441 
+00442                                 // if it is closer to the estimation than the previous remembered...
+00443                                 found = true;
+00444                                 float   distance = sortByDistance ? (float)fabs(localEstimated.z-meanHeight) : meanHeight;
+00445                                 cst.SortedSurfaces.push_back(CCollisionSurfaceTemp::CDistanceSurface(distance, (uint16)surf, (uint16)_InstanceId, cst.SurfaceLUT[surf].FoundCloseEdge));
+00446 
+00447                         }
+00448                         else if (cst.SurfaceLUT[surf].Counter != 0)
+00449                         {
+00450                                 nlwarning("PACS: unexpected surface (%d) count (%d) at instance %d (pos=(%f,%f,%f))", surf, cst.SurfaceLUT[surf].Counter, _InstanceId, estimated.x, estimated.y, estimated.z);
+00451                         }
+00452 
+00453                         cst.SurfaceLUT[surf].reset();
+00454                 }
+00455 
+00456                 break;
+00457 
+00458         case CLocalRetriever::Interior:
+00459                 // for interior
+00460                 for (i=0; i<cst.PossibleSurfaces.size(); ++i)
+00461                 {
+00462                         surf = cst.PossibleSurfaces[i];
+00463                         // if the surface contains the estimated position.
+00464                         if (cst.SurfaceLUT[surf].Counter == 2)
+00465                         {
+00466                                 ULocalPosition  lp;
+00467                                 bool                    lfound = false;
+00468 
+00469                                 // get the exact position
+00470                                 lp.Surface = surf;
+00471                                 lp.Estimation = localEstimated;
+00472                                 retriever.snapToInteriorGround(lp, lfound);
+00473                                 if (lfound)
+00474                                 {
+00475                                         // if it is closer to the estimation than the previous remembered...
+00476                                         found = true;
+00477                                         float   distance = sortByDistance ? (float)fabs(localEstimated.z-lp.Estimation.z) : lp.Estimation.z;
+00478                                         cst.SortedSurfaces.push_back(CCollisionSurfaceTemp::CDistanceSurface(distance, (uint16)surf, (uint16)_InstanceId, cst.SurfaceLUT[surf].FoundCloseEdge));
+00479                                 }
+00480                         }
+00481                         else if (cst.SurfaceLUT[surf].Counter != 0)
+00482                         {
+00483                                 nlwarning("PACS: unexpected surface (%d) count (%d) at instance %d (pos=(%f,%f,%f))", surf, cst.SurfaceLUT[surf].Counter, _InstanceId, estimated.x, estimated.y, estimated.z);
+00484                         }
+00485 
+00486                         cst.SurfaceLUT[surf].reset();
+00487                 }
+00488                 break;
+00489 
+00490         default:
+00491                 nlerror("Unknown instance type %d !!", _Type);
+00492                 break;
+00493         }
+00494 
+00495         cst.OutCounter = 0;
+00496 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NLPACS::CRetrieverInstance::retrievePosition const NLMISC::CVector estimated,
const CLocalRetriever retriever,
CCollisionSurfaceTemp cst,
bool  sortByDistance = true
const
+
+ + + + + +
+   + + +

+Retrieves the position in the instance from an estimated position. WARNING: the estimated position is a GLOBAL position, and the returned position is a LOCAL position (to the retriever). +

+Definition at line 294 of file retriever_instance.cpp. +

+Referenced by NLPACS::CGlobalRetriever::retrievePosition(). +

+

00296 {
+00297 /*
+00298         CVector                                                 localEstimated;
+00299         CLocalRetriever::CLocalPosition retrieved;
+00300 
+00301         // get local coordinates
+00302         localEstimated = getLocalPosition(estimated);
+00303         // Yoyo: must snap vector.
+00304         CRetrieverInstance::snapVector(localEstimated);
+00305 
+00306         // fills _RetrieveTable by retrievingPosition.
+00307         retriever.retrievePosition(localEstimated, cst);
+00308 
+00309         uint    i, surf;
+00310         sint    bestSurf = -1;
+00311         sint    lastSurf = -1;
+00312         float   bestDistance = 1.0e10f;
+00313         float   bestHeight;
+00314         bool    lfound;
+00315 
+00316         // for each surface in the retriever
+00317         for (i=0; i<cst.PossibleSurfaces.size(); ++i)
+00318         {
+00319                 surf = cst.PossibleSurfaces[i];
+00320                 cst.SurfaceLUT[surf].first = false;
+00321                 // if the surface contains the estimated position.
+00322                 if (cst.SurfaceLUT[surf].second != 0)
+00323                 {
+00324                         // at least remembers the last seen surface...
+00325                         cst.SurfaceLUT[surf].second = 0;
+00326                         float                   meanHeight;
+00327                         const CQuadLeaf *leaf;
+00328                         ULocalPosition  lp;
+00329                         lfound = false;
+00330 
+00331                         switch (_Type)
+00332                         {
+00333                         case CLocalRetriever::Landscape:
+00334                                 // for landscape
+00335                                 // search in the surface's quad tree for the actual height
+00336                                 leaf = retriever.getSurfaces()[surf].getQuadTree().getLeaf(localEstimated);
+00337                                 // if there is no acceptable leaf, just give up
+00338                                 if (leaf == NULL)
+00339                                         continue;
+00340                                 meanHeight = leaf->getMaxHeight();
+00341                                 lfound = true;
+00342                                 break;
+00343                         case CLocalRetriever::Interior:
+00344                                 // for interior
+00345                                 // get the exact position
+00346                                 lp.Surface = surf;
+00347                                 lp.Estimation = localEstimated;
+00348                                 meanHeight = localEstimated.z;
+00349                                 retriever.snapToInteriorGround(lp, lfound);
+00350                                 if (lfound)
+00351                                         meanHeight = lp.Estimation.z;
+00352                                 break;
+00353                         default:
+00354                                 // hu?
+00355                                 continue;
+00356                         }
+00357 
+00358                         // if it is closer to the estimation than the previous remembered...
+00359                         float   distance = (float)fabs(localEstimated.z-meanHeight);
+00360                         if (distance < bestDistance && lfound)
+00361                         {
+00362                                 bestDistance = distance;
+00363                                 bestHeight = meanHeight;
+00364                                 bestSurf = surf;
+00365                         }
+00366                 }
+00367         }
+00368 
+00369         if (bestSurf != -1)
+00370         {
+00371                 // if there is a best surface, returns it
+00372                 retrieved.Surface = bestSurf;
+00373                 retrieved.Estimation = CVector(localEstimated.x, localEstimated.y, bestHeight);
+00374         }
+00375         else
+00376         {
+00377                 // else return the last remembered...
+00378                 retrieved.Surface = lastSurf;
+00379                 retrieved.Estimation = localEstimated;
+00380         }
+00381 
+00382         return retrieved;
+00383 */
+00384         retrievePosition(CVectorD(estimated), retriever, cst, sortByDistance);
+00385 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLPACS::CRetrieverInstance::serial NLMISC::IStream f  ) 
+
+ + + + + +
+   + + +

+Serialises this CRetrieverInstance. +

+ +

+Definition at line 736 of file retriever_instance.cpp. +

+References _BorderChainLinks, _ExteriorEdgeQuad, _InstanceId, _Neighbors, _NodesInformation, _Orientation, _Origin, _RetrieverId, NLMISC::IStream::isReading(), NLMISC::IStream::serial(), NLMISC::IStream::serialCont(), NLMISC::IStream::serialEnum(), NLMISC::IStream::serialVersion(), sint, and uint16. +

+

00737 {
+00738         /*
+00739         Version 0:
+00740                 - base version.
+00741         Version 1:
+00742                 - added type and _EdgeQuad
+00743         */
+00744         sint    ver= f.serialVersion(1);
+00745 
+00746         f.serial(_InstanceId, _RetrieverId, _Orientation, _Origin);
+00747         f.serialCont(_Neighbors);
+00748         f.serialCont(_BorderChainLinks);
+00749         f.serial(_BBox);
+00750 
+00751         // serialises the number of nodes
+00752         uint16  totalNodes = _NodesInformation.size();
+00753         f.serial(totalNodes);
+00754         if (f.isReading())
+00755         {
+00756                 // if the stream is reading, reinits the temps table...
+00757                 _NodesInformation.resize(totalNodes);
+00758         }
+00759 
+00760         if (ver >= 1)
+00761         {
+00762                 f.serialEnum(_Type);
+00763                 f.serial(_ExteriorEdgeQuad);
+00764 
+00765                 // a fix for old versions (with wrong _Type value)
+00766                 if (_Type != CLocalRetriever::Interior) _Type = CLocalRetriever::Landscape;
+00767         }
+00768 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLPACS::CRetrieverInstance::snap ULocalPosition position,
const CLocalRetriever retriever
const
+
+ + + + + +
+   + + +

+ +

+Definition at line 507 of file retriever_instance.cpp. +

+References _InstanceId, NLPACS::ULocalPosition::Estimation, NLPACS::CLocalRetriever::getHeight(), nlwarning, NLPACS::CLocalRetriever::snapToInteriorGround(), and NLMISC::CVector::z. +

+Referenced by NLPACS::CGlobalRetriever::retrievePosition(). +

+

00508 {
+00509         if (_Type == CLocalRetriever::Landscape)
+00510         {
+00511                 // search in the surface's quad tree for the actual height
+00512 //              position.Estimation.z = retriever.getSurfaces()[position.Surface].getQuadTree().getInterpZ(position.Estimation);
+00513 
+00514                 position.Estimation.z = retriever.getHeight(position);
+00515 
+00516 /*
+00517                 const CQuadLeaf *leaf = retriever.getSurfaces()[position.Surface].getQuadTree().getLeaf(position.Estimation);
+00518                 // if there is no acceptable leaf, just give up
+00519                 if (leaf != NULL)
+00520                 {
+00521                         position.Estimation.z = leaf->getMaxHeight();
+00522                 }
+00523                 else
+00524                 {
+00525                         nlwarning("PACS: couldn't snap position (%f,%f,%f) on surface %d instance %d", position.Estimation.x, position.Estimation.y, position.Estimation.z, position.Surface, _InstanceId);
+00526                 }
+00527 */
+00528         }
+00529         else if (_Type == CLocalRetriever::Interior)
+00530         {
+00531                 bool    lfound;
+00532                 retriever.snapToInteriorGround(position, lfound);
+00533         }
+00534         else
+00535         {
+00536                 nlwarning("PACS: unknown instance (%d) type %d", _InstanceId, _Type);
+00537         }
+00538 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLPACS::CRetrieverInstance::snapToInteriorGround ULocalPosition position,
const CLocalRetriever retriever
const
+
+ + + + + +
+   + + +

+For the interior instances, snaps the point to the ground. +

+Retrieves the position in the instance from an estimated position (double instead.) WARNING: the estimated position is a GLOBAL position, and the returned position is a LOCAL position (to the retriever). +

+Definition at line 500 of file retriever_instance.cpp. +

+References NLPACS::CLocalRetriever::snapToInteriorGround(). +

+

00502 {
+00503         bool    lfound;
+00504         retriever.snapToInteriorGround(position, lfound);
+00505 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLPACS::CRetrieverInstance::snapVector CVector2f v  )  [inline, static]
+
+ + + + + +
+   + + +

+Snap a vector at 1mm (1/1024). v must be a local position (ie range from -80 to +240). Doing this, we are sure we have precision of 9+10 bits, which is enough for 24 bits float precision. +

+Definition at line 300 of file retriever_instance.h. +

+References NLPACS::SnapPrecision, and v. +

+

00301         {
+00302                 v.x= (float)floor(v.x*SnapPrecision)/SnapPrecision;
+00303                 v.y= (float)floor(v.y*SnapPrecision)/SnapPrecision;
+00304         }
+
+

+ + + + +
+ + + + + + + + + + +
void NLPACS::CRetrieverInstance::snapVector CVector v  )  [inline, static]
+
+ + + + + +
+   + + +

+Snap a vector at 1mm (1/1024). v must be a local position (ie range from -80 to +240). Doing this, we are sure we have precision of 9+10 bits, which is enough for 24 bits float precision. NB: z is not snapped. +

+Definition at line 292 of file retriever_instance.h. +

+References NLPACS::SnapPrecision, and v. +

+Referenced by NLPACS::CLocalRetriever::insurePosition(). +

+

00293         {
+00294                 v.x= (float)floor(v.x*SnapPrecision)/SnapPrecision;
+00295                 v.y= (float)floor(v.y*SnapPrecision)/SnapPrecision;
+00296         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NLPACS::CRetrieverInstance::testExteriorCollision CCollisionSurfaceTemp cst,
const NLMISC::CAABBox bboxMoveLocal,
const NLMISC::CVector2f transBase,
const CLocalRetriever localRetriever
const
+
+ + + + + +
+   + + +

+Test for collisions with the exterior mesh of an interior instance. This only works for interior instances !! see also testCollision() in CLocalRetriever +

+Definition at line 635 of file retriever_instance.cpp. +

+References _ExteriorEdgeQuad, NLPACS::CLocalRetriever::_ExteriorMesh, NLPACS::CCollisionSurfaceTemp::allocEdgeCollideNode(), NLPACS::CCollisionSurfaceTemp::CollisionChains, NLPACS::CExteriorEdgeEntry::EdgeId, NLPACS::CExteriorEdgeEntry::Exterior, NLPACS::CCollisionSurfaceTemp::ExteriorEdgeIndexes, NLPACS::CCollisionChain::FirstEdgeCollide, NLPACS::CExteriorMesh::getEdge(), NLPACS::CCollisionSurfaceTemp::getEdgeCollideNode(), NLPACS::CEdgeQuad::getEdgeEntry(), NLPACS::CExteriorEdgeEntry::Interior, NLPACS::CEdgeCollide::make(), NLPACS::CEdgeCollideNode::Next, NLPACS::CCollisionSurfaceTemp::OChainLUT, NLPACS::CEdgeQuad::selectEdges(), sint, uint, uint16, and uint32. +

+Referenced by NLPACS::CGlobalRetriever::findCollisionChains(). +

+

00636 {
+00637         sint    i;
+00638 
+00639         // 0. select ordered chains in the chainquad.
+00640         //=====================================
+00641         sint    nEei= _ExteriorEdgeQuad.selectEdges(bboxMove, cst);
+00642         // NB: cst.OChainLUT is assured to be full of 0xFFFF after this call (if was right before).
+00643 
+00644 
+00645         // 1. regroup them in chains. build cst.CollisionChains
+00646         //=====================================
+00647         // NB: use cst.OChainLUT to look if a Chain has been inserted before.
+00648         uint16  *edgeLUT= cst.OChainLUT;
+00649 
+00650         // bkup where we begin to add chains.
+00651         uint    firstChainAdded= cst.CollisionChains.size();
+00652 
+00653         // For all exterioredge entry.
+00654         for(i=0;i<nEei;i++)
+00655         {
+00656                 // get the edge entry and the edge
+00657                 uint16                                          eei = cst.ExteriorEdgeIndexes[i];
+00658                 const CExteriorEdgeEntry        &eee = _ExteriorEdgeQuad.getEdgeEntry(eei);
+00659 
+00660                 // WELL ACTUALLY DO BOTHER ABOUT DOORS !!
+00661 /*
+00662                 // don't bother about doors
+00663                 if (eee.Interior.RetrieverInstanceId != -1)
+00664                         continue;
+00665 */
+00666 
+00667                 // add/retrieve the id in cst.CollisionChains.
+00668                 //=================================
+00669                 uint                            ccId;
+00670                 // if never added.
+00671                 if(edgeLUT[eei]==0xFFFF)
+00672                 {
+00673                         // add a new CCollisionChain.
+00674                         ccId= cst.CollisionChains.size();
+00675                         cst.CollisionChains.push_back(CCollisionChain());
+00676                         // Fill it with default.
+00677                         cst.CollisionChains[ccId].Tested= false;
+00678                         cst.CollisionChains[ccId].ExteriorEdge = true;
+00679                         cst.CollisionChains[ccId].FirstEdgeCollide= 0xFFFFFFFF;
+00680                         cst.CollisionChains[ccId].ChainId= eei;
+00681                         // Fill Left right info.
+00682                         cst.CollisionChains[ccId].LeftSurface = eee.Interior;
+00683                         cst.CollisionChains[ccId].RightSurface = eee.Exterior;
+00684 
+00685                         // store this Id in the LUT of chains.
+00686                         edgeLUT[eei]= ccId;
+00687                 }
+00688                 else
+00689                 {
+00690                         // get the id of this collision chain.
+00691                         ccId= edgeLUT[eei];
+00692 
+00693                         // ACTUALLY, THIS SHOULD NEVER HAPPEN
+00694                         // since ext edge are only 1 segment
+00695                 }
+00696 
+00697                 // add edge collide to the list.
+00698                 //=================================
+00699                 CCollisionChain                 &colChain= cst.CollisionChains[ccId];
+00700 
+00701                 CVector2f       p0 = CVector2f(retriever._ExteriorMesh.getEdge(eee.EdgeId).Start);
+00702                 CVector2f       p1 = CVector2f(retriever._ExteriorMesh.getEdge(eee.EdgeId+1).Start);
+00703 
+00704                 // alloc a new edgeCollide.
+00705                 uint32  ecnId= cst.allocEdgeCollideNode();
+00706                 CEdgeCollideNode        &ecn= cst.getEdgeCollideNode(ecnId);
+00707 
+00708                 // append to the front of the list.
+00709                 ecn.Next= colChain.FirstEdgeCollide;
+00710                 colChain.FirstEdgeCollide= ecnId;
+00711 
+00712                 // build this edge.
+00713                 p0+= transBase;
+00714                 p1+= transBase;
+00715                 ecn.make(p0, p1);
+00716         }
+00717 
+00718 
+00719 
+00720         // 2. Reset LUT to 0xFFFF.
+00721         //=====================================
+00722 
+00723         // for all collisions chains inserted (starting from firstChainAdded), reset LUT.
+00724         for(i=firstChainAdded; i<(sint)cst.CollisionChains.size(); i++)
+00725         {
+00726                 uint    ccId= cst.CollisionChains[i].ChainId;
+00727                 edgeLUT[ccId]= 0xFFFF;
+00728                 cst.CollisionChains[i].ChainId = _ExteriorEdgeQuad.getEdgeEntry(ccId).EdgeId;
+00729         }
+00730 
+00731 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLPACS::CRetrieverInstance::unlink std::vector< CRetrieverInstance > &  instances  ) 
+
+ + + + + +
+   + + +

+Unlinks the instance. The neighbor instance are AFFECTED. +

+ +

+Definition at line 281 of file retriever_instance.cpp. +

+References _InstanceId, _Neighbors, resetLinks(), and uint. +

+Referenced by NLPACS::CGlobalRetriever::removeInstance(). +

+

00282 {
+00283         uint    i;
+00284 
+00285         for (i=0; i<_Neighbors.size(); ++i)
+00286                 instances[_Neighbors[i]].resetLinks(_InstanceId);
+00287 
+00288         resetLinks();
+00289 }
+
+


Friends And Related Function Documentation

+

+ + + + +
+ + +
friend class CGlobalRetriever [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 76 of file retriever_instance.h.

+


Field Documentation

+

+ + + + +
+ + +
NLMISC::CAABBox NLPACS::CRetrieverInstance::_BBox [protected] +
+
+ + + + + +
+   + + +

+The BBox of the instance. +

+ +

+Definition at line 134 of file retriever_instance.h.

+

+ + + + +
+ + +
std::vector<CLink> NLPACS::CRetrieverInstance::_BorderChainLinks [protected] +
+
+ + + + + +
+   + + +

+The neighbor chains on the border. +

+ +

+Definition at line 145 of file retriever_instance.h. +

+Referenced by forceBorderChainLink(), getBorderChainLink(), getBorderChainLinks(), init(), link(), linkEdgeQuad(), reset(), resetBorderChainLinks(), resetLinks(), and serial().

+

+ + + + +
+ + +
CEdgeQuad NLPACS::CRetrieverInstance::_ExteriorEdgeQuad [protected] +
+
+ + + + + +
+   + + +

+The edges of the exterior collision mesh, stored in a quad grid. The edges are stored in the instance rather than in the local retriever. +

+Definition at line 154 of file retriever_instance.h. +

+Referenced by initEdgeQuad(), linkEdgeQuad(), reset(), resetLinks(), serial(), and testExteriorCollision().

+

+ + + + +
+ + +
sint32 NLPACS::CRetrieverInstance::_InstanceId [protected] +
+
+ + + + + +
+   + + +

+The id of this instance. +

+ +

+Definition at line 120 of file retriever_instance.h. +

+Referenced by forceBorderChainLink(), getInstanceId(), initEdgeQuad(), link(), linkEdgeQuad(), make(), reset(), retrievePosition(), serial(), snap(), and unlink().

+

+ + + + +
+ + +
std::vector<sint32> NLPACS::CRetrieverInstance::_Neighbors [protected] +
+
+ + + + + +
+   + + +

+The instance ids of the neighbors. +

+ +

+Definition at line 142 of file retriever_instance.h. +

+Referenced by getNeighbor(), getNeighbors(), link(), resetLinks(), serial(), and unlink().

+

+ + + + +
+ + +
std::vector<CAStarNodeInfo> NLPACS::CRetrieverInstance::_NodesInformation [protected] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 116 of file retriever_instance.h. +

+Referenced by NLPACS::CGlobalRetriever::findAStarPath(), reset(), and serial().

+

+ + + + +
+ + +
uint8 NLPACS::CRetrieverInstance::_Orientation [protected] +
+
+ + + + + +
+   + + +

+The BBox of the instance. +

+ +

+Definition at line 130 of file retriever_instance.h. +

+Referenced by getDoubleGlobalPosition(), getGlobalPosition(), getInstanceEdge(), getLocalPosition(), getOrientation(), getRetrieverEdge(), make(), reset(), and serial().

+

+ + + + +
+ + +
NLMISC::CVector NLPACS::CRetrieverInstance::_Origin [protected] +
+
+ + + + + +
+   + + +

+The BBox of the instance. +

+ +

+Definition at line 131 of file retriever_instance.h. +

+Referenced by getDoubleGlobalPosition(), getGlobalPosition(), getLocalPosition(), getOrigin(), link(), make(), reset(), and serial().

+

+ + + + +
+ + +
sint32 NLPACS::CRetrieverInstance::_RetrieverId [protected] +
+
+ + + + + +
+   + + +

+The id of the retrievable surface pattern. +

+ +

+Definition at line 123 of file retriever_instance.h. +

+Referenced by getRetrieverId(), initEdgeQuad(), link(), linkEdgeQuad(), make(), reset(), and serial().

+

+ + + + +
+ + +
CLocalRetriever::EType NLPACS::CRetrieverInstance::_Type [protected] +
+
+ + + + + +
+   + + +

+The type of the instance (see CLocalRetriever::_Type). +

+ +

+Definition at line 126 of file retriever_instance.h.

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 14:23:55 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1