eHalfEdge Class Reference

#include <eTess2.h>

Inheritance diagram for eHalfEdge:

Inheritance graph
[legend]
Collaboration diagram for eHalfEdge:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 eHalfEdge (ePoint *a, ePoint *b, eWall *w=NULL)
void SetWall (eWall *w)
void ClearWall (void)
void SetOther (eHalfEdge *e)
void Destroy ()
REAL Ratio (const eCoord &c) const
eCoord Vec () const
bool Movable () const
bool Splittable () const
void Split (eHalfEdge *&e1, eHalfEdge *&e2, ePoint *s)
eCoord IntersectWithCareless (const eHalfEdge *e2) const
ePointIntersectWith (const eHalfEdge *e2) const
void CopyIntoGrid (eGrid *grid, bool change_grid=1)
bool Simplify (eGrid *grid)
void Print (std::ostream &s) const
ePointPoint () const
eFaceFace () const
eHalfEdgeOther () const
eHalfEdgeNext () const
eWallCrossesNewWall (const eGrid *grid) const

Static Public Member Functions

static void FindPath (const eCoord &originPoint, const eFace *originFace, const eCoord &targetPoint, const eFace *targetFace, const eGameObject *gameObject, ePath &path)
static void ClearPathData ()

Protected Member Functions

REAL MinPathLength ()
void SetMinPathLength (REAL length, tHeapBase &heap, ePATH_ORIGIN origin)
void PossiblePath (ePATH_ORIGIN origin, REAL minLength)
virtual tHeapBaseHeap () const
void Unlink ()
bool Check () const
void SetPoint (ePoint *p)
void SetFace (eFace *p)

Protected Attributes

ePATH_ORIGIN origin_
int ID
tJUST_CONTROLLED_PTR< ePointpoint
tJUST_CONTROLLED_PTR< eFaceface
tJUST_CONTROLLED_PTR< eHalfEdgenext
tJUST_CONTROLLED_PTR< eHalfEdgeprev
tJUST_CONTROLLED_PTR< eHalfEdgeother

Private Member Functions

 ~eHalfEdge ()
 eHalfEdge (ePoint *p=NULL)

Friends

class eDual
class ePoint
class eFace
class eGrid
class eTempEdge
class eWall
class tReferencable< eHalfEdge >


Detailed Description

Definition at line 82 of file eTess2.h.


Constructor & Destructor Documentation

eHalfEdge::~eHalfEdge (  )  [private]

Definition at line 160 of file eGrid.cpp.

References tHeapElement::RemoveFromHeap(), and Unlink().

00161 {
00162     Unlink();
00163     RemoveFromHeap();
00164 }

Here is the call graph for this function:

eHalfEdge::eHalfEdge ( ePoint p = NULL  )  [private]

Definition at line 2248 of file eGrid.cpp.

References face, origin_, PATH_NONE, and point.

Referenced by eHalfEdge().

02248                              :ID(-1),next(NULL), prev(NULL), other(NULL)
02249 {
02250     origin_ = PATH_NONE;
02251 
02252     point = p;
02253     face  = 0;
02254 }

Here is the caller graph for this function:

eHalfEdge::eHalfEdge ( ePoint a,
ePoint b,
eWall w = NULL 
)

Definition at line 2257 of file eGrid.cpp.

References eHalfEdge(), origin_, PATH_NONE, SetOther(), SetPoint(), SetWall(), and tASSERT.

02258         :ID(-1),next(NULL), prev(NULL), other(NULL)
02259 {
02260     tASSERT( a !=  b);
02261 
02262     origin_ = PATH_NONE;
02263 
02264     SetPoint(a);
02265     SetOther(new eHalfEdge(b));
02266     SetWall(w);
02267 }

Here is the call graph for this function:


Member Function Documentation

void eHalfEdge::SetWall ( eWall w  )  [inline]

Reimplemented from eWallHolder.

Definition at line 99 of file eGrid.cpp.

References eWall::CalcLen(), eWall::Flip(), eWallHolder::GetWall(), other, eWall::RunsParallelActive(), and eWallHolder::SetWall().

Referenced by eGrid::DrawLine(), and eHalfEdge().

