eGrid Class Reference

#include <eGrid.h>

Inheritance diagram for eGrid:

Inheritance graph
[legend]
Collaboration diagram for eGrid:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 eGrid ()
int WindingNumber () const
int DirectionWinding (const eCoord &dir)
eCoord GetDirection (int winding)
void SetWinding (int number)
void SetWinding (int number, eCoord directions[], bool normalise=true)
void Turn (int &currentWinding, int direction)
void SimplifyNum (int e)
void SimplifyAll (int count=1)
void Check () const
void Create ()
void Clear ()
void Range (REAL range_squared)
void Grow ()
void Render (eCamera *cam, int viewer, REAL &zNear)
ePointInsert (const eCoord &coord, eFace *guessFace=NULL)
eFaceFindSurroundingFace (const eCoord &coord, eFace *start=NULL) const
ePointDrawLine (ePoint *start, const eCoord &end, eWall *wal=NULL, bool change_grid=1)
const tList< eCamera > & Cameras () const
const tList< eGameObject > & GameObjects () const
const tList< eGameObject > & GameObjectsInteresting () const
const tList< eGameObject > & GameObjectsInactive () const
int NumberOfCameras ()
const eCoord & CameraPos (int i)
eCoord CameraGlancePos (int i)
const eCoord & CameraDir (int i)
REAL CameraHeight (int i)
void AddGameObjectInteresting (eGameObject *o)
void RemoveGameObjectInteresting (eGameObject *o)
void AddGameObjectInactive (eGameObject *o)
void RemoveGameObjectInactive (eGameObject *o)
typedef void WallProcessor (eWall *w)
void ProcessWallsInRange (WallProcessor *proc, const eCoord &pos, REAL range, eFace *startFace)

Static Public Member Functions

static eGridCurrentGrid ()

Protected Member Functions

 ~eGrid ()
void display_simple (int viewer, bool floor, bool sr_upperSky, bool sr_lowerSky, REAL flooralpha, bool eWalls, bool gameObjects, REAL &zNear)
void AddFace (eFace *f)
void RemoveFace (eFace *f)
void AddEdge (eHalfEdge *e)
void RemoveEdge (eHalfEdge *e)
void AddPoint (ePoint *p)
void RemovePoint (ePoint *p)
void KillFace (eFace *f)
void KillEdge (eHalfEdge *e)
void KillPoint (ePoint *p)
tControlledPTR< eFaceZombifyFace (eFace *f)
void AddFaceAll (eFace *f)

Protected Attributes

eAxis axis
bool requestCleanup
tJUST_CONTROLLED_PTR< ePointA
tJUST_CONTROLLED_PTR< ePointB
tJUST_CONTROLLED_PTR< ePointC
tJUST_CONTROLLED_PTR< eHalfEdgea
tJUST_CONTROLLED_PTR< eHalfEdgeb
tJUST_CONTROLLED_PTR< eHalfEdgec
REAL maxNormSquared
eCoord base
tList< eHalfEdge, false, true > edges
tList< ePoint, false, true > points
tList< eFace, false, true > faces
tList< eGameObjectgameObjects
tList< eGameObjectgameObjectsInactive
tList< eGameObjectgameObjectsInteresting
tList< eCameracameras
tList< eWallwallsNotYetInserted

Friends

class eCamera
class eFace
class eHalfEdge
class ePoint
class eGameObject
class eWall
class tReferencable< eGrid >


Detailed Description

Definition at line 76 of file eGrid.h.


Constructor & Destructor Documentation

eGrid::~eGrid (  )  [protected]

Definition at line 2692 of file eGrid.cpp.

References NULL.

02693 {
02694     if (currentGrid == this)
02695         currentGrid = NULL;
02696 }

eGrid::eGrid (  ) 

Definition at line 2681 of file eGrid.cpp.

02682         :        requestCleanup(false),
02683         A(NULL), B(NULL), C(NULL),
02684         a(NULL), b(NULL), c(NULL),
02685         maxNormSquared(-1),
02686         base(100,100)
02687 {
02688     currentGrid = this;
02689 }


Member Function Documentation

int eGrid::WindingNumber (  )  const [inline]

Definition at line 93 of file eGrid.h.

References axis, and eAxis::WindingNumber().

Referenced by CheckLoop(), and gCycleMovement::SetWindingNumberWrapped().

00093 {return axis.WindingNumber();}

Here is the call graph for this function:

Here is the caller graph for this function:

int eGrid::DirectionWinding ( const eCoord &  dir  ) 

Definition at line 675 of file eGrid.cpp.

References axis, and eAxis::NearestWinding().

Referenced by gCycle::gCycle(), gCycleMovement::gCycleMovement(), and gAIPlayer::Think().

00676 {
00677     return axis.NearestWinding(dir);
00678 }

Here is the call graph for this function:

Here is the caller graph for this function:

eCoord eGrid::GetDirection ( int  winding  ) 

Definition at line 683 of file eGrid.cpp.

References axis, and eAxis::GetDirection().

Referenced by gCycleMovement::DistanceToDestination(), gCycleMovement::DoTurn(), gCycle::gCycle(), gCycleMovement::GetMaxSpaceAhead(), gCycle::ReadSync(), sg_GetSensor(), gCycleMovement::Timestep(), and gJoystick::Turn().

