NLMISC::CBSPNode2v Class Reference


Public Member Functions

 CBSPNode2v (const CPlane &plane, CVector p0, CVector p1, uint v0, uint v1)
 CBSPNode2v ()
void insert (CBSPNode2v *node)
bool intersect (const CVector &p0, const CVector &p1, uint v0, uint v1) const
 ~CBSPNode2v ()

Data Fields

CBSPNode2vBack
CBSPNode2vFront
CVector P0
CVector P1
CBSPNode2vParent
CPlane Plane
uint V0
uint V1

Constructor & Destructor Documentation

NLMISC::CBSPNode2v::CBSPNode2v  )  [inline]
 

Definition at line 198 of file polygon.cpp.

Referenced by insert().

00199         {
00200                 Back = NULL;
00201                 Front = NULL;
00202         }

NLMISC::CBSPNode2v::CBSPNode2v const CPlane plane,
CVector  p0,
CVector  p1,
uint  v0,
uint  v1
[inline]
 

Definition at line 203 of file polygon.cpp.

References uint, V0, and V1.

00203                                                                                      : Plane (plane), P0 (p0), P1 (p1)
00204         {
00205                 Back = NULL;
00206                 Front = NULL;
00207                 Parent = NULL;
00208                 V0 = v0;
00209                 V1 = v1;
00210         }

NLMISC::CBSPNode2v::~CBSPNode2v  )  [inline]
 

Definition at line 211 of file polygon.cpp.

00212         {
00213                 if (Front)
00214                         delete Front;
00215                 if (Back)
00216                         delete Back;
00217         }


Member Function Documentation

void NLMISC::CBSPNode2v::insert CBSPNode2v node  )  [inline]
 

Definition at line 219 of file polygon.cpp.

References CBSPNode2v(), NLMISC::CPlane::intersect(), P0, P1, Parent, Plane, V0, and V1.

Referenced by NLMISC::CPolygon::toConvexPolygonsLocalAndBSP().

00220         {
00221                 // Front ?
00222                 bool p0Front = (Plane * node->P0) > 0;
00223                 bool p1Front = (Plane * node->P1) > 0;
00224                 if (p0Front && p1Front)
00225                 {
00226                         // Front child ?
00227                         if (Front)
00228                                 Front->insert (node);
00229                         else
00230                         {
00231                                 // Link left
00232                                 Front = node;
00233                                 node->Parent = this;
00234                         }
00235                 }
00236                 else if ((!p0Front) && (!p1Front))
00237                 {
00238                         // Back child ?
00239                         if (Back)
00240                                 Back->insert (node);
00241                         else
00242                         {
00243                                 // Link left
00244                                 Back = node;
00245                                 node->Parent = this;
00246                         }
00247                 }
00248                 else
00249                 {
00250                         // Split vertex
00251                         CVector newVertex = Plane.intersect (node->P0, node->P1);
00252 
00253                         // New node
00254                         CBSPNode2v *newNode = new CBSPNode2v (node->Plane, node->P0, newVertex, node->V0, node->V1);
00255 
00256                         // Old node
00257                         node->P0 = newVertex;
00258 
00259                         // Insert child
00260                         CBSPNode2v **p0Parent;
00261                         CBSPNode2v **p1Parent;
00262 
00263                         // Get insertion pointer
00264                         if (p0Front)
00265                         {
00266                                 p0Parent = &Front;
00267                                 p1Parent = &Back;
00268                         }
00269                         else
00270                         {
00271                                 p0Parent = &Back;
00272                                 p1Parent = &Front;
00273                         }
00274 
00275                         // Insert children
00276                         if (*p0Parent)
00277                         {
00278                                 (*p0Parent)->insert (newNode);
00279                         }
00280                         else
00281                         {
00282                                 *p0Parent = newNode;
00283                                 newNode->Parent = this;
00284                         }
00285 
00286                         // Insert children
00287                         if (*p1Parent)
00288                         {
00289                                 (*p1Parent)->insert (node);
00290                         }
00291                         else
00292                         {
00293                                 *p1Parent = node;
00294                                 node->Parent = this;
00295                         }
00296                 }
00297         }

bool NLMISC::CBSPNode2v::intersect const CVector p0,
const CVector p1,
uint  v0,
uint  v1
const [inline]
 

Definition at line 299 of file polygon.cpp.

References uint, V0, and V1.

Referenced by NLMISC::CPolygon::chain(), and NLMISC::CPolygon::toConvexPolygonsDiagonal().

00300         {
00301                 // Front ?
00302                 bool p0Front = (Plane * p0) > 0;
00303                 bool p1Front = (Plane * p1) > 0;
00304 
00305                 if (p0Front != p1Front)
00306                         if ( (v0 != V0) && (v0 != V1) && (v1 != V0) && (v1 != V1) )
00307                                 if (CPolygon::toConvexPolygonsEdgeIntersect ((CVector2f) P0, (CVector2f) P1, (CVector2f) p0, (CVector2f) p1))
00308                                         return true;
00309 
00310                 if (p0Front || p1Front)
00311                 {
00312                         if (Front)
00313                                 if (Front->intersect (p0, p1, v0, v1))
00314                                         return true;
00315                 }
00316 
00317                 if ((!p0Front) || (!p1Front))
00318                 {
00319                         if (Back)
00320                                 if (Back->intersect (p0, p1, v0, v1))
00321                                         return true;
00322                 }
00323 
00324                 return false;
00325         }


Field Documentation

CBSPNode2v* NLMISC::CBSPNode2v::Back
 

Definition at line 327 of file polygon.cpp.

CBSPNode2v * NLMISC::CBSPNode2v::Front
 

Definition at line 327 of file polygon.cpp.

CVector NLMISC::CBSPNode2v::P0
 

Definition at line 329 of file polygon.cpp.

Referenced by insert().

CVector NLMISC::CBSPNode2v::P1
 

Definition at line 330 of file polygon.cpp.

Referenced by insert().

CBSPNode2v * NLMISC::CBSPNode2v::Parent
 

Definition at line 327 of file polygon.cpp.

Referenced by insert().

CPlane NLMISC::CBSPNode2v::Plane
 

Definition at line 328 of file polygon.cpp.

Referenced by insert().

uint NLMISC::CBSPNode2v::V0
 

Definition at line 331 of file polygon.cpp.

Referenced by CBSPNode2v(), insert(), and intersect().

uint NLMISC::CBSPNode2v::V1
 

Definition at line 332 of file polygon.cpp.

Referenced by CBSPNode2v(), insert(), and intersect().


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 13:05:36 2004 for NeL by doxygen 1.3.6