00099                                       {
00100     if (!w)
00101         return;
00102 
00103     // emulate rip bug
00104     if ( se_bugRip )
00105     {
00106         // delete old wall
00107         if ( other && other->GetWall() && other->GetWall()->Splittable() )
00108             other->eWallHolder::SetWall( 0 );
00109 
00110         // set new wall
00111         eWallHolder::SetWall( w );
00112 
00113         w->CalcLen();
00114 
00115         return;
00116     }
00117 
00118     // get other wall
00119     eWall* otherWall = 0;
00120     if ( other )
00121         otherWall = other->GetWall();
00122 
00123     // ask for permission
00124     if ( otherWall && !w->RunsParallelActive( otherWall ) )
00125         return;
00126 
00127     eWall* thisWall = GetWall();
00128     if ( thisWall )
00129     {
00130         // ask this wall for permission
00131         bool allowed = w->RunsParallelActive( thisWall );
00132         if ( otherWall )
00133         {
00134             // inform wall, but don't insert it ( since it is impossible )
00135             w->RunsParallelActive( otherWall );
00136             // st_Breakpoint();
00137         }
00138         else if ( allowed && other )
00139         {
00140             // simply flip the wall and attach it to the other edge :-)
00141             w->Flip();
00142             other->eWallHolder::SetWall(w);
00143             //            return;
00144         }
00145     }
00146     else
00147     {
00148         eWallHolder::SetWall( w );
00149     }
00150 
00151     w->CalcLen();
00152 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eHalfEdge::ClearWall ( void   ) 

Definition at line 154 of file eGrid.cpp.

References NULL, and eWallHolder::SetWall().

Referenced by Simplify().

00155 {
00156     eWallHolder::SetWall( NULL );
00157 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eHalfEdge::SetOther ( eHalfEdge e  )  [inline]

Definition at line 101 of file eTess2.h.

References NULL, other, and tASSERT.

Referenced by eHalfEdge().

00102     {
00103         tASSERT(e != this);
00104 
00105         if (e == other)
00106             return;
00107 
00108         if (other)
00109             other->other = NULL;
00110 
00111         if (e->other)
00112             e->other->other = NULL;
00113 
00114         e->other = this;
00115         other = e;
00116     }

Here is the caller graph for this function:

void eHalfEdge::Destroy (  )  [inline]

Definition at line 119 of file eTess2.h.

References Unlink().

00120     {
00121         tJUST_CONTROLLED_PTR< eHalfEdge > holder( this );
00122         Unlink();
00123     }

Here is the call graph for this function:

REAL eHalfEdge::Ratio ( const eCoord &  c  )  const [inline]

Definition at line 422 of file eTess2.h.

References other, and Point().

Referenced by gEnemyInfluence::AddWall(), CrossesNewWall(), gCycleChatBot::Sensor::DoExtraDetectionStuff(), eGrid::DrawLine(), IntersectWith(), eGameObject::Move(), sg_TopologyPoliceCheck(), and Split().

00423 {
00424     return eCoord::V(*Point(),c,*other->Point());
00425 }

Here is the call graph for this function:

Here is the caller graph for this function:

eCoord eHalfEdge::Vec (  )  const [inline]

Definition at line 409 of file eTess2.h.

References other, Point(), and tASSERT.

Referenced by ClampMovement(), eFace::CorrectArea(), eGrid::DrawLine(), EdgePenalty(), eGameObject::FindCurrentFace(), FindPath(), eGrid::FindSurroundingFace(), eGameObject::Move(), eGrid::ProcessWallsInRange(), ProcessWallsRecursive(), and eWall::Vec().

00409                                   {
00410     tASSERT(other);
00411     return *(other->Point()) - *Point();
00412 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool eHalfEdge::Movable (  )  const [inline]

Definition at line 132 of file eTess2.h.

References eWallHolder::GetWall(), and other.

Referenced by eFace::CorrectArea(), eGrid::DrawLine(), and Movable().

00132 {return !GetWall() && (!other || !other->GetWall());}

Here is the call graph for this function:

Here is the caller graph for this function:

bool eHalfEdge::Splittable (  )  const

Definition at line 1617 of file eGrid.cpp.

References eWallHolder::GetWall(), other, and eWall::Splittable().

Referenced by eGrid::DrawLine().

01618 {
01619     eWall *w = GetWall();
01620     if (!w && other)
01621         w = other->GetWall();
01622     return !w || w->Splittable();
01623 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eHalfEdge::Split ( eHalfEdge *&  e1,
eHalfEdge *&  e2,
ePoint s 
)

Definition at line 1626 of file eGrid.cpp.

References eWall::CalcLen(), eWallHolder::GetWall(), other, Point(), Ratio(), eWall::Split(), eWall::Splittable(), tASSERT, tERR_ERROR_INT, and tNEW.

Referenced by eGrid::DrawLine().

01627 {
01628     tASSERT(other);
01629 
01630     e1=tNEW(eHalfEdge) (Point(),s);
01631     e2=tNEW(eHalfEdge) (s,other->Point());
01632 
01633     if (GetWall())
01634     {
01635         if (!GetWall()->Splittable())
01636             tERR_ERROR_INT("I told you not to split that!");
01637         // first, split the eWall structure:
01638         eWall *w1,*w2;
01639         GetWall()->Split(w1,w2,Ratio(*s));
01640 
01641         // we use the base class' function to set walls so we don't alarm the topology police
01642         e1->eWallHolder::SetWall(w1);
01643         e2->eWallHolder::SetWall(w2);
01644         w1->CalcLen();
01645         w2->CalcLen();
01646     }
01647     if (other->GetWall())
01648     {
01649         if (!other->GetWall()->Splittable())
01650             tERR_ERROR_INT("I told you not to split that!");
01651         // first, split the eWall structure:
01652         eWall *w1,*w2;
01653         other->GetWall()->Split(w2,w1,1-Ratio(*s));
01654 
01655         // the topology police would crash right here.
01656         e1->other->eWallHolder::SetWall(w1);
01657         e2->other->eWallHolder::SetWall(w2);
01658         w1->CalcLen();
01659         w2->CalcLen();
01660     }
01661 }

Here is the call graph for this function:

Here is the caller graph for this function:

eCoord eHalfEdge::IntersectWithCareless ( const eHalfEdge e2  )  const

Definition at line 2272 of file eGrid.cpp.

References eCoord, EPS, other, Point(), REAL, and se_EstimatedRangeOfMult().

Referenced by eGrid::DrawLine(), eGameObject::Move(), and gPlayerWall::SplitByActive().

02273 {
02274     eCoord vec  = *other->Point()     -     *Point();
02275     eCoord e2vec= *e2->other->Point() - *e2->Point();
02276     eCoord e2_t = *Point()     - *e2->Point();
02277 
02278     REAL inv = (vec*e2vec);
02279     if (fabs(inv) > EPS * se_EstimatedRangeOfMult( vec, e2vec ) )
02280     {
02281         // return intersection poin
02282         return (*Point()-vec*((e2_t*e2vec)/inv));
02283     }
02284     else
02285     {
02286         // lines lie almost parallel; return "inverse center of gravity" ( the swapped
02287         // weighting is intentional, the smaller line should have a bigger influence )
02288         REAL m1 = vec.Norm();
02289         REAL m2 = e2vec.Norm();
02290         if ( m1 + m2 <= 0 ) // sanity check weights
02291             m1=m2=1;
02292         return ((*Point() + *other->Point())*m2 + (*e2->Point() + *e2->other->Point())*m1)*(.5/(m1+m2));
02293     }
02294 }

Here is the call graph for this function:

Here is the caller graph for this function:

ePoint * eHalfEdge::IntersectWith ( const eHalfEdge e2  )  const

Definition at line 2298 of file eGrid.cpp.

References eCoord, NULL, other, Point(), Ratio(), REAL, and tNEW.

Referenced by CrossesNewWall(), and eGameObject::Move().

02299 {
02300     eCoord vec  = *other->Point()     -     *Point();
02301     eCoord e2vec= *e2->other->Point() - *e2->Point();
02302     eCoord e2_t = *Point()     - *e2->Point();
02303 
02304     REAL div=(vec*e2vec);
02305 
02306     if (div==0) return NULL;
02307 
02308     eCoord ret=*Point()-vec*((e2_t*e2vec)/ div);
02309 
02310 
02311     REAL v=Ratio(ret);
02312     if (v<0 || v>1) return NULL;
02313     v=e2->Ratio(ret);
02314     if (v<0 || v>1) return NULL;
02315 
02316     return tNEW(ePoint) (ret);
02317 
02318 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eHalfEdge::CopyIntoGrid ( eGrid grid,
bool  change_grid = 1 
)

Definition at line 2321 of file eGrid.cpp.

References eGrid::DrawLine(), eWallHolder::GetWall(), eGrid::Insert(), other, Point(), and tASSERT.

02321                                                          {
02322     tASSERT(other);
02323     ePoint *start = grid->Insert(*Point());
02324     grid->DrawLine(start, *other->Point(), GetWall(), change_grid);
02325 }

Here is the call graph for this function:

bool eHalfEdge::Simplify ( eGrid grid  ) 

Definition at line 1835 of file eGrid.cpp.

References tRecorderSync< DATA >::Archive(), bb, eGrid::Check(), ClearWall(), eCoord, eDual::edge, F, face, eWallHolder::GetWall(), ID, eGrid::KillEdge(), eGrid::KillPoint(), next, Next(), other, Point(), point, REAL, ePoint::Replace(), se_LinkFaces(), tASSERT, and eGrid::ZombifyFace().

Referenced by eGrid::SimplifyNum().

01836 {
01837     if (GetWall() && GetWall()->Deletable() && face)
01838     {
01839         ClearWall();
01840     }
01841 
01842     if (other && other->GetWall() && other->GetWall()->Deletable() && other->face)
01843     {
01844         other->ClearWall();
01845     }
01846 
01847     if (GetWall() || !other || other->GetWall() || !face || !other->face)
01848         return false;
01849 
01850     ePoint  *to_be_removed=point; // we'll remove this ePoint
01851     ePoint  *stay=other->point;   // and redirect all his edges to this ePoint
01852 
01853     // first, we find the faces that are going to be modified:
01854     // they are neighbours of the ePoint we'll remove.
01855 
01856     eHalfEdge *run = this->other->next;
01857     do{
01858         //    eFace *F = run->face; // eFace to be modified
01859         tASSERT(run->other);
01860 
01861 
01862 
01863 
01864         /*
01865 
01866 
01867 
01868 
01869           C  this
01870           A ------------ --------------- stays
01871           Next    |
01872           | 
01873           |r 
01874           |u   
01875           |n    
01876           |     
01877           |
01878           B
01879 
01880 
01881 
01882 
01883         */
01884 
01885 
01886         // if any of the to-be-modified edges is a eWall, abort the operation.
01887         if (run->GetWall() || run->other->GetWall() || !run->face)
01888             return false;
01889 
01890         eHalfEdge *Next = run->other->next;
01891         eCoord &A = *Next->other->point;
01892         eCoord &B = *run->other->point;
01893         eCoord &C = *stay;
01894 #ifdef DEBUG
01895         //    eCoord &D = *to_be_removed;
01896         //    eCoord leftvec_b  = B-D;
01897         //    eCoord rightvec_b = A-D;
01898         //    REAL orientation_b=leftvec_b*rightvec_b;
01899 #endif
01900 
01901 
01902         // if the eFace is to be modified (and not deleted), check
01903         // if it will flip orientation; if yes, abort.
01904 
01905         eCoord leftvec = B-C;
01906         eCoord rightvec= A-C;
01907 
01908         REAL orientation=leftvec*rightvec;
01909 
01910         if (orientation <= 0)
01911             return false;
01912 
01913         // test if the face contains a gameobject or is otherwise referenced; abort if that is the case
01914         // four references are nominal: three from the edges, one from the grid
01915         if ( !Next->face || Next->face->GetRefcount() > 4 )
01916             return false;
01917 
01918         //    tASSERT(orientation_b > 0);
01919 
01920         run = Next;
01921     }
01922     while (run && run->other &&  !(this == run->other->next));
01923 
01924     // dangerously close to the rim....
01925     if (!run || !run->other)
01926         return false;
01927 
01928     // Allright! everything is safe.
01929 #ifdef DEBUG
01930     grid->Check();
01931 #endif
01932 
01933     eHalfEdge *a  = next;
01934     eHalfEdge *aa = a->next;
01935     ePoint *A     = aa->Point();
01936 
01937     eHalfEdge *b  = other->next;
01938     eHalfEdge *bb = b->next;
01939     ePoint *B     = bb->Point();
01940 
01941     if (a->GetWall() || a->other->GetWall())
01942         return false;
01943 
01944     if (aa->GetWall() || aa->other->GetWall())
01945         return false;
01946 
01947     if (b->GetWall() || b->other->GetWall())
01948         return false;
01949 
01950     if (bb->GetWall() || bb->other->GetWall())
01951         return false;
01952 
01953     tControlledPTR< eHalfEdge > keep( this );
01954 
01955     int idrec = ID;
01956     tRecorderSync< int >::Archive( "_GRID_SIMPLIFY_REAL", 8, idrec );
01957 
01958     // the faces that will be removed
01959     tControlledPTR< eFace > killed1 = grid->ZombifyFace( face );
01960     tControlledPTR< eFace > killed2 = grid->ZombifyFace( other->face );
01961 
01962     // all faces that will replace them get added to their replacement list
01963     run = this->other->next->other->next;
01964     do{
01965         tASSERT(run->other);
01966 
01967         //       eHalfEdge *Next = run->other->next;
01968         eFace *F = run->face; // eFace to be modified
01969         tASSERT( F != killed1 );
01970         tASSERT( F != killed2 );
01971         if( F )
01972         {
01973             se_LinkFaces( killed1, F );
01974             se_LinkFaces( killed2, F );
01975         }
01976 
01977         run = run->other->next;
01978     }
01979     while (run && run->other &&  !(this == run));
01980 
01981     stay->Replace(to_be_removed);
01982 
01983     // kill everything that goes away:
01984     //  grid->KillFace( killed1 );
01985     //  grid->KillFace( killed2 );
01986     grid->KillPoint(stay);
01987 
01988     grid->KillEdge(this);
01989 
01990     to_be_removed->edge = aa->other;
01991     A            ->edge = a->other;
01992     B            ->edge = b->other;
01993 
01994     // sew the edges of the faces that are going to disappear together:
01995     a->other->SetOther(aa->other);
01996     b->other->SetOther(bb->other);
01997 
01998     grid->KillEdge(a);
01999     grid->KillEdge(aa);
02000     grid->KillEdge(b);
02001     grid->KillEdge(bb);
02002 
02003     return true;
02004 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eHalfEdge::Print ( std::ostream &  s  )  const

Definition at line 652 of file eGrid.cpp.

References other, and Point().

Referenced by operator<<().

00652 { s << "[" << *Point() << "->" << *other->Point() << "]"; }

Here is the call graph for this function:

Here is the caller graph for this function:

ePoint * eHalfEdge::Point (  )  const [inline]

Definition at line 415 of file eTess2.h.

References point.

Referenced by ePath::Add(), eGrid::AddEdge(), eGrid::AddFaceAll(), Check(), CopyIntoGrid(), eFace::CorrectArea(), eFace::Create(), CrossesNewWall(), eGrid::display_simple(), Distance(), eGrid::DrawLine(), EdgePenalty(), eWall::EndPoint(), eGameObject::FindCurrentFace(), eGrid::FindSurroundingFace(), eGrid::Insert(), eFace::Insideness(), IntersectWith(), IntersectWithCareless(), eFace::IsInside(), eCameraSensor::LookAround(), eGameObject::Move(), Print(), eGrid::ProcessWallsInRange(), ProcessWallsRecursive(), Ratio(), ePoint::Replace(), Simplify(), Split(), gAIPlayer::ThinkTrace(), ePoint::Unlink(), and Vec().

00415 { return point;}

Here is the caller graph for this function:

eFace * eHalfEdge::Face (  )  const [inline]

Definition at line 418 of file eTess2.h.

References face.

Referenced by Check(), eGrid::display_simple(), eGrid::DrawLine(), EdgePenalty(), FindPath(), eGrid::FindSurroundingFace(), eFace::Insideness(), eFace::IsInside(), eGrid::ProcessWallsInRange(), ProcessWallsRecursive(), and eFace::Unlink().

00418 {return face;}

Here is the caller graph for this function:

eHalfEdge* eHalfEdge::Other (  )  const [inline]

Definition at line 197 of file eTess2.h.

References other.

Referenced by eGrid::AddEdge(), CanPass(), ClampMovement(), CrossesNewWall(), eWall::EndPoint(), FindPath(), eGrid::FindSurroundingFace(), eCameraSensor::LookAround(), Modifier(), Movable(), eGameObject::Move(), eGrid::ProcessWallsInRange(), ProcessWallsRecursive(), and gAIPlayer::ThinkTrace().

00197 {return other;}

Here is the caller graph for this function:

eHalfEdge* eHalfEdge::Next (  )  const [inline]

Definition at line 198 of file eTess2.h.

References next.

Referenced by ePath::Add(), ClampMovement(), eGameObject::FindCurrentFace(), FindPath(), eGrid::FindSurroundingFace(), eCameraSensor::LookAround(), Movable(), eGameObject::Move(), ProcessWallsRecursive(), and Simplify().

00198 {return next;}

Here is the caller graph for this function:

void eHalfEdge::FindPath ( const eCoord &  originPoint,
const eFace originFace,
const eCoord &  targetPoint,
const eFace targetFace,
const eGameObject gameObject,
ePath path 
) [static]

Definition at line 149 of file ePath.cpp.

References ePath::Add(), CanPass(), ePath::Clear(), ClearPathData(), con, CrossesNewWall(), Distance(), eDual::Edge(), EdgePenalty(), Face(), eGameObject::Grid(), tHeap< T >::Insert(), tHeap< T >::Len(), MinPathLength(), Modifier(), next, Next(), NULL, origin_, Other(), PATH_CLOSED, PATH_NEXT, PATH_OTHER_NEXT, PATH_PREV, PATH_PREV_OTHER, PATH_START, PossiblePath(), prev, REAL, tHeap< T >::Remove(), SetMinPathLength(), sqrt(), tASSERT, tERR_WARN, and Vec().

Referenced by gAIPlayer::ThinkPath().

00153 {
00154     tASSERT( startFace );
00155     tASSERT( stopFace );
00156     tASSERT( gameObject );
00157 
00158     // cleanup previous path data (we'll keep it around for debugging)
00159     ClearPathData();
00160     path.Clear();
00161 
00162     // start: add the three vertices around the origin to the open list
00163     {
00164         eHalfEdge *run = startFace->Edge();
00165         for (int i=2; i>=0; i--)
00166         {
00167             run->SetMinPathLength( Distance(run, startPoint) + Distance(run, stopPoint), openEdges, PATH_START );
00168 
00169             run = run->Next();
00170         }
00171     }
00172 
00173     // search for a path until one of the edges of the goal face is in the closed list or we have to give up
00174     eHalfEdge* stopEdge = NULL;
00175 
00176     while (openEdges.Len() > 0 && !stopEdge)
00177     {
00178         // take the most promising HalfEdge out of the open list, put it
00179         // into the closed list
00180         // and add all possible ways from there to the open list.
00181 
00182         eHalfEdge *e = openEdges.Remove(0);
00183 
00184         int origin = e->origin_;
00185         origin |= PATH_CLOSED;
00186         e->origin_ = static_cast<ePATH_ORIGIN>(origin);
00187 
00188         closedEdges.Insert(e);
00189 
00190         // check if we are at the goal
00191         if (e->Face() == stopFace)
00192             stopEdge = e;
00193 
00194 #ifdef DEBUG
00195         //      con << "examining " << *e->Point() << ", " << e->Vec() << "\n";
00196 #endif
00197 
00198         eHalfEdge *next = e->Next();
00199         eHalfEdge *prev = NULL;
00200 
00201         eHalfEdge *other_next = e->Other()->Next();
00202         eHalfEdge *prev_other = NULL;
00203 
00204         // try the next HalfEdge in this triangle
00205         {
00206             if (next)
00207             {
00208                 prev = next->Next();
00209 
00210                 // check if we cross a new wall on the way
00211                 if (!e->CrossesNewWall(gameObject->Grid()))
00212                 {
00213                     // we get this much closer to the target by going this way:
00214                     REAL closer  = Distance(e, stopPoint) - Distance(next, stopPoint);
00215 
00216                     // but have to go this much to get there:
00217                     REAL way     = sqrt(e->Vec().NormSquared()) * Modifier(gameObject, e);
00218 
00219                     // tell n that there is a possible path to it
00220                     next->PossiblePath(PATH_PREV, e->MinPathLength() + way - closer + EdgePenalty(e, gameObject) );
00221                 }
00222             }
00223         }
00224 
00225 
00226         // try the previous HalfEdge in this triangle
00227         if (prev)
00228         {
00229             tASSERT(prev->Next() == e);
00230             prev_other = prev->Other();
00231 
00232             // check if we cross a new wall on the way
00233             if (!prev->CrossesNewWall(gameObject->Grid()))
00234             {
00235                 // we get this much closer to the target by going this way:
00236                 REAL closer  = Distance(e, stopPoint) - Distance(prev, stopPoint);
00237 
00238                 // but have to go this much to get there:
00239                 REAL way     = sqrt(prev->Vec().NormSquared()) * Modifier(gameObject, e);
00240 
00241                 // tell n that there is a possible path to it
00242                 prev->PossiblePath(PATH_NEXT, e->MinPathLength() + way - closer  + EdgePenalty(e, gameObject));
00243             }
00244         }
00245 
00246 
00247         // now the edges that are just around the corner. They do not
00248         // make the way longer, but require the passed edge to be harmless
00249         // to the object.
00250 
00251         if (other_next && CanPass(gameObject, e))
00252             other_next->PossiblePath(PATH_PREV_OTHER, e->MinPathLength() + EdgePenalty(e, gameObject) + .000001f);
00253         if (prev_other && CanPass(gameObject, prev))
00254             prev_other->PossiblePath(PATH_OTHER_NEXT, e->MinPathLength() + EdgePenalty(e, gameObject) + .000001f);
00255     }
00256 
00257     // no path found...
00258     if (!stopEdge)
00259     {
00260         ClearPathData();
00261         return;
00262     }
00263 
00264     // allright! Now we just go back from the goal to the origin,
00265     // following the crumbs of bread we left behind.
00266 
00267 #ifdef DEBUG
00268     con << "Found path.\n";
00269     //  con << startPoint << "\n";
00270 #endif
00271 
00272     path.Add(stopPoint);
00273 
00274     eHalfEdge* run = stopEdge;
00275     while (run && run->Face() != startFace)
00276     {
00277         path.Add(run);
00278 
00279 #ifdef DEBUG
00280         //      con << *run->Point() << ", " << run->Vec() << "\n";
00281 #endif
00282 
00283         tASSERT(run->origin_ >= PATH_CLOSED);
00284 
00285         switch (run->origin_-PATH_CLOSED)
00286         {
00287         case (PATH_NEXT):
00288                         run = run->Next();
00289             break;
00290         case (PATH_PREV):
00291                         run = run->Next()->Next();
00292             break;
00293         case (PATH_OTHER_NEXT):
00294                         run = run->Other()->Next();
00295             break;
00296         case (PATH_PREV_OTHER):
00297                         run = run->Next()->Next()->Other();
00298             break;
00299         default:
00300             tERR_WARN("Pathfinding error!\n");
00301             run = startFace->Edge();
00302         }
00303     }
00304 
00305     //  path.Add(run);
00306     //  path.Add(startPoint);
00307 
00308 #ifdef DEBUG
00309     //  con << stopPoint << "\n";
00310 #endif
00311 
00312     ClearPathData();
00313 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eHalfEdge::ClearPathData (  )  [static]

Definition at line 111 of file ePath.cpp.

References tHeap< T >::Len(), origin_, PATH_NONE, and tHeap< T >::Remove().

Referenced by eGrid::Clear(), and FindPath().

00112 {
00113     while (openEdges.Len())
00114     {
00115         eHalfEdge *e = openEdges.Remove(0);
00116         e->origin_ = PATH_NONE;
00117     }
00118     while (closedEdges.Len())
00119     {
00120         eHalfEdge *e = closedEdges.Remove(0);
00121         e->origin_ = PATH_NONE;
00122     }
00123 }

Here is the call graph for this function:

Here is the caller graph for this function:

eWall * eHalfEdge::CrossesNewWall ( const eGrid grid  )  const

sg_netPlayerWalls(i)->Preliminary() &&

Definition at line 81 of file ePath.cpp.

References eWallHolder::GetWall(), IntersectWith(), GrowingArrayBase::Len(), NULL, Other(), Point(), Ratio(), REAL, and eGrid::wallsNotYetInserted.

Referenced by FindPath().

00082 {
00083     // check all the currently drawn eWalls:
00084     for(int i=grid->wallsNotYetInserted.Len()-1;i>=0;i--)
00085     {
00086         const eHalfEdge *other_e=grid->wallsNotYetInserted(i)->Edge();
00087         if (
00088             other_e->Point() && other_e->Other() && other_e->Other()->Point())
00089         {
00090             tJUST_CONTROLLED_PTR< ePoint > new_cross_p=IntersectWith(other_e);
00091             if (new_cross_p)
00092             {
00093                 REAL e_ratio =Ratio(*new_cross_p);
00094                 REAL o_ratio =other_e->Ratio(*new_cross_p);
00095                 if (0<=e_ratio && 1>=e_ratio &&
00096                         0<=o_ratio && 1>=o_ratio)
00097                 { // find the fall
00098                     eWall *w = other_e->GetWall();
00099                     if (!w)
00100                         w = other_e->Other()->GetWall();
00101 
00102                     if (w)
00103                         return w;
00104                 }
00105             }
00106         }
00107     }
00108     return NULL;
00109 }

Here is the call graph for this function:

Here is the caller graph for this function:

REAL eHalfEdge::MinPathLength (  )  [inline, protected]

Definition at line 216 of file eTess2.h.

References tHeapElement::Val().

Referenced by FindPath(), and PossiblePath().

00216 { return Val(); }   // the minimum length of a path through this edge

Here is the call graph for this function:

Here is the caller graph for this function:

void eHalfEdge::SetMinPathLength ( REAL  length,
tHeapBase heap,
ePATH_ORIGIN  origin 
) [protected]

Definition at line 140 of file ePath.cpp.

References Heap(), origin_, tHeapElement::SetVal(), and tASSERT.

Referenced by FindPath(), and PossiblePath().

00141 {
00142     origin_ = origin;
00143     tHeapElement::SetVal( length, heap );
00144 
00145     tASSERT( &heap == Heap() );
00146 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eHalfEdge::PossiblePath ( ePATH_ORIGIN  origin,
REAL  minLength 
) [protected]

Definition at line 316 of file ePath.cpp.

References MinPathLength(), origin_, PATH_CLOSED, PATH_NONE, and SetMinPathLength().

Referenced by FindPath().

00317 {
00318     // nothing needs to be done if there is already a shorter path known
00319     if( origin_ == PATH_NONE )
00320     {
00321         // completely new entry.
00322 
00323         SetMinPathLength( minLength, openEdges, newOrigin );
00324 
00325 #ifdef DEBUG
00326         //      con << "adding " << *Point() << ", " << Vec() << ", origin "
00327         //        << origin << " to open list.\n";
00328 #endif
00329     }
00330     else if( minLength <  MinPathLength() && origin_ < PATH_CLOSED)
00331     {
00332         // just update our info; the path got shorter.
00333         SetMinPathLength( minLength, openEdges, newOrigin );
00334 
00335 #ifdef DEBUG
00336         //      con << "updating " << *Point() << ", " << Vec() << ", origin "
00337         //        << origin << " to open list.\n";
00338 #endif
00339 
00340     }
00341 }

Here is the call graph for this function:

Here is the caller graph for this function:

tHeapBase * eHalfEdge::Heap (  )  const [protected, virtual]

Implements tHeapElement.

Definition at line 344 of file ePath.cpp.

References NULL, origin_, PATH_CLOSED, and PATH_NONE.

Referenced by SetMinPathLength().

00345 {
00346     if (origin_ >= PATH_NONE)
00347         return NULL;
00348     if (origin_ >= PATH_CLOSED)
00349         return &closedEdges;
00350 
00351     return &openEdges;
00352 }

Here is the caller graph for this function:

void eHalfEdge::Unlink (  )  [inline, protected]

Definition at line 166 of file eGrid.cpp.

References face, next, NULL, other, point, and prev.

Referenced by Destroy(), eGrid::KillEdge(), and ~eHalfEdge().

00167 {
00168     if (point && this == point->edge)
00169     {
00170         if (prev && prev->other && prev->other)
00171             point->edge = prev->other;
00172         else if (other && other->next)
00173             point->edge = other->next;
00174         else
00175             point->edge = 0;
00176     }
00177     if (face && this == face->edge)
00178     {
00179         if (next)
00180             face->edge = next;
00181         if (prev)
00182             face->edge = prev;
00183     }
00184 
00185     if (next)
00186         next->prev = NULL;
00187     if (prev)
00188         prev->next = NULL;
00189     if (other)
00190         other->other = NULL;
00191 
00192     point   = NULL;
00193     face    = NULL;
00194     prev    = NULL;
00195     next    = NULL;
00196     other   = NULL;
00197 }

Here is the caller graph for this function:

bool eHalfEdge::Check (  )  const [protected]

Definition at line 2331 of file eGrid.cpp.

References face, Face(), eWallHolder::GetWall(), ID, next, other, Point(), prev, eWall::Splittable(), and tASSERT.

02331                            {
02332 #ifdef DEBUG
02333     if (other && other->next)
02334         tASSERT(other->next->Point() == Point());
02335     if (next)
02336         tASSERT(next->Face() == Face());
02337     if (next)
02338         tASSERT(this == next->prev);
02339     if (prev)
02340         tASSERT(this == prev->next);
02341 
02342     if (ID>=0)
02343     {
02344         tASSERT(!Point() || Point()->ID >=0);
02345         tASSERT(!Face()  || Face()->ID  >=0);
02346         tASSERT(!next    || next->ID    >=0);
02347         tASSERT(!prev    || prev->ID    >=0);
02348         tASSERT(!other   || other->ID   >=0);
02349     }
02350 #endif
02351 
02352     // only the three outer edges are allowed to have missing faces
02353     if ( !face )
02354     {
02355         eWall* wall = GetWall();
02356         if ( !wall && other )
02357             wall = other->GetWall();
02358         tASSERT( wall );
02359 
02360         tASSERT( !wall->Splittable() );
02361         // the outer walls are unsplittable ( and right now are the only unsplittable
02362         // walls; all real walls need to be split sometimes when laid out. )
02363     }
02364 
02365     return true;
02366 }

Here is the call graph for this function:

void eHalfEdge::SetPoint ( ePoint p  )  [inline, protected]

Definition at line 416 of file eTess2.h.

References point.

Referenced by eHalfEdge(), and ePoint::Replace().

00416 {point = p;}

Here is the caller graph for this function:

void eHalfEdge::SetFace ( eFace p  )  [inline, protected]

Definition at line 419 of file eTess2.h.

References face.

Referenced by eFace::Create(), and eFace::Unlink().

00419 {face = f;}

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class eDual [friend]

Definition at line 83 of file eTess2.h.

friend class ePoint [friend]

Definition at line 84 of file eTess2.h.

friend class eFace [friend]

Definition at line 85 of file eTess2.h.

friend class eGrid [friend]

Definition at line 86 of file eTess2.h.

friend class eTempEdge [friend]

Definition at line 87 of file eTess2.h.

friend class eWall [friend]

Reimplemented from eWallHolder.

Definition at line 88 of file eTess2.h.

friend class tReferencable< eHalfEdge > [friend]

Definition at line 89 of file eTess2.h.


Member Data Documentation

ePATH_ORIGIN eHalfEdge::origin_ [protected]

Definition at line 214 of file eTess2.h.

Referenced by ClearPathData(), eHalfEdge(), FindPath(), Heap(), PossiblePath(), and SetMinPathLength().

int eHalfEdge::ID [protected]

Definition at line 233 of file eTess2.h.

Referenced by eGrid::AddEdge(), Check(), eGrid::RemoveEdge(), and Simplify().

tJUST_CONTROLLED_PTR<ePoint> eHalfEdge::point [protected]

Definition at line 234 of file eTess2.h.

Referenced by eGrid::DrawLine(), eHalfEdge(), Point(), SetPoint(), Simplify(), and Unlink().

tJUST_CONTROLLED_PTR<eFace> eHalfEdge::face [protected]

Definition at line 235 of file eTess2.h.

Referenced by Check(), eHalfEdge(), Face(), SetFace(), Simplify(), and Unlink().

tJUST_CONTROLLED_PTR<eHalfEdge> eHalfEdge::next [protected]

Definition at line 236 of file eTess2.h.

Referenced by eGrid::AddFaceAll(), Check(), ClampMovement(), eFace::CorrectArea(), eFace::Create(), eGrid::DrawLine(), FindPath(), eGrid::Insert(), eFace::Insideness(), eFace::IsInside(), Next(), Simplify(), eFace::Unlink(), ePoint::Unlink(), and Unlink().

tJUST_CONTROLLED_PTR<eHalfEdge> eHalfEdge::prev [protected]

Definition at line 237 of file eTess2.h.

Referenced by Check(), eFace::Create(), FindPath(), and Unlink().

tJUST_CONTROLLED_PTR<eHalfEdge> eHalfEdge::other [protected]

Definition at line 238 of file eTess2.h.

Referenced by eGrid::AddFaceAll(), Check(), CopyIntoGrid(), eFace::Create(), eGrid::display_simple(), eGrid::DrawLine(), eGrid::Grow(), IntersectWith(), IntersectWithCareless(), eGrid::KillEdge(), Movable(), Other(), Print(), Ratio(), ePoint::Replace(), SetOther(), SetWall(), Simplify(), eGrid::SimplifyNum(), Split(), Splittable(), ePoint::Unlink(), Unlink(), and Vec().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:25:58 2008 for Armagetron Advanced by  doxygen 1.5.4