00684 {
00685     return axis.GetDirection(winding);
00686 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::SetWinding ( int  number  ) 

Definition at line 691 of file eGrid.cpp.

References axis, and eAxis::Init().

Referenced by gParser::parseAxes(), and gArena::PrepareGrid().

00692 {
00693     axis.Init(number);
00694 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::SetWinding ( int  number,
eCoord  directions[],
bool  normalise = true 
)

Definition at line 700 of file eGrid.cpp.

References axis, and eAxis::Init().

00701 {
00702     axis.Init(number, directions, normalise);
00703 }

Here is the call graph for this function:

void eGrid::Turn ( int &  currentWinding,
int  direction 
)

Definition at line 708 of file eGrid.cpp.

References axis, and eAxis::Turn().

Referenced by gCycleMovement::DistanceToDestination(), gCycleMovement::DoTurn(), draw_eWall(), gCycleMovement::GetMaxSpaceAhead(), sg_GetSensor(), gCycleMovement::Timestep(), and gJoystick::Turn().

00709 {
00710     axis.Turn(currentWinding, direction);
00711 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::SimplifyNum ( int  e  ) 

Definition at line 2006 of file eGrid.cpp.

References tRecorderSync< DATA >::Archive(), Check(), edges, GrowingArrayBase::Len(), eHalfEdge::other, se_simplifyEdges, se_simplifyEdgesSuccess, eHalfEdge::Simplify(), and tASSERT.

Referenced by SimplifyAll().

02006                             {
02007 #ifdef DEBUG
02008     Check();
02009 #endif
02010 
02011     if (e>=0 && e < edges.Len()){
02012         eHalfEdge *E=edges(e);
02013 #ifdef DEBUG
02014         eHalfEdge *Esave=E;
02015 #endif
02016         if ( !E || !E->other )
02017             return;
02018 
02019         // this point will be removed. Make sure it is none of the points on the outer rim.
02020         ePoint * toBeRemoved = E->other->Point();
02021         if ( toBeRemoved == A || toBeRemoved == B || toBeRemoved == C )
02022             return;
02023 
02024         tRecorderSync< int >::Archive( "_GRID_SIMPLIFY", 8, e );
02025 
02026         if ( E->Simplify(this) )
02027         {
02028             se_simplifyEdges += se_simplifyEdgesSuccess;
02029         }
02030 
02031 #ifdef DEBUG
02032         tASSERT(Esave);
02033 
02034         Check();
02035 #endif
02036     }
02037 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::SimplifyAll ( int  count = 1  ) 

Definition at line 2041 of file eGrid.cpp.

References edges, faces, GrowingArrayBase::Len(), requestCleanup, se_simplifyEdges, and SimplifyNum().

Referenced by gGame::GameLoop().

02041                                 {
02042     if (requestCleanup)
02043     {
02044         requestCleanup = false;
02045         for (int i=faces.Len()-1; i>=0; i--)
02046             requestCleanup |= faces(i)->CorrectArea();
02047     }
02048 
02049 
02050     static int counter=0;
02051 
02052     // try to simplify at least one edge
02053     se_simplifyEdges++;
02054 
02055     for(;count>0 && se_simplifyEdges>0;count--,se_simplifyEdges--){
02056         counter--;
02057 
02058         if (counter<0 || counter>=edges.Len())
02059             counter=edges.Len()-1;
02060 
02061         SimplifyNum(counter);
02062     }
02063 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::Check (  )  const

Definition at line 205 of file eGrid.cpp.

References c, edges, faces, GrowingArrayBase::Len(), points, and tASSERT.

Referenced by Create(), DrawLine(), gGame::GameLoop(), Grow(), Insert(), gNetPlayerWall::PartialCopyIntoGrid(), gNetPlayerWall::real_CopyIntoGrid(), eGameObject::s_Timestep(), eHalfEdge::Simplify(), and SimplifyNum().

00205                        {
00206     //    return;
00207     if ( a )
00208     {
00209         tASSERT( a->Point() == B );
00210         tASSERT( a->other->Point() == C );
00211         tASSERT( b->Point() == C );
00212         tASSERT( b->other->Point() == A );
00213         tASSERT( c->Point() == A );
00214         tASSERT( c->other->Point() == B );
00215     }
00216 
00217 #ifdef DEBUG_EXPENSIVE
00218     if (!doCheck)
00219         return;
00220 
00221     int i;
00222     for (i = points.Len()-1; i>=0; i--)
00223         points(i)->Check();
00224 
00225     for (i = faces.Len()-1; i>=0; i--)
00226         faces(i)->Check();
00227 
00228     for (i = edges.Len()-1; i>=0; i--)
00229         edges(i)->Check();
00230 #endif
00231 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::Create (  ) 

Definition at line 2071 of file eGrid.cpp.

References AddFaceAll(), c, Check(), Clear(), eCoord, eWall, maxNormSquared, requestCleanup, and tNEW.

Referenced by gArena::PrepareGrid(), and Range().

02071                   {
02072     currentGrid = this;
02073 
02074     if (!A)
02075         Clear();
02076 
02077     base=eCoord(20,100);
02078 
02079 #ifdef DEBUG
02080     doCheck = true;
02081 #endif
02082     requestCleanup = false;
02083 
02084 
02085     A=tNEW(ePoint) (base.Turn(1,0));
02086     B=tNEW(ePoint) (base.Turn(-.5,.87));
02087     C=tNEW(ePoint) (base.Turn(-.5,-.87));
02088 
02089     a=tNEW(eHalfEdge) (B,C,tNEW(eWall(this)));
02090     b=tNEW(eHalfEdge) (C,A,tNEW(eWall(this)));
02091     c=tNEW(eHalfEdge) (A,B,tNEW(eWall(this)));
02092 
02093     a->other->next = c->other;
02094     a->other->prev = b->other;
02095     b->other->next = a->other;
02096     b->other->prev = c->other;
02097     c->other->next = b->other;
02098     c->other->prev = a->other;
02099 
02100     AddFaceAll(tNEW(eFace) (a,b,c));
02101 
02102     maxNormSquared=base.NormSquared();
02103 
02104 #ifdef DEBUG
02105     Check();
02106 #endif
02107 
02108 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::Clear (  ) 

Definition at line 2111 of file eGrid.cpp.

References c, eHalfEdge::ClearPathData(), eGameObject::DeleteAll(), eCoord, edges, faces, GrowingArrayBase::Len(), maxNormSquared, NULL, points, RemoveEdge(), RemoveFace(), and RemovePoint().

Referenced by Create(), and exit_game_grid().

02111                  {
02112     eHalfEdge::ClearPathData();
02113 
02114     base=eCoord(0,100);
02115     maxNormSquared=0;
02116 
02117     int i;
02118     for(i=faces.Len()-1; i>=0; i--)
02119     {
02120         faces(i)->Unlink();
02121         RemoveFace(faces(i));
02122     }
02123     for(i=points.Len()-1; i>=0; i--)
02124     {
02125         points(i)->Unlink();
02126         RemovePoint(points(i));
02127     }
02128     for(i=edges.Len()-1; i>=0; i--)
02129     {
02130         edges(i)->Unlink();
02131         RemoveEdge(edges(i));
02132     }
02133 
02134 
02135     A=B=C=NULL;
02136     a=b=c=NULL;
02137 
02138     eGameObject::DeleteAll( this );
02139 
02140     //  se_faceReplacements.clear();
02141 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::Range ( REAL  range_squared  ) 

Definition at line 2202 of file eGrid.cpp.

References Create(), Grow(), maxNormSquared, NULL, and se_maxGridSize.

Referenced by DrawLine(), and Insert().

02202                                  {
02203     if (A==NULL)
02204         Create();
02205     //    tERR_ERROR_INT("Wanted to insert something into the nonexistant grid!");
02206 
02207     // the magic factor of 4 is chosen so that no points can be added outside of the
02208     // current tiangle abc added by Grow().
02209     while (NormSquared * 4 > maxNormSquared && maxNormSquared < se_maxGridSize )
02210         Grow();
02211 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::Grow (  ) 

Definition at line 2143 of file eGrid.cpp.

References AddFaceAll(), c, Check(), eWall, maxNormSquared, NULL, eHalfEdge::other, se_maxGridSize, and tNEW.

Referenced by DrawLine(), and Range().

02144 {
02145 #ifdef DEBUG
02146     Check();
02147 #endif
02148 
02149     if ( maxNormSquared > se_maxGridSize )
02150         return;
02151 
02152     base = base.Turn(-4,0);
02153     maxNormSquared=base.NormSquared();
02154 
02155     a->ClearWall();
02156     b->ClearWall();
02157     c->ClearWall();
02158 
02159     ePoint *newA=tNEW(ePoint) (base.Turn(1,0));
02160     ePoint *newB=tNEW(ePoint) (base.Turn(-.5,.87));
02161     ePoint *newC=tNEW(ePoint) (base.Turn(-.5,-.87));
02162 
02163     eHalfEdge *newa=tNEW(eHalfEdge) (newB,newC,tNEW(eWall(this)));
02164     eHalfEdge *newb=tNEW(eHalfEdge) (newC,newA,tNEW(eWall(this)));
02165     eHalfEdge *newc=tNEW(eHalfEdge) (newA,newB,tNEW(eWall(this)));
02166 
02167     eHalfEdge *AnewB=tNEW(eHalfEdge) (A,newB,NULL);
02168     eHalfEdge *AnewC=tNEW(eHalfEdge) (A,newC,NULL);
02169     eHalfEdge *BnewA=tNEW(eHalfEdge) (B,newA,NULL);
02170     eHalfEdge *BnewC=tNEW(eHalfEdge) (B,newC,NULL);
02171     eHalfEdge *CnewA=tNEW(eHalfEdge) (C,newA,NULL);
02172     eHalfEdge *CnewB=tNEW(eHalfEdge) (C,newB,NULL);
02173 
02174     AddFaceAll(tNEW(eFace) (a->other,BnewA,CnewA->other));
02175     AddFaceAll(tNEW(eFace) (b->other,CnewB,AnewB->other));
02176     AddFaceAll(tNEW(eFace) (c->other,AnewC,BnewC->other));
02177 
02178     AddFaceAll(tNEW(eFace) (newa,AnewC->other,AnewB));
02179     AddFaceAll(tNEW(eFace) (newb,BnewA->other,BnewC));
02180     AddFaceAll(tNEW(eFace) (newc,CnewB->other,CnewA));
02181 
02182     a=newa;
02183     b=newb;
02184     c=newc;
02185 
02186     A=newA;
02187     B=newB;
02188     C=newC;
02189 
02190     a->other->next = c->other;
02191     a->other->prev = b->other;
02192     b->other->next = a->other;
02193     b->other->prev = c->other;
02194     c->other->next = b->other;
02195     c->other->prev = a->other;
02196 
02197 #ifdef DEBUG
02198     Check();
02199 #endif
02200 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::Render ( eCamera cam,
int  viewer,
REAL zNear 
)

Definition at line 599 of file eDisplay.cpp.

References CameraHeight(), display_simple(), ls, ModelMatrix(), ProjMatrix(), rMIRROR_ALL, rMIRROR_OBJECTS, rMIRROR_WALLS, eCamera::SetRenderingMain(), sr_floorMirror, sr_floorMirror_strength, sr_glOut, sr_lowerSky, sr_upperSky, us, and z.

00599                                                          {
00600     if (!sr_glOut)
00601         return;
00602 #ifndef DEDICATED
00603     ProjMatrix();
00604 
00605     z=CameraHeight(viewer);
00606     if ( zNear > z )
00607     {
00608         zNear = z;
00609     }
00610 
00611     if (sr_floorMirror){
00612         ModelMatrix();
00613         glScalef(1,1,-1);
00614 
00615         if (z>10) z=10;
00616         glFrontFace(GL_CW);
00617 
00618         bool us=false;
00619         bool ls=false;
00620 
00621         if (sr_floorMirror>=rMIRROR_ALL){
00622             us=sr_upperSky;
00623             ls=sr_lowerSky;
00624         }
00625         else if (sr_floorMirror>=rMIRROR_WALLS){
00626             if (sr_lowerSky)
00627                 ls=true;
00628             else if (sr_upperSky)
00629                 us=true;
00630         }
00631 
00632         cam->SetRenderingMain(false);
00633         display_simple(viewer,false,
00634                        us,ls,
00635                        0,
00636                        sr_floorMirror>=rMIRROR_WALLS,
00637                        sr_floorMirror>=rMIRROR_OBJECTS,
00638                        zNear);
00639         z=CameraHeight(viewer);
00640         glFrontFace(GL_CCW);
00641         ModelMatrix();
00642         glScalef(1,1,-1);
00643 
00644 
00645         cam->SetRenderingMain(true);
00646         display_simple(viewer,true,
00647                        sr_upperSky,sr_lowerSky,
00648                        1-sr_floorMirror_strength,
00649                        true,true,zNear);
00650 
00651     }
00652     else
00653     {
00654         cam->SetRenderingMain(true);
00655         display_simple(viewer,true,
00656                        sr_upperSky,sr_lowerSky,
00657                        1,
00658                        true,true,zNear);
00659     }
00660 
00661 
00662 #ifdef EVENT_DEB
00663     //  for(int i=eEdge_crossing.Len()-1;i>=0;i--){
00664     //    eEdge_crossing(i)->Render();
00665     //  }
00666 #endif
00667 #endif
00668 }

Here is the call graph for this function:

eGrid * eGrid::CurrentGrid (  )  [static]

Definition at line 2069 of file eGrid.cpp.

Referenced by cWidget::Map::DrawObjects(), fill_audio(), and se_Cleanup().

02069 {return currentGrid;}

Here is the caller graph for this function:

ePoint * eGrid::Insert ( const eCoord &  coord,
eFace guessFace = NULL 
)

Definition at line 2494 of file eGrid.cpp.

References Check(), DrawLine(), FindSurroundingFace(), eHalfEdge::next, NULL, eHalfEdge::Point(), Range(), and tASSERT.

Referenced by eHalfEdge::CopyIntoGrid(), eTempEdge::CopyIntoGrid(), DrawLine(), gParser::parseObstacleWall(), gParser::parseWall(), gParser::parseWallLine(), and gParser::parseWallRect().

02494                                                    {
02495 #ifdef DEBUG
02496     Check();
02497 #endif
02498     Range(x.NormSquared());
02499 
02500     eFace *f = FindSurroundingFace(x, start);
02501     if (!f)
02502         return NULL;
02503 
02504     /*
02505       for(int i=faces.Len()-1;i>=0;i--)
02506       {
02507          eFace *f = faces(i);
02508          if (f->IsInside(x)){
02509 
02510     */
02511 
02512     eHalfEdge *run = f->edge;
02513     int j;
02514     for(j=0;j<=2;j++){
02515         if (*run->Point() == x)
02516             return run->Point();
02517         run = run->next;
02518     }
02519     tASSERT (run == f->edge);
02520 
02521 #ifdef DEBUG
02522     // check again ( possibly with breakpoint )
02523     for(j=0;j<=2;j++){
02524         if (*run->Point() == x)
02525             return run->Point();
02526         run = run->next;
02527     }
02528     tASSERT (run == f->edge);
02529 #endif
02530 
02531     return DrawLine(f->edge->Point(), x);
02532     /*
02533       break;
02534          }
02535       }
02536       return NULL; 
02537     */
02538 }

Here is the call graph for this function:

Here is the caller graph for this function:

eFace * eGrid::FindSurroundingFace ( const eCoord &  coord,
eFace start = NULL 
) const

Definition at line 2543 of file eGrid.cpp.

References con, eCoord, eDual::Edge(), eHalfEdge::Face(), faces, eDual::ID, in, eFace::IsInside(), GrowingArrayBase::Len(), eHalfEdge::Next(), NULL, eHalfEdge::Other(), eHalfEdge::Point(), REAL, score, tASSERT, and eHalfEdge::Vec().

Referenced by gCycleExtrapolator::gCycleExtrapolator(), Insert(), and ProcessWallsInRange().

02543                                                                              {
02544     if (faces.Len()<1)
02545         return NULL;
02546 
02547     if (!currentFace || currentFace->ID < 0 || currentFace->ID >= faces.Len() || faces(currentFace->ID) != currentFace)
02548         currentFace=faces(0);
02549 
02550     int timeout=faces.Len()+2;
02551 
02552     while (currentFace && timeout >0 && !currentFace->IsInside(pos)){
02553         timeout--;
02554 
02555         eHalfEdge *run   = currentFace->Edge(); // runs through all edges of the face
02556         eHalfEdge *best  = NULL;                // the best face to leave
02557         eHalfEdge *first = NULL;
02558         eHalfEdge *in    = NULL;
02559         REAL bestScore   = 0;
02560 
02561 
02562         // look for the best way out
02563         while(run != first)
02564         {
02565             if (run == in)
02566             {
02567                 run = run->Next();
02568                 continue;
02569             }
02570 
02571             if ( run->Other() && run->Other()->Face() )
02572             {
02573                 eCoord vec=pos - (*run->Point()); // the vector to our destination
02574 
02575                 REAL score = run->Vec() * vec;
02576 
02577                 if (score > bestScore)
02578                 {
02579                     best      = run;
02580                     bestScore = score;
02581                 }
02582             }
02583 
02584             if (!first)
02585                 first = run;
02586 
02587             run = run->Next();
02588         }
02589 
02590         if (best)
02591         {
02592             in = best->Other();
02593             tASSERT(in);
02594 
02595             currentFace = in->Face();
02596             timeout--;
02597         }
02598         else
02599         {
02600             timeout = 0;
02601             //                  st_Breakpoint();
02602         }
02603     }
02604 
02605     if (timeout<=0){ // normal way failed
02606 #ifdef DEBUG
02607         con << "WARNING! FindSurroundingFace failed.\n";
02608 #endif
02609         // do it the hard way:
02610         for(int i=faces.Len()-1;i>=0;i--)
02611             if(faces(i)->IsInside(pos)){
02612                 currentFace=faces(i);
02613                 i=-1;
02614             }
02615     }
02616 
02617     return currentFace;
02618 }

Here is the call graph for this function:

Here is the caller graph for this function:

ePoint * eGrid::DrawLine ( ePoint start,
const eCoord &  end,
eWall wal = NULL,
bool  change_grid = 1 
)

Definition at line 720 of file eGrid.cpp.

References AddFaceAll(), bb, c, Check(), eFace::CorrectArea(), d, eCoord, eDual::edge, ePoint, EPS, F, eHalfEdge::Face(), G, eWallHolder::GetWall(), good(), Grow(), Insert(), eHalfEdge::IntersectWithCareless(), KillEdge(), KillPoint(), eHalfEdge::Movable(), eHalfEdge::next, NULL, eHalfEdge::other, eHalfEdge::point, eHalfEdge::Point(), Range(), eHalfEdge::Ratio(), REAL, ePoint::Replace(), requestCleanup, score, se_EstimatedRangeOfMult(), se_LinkFaces(), se_maxGridSize, se_simplifyEdges, se_simplifyEdgesNew, eHalfEdge::SetWall(), eHalfEdge::Split(), eWall::Splittable(), eHalfEdge::Splittable(), st_Breakpoint(), tASSERT, tERR_ERROR_INT, tNEW, eHalfEdge::Vec(), and ZombifyFace().

Referenced by eHalfEdge::CopyIntoGrid(), eTempEdge::CopyIntoGrid(), gParser::DrawRim(), and Insert().

00720                                                                                     {
00721     // for every edge we add, allow to simplify
00722     se_simplifyEdges += se_simplifyEdgesNew;
00723 
00724     // prepare a teporary edge so we always know what the wall we are placing looks like
00725     tStackObject< eTempEdge > toBePlaced( *start, end, w );
00726     //tJUST_CONTROLLED_PTR< eWall > wal( w );
00727 
00728     // sanity check
00729     if ( !finite( end.x ) || !finite( end.y ) )
00730         return start;
00731 
00732     Range(end.NormSquared());
00733     int restart=1;
00734     //  eEdge *todo=tNEW(eEdge) (start,end,wal);
00735 
00736 
00737     // now the loop: go from source to destination,
00738     // "rotate" the edges we cross out of our way (if possible)
00739     // or cut them in half.
00740 
00741     tJUST_CONTROLLED_PTR<eHalfEdge> currentEdge  = NULL;
00742     // the edge we are currently considering.
00743     // the line we are to draw starts at currentEdge->Point()
00744     // and goes into currentEdge->Face().
00745 
00746 
00747     REAL left_test,right_test;
00748     int exactly_onLeft=0;
00749 
00750     tASSERT(start->edge);
00751 
00752 #ifdef DEBUG
00753     bool foundCurrentEdge;
00754     static const int laststarts_max = 10;
00755     ePoint *laststarts[laststarts_max];
00756 #endif
00757 
00758     eCoord dir=eCoord(1,1); // the direction we are going
00759 
00760     int timeout = se_drawLineTimeout;
00761 
00762     // distance to end to know when we are going backwards
00763     REAL distToEnd = ( *start - end ).NormSquared();
00764     ePoint * lastStart = start;
00765 
00766     bool goon=1;
00767     while (goon && dir.NormSquared()>0){
00768 #ifdef DEBUG
00769         static int count = 0;
00770         count++;
00771         //    if (count == 40)
00772         //      st_Breakpoint();
00773 #endif
00774 
00775         dir=end-*start; // the direction we are going
00776 
00777         // check if we got closer to the end, if not, accelerate timeout and set breakpoint
00778         REAL newDistToEnd = dir.NormSquared();
00779         // std::cout << distToEnd << ", " << newDistToEnd << "\n";
00780         if ( newDistToEnd > distToEnd && start != lastStart )
00781         {
00782             //st_Breakpoint();
00783             timeout -= 100;
00784         }
00785         distToEnd = newDistToEnd;
00786         lastStart = start;
00787 
00788 #ifdef DEBUG
00789         for (int i = laststarts_max-1; i>=1; i--)
00790             laststarts[i] = laststarts[i-1];
00791 
00792         laststarts[0] = start;
00793 
00794         if (timeout < 10)
00795             st_Breakpoint();
00796 #endif
00797 
00798         if (timeout-- < 0)
00799         {
00800             requestCleanup = true;
00801             return start;  // give up.
00802         }
00803 
00804 #ifdef DEBUG
00805         Check();
00806 #endif
00807 
00808         // first, we need to find the first eFace:
00809         //    int i;
00810 
00811 #ifdef DEBUG
00812         //    if (doCheck && start->id == 4792)
00813         //      st_Breakpoint();
00814 #endif
00815 
00816         tASSERT(restart || currentEdge);
00817 
00818         if (restart){
00819             exactly_onLeft = -1;
00820 
00821             eHalfEdge *run  = start->edge;
00822             tASSERT(run);
00823             eHalfEdge *stop = run;
00824 
00825             eCoord lvec = run->Vec();
00826             eCoord rvec;
00827             left_test = lvec * dir;
00828 
00829             eHalfEdge *best = NULL;
00830             REAL best_score = -100;
00831 
00832             currentEdge = NULL;
00833 
00834             while (run)
00835             {
00836                 eHalfEdge *next = run->next->next;
00837                 tASSERT(next->next = run);
00838                 next = next->other;
00839 
00840                 tASSERT(next->Point() == start);
00841 
00842                 right_test = left_test;
00843                 rvec = lvec;
00844                 lvec = next->Vec();
00845                 left_test = lvec * dir;
00846 
00847                 if (right_test <= 0 && left_test >= 0)
00848                 {
00849                     bool good = rvec * lvec < 0 && right_test < 0;
00850                     if (good)
00851                         next = NULL;
00852 
00853                     if (good || !currentEdge)
00854                     {
00855                         currentEdge = run;
00856 
00857                         // are dir and lvec exactly on one line?
00858                         exactly_onLeft=(left_test<=EPS * EPS * se_EstimatedRangeOfMult(lvec,dir));
00859                     }
00860                 }
00861 
00862                 REAL score = right_test * left_test;
00863                 if (right_test < 0 && left_test < 0)
00864                     score *= -1;     // here, - * - still is -.....
00865 
00866                 if (!best || score > best_score  && rvec * lvec < 0
00867                    )
00868                     best = run;
00869 
00870                 run = next;
00871                 if (run == stop)
00872                     run = NULL;
00873             }
00874 
00875 #ifdef DEBUG
00876             foundCurrentEdge = currentEdge;
00877             //      tASSERT(run || currentEdge);
00878 #endif
00879 
00880 
00881             if (!currentEdge && best)
00882             {
00883                 if (restart >= 3)
00884                 {
00885                     requestCleanup = true;
00886                     // give up.
00887                     // st_Breakpoint();
00888                     return start;
00889                 }
00890 
00891                 start = Insert(*start, best->Face());
00892                 restart ++;
00893                 continue;
00894 
00895                 currentEdge = best;
00896             }
00897 
00898             if (!currentEdge)
00899                 tERR_ERROR_INT("Point " << *start << " does not have a eFace in direction "
00900                                << dir << "!");
00901             // I know this bug happens a lot more often than"
00902             //  " I'd like to. Don't send a bug report!");
00903 
00904             restart=0;
00905         }
00906 
00907         if (start != currentEdge->Point())
00908             tERR_ERROR_INT("currentEdge not correct!");
00909 
00910         eHalfEdge *rightFromCurrent = currentEdge->next;
00911         eHalfEdge *leftFromCurrent  = rightFromCurrent->next;
00912         tASSERT (currentEdge == leftFromCurrent->next);
00913         // are we finished?
00914 
00915         if (exactly_onLeft<0)
00916         {
00917             eCoord lvec = leftFromCurrent->Vec();
00918             exactly_onLeft =  dir * lvec < EPS * EPS * se_EstimatedRangeOfMult(lvec, dir);
00919         }
00920 
00921         eCoord left_point_to_dest = end - *(leftFromCurrent->Point());
00922         eCoord lvec               = rightFromCurrent->Vec();
00923 
00924         REAL test = lvec * left_point_to_dest;
00925         if(test<0){
00926             // endpoint lies within current eFace; cut it into three and be finnished.
00927 
00928             // XXX have to check that we didnt start from a edge that jumps
00929             // to another field. If thats the case, then recall drawLine on the
00930             // other field
00931             goon=0;
00932 
00933             /*
00934               Should this figure get distorted, align the :
00935 
00936               :   C        a        B
00937               :   #################
00938               :   #\           _/#
00939               :   # \ cc   bb_/ #
00940               :   #  \     _/  #
00941               :   #   \  _/  ##
00942               : b #   D\/   #
00943               :   #    /  ##  c
00944               :   # aa/  #
00945               :   #  / ##
00946               :   # / #
00947               :   #/##
00948               :   ##
00949               :   A
00950 
00951 
00952             */
00953 
00954             ePoint *A=currentEdge->Point();
00955 
00956             if ((*A) == end){
00957 #ifdef DEBUG
00958                 Check();
00959 #endif
00960                 return A;
00961             }
00962             else{
00963                 eHalfEdge* a=rightFromCurrent;
00964                 eHalfEdge* b=leftFromCurrent;
00965                 eHalfEdge* c=currentEdge;
00966 
00967                 ePoint*    B=a->Point();
00968                 ePoint*    C=b->Point();
00969 
00970                 if ((*B) == end)
00971                 {
00972                     c->SetWall(toBePlaced.Wall());
00973                     return B;
00974                 }
00975 
00976                 if ((*C) == end)
00977                 {
00978                     tASSERT( b->other );
00979                     b->other->SetWall(toBePlaced.Wall());
00980                     return C;
00981                 }
00982 
00983                 if(!exactly_onLeft)
00984                 {
00985                     ePoint*    D=tNEW(ePoint(end));
00986 #ifdef DEBUG
00987                     Check();
00988 #endif
00989                     tControlledPTR< eFace > oldFace = ZombifyFace(a->Face());
00990 
00991                     // no problem: D really lies within current eFace.
00992                     // just split it in three parts:
00993 
00994                     eHalfEdge *aa = tNEW(eHalfEdge) (A, D);
00995                     eHalfEdge *bb = tNEW(eHalfEdge) (B, D);
00996                     eHalfEdge *cc = tNEW(eHalfEdge) (C, D);
00997 
00998                     //    aa->SetOther(   tNEW(eHalfEdge) (D));
00999                     //      bb->SetOther(   tNEW(eHalfEdge) (D));
01000                     //    cc->SetOther(   tNEW(eHalfEdge) (D));
01001 
01002                     AddFaceAll(tNEW(eFace) (b,aa,cc->other, oldFace ));
01003                     AddFaceAll(tNEW(eFace) (bb,aa->other,c, oldFace ));
01004                     AddFaceAll(tNEW(eFace) (bb->other,a,cc, oldFace ));
01005 
01006                     aa->SetWall(toBePlaced.Wall());
01007 
01008 #ifdef DEBUG
01009                     Check();
01010 #endif
01011                     return D;
01012                 }
01013                 else // exactly_onLeft
01014                 {
01015                     /*
01016                       Should this figure get distorted, align the ":"
01017 
01018                       Bad luck, D lies on eEdge b. We are going to need
01019                       the other triangle touching b.
01020 
01021 
01022                       :          C
01023                       :          #
01024                       :         ####
01025                       :        # #  ##
01026                       :       #  #    ##
01027                       :  e2  #   #      ##
01028                       :     #    #        ##  a
01029                       :    #   D X          ##
01030                       : E #      #            ##
01031                       :   #      # b            ##
01032                       :    #     #                ## B
01033                       :     #    #              ##
01034                       :     #    #            ##
01035                       :      #   #          ##
01036                       :  e1   #  #        ##
01037                       :       #  #      ##   c
01038                       :        # #    ##
01039                       :         ##  ##
01040                       :         ####
01041                       :          #
01042                       :          A
01043 
01044                       Make four new faces around D. 4 new half 
01045                       segments DA, DB, DC and DE are created.
01046                       :          C
01047                       :          #
01048                       :         #|##
01049                       :        # |  ##
01050                       :       #  | DC ##
01051                       :  e2  #   |      ##
01052                       :     #    | D      ##  a
01053                       :    #  ___X____      ##
01054                       : E #__/   |    \___    ##
01055                       :   #  DE  |     DB \___  ##
01056                       :    #     |            \___## B
01057                       :     #    | DA           ##
01058                       :     #    |            ##
01059                       :      #   |          ##
01060                       :  e1   #  |        ##
01061                       :       #  |      ##   c
01062                       :        # |    ##
01063                       :         #|  ##
01064                       :         #|##
01065                       :          #
01066                       :          A
01067 
01068                     */
01069 
01070                     tASSERT(b->other);
01071 
01072                     // eFace *G=b->other->face;
01073 
01074                     // tASSERT(G);
01075 
01076                     eHalfEdge *e1=b->other->next;
01077                     eHalfEdge *e2=e1->next;
01078                     tASSERT(e2);
01079                     ePoint *E=e2->point;
01080                     tASSERT(E);
01081                     // easy: edge is just right
01082                     if (*E == end)
01083                     {
01084                         e2->other->SetWall(toBePlaced.Wall());
01085                         return E;
01086                     }
01087 
01088                     // ask walls for permission to lay a parallel wall
01089                     //                                  if ( b->GetWall() && wal && !wal->RunsParallel( b->GetWall() ) )
01090                     //                                          return start;
01091                     //                                  if ( b->other->GetWall() && wal && !wal->RunsParallel( b->other->GetWall() ) )
01092                     //                                          return start;
01093 
01094                     // ask edge if it is splittalbe
01095                     if ( !b->Splittable() )
01096                         return start;
01097 
01098                     // create endpoint
01099                     ePoint*    D=tNEW(ePoint(end));
01100 #ifdef DEBUG
01101                     Check();
01102 #endif
01103                     // delete faces inside quad ABCE and connect A...E with new
01104                     // ePoint D.
01105 
01106                     tControlledPTR< eFace > oldFace_b = ZombifyFace( b->Face());
01107                     tControlledPTR< eFace > oldFace_bOther = ZombifyFace( b->other->Face() );
01108 
01109                     eHalfEdge *DC, *DA;
01110                     b->Split( DC, DA, D );
01111                     KillEdge(b);
01112                     DC = DC->other;
01113 
01114                     tASSERT( DC->Point() == D );
01115                     tASSERT( DA->Point() == D );
01116                     tASSERT( DC->other->Point() == C );
01117                     tASSERT( DA->other->Point() == A );
01118 
01119                     eHalfEdge *DE=tNEW(eHalfEdge) (D,E);
01120                     eHalfEdge *DB=tNEW(eHalfEdge) (D,B);
01121                     DA->other->SetWall(toBePlaced.Wall());
01122 
01123                     AddFaceAll(tNEW(eFace) (DE,e2,DA->other, oldFace_bOther ) );
01124                     AddFaceAll(tNEW(eFace) (DC,e1,DE->other, oldFace_bOther ) );
01125                     AddFaceAll(tNEW(eFace) (DB,a ,DC->other, oldFace_b ) );
01126                     AddFaceAll(tNEW(eFace) (DA,c ,DB->other, oldFace_b ) );
01127 
01128 #ifdef DEBUG
01129                     Check();
01130 #endif
01131                     return D;
01132                 }
01133             }
01134             // finnished!
01135         }
01136 
01137 
01138         else{
01139             // some definitions and trivial tests:
01140 
01141             eHalfEdge* c = currentEdge;
01142             eHalfEdge* e = rightFromCurrent;
01143             eHalfEdge* d = leftFromCurrent;
01144 
01145             eFace  *F = c->Face();
01146             ePoint *C = c->Point();
01147 
01148             if (*C == end){
01149 #ifdef DEBUG
01150                 Check();
01151 #endif
01152                 return C;
01153             }
01154             //      eHalfEdge *dummy=NULL;
01155 
01156 
01157             ePoint *D = d->Point();
01158 
01159             if (*D == end){
01160                 d->other->SetWall(toBePlaced.Wall());
01161 
01162 #ifdef DEBUG
01163                 Check();
01164 #endif
01165                 return D;
01166             }
01167 
01168             ePoint *B= e->Point();
01169 
01170             if (*B == end){
01171                 c->SetWall(toBePlaced.Wall());
01172 
01173 #ifdef DEBUG
01174                 Check();
01175 #endif
01176                 return B;
01177             }
01178 
01179             // if dir is parallel with eEdge c:
01180 
01181             /*
01182               if(exactly_onLeft){
01183               todo->Split(d,dummy);
01184               delete todo;
01185               todo=dummy;
01186               start=todo->p[0];
01187               restart=1;
01188               }
01189                
01190               else
01191             */
01192             {
01193                 if (!e->other || !e->other->Face())
01194                 {
01195                     // tERR_ERROR_INT ("Left Grid!");
01196                     // z-man: no need for an error! We can go on!
01197                     // nevertheless, should you get here in the debugger, I would
01198                     // ask you to follow the rest of this code block carefully
01199                     // and send me a trace ( which lines were visited, which pointers
01200                     // were set ) of it.
01201                     st_Breakpoint();
01202 
01203                     // grid rift or outer rim?
01204                     bool rift = false;
01205 
01206                     if ( !e->other )
01207                     {
01208                         // all gridded edges have other correctly set. Even the outer ones.
01209                         rift = true;
01210                     }
01211 
01212                     // get the wall of the halfopen edge
01213                     eWall* wall = e->GetWall();
01214                     if ( !wall && e->other )
01215                         wall = e->other->GetWall();
01216 
01217                     // no wall or splittable wall? This is not the outer edge, it is a rift.
01218                     if ( !wall || wall->Splittable() )
01219                         rift = true;
01220 
01221                     // wall is useless when e is not complete; forgt about it.
01222                     if ( !e->other )
01223                         wall = 0;
01224 
01225                     if ( rift )
01226                     {
01227                         // a rift! topology police to the rescue ( after eliminating
01228                         // the witnesses, of course )!
01229                         toBePlaced.Wall()->SplitByActive( wall );
01230                         return start;
01231                     }
01232                     else
01233                     {
01234                         // line to be drawn hit the outer edge.
01235                         // should not happen either; Range() should have prevented it.
01236                         // grow one step anyway:
01237                         Grow();
01238 
01239                         // test again
01240                         if (!e->other || !e->other->Face())
01241                         {
01242                             // still no luck? a case for the topology police.
01243                             toBePlaced.Wall()->SplitByActive( 0 );
01244                             return start;
01245                         }
01246                     }
01247                     // z-man: Thanks for debugging, this is all I need.
01248                 }
01249 
01250                 {
01251                     eFace  *G=e->other->Face();
01252 
01253                     eHalfEdge* b = e->other->next;
01254                     eHalfEdge* a = b->next;
01255                     tASSERT(a->next == e->other);
01256 
01257                     ePoint *A = a->Point();
01258 
01259                     /* we have the following Situation:
01260 
01261                     Should this figure get distorted, align the ":"
01262 
01263                     :         A
01264                     :         #
01265                     :        # ##
01266                     :   a   #  [eFace G]
01267                     :      #       ##
01268                     :     #       X  ##  b
01269                     :    #   e   /     ## 
01270                     : D ########/######### B
01271                     :   #      /(new eWall)
01272                     :   #     /      #
01273                     :   #    /  [eFace F]
01274                     :   #   /    #
01275                     : d #  /   # c 
01276                     :   # /  #
01277                     :   #/ #
01278                     :   ##   
01279                     :   C
01280                             
01281                     */
01282 
01283 
01284                     eCoord dd=*C-*D;
01285                     eCoord aa=*A-*D;
01286                     eCoord bb=*A-*B;
01287                     eCoord cc=*C-*B;
01288 
01289                     REAL scale = aa.NormSquared() + bb.NormSquared() +
01290                                  bb.NormSquared() + cc.NormSquared();
01291 
01292                     tASSERT(scale > 0);
01293                     //tASSERT(aa.NormSquared() > scale *SMALL_FLOAT);
01294                     //tASSERT(bb.NormSquared() > scale *SMALL_FLOAT);
01295                     //tASSERT(dd.NormSquared() > scale *SMALL_FLOAT);
01296                     //tASSERT(cc.NormSquared() > scale *SMALL_FLOAT);
01297 
01298 #ifdef DEBUG
01299                     Check();
01300 #endif
01301 
01302                     if (change_grid && e->Movable() && aa*dd>scale*.0001 && cc*bb >scale*.0001){
01303                         /*
01304 
01305                         if the angles CDA and ABC are less than 180deg, we can 
01306                         just "turn" eEdge e:
01307 
01308 
01309                         :         A
01310                         :[eFace F]#
01311                         :        #|##  [eFace G]
01312                         :   a   # |  ## b
01313                         :      # |     ##
01314                         :     #  |       ##
01315                         :    #  |    X     ## 
01316                         : D #   |   |        # B
01317                         :   #  |   |(new eWall)
01318                         :   #  e  |      #
01319                         :   # |  |     #
01320                         :   # | |    #
01321                         : d #| |   # c 
01322                         :   #||  #
01323                         :   #| #
01324                         :   ##   
01325                         :   C
01326 
01327                         */
01328                         if (*A == *C)
01329                         {
01330                             start = A;
01331                             restart = 1;
01332                             continue;
01333                         }
01334 
01335 
01336                         tControlledPTR< eFace > oldF = ZombifyFace(F);
01337                         tControlledPTR< eFace > oldG = ZombifyFace(G);
01338                         KillEdge(e);
01339 
01340                         e=tNEW(eHalfEdge) (C,A);
01341                         F=tNEW(eFace)     (a,d,e, oldF, oldG);
01342                         G=tNEW(eFace)     (b,e->other,c, oldF, oldG);
01343 
01344                         AddFaceAll(F);
01345                         AddFaceAll(G);
01346 
01347                         eCoord ee=*A-*C;
01348                         REAL x_test=ee*dir;
01349                         if (x_test>=0){
01350                             exactly_onLeft=(x_test<=EPS * EPS * se_EstimatedRangeOfMult(ee,dir));
01351                             currentEdge = c;
01352                             tASSERT(currentEdge->ID >= 0);
01353                         }
01354                         else{
01355                             exactly_onLeft=-1;
01356                             currentEdge = e;
01357                             tASSERT(currentEdge->ID >= 0);
01358                         }
01359 
01360 #ifdef DEBUG
01361                         Check();
01362 #endif
01363 
01364                     }
01365 
01366                     /* if not, we hace to introduce a new ePoint E: the cut between our
01367                        new eWall and eEdge e.
01368 
01369                             
01370                        :        A
01371                        :        ##
01372                        :        #\##
01373                        :         # \###
01374                        :         #  \  ##
01375                        : [eFace G]#  \   ## [eFace GG]
01376                        :          #   \    ###
01377                        :           #   aa     ##
01378                        :       a   #     \      ## b
01379                        :            #     \       ### 
01380                        :            #      \   CC    ##
01381                        :             #      \ /        ## 
01382                        :           D ## dd ##E### bb #### B [BD = e]
01383                        :            #      /(new eWall)
01384                        : [eFace F] #     /      #
01385                        :          #   cc     # [eFace FF]
01386                        :         #   /    #
01387                        :      d #  /   # c 
01388                        :       # /  #
01389                        :      #/ #
01390                        :     #/#   
01391                        :    ##
01392                        :   C
01393                             
01394 
01395                     */
01396 
01397                     else{
01398                         // calculate the coordinates of the intersection ePoint E:
01399                         ePoint *E;
01400                         eHalfEdge *bb,*cc,*dd;
01401 
01402                         if (*C == *A)
01403                         {
01404                             start = A;
01405                             restart = 1;
01406                             continue;
01407                         }
01408 
01409                         REAL ar = .5f;
01410 
01411                         {
01412                             eHalfEdge *newtodo;
01413                             ePoint *CC = tNEW(ePoint(end));
01414                             tStackObject< eTempEdge > todo (C, CC);
01415                             E=tNEW(ePoint) (e->IntersectWithCareless(todo.Edge(0)));
01416 
01417                             ar = e->Ratio(*E);
01418 
01419                             //        REAL br = todo.Edge(0)->Ratio(*E);
01420                             //        tASSERT(-.1f < ar && ar < 1.1f);
01421                             //        tASSERT(-.1f < br && br < 1.1f);
01422 
01423 
01424                             tASSERT(E->NormSquared() < se_maxGridSize*100);
01425                             todo.Edge(0)->Split(cc,newtodo,E);
01426                             KillEdge(newtodo);  // not needed. Make sure it gets deleted.
01427                         }
01428 
01429                         if (toBePlaced.Wall())
01430                         {
01431 #ifdef DEBUG
01432                             tASSERT(toBePlaced.Wall()->Splittable());
01433                             Check();
01434 #endif
01435 
01436                             // inform walls about the reason of their split
01437                             if ( !e->Movable() )
01438                             {
01439                                 eWall *other = e->GetWall();
01440                                 if ( other )
01441                                 {
01442                                     toBePlaced.Wall()->SplitByActive( other );
01443                                 }
01444                                 other = e->other->GetWall();
01445                                 if ( other )
01446                                 {
01447                                     toBePlaced.Wall()->SplitByActive( other );
01448                                 }
01449                             }
01450 
01451                             eWall *wa, *wb;
01452                             toBePlaced.Wall()->Split(wa, wb, eCoord::V(*start, *E, end));
01453 
01454                             // place the first bit of wall
01455                             cc->SetWall(wa);
01456 
01457                             // modify the temp edge to be placed to represent the rest of the wall
01458                             toBePlaced.SetWall( wb );
01459                             toBePlaced.Coord(0) = *E;
01460                         }
01461 
01462                         REAL arreal = ar;
01463                         if (ar > .99999f)
01464                             ar = .99999f;
01465                         if (ar < .00001f)
01466                             ar = .00001f;
01467                         *E = *B + (*D - *B) * ar;
01468 
01469                         if (*E == *D || (arreal >= 1.0f && !d->other->GetWall()))
01470                         {
01471                             d->other->SetWall(cc->GetWall());
01472                             KillEdge(cc);
01473                             start = D;
01474                             restart = 1;
01475                             continue;
01476                         }
01477 
01478                         if (*E == *B || (arreal <= 0.0f && !c->GetWall()))
01479                         {
01480                             c->SetWall(cc->GetWall());
01481 
01482                             KillEdge(cc);
01483                             start = B;
01484                             restart = 1;
01485                             continue;
01486                         }
01487 
01488 
01489 
01490                         e->other->Split(dd,bb,E);
01491 
01492                         F->CorrectArea();
01493                         G->CorrectArea();
01494                         tControlledPTR< eFace > oldF = ZombifyFace(F);
01495                         tControlledPTR< eFace > oldG = ZombifyFace(G);
01496                         KillEdge(e);
01497 
01498 
01499                         start = E;
01500 
01501                         bool aeq = false, ceq = false;
01502 
01503                         if (*A == *E)
01504                         {
01505                             if (A==leakPoint)
01506                                 st_Breakpoint();
01507 
01508                             A->Replace(E);
01509                             KillPoint(A);
01510 
01511                             a->other->SetWall(dd->GetWall());
01512                             a->SetWall(dd->other->GetWall());
01513                             b->SetWall(bb->other->GetWall());
01514                             b->other->SetWall(bb->GetWall());
01515                             KillEdge(dd);
01516                             KillEdge(bb);
01517                             dd = a->other;
01518                             bb = b->other;
01519                             aeq = true;
01520 
01521                             se_LinkFaces( oldG, oldF );
01522                         }
01523 
01524                         if (*C == *E)
01525                         {
01526                             tASSERT(!aeq);
01527 
01528                             C->Replace(E);
01529                             KillPoint(C);
01530 
01531                             d->other->SetWall(dd->other->GetWall());
01532                             d->SetWall(dd->GetWall());
01533                             c->other->SetWall(bb->other->GetWall());
01534                             c->SetWall(bb->GetWall());
01535 
01536                             KillEdge(dd);
01537                             KillEdge(bb);
01538                             KillEdge(cc);
01539                             dd = d;
01540                             bb = c;
01541                             ceq = true;
01542 
01543                             se_LinkFaces( oldF, oldG );
01544                         }
01545 
01546                         if (!ceq)
01547                         {
01548                             F=tNEW(eFace) (d,cc,dd->other, oldF );
01549                             eFace *FF=tNEW(eFace) (c,bb->other,cc->other, oldF );
01550 
01551                             AddFaceAll(F);
01552                             AddFaceAll(FF);
01553                         }
01554 
01555                         eHalfEdge *aa=NULL;
01556 
01557 
01558                         if (!aeq)
01559                         {
01560                             aa = tNEW(eHalfEdge) (E,A);
01561 
01562                             eFace *GG=tNEW(eFace) (b,aa->other,bb, oldG );
01563                             G=tNEW(eFace) (a,dd,aa, oldG );
01564                             AddFaceAll(G);
01565                             AddFaceAll(GG);
01566                         }
01567                         else
01568                         {
01569                             start = E;
01570                             restart = true;
01571                             continue;
01572                         }
01573 
01574 #ifdef DEBUG
01575                         Check();
01576 #endif
01577                         if (end == *E)
01578                             return E;
01579 
01580                         //          start = E;
01581                         eCoord ea=*A-*E;
01582                         dir   = end - *E;
01583                         REAL x_test=ea*dir;
01584 
01585                         tASSERT (aa);
01586                         if (x_test>=0){
01587                             currentEdge=bb;
01588                             tASSERT(currentEdge->ID >= 0);
01589                             exactly_onLeft=(x_test<=EPS*EPS*se_EstimatedRangeOfMult(ea,dir));
01590                             // if (exactly_onLeft) std::cerr << "Achtung 3!\n";
01591                         }
01592 
01593                         else{
01594                             currentEdge=aa;
01595                             tASSERT(currentEdge->ID >= 0);
01596                             exactly_onLeft=-1;
01597                         }
01598                     }
01599                 }
01600             }
01601         }
01602     }
01603 
01604     tERR_ERROR_INT("We shound never get here!");
01605     return NULL;
01606 }

Here is the call graph for this function:

Here is the caller graph for this function:

const tList<eCamera>& eGrid::Cameras (  )  const [inline]

Definition at line 150 of file eGrid.h.

References cameras.

Referenced by fill_audio(), and RenderAllViewports().

00150 {return cameras;}

Here is the caller graph for this function:

const tList<eGameObject>& eGrid::GameObjects (  )  const [inline]

Definition at line 151 of file eGrid.h.

References gameObjects.

Referenced by gGame::Analysis(), gBaseZoneHack::CheckSurvivor(), gBaseZoneHack::CountZonesOfTeam(), cWidget::Map::DrawObjects(), gAIPlayer::EmergencySurvive(), gGame::StateUpdate(), gAIPlayer::Think(), gAIPlayer::ThinkSurvive(), gAIPlayer::ThinkTrace(), and gBaseZoneHack::Timestep().

00151 {return gameObjects;}

Here is the caller graph for this function:

const tList<eGameObject>& eGrid::GameObjectsInteresting (  )  const [inline]

Definition at line 152 of file eGrid.h.

References gameObjectsInteresting.

00152 {return gameObjectsInteresting;}

const tList<eGameObject>& eGrid::GameObjectsInactive (  )  const [inline]

Definition at line 153 of file eGrid.h.

References gameObjectsInactive.

00153 {return gameObjectsInactive;}

int eGrid::NumberOfCameras (  ) 

Definition at line 193 of file eDisplay.cpp.

References cameras, and GrowingArrayBase::Len().

00193 {return cameras.Len();}

Here is the call graph for this function:

const eCoord & eGrid::CameraPos ( int  i  ) 

Definition at line 194 of file eDisplay.cpp.

References cameras.

Referenced by display_simple(), and draw_eWall().

00194 {return cameras(i)->CameraPos();}

Here is the caller graph for this function:

eCoord eGrid::CameraGlancePos ( int  i  ) 

Definition at line 195 of file eDisplay.cpp.

References cameras.

Referenced by display_simple().

00195 {return cameras(i)->CameraGlancePos();}

Here is the caller graph for this function:

const eCoord & eGrid::CameraDir ( int  i  ) 

Definition at line 196 of file eDisplay.cpp.

References cameras.

Referenced by display_simple(), draw_eWall(), and paint_sr_lowerSky().

00196 {return cameras(i)->CameraDir();}

Here is the caller graph for this function:

REAL eGrid::CameraHeight ( int  i  ) 

Definition at line 197 of file eDisplay.cpp.

References cameras.

Referenced by Render().

00197 {return cameras(i)->CameraZ();}

Here is the caller graph for this function:

void eGrid::AddGameObjectInteresting ( eGameObject o  ) 

Definition at line 2620 of file eGrid.cpp.

References tList< T, MALLOC, REFERENCE >::Add(), gameObjectsInteresting, and eGameObject::interestingID.

02620                                                       {
02621     gameObjectsInteresting.Add(o, o->interestingID);
02622 }

Here is the call graph for this function:

void eGrid::RemoveGameObjectInteresting ( eGameObject o  ) 

Definition at line 2624 of file eGrid.cpp.

References gameObjectsInteresting, eGameObject::interestingID, and tList< T, MALLOC, REFERENCE >::Remove().

02624                                                       {
02625     gameObjectsInteresting.Remove(o, o->interestingID);
02626 }

Here is the call graph for this function:

void eGrid::AddGameObjectInactive ( eGameObject o  ) 

Definition at line 2628 of file eGrid.cpp.

References tList< T, MALLOC, REFERENCE >::Add(), gameObjectsInactive, and eGameObject::inactiveID.

02628                                                       {
02629     gameObjectsInactive.Add(o, o->inactiveID);
02630 }

Here is the call graph for this function:

void eGrid::RemoveGameObjectInactive ( eGameObject o  ) 

Definition at line 2632 of file eGrid.cpp.

References gameObjectsInactive, eGameObject::inactiveID, and tList< T, MALLOC, REFERENCE >::Remove().

02632                                                       {
02633     gameObjectsInactive.Remove(o, o->inactiveID);
02634 }

Here is the call graph for this function:

typedef void eGrid::WallProcessor ( eWall w  ) 

void eGrid::ProcessWallsInRange ( WallProcessor *  proc,
const eCoord &  pos,
REAL  range,
eFace startFace 
)

Definition at line 2764 of file eGrid.cpp.

References eCoord, eWall::Edge(), edges, eHalfEdge::Face(), FindSurroundingFace(), GrowingArrayBase::Len(), eFace::nextProcessed, NULL, eHalfEdge::Other(), eHalfEdge::Point(), ProcessWallsRecursive(), REAL, st_Breakpoint(), tASSERT, eHalfEdge::Vec(), and wallsNotYetInserted.

02768 {
02769     int i;
02770 
02771     start = FindSurroundingFace( pos, start );
02772     if ( !start )
02773         return;
02774 
02775     s_rangeSquared = range * range;
02776     s_start = start;
02777     s_processed = start;
02778 
02779     // process the gridded walls
02780     ProcessWallsRecursive( proc, pos, range, start, NULL, 100 );
02781 
02782 #ifdef DEBUG_OLD
02783     // make sure all walls were processed
02784 
02785     // process the not gridded walls
02786     for ( i = edges.Len()-1; i>=0; --i )
02787     {
02788         const eHalfEdge *leave = edges(i);
02789 
02790         if ( !leave->Other() || !leave->Face() || !leave->Other()->Face() )
02791             continue;
02792 
02793         eCoord normal = leave->Vec().Conj();
02794         REAL normalLen = normal.Norm();
02795         if ( normalLen <= 0 )
02796             continue;
02797         normal *= 1/ normalLen;
02798 
02799         eCoord Pos1 = normal.Turn( *leave->Point() - pos );
02800         eCoord Pos2 = normal.Turn( *leave->Other()->Point() - pos );
02801 
02802         tASSERT( fabs( Pos1.y - Pos2.y ) <= fabs( Pos1.y + Pos2.y +.1f ) * .1f );
02803 
02804         // start test: the line through the edge "leave" must come closer than "range" to "pos"
02805         if ( Pos1.y < range && Pos1.y > -range )
02806         {
02807             // check for real hit
02808             if ( Pos1.x * Pos2.x < 0 ||
02809                     Pos1.NormSquared() < s_rangeSquared ||
02810                     Pos2.NormSquared() < s_rangeSquared )
02811             {
02812                 if ( !leave->Face()->nextProcessed || !leave->Other()->Face()->nextProcessed )
02813                 {
02814                     st_Breakpoint();
02815                 }
02816 
02817                 if ( leave->Face()->nextProcessed &&  !leave->Other()->Face()->nextProcessed )
02818                 {
02819                     while ( s_processed != start )
02820                     {
02821                         eFace* next = s_processed->nextProcessed;
02822                         s_processed->nextProcessed = NULL;
02823                         s_processed = next;
02824                     }
02825 
02826                     start->nextProcessed = NULL;
02827                     s_processed = leave->Face();
02828                     leave->Face()->nextProcessed = start;
02829 
02830                     st_Breakpoint();
02831 
02832                     ProcessWallsRecursive( proc, pos, range, leave->Face(), NULL, 100 );
02833 
02834                     while ( s_processed != start )
02835                     {
02836                         eFace* next = s_processed->nextProcessed;
02837                         s_processed->nextProcessed = NULL;
02838                         s_processed = next;
02839                     }
02840 
02841                     start->nextProcessed = NULL;
02842                     s_processed = NULL;
02843 
02844                 }
02845             }
02846         }
02847     }
02848 #endif
02849 
02850     while ( s_processed && s_processed != start )
02851     {
02852         eFace* next = s_processed->nextProcessed;
02853         s_processed->nextProcessed = NULL;
02854         s_processed = next;
02855     }
02856 
02857     start->nextProcessed = NULL;
02858     s_processed = NULL;
02859 
02860     // process the not gridded walls
02861     for ( i = wallsNotYetInserted.Len()-1; i>=0; --i )
02862     {
02863         eWall* w= wallsNotYetInserted(i);
02864         const eHalfEdge *leave = w->Edge();
02865 
02866         eCoord normal = leave->Vec().Conj();
02867         REAL normalLen = normal.Norm();
02868         if ( normalLen <= 0 )
02869             continue;
02870         normal *= 1/ normalLen;
02871 
02872         eCoord Pos1 = normal.Turn( *leave->Point() - pos );
02873         eCoord Pos2 = normal.Turn( *leave->Other()->Point() - pos );
02874 
02875         tASSERT( fabs( Pos1.y - Pos2.y ) <= fabs( Pos1.y + Pos2.y +.1f ) * .1f );
02876 
02877         // start test: the line through the edge "leave" must come closer than "range" to "pos"
02878         if ( Pos1.y < range && Pos1.y > -range )
02879         {
02880             // check for real hit
02881             if ( Pos1.x * Pos2.x < 0 ||
02882                     Pos1.NormSquared() < s_rangeSquared ||
02883                     Pos2.NormSquared() < s_rangeSquared )
02884             {
02885                 (*proc) ( w );
02886             }
02887         }
02888 
02889     }
02890 }

Here is the call graph for this function:

void eGrid::display_simple ( int  viewer,
bool  floor,
bool  sr_upperSky,
bool  sr_lowerSky,
REAL  flooralpha,
bool  eWalls,
bool  gameObjects,
REAL zNear 
) [protected]

Definition at line 294 of file eDisplay.cpp.

References BeginLines(), CameraDir(), CameraGlancePos(), CameraPos(), cameras, eCoord, edges, EXTENSION, eHalfEdge::Face(), tReferencable< T, MUTEX >::GetRefcount(), infinity_xy_plane(), INTENSITY, GrowingArrayBase::Len(), lower_height, ModelMatrix(), eHalfEdge::other, paint_sr_lowerSky(), eHalfEdge::Point(), points, REAL, eDebugLine::Render(), eGameObject::RenderAll(), eWallRim::RenderAll(), RenderEnd(), rFLOOR_GRID, rFLOOR_OFF, rFLOOR_TEXTURE, rFLOOR_TWOTEXTURE, se_BlackSky(), se_glFloorColor(), se_glFloorTexture(), se_glFloorTexture_a(), se_glFloorTexture_b(), se_GridSize(), SIDELEN, sr_alphaBlend, sr_CheckGLError(), sr_DepthOffset(), sr_floorDetail, sr_highRim, su_FetchAndStoreSDLInput(), TexMatrix(), upper_height, x, and z.

Referenced by Render().

00298                                         {
00299     sr_CheckGLError();
00300 
00301     /*
00302     static GLfloat S[]={1,0,0,0};
00303     static GLfloat T[]={0,1,0,0};
00304     static GLfloat R[]={0,0,1,0};
00305     static GLfloat Q[]={0,0,0,1};
00306 
00307     glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
00308     glTexGenfv(GL_S,GL_OBJECT_PLANE,S);
00309 
00310     glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
00311     glTexGenfv(GL_T,GL_OBJECT_PLANE,T);
00312 
00313     glTexGeni(GL_R,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
00314     glTexGenfv(GL_R,GL_OBJECT_PLANE,R);
00315 
00316     glTexGeni(GL_Q,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
00317     glTexGenfv(GL_Q,GL_OBJECT_PLANE,Q);
00318 
00319     glDisable(GL_TEXTURE_GEN_T);
00320     glDisable(GL_TEXTURE_GEN_S);
00321     glDisable(GL_TEXTURE_GEN_R);
00322     glDisable(GL_TEXTURE_GEN_Q);
00323     */
00324 
00325 
00326     glDisable(GL_DEPTH_TEST);
00327     glDepthMask(GL_FALSE);
00328 
00329     glDisable(GL_CULL_FACE);
00330 
00331     eCoord camPos = CameraGlancePos( viewer );
00332     // eWallRim::Bound( camPos, 10 );
00333 
00334     if (sr_upperSky || se_BlackSky()){
00335         if (se_BlackSky()){
00336             //glDisable(GL_TEXTURE);
00337             glDisable(GL_TEXTURE_2D);
00338 
00339             glColor3f(0,0,0);
00340 
00341             if ( z < lower_height )
00342                 infinity_xy_plane(camPos, this->CameraDir(viewer),lower_height);
00343 
00344             glEnable(GL_TEXTURE_2D);
00345         }
00346         else {
00347             TexMatrix();
00348             glLoadIdentity();
00349             //      glScalef(.25,.25,.25);
00350 
00351             se_glFloorTexture();
00352 
00353             glColor3f(.5,.5,1);
00354 
00355             if ( z < upper_height )
00356                 infinity_xy_plane(camPos, this->CameraDir(viewer),upper_height);
00357         }
00358     }
00359 
00360     if (sr_lowerSky && !sr_highRim){
00361         paint_sr_lowerSky(this, viewer,sr_upperSky, camPos);
00362     }
00363 
00364     if (floor){
00365         sr_DepthOffset(false);
00366 
00367         su_FetchAndStoreSDLInput();
00368         int floorDetail = sr_floorDetail;
00369 
00370         // no multitexturing without alpha blending
00371         if ( !sr_alphaBlend && floorDetail > rFLOOR_TEXTURE )
00372             floorDetail = rFLOOR_TEXTURE;
00373 
00374         switch(floorDetail){
00375         case rFLOOR_OFF:
00376             break;
00377         case rFLOOR_GRID:
00378             {
00379         #define SIDELEN   (se_GridSize())
00380         #define EXTENSION 10
00381 
00382                 eCoord center = CameraPos(viewer) + CameraDir(viewer) * (SIDELEN * EXTENSION * .8);
00383 
00384                 REAL x=center.x;
00385                 REAL y=center.y;
00386                 int xn=static_cast<int>(x/SIDELEN);
00387                 int yn=static_cast<int>(y/SIDELEN);
00388 
00389 
00390                 //glDisable(GL_TEXTURE);
00391                 glDisable(GL_TEXTURE_2D);
00392 
00393         #define INTENSITY(x,xx) (1-(((x)-(xx))*((x)-(xx))/(EXTENSION*SIDELEN*EXTENSION*SIDELEN)))
00394 
00395 
00396                 BeginLines();
00397                 for(int i=xn-EXTENSION;i<=xn+EXTENSION;i++){
00398                     REAL intens=INTENSITY(i*SIDELEN,x);
00399                     if (intens<0) intens=0;
00400                     se_glFloorColor(intens,intens);
00401                     glVertex2f(i*SIDELEN,y-SIDELEN*(EXTENSION+1));
00402                     glVertex2f(i*SIDELEN,y+SIDELEN*(EXTENSION+1));
00403                 }
00404                 for(int j=yn-EXTENSION;j<=yn+EXTENSION;j++){
00405                     REAL intens=INTENSITY(j*SIDELEN,y);
00406                     if (intens<0) intens=0;
00407                     se_glFloorColor(intens,intens);
00408                     glVertex2f(x-(EXTENSION+1)*SIDELEN,j*SIDELEN);
00409                     glVertex2f(x+(EXTENSION+1)*SIDELEN,j*SIDELEN);
00410                 }
00411                 RenderEnd();
00412             }
00413             break;
00414 
00415         case rFLOOR_TEXTURE:
00416             TexMatrix();
00417             glLoadIdentity();
00418             glScalef(1/se_GridSize(),1/se_GridSize(),1.);
00419 
00420             se_glFloorTexture();
00421             se_glFloorColor(flooralpha);
00422 
00423             infinity_xy_plane( camPos, CameraDir(viewer) );
00424 
00425             /* old way: draw every triangle
00426             for(int i=eFace::faces.Len()-1;i>=0;i--){
00427             eFace *f=eFace::faces(i);
00428 
00429             if (f->visHeight[viewer]<z){
00430             glBegin(GL_TRIANGLES);
00431             for(int j=0;j<=2;j++){
00432             glVertex3f(f->p[j]->x,f->p[j]->y,0);
00433             }
00434             glEnd();
00435             }
00436             }
00437             */
00438 
00439             break;
00440 
00441         case rFLOOR_TWOTEXTURE:
00442             se_glFloorColor(flooralpha);
00443 
00444             TexMatrix();
00445             glLoadIdentity();
00446             REAL gs = 1/se_GridSize();
00447             glScalef(0.01*gs,gs,1.);
00448 
00449             se_glFloorTexture_a();
00450             infinity_xy_plane( camPos, CameraDir(viewer) );
00451 
00452             se_glFloorColor(flooralpha);
00453 
00454             TexMatrix();
00455             glLoadIdentity();
00456             glScalef(gs,.01*gs,1.);
00457 
00458             se_glFloorTexture_b();
00459 
00460             glDepthFunc(GL_LEQUAL);
00461             glBlendFunc(GL_SRC_ALPHA,GL_ONE);
00462             infinity_xy_plane( camPos, CameraDir(viewer) );
00463             glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
00464 
00465             break;
00466         }
00467     }
00468 
00469     glEnable(GL_DEPTH_TEST);
00470     glDepthMask(GL_TRUE);
00471 
00472     TexMatrix();
00473     glLoadIdentity();
00474     ModelMatrix();
00475 
00476     //  glDisable(GL_TEXTURE_GEN_S);
00477     //  glDisable(GL_TEXTURE_GEN_T);
00478     //  glDisable(GL_TEXTURE_GEN_Q);
00479     //  glDisable(GL_TEXTURE_GEN_R);
00480 
00481     if(eWalls){
00482         {
00483             su_FetchAndStoreSDLInput();
00484     
00485             eWallRim::RenderAll( cameras(viewer) );
00486         }
00487 
00488         if (sr_lowerSky && sr_highRim){
00489             //      glEnable(GL_TEXTURE_GEN_S);
00490             //      glEnable(GL_TEXTURE_GEN_T);
00491             //      glEnable(GL_TEXTURE_GEN_Q);
00492             //      glEnable(GL_TEXTURE_GEN_R);
00493 
00494             paint_sr_lowerSky(this, viewer,sr_upperSky, camPos);
00495 
00496             //      glDisable(GL_TEXTURE_GEN_S);
00497             //      glDisable(GL_TEXTURE_GEN_T);
00498             //      glDisable(GL_TEXTURE_GEN_Q);
00499             //      glDisable(GL_TEXTURE_GEN_R);
00500 
00501             TexMatrix();
00502             glLoadIdentity();
00503             ModelMatrix();
00504         }
00505     }
00506 
00507     sr_CheckGLError();
00508 
00509     if (eWalls){
00510         // glDisable(GL_CULL_FACE);
00511         // draw_eWall(this,viewer,0,zNear,cameras(viewer));
00512 
00513         /*
00514         #ifdef DEBUG
00515         for(int i=sg_netPlayerWalls.Len()-1;i>=0;i--){
00516           glMatrixMode(GL_MODELVIEW);
00517           glPushMatrix();
00518           if (sg_netPlayerWalls(i)->Preliminary())
00519         glTranslatef(0,0,4);
00520           else
00521         glTranslatef(0,0,8);
00522           if (sg_netPlayerWalls(i)->Wall())
00523         sg_netPlayerWalls(i)->Wall()->RenderList(false);
00524           glPopMatrix();
00525           }
00526         #endif
00527         */
00528 
00529         /*
00530         static int oldlen=0;
00531         int newlen=sg_netPlayerWalls.Len();
00532         if (newlen!=oldlen){
00533           con << "Number of player eWalls now " << newlen << '\n';
00534           oldlen=newlen;
00535         }
00536         */
00537 
00538     }
00539 
00540     sr_CheckGLError();
00541 
00542     if (gameObjects)
00543         eGameObject::RenderAll(this, cameras(viewer));
00544 
00545     eDebugLine::Render();
00546 #ifdef DEBUG
00547 
00548     ePath::RenderLast();
00549 
00550     if (debug_grid){
00551         //glDisable(GL_TEXTURE);
00552         glDisable(GL_TEXTURE_2D);
00553         glDisable(GL_LIGHTING);
00554         BeginLines();
00555 
00556         int i;
00557         for(i=edges.Len()-1;i>=0;i--){
00558             eHalfEdge *e=edges[i];
00559             if (e->Face())
00560                 glColor4f(1,1,1,1);
00561             else
00562                 glColor4f(0,0,1,1);
00563 
00564             glVertex3f(e->Point()->x,e->Point()->y,10);
00565             glVertex3f(e->Point()->x,e->Point()->y,15);
00566             glVertex3f(e->Point()->x,e->Point()->y,.1);
00567             glVertex3f(e->other->Point()->x,e->other->Point()->y,.1);
00568             glVertex3f(e->other->Point()->x,e->other->Point()->y,10);
00569             glVertex3f(e->other->Point()->x,e->other->Point()->y,15);
00570 
00571         }
00572 
00573         for(i=points.Len()-1;i>=0;i--){
00574             ePoint *p=points[i];
00575             glColor4f(1,0,0,1);
00576             glVertex3f(p->x,p->y,0);
00577             glVertex3f(p->x,p->y,(p->GetRefcount()+1)*5);
00578         }
00579         /*
00580         for(int i=sg_netPlayerWalls.Len()-1;i>=0;i--){
00581           eEdge *e=sg_netPlayerWalls[i]->Edge();
00582         glColor4f(0,1,0,1);
00583 
00584           glVertex3f(e->Point()->x,e->Point()->y,5);
00585           glVertex3f(e->Point()->x,e->Point()->y,10);
00586           glVertex3f(e->Point()->x,e->Point()->y,10);
00587           glVertex3f(e->other->Point()->x,e->other->Point()->y,10);
00588           glVertex3f(e->other->Point()->x,e->other->Point()->y,10);
00589           glVertex3f(e->other->Point()->x,e->other->Point()->y,5);
00590         }
00591         */
00592         RenderEnd();
00593     }
00594 #endif
00595 
00596 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::AddFace ( eFace f  )  [protected]

Definition at line 2370 of file eGrid.cpp.

References tList< T, MALLOC, REFERENCE >::Add(), eFace::CorrectArea(), faces, eDual::ID, and requestCleanup.

Referenced by AddFaceAll().

02371 {
02372     if (f->ID >= 0)
02373         return;
02374 
02375     faces.Add(f, f->ID);
02376 
02377     if (f->CorrectArea())
02378         requestCleanup = true;
02379 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::RemoveFace ( eFace f  )  [protected]

Definition at line 2381 of file eGrid.cpp.

References faces, eDual::ID, and tList< T, MALLOC, REFERENCE >::Remove().

Referenced by Clear(), KillFace(), and ZombifyFace().

02382 {
02383     if (f->ID < 0)
02384         return;
02385 
02386     faces.Remove(f, f->ID);
02387 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::AddEdge ( eHalfEdge e  )  [protected]

Definition at line 2389 of file eGrid.cpp.

References tList< T, MALLOC, REFERENCE >::Add(), tRecorderSync< DATA >::Archive(), edges, eHalfEdge::ID, eHalfEdge::Other(), eHalfEdge::Point(), and tASSERT.

Referenced by AddFaceAll().

02390 {
02391     if (e->ID >= 0)
02392         return;
02393 
02394     tASSERT(e->Other() && *e->Point() != *e->Other()->Point());
02395 
02396     edges.Add(e, e->ID);
02397 
02398     int idrec = e->ID;
02399     tRecorderSync< int >::Archive( "_GRID_ADD_EDGE", 8, idrec );
02400 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::RemoveEdge ( eHalfEdge e  )  [protected]

Definition at line 2402 of file eGrid.cpp.

References tRecorderSync< DATA >::Archive(), edges, eHalfEdge::ID, tList< T, MALLOC, REFERENCE >::Remove(), and st_Breakpoint().

Referenced by Clear(), and KillEdge().

02403 {
02404     if (e == leakEdge)
02405         st_Breakpoint();
02406 
02407     if (e->ID < 0)
02408         return;
02409 
02410     int idrec = e->ID;
02411     tRecorderSync< int >::Archive( "_GRID_REMOVE_EDGE", 8, idrec );
02412 
02413     edges.Remove(e, e->ID);
02414 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::AddPoint ( ePoint p  )  [protected]

Definition at line 2416 of file eGrid.cpp.

References tList< T, MALLOC, REFERENCE >::Add(), eCoord, eDual::ID, and points.

Referenced by AddFaceAll().

02417 {
02418     if (p->ID >= 0)
02419         return;
02420 
02421     points.Add(p, p->ID);
02422 
02423 #ifdef DEBUG_DISTORT
02424     // debug facility: distort grid
02425     static eCoord distortion(1,0);
02426     distortion = distortion.Turn(.6,.8);
02427     *p = *p + distortion;
02428 #endif
02429 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::RemovePoint ( ePoint p  )  [protected]

Definition at line 2431 of file eGrid.cpp.

References eDual::ID, points, tList< T, MALLOC, REFERENCE >::Remove(), and st_Breakpoint().

Referenced by Clear(), and KillPoint().

02432 {
02433     if (p == leakPoint)
02434         st_Breakpoint();
02435 
02436     if (p->ID < 0)
02437         return;
02438 
02439     points.Remove(p, p->ID);
02440 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::KillFace ( eFace f  )  [protected]

Definition at line 2442 of file eGrid.cpp.

References RemoveFace(), and eFace::Unlink().

02443 {
02444     tControlledPTR< eFace > keep( f );
02445     RemoveFace(f);
02446     f->Unlink();
02447 }

Here is the call graph for this function:

void eGrid::KillEdge ( eHalfEdge e  )  [protected]

Definition at line 2457 of file eGrid.cpp.

References eHalfEdge::other, RemoveEdge(), and eHalfEdge::Unlink().

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

02458 {
02459     tControlledPTR< eHalfEdge > keep( e );
02460     RemoveEdge(e);
02461     tControlledPTR< eHalfEdge > o ( e->other );
02462 
02463     e->Unlink();
02464 
02465     if (o)
02466     {
02467         KillEdge(o);
02468     }
02469 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::KillPoint ( ePoint p  )  [protected]

Definition at line 2471 of file eGrid.cpp.

References RemovePoint(), and ePoint::Unlink().

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

02472 {
02473     tControlledPTR< ePoint > keep( p );
02474     RemovePoint(p);
02475     p->Unlink();
02476 }

Here is the call graph for this function:

Here is the caller graph for this function:

tControlledPTR< eFace > eGrid::ZombifyFace ( eFace f  )  [protected]

Definition at line 2449 of file eGrid.cpp.

References RemoveFace(), and eFace::Unlink().

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

02450 {
02451     tControlledPTR< eFace > keep( f );
02452     RemoveFace(f);
02453     f->Unlink();
02454     return keep;
02455 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eGrid::AddFaceAll ( eFace f  )  [protected]

Definition at line 2478 of file eGrid.cpp.

References AddEdge(), AddFace(), AddPoint(), eDual::edge, eHalfEdge::next, eHalfEdge::other, eHalfEdge::Point(), and tASSERT.

Referenced by Create(), DrawLine(), and Grow().

02479 {
02480     eHalfEdge *run = f->edge;
02481     for(int j=0;j<=2;j++){
02482         AddEdge(run);
02483         AddEdge(run->other);
02484         AddPoint(run->Point());
02485         run = run->next;
02486     }
02487     tASSERT (run == f->edge);
02488 
02489     AddFace(f);
02490 }

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class eCamera [friend]

Definition at line 77 of file eGrid.h.

friend class eFace [friend]

Definition at line 78 of file eGrid.h.

friend class eHalfEdge [friend]

Definition at line 79 of file eGrid.h.

friend class ePoint [friend]

Definition at line 80 of file eGrid.h.

Referenced by DrawLine().

friend class eGameObject [friend]

Definition at line 81 of file eGrid.h.

friend class eWall [friend]

Definition at line 82 of file eGrid.h.

Referenced by Create(), and Grow().

friend class tReferencable< eGrid > [friend]

Definition at line 83 of file eGrid.h.


Member Data Documentation

eAxis eGrid::axis [protected]

Definition at line 87 of file eGrid.h.

Referenced by DirectionWinding(), GetDirection(), SetWinding(), Turn(), and WindingNumber().

bool eGrid::requestCleanup [protected]

Definition at line 208 of file eGrid.h.

Referenced by AddFace(), Create(), DrawLine(), and SimplifyAll().

tJUST_CONTROLLED_PTR< ePoint > eGrid::A [protected]

Definition at line 211 of file eGrid.h.

tJUST_CONTROLLED_PTR< ePoint > eGrid::B [protected]

Definition at line 211 of file eGrid.h.

tJUST_CONTROLLED_PTR< ePoint > eGrid::C [protected]

Definition at line 211 of file eGrid.h.

tJUST_CONTROLLED_PTR< eHalfEdge > eGrid::a [protected]

Definition at line 212 of file eGrid.h.

tJUST_CONTROLLED_PTR< eHalfEdge > eGrid::b [protected]

Definition at line 212 of file eGrid.h.

tJUST_CONTROLLED_PTR< eHalfEdge > eGrid::c [protected]

Definition at line 212 of file eGrid.h.

Referenced by Check(), Clear(), Create(), DrawLine(), and Grow().

REAL eGrid::maxNormSquared [protected]

Definition at line 213 of file eGrid.h.

Referenced by Clear(), Create(), Grow(), and Range().

eCoord eGrid::base [protected]

Definition at line 214 of file eGrid.h.

tList<eHalfEdge, false, true> eGrid::edges [protected]

Definition at line 217 of file eGrid.h.

Referenced by AddEdge(), Check(), Clear(), display_simple(), ProcessWallsInRange(), RemoveEdge(), SimplifyAll(), and SimplifyNum().

tList<ePoint, false, true> eGrid::points [protected]

Definition at line 218 of file eGrid.h.

Referenced by AddPoint(), Check(), Clear(), display_simple(), and RemovePoint().

tList<eFace, false, true> eGrid::faces [protected]

Definition at line 219 of file eGrid.h.

Referenced by AddFace(), Check(), Clear(), FindSurroundingFace(), RemoveFace(), and SimplifyAll().

tList<eGameObject> eGrid::gameObjects [protected]

Definition at line 222 of file eGrid.h.

Referenced by eGameObject::DeleteAll(), GameObjects(), eGameObject::RenderAll(), and eGameObject::s_Timestep().

tList<eGameObject> eGrid::gameObjectsInactive [protected]

Definition at line 223 of file eGrid.h.

Referenced by AddGameObjectInactive(), GameObjectsInactive(), and RemoveGameObjectInactive().

tList<eGameObject> eGrid::gameObjectsInteresting [protected]

Definition at line 224 of file eGrid.h.

Referenced by AddGameObjectInteresting(), GameObjectsInteresting(), and RemoveGameObjectInteresting().

tList<eCamera> eGrid::cameras [protected]

Definition at line 227 of file eGrid.h.

Referenced by CameraDir(), CameraGlancePos(), CameraHeight(), CameraPos(), Cameras(), display_simple(), NumberOfCameras(), and eCamera::s_Timestep().

tList<eWall> eGrid::wallsNotYetInserted [protected]

Definition at line 231 of file eGrid.h.

Referenced by eHalfEdge::CrossesNewWall(), and ProcessWallsInRange().


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