#include <gCycle.h>
Public Member Functions | |
void | CopyFrom (const gCycleMovement &other) |
copies relevant info from other cylce | |
void | CopyFrom (const SyncData &sync, const gCycle &other) |
gCycleExtrapolator (eGrid *grid, const eCoord &pos, const eCoord &dir, ePlayerNetID *p=NULL, bool autodelete=1) | |
virtual | ~gCycleExtrapolator () |
virtual bool | EdgeIsDangerous (const eWall *w, REAL time, REAL a) const |
returns whether a given wall is dangerous to this cycle | |
virtual void | PassEdge (const eWall *w, REAL time, REAL a, int recursion=1) |
virtual bool | TimestepCore (REAL currentTime, bool calculateAcceleration=true) |
core physics simulation routine | |
Public Attributes | |
REAL | trueDistance_ |
Private Member Functions | |
virtual nDescriptor & | CreatorDescriptor () const |
Private Attributes | |
const gCycleMovement * | parent_ |
Definition at line 87 of file gCycle.h.
gCycleExtrapolator::gCycleExtrapolator | ( | eGrid * | grid, | |
const eCoord & | pos, | |||
const eCoord & | dir, | |||
ePlayerNetID * | p = NULL , |
|||
bool | autodelete = 1 | |||
) |
Definition at line 1756 of file gCycle.cpp.
References eGameObject::currentFace, eGrid::FindSurroundingFace(), and eGameObject::RemoveFromList().
01757 :gCycleMovement( grid, pos, dir, p, autodelete ) 01758 ,trueDistance_( 0 ) 01759 ,parent_( 0 ) 01760 { 01761 // an extrapolator should not be visible as a gameobject from the outside 01762 eFace * currentFaceBack = currentFace; 01763 RemoveFromList(); 01764 currentFace = currentFaceBack; 01765 if ( !currentFace ) 01766 currentFace = grid->FindSurroundingFace( pos, currentFace ); 01767 }
gCycleExtrapolator::~gCycleExtrapolator | ( | ) | [virtual] |
void gCycleExtrapolator::CopyFrom | ( | const gCycleMovement & | other | ) |
copies relevant info from other cylce
other | the cycle to copy everything from |
Reimplemented from gCycleMovement.
Definition at line 1714 of file gCycle.cpp.
References gCycleMovement::CopyFrom(), gCycleMovement::GetDistance(), parent_, and trueDistance_.
Referenced by gCycleMovement::CopyFrom().
01715 { 01716 // delegate 01717 gCycleMovement::CopyFrom( other ); 01718 01719 // set parent 01720 parent_ = &other; 01721 01722 // copy distance 01723 trueDistance_ = GetDistance(); 01724 }
Definition at line 1727 of file gCycle.cpp.
References gCycleMovement::CopyFrom(), eGameObject::currentFace, gCycleMovement::GetDistance(), gCycle::lastGoodPosition_, gCycleMovement::SyncData::lastTurn, gCycleMovement::lastTurnPos_, gCycleMovement::MoveSafely(), parent_, gCycleMovement::SyncData::pos, gCycleMovement::SyncData::time, and trueDistance_.
01728 { 01729 // delegate 01730 gCycleMovement::CopyFrom( sync, other ); 01731 01732 //eFace* face1 = currentFace; 01733 MoveSafely( other.lastGoodPosition_, sync.time, sync.time ); 01734 //eFace* face2 = currentFace; 01735 MoveSafely( sync.pos, sync.time, sync.time ); 01736 01737 #ifdef DEBUG_X 01738 if ( face1 != face2 || face1 != currentFace ) 01739 { 01740 currentFace = face1; 01741 MoveSafely( sync.lastTurn *.01 + sync.pos * .99, sync.time, sync.time ); 01742 MoveSafely( sync.pos, sync.time, sync.time ); 01743 } 01744 #endif 01745 01746 // set parent 01747 parent_ = &other; 01748 01749 // set last turn 01750 lastTurnPos_ = sync.lastTurn; 01751 01752 // copy distance 01753 trueDistance_ = GetDistance(); 01754 }
bool gCycleExtrapolator::EdgeIsDangerous | ( | const eWall * | wall, | |
REAL | time, | |||
REAL | alpha | |||
) | const [virtual] |
returns whether a given wall is dangerous to this cycle
wall | the wall to check for danger | |
time | the time of the possible collision | |
alpha | the local wall coordinate of the collision |
Reimplemented from gCycleMovement.
Definition at line 1798 of file gCycle.cpp.
References gPlayerWall::Cycle(), gCycleMovement::dirDrive, gCycleMovement::EdgeIsDangerous(), EPS, gCycleMovement::GetDistance(), gCycleMovement::GetTurnDelay(), gPlayerWall::NetWall(), parent_, gPlayerWall::Pos(), gNetPlayerWall::Preliminary(), REAL, sg_delayCycle, gCycleMovement::Speed(), gCycleMovement::SpeedMultiplier(), gPlayerWall::Time(), and eWall::Vec().
Referenced by PassEdge().
01799 { 01800 const gPlayerWall *w = dynamic_cast<const gPlayerWall*>(ww); 01801 if (w) 01802 { 01803 gNetPlayerWall* nw = w->NetWall(); 01804 01805 // get time the wall was built 01806 REAL builtTime = w->Time(alpha); 01807 01808 // is the wall built in the future ( happens during extrapolation ) 01809 if ( builtTime > time ) 01810 return false; 01811 01812 // ignore temporary walls in some cases, they may not be real 01813 if ( nw && nw->Preliminary() && w->Cycle() == parent_ && fabs( dirDrive * w->Vec() ) < EPS ) 01814 return false; 01815 01816 // ignore recent walls of parent cycle 01817 gCycle *otherPlayer=w->Cycle(); 01818 if (otherPlayer==parent_ && 01819 ( time < builtTime + 2 * GetTurnDelay() || GetDistance() < w->Pos( alpha ) + .01 * sg_delayCycle*Speed()/SpeedMultiplier() ) 01820 ) 01821 return false; 01822 } 01823 01824 // delegate 01825 return bool(parent_) && parent_->EdgeIsDangerous( ww, time, alpha ) && gCycleMovement::EdgeIsDangerous( ww, time, alpha ); 01826 }
void gCycleExtrapolator::PassEdge | ( | const eWall * | w, | |
REAL | time, | |||
REAL | a, | |||
int | recursion = 1 | |||
) | [virtual] |
Reimplemented from eGameObject.
Definition at line 1828 of file gCycle.cpp.
References gCycleMovement::Alive(), eCoord, EdgeIsDangerous(), and eWall::Point().
01828 { 01829 { 01830 if (!EdgeIsDangerous(ww,time,a) || !Alive() ) 01831 { 01832 return; 01833 } 01834 else 01835 { 01836 eCoord collPos = ww->Point( a ); 01837 throw gCycleDeath( collPos ); 01838 } 01839 } 01840 }
bool gCycleExtrapolator::TimestepCore | ( | REAL | currentTime, | |
bool | calculateAcceleration = true | |||
) | [virtual] |
core physics simulation routine
currentTime | time to simulate up to |
Reimplemented from gCycleMovement.
Definition at line 1842 of file gCycle.cpp.
References gCycleMovement::distance, gCycleMovement::GetCurrentDestination(), parent_, tASSERT, gCycleMovement::TimestepCore(), and trueDistance_.
01843 { 01844 // determine a suitable next destination 01845 gDestination destDefault( *parent_ ), *dest=&destDefault; 01846 if ( GetCurrentDestination() ) 01847 { 01848 dest = GetCurrentDestination(); 01849 } 01850 01851 // correct distance 01852 // distance = dest->distance - DistanceToDestination( *dest ); 01853 // REAL distanceBefore = GetDistance(); 01854 tASSERT(finite(distance)); 01855 01856 // delegate 01857 bool ret = false; 01858 try{ 01859 ret = gCycleMovement::TimestepCore( currentTime, calculateAcceleration ); 01860 } 01861 catch( gCycleDeath & ) 01862 { 01863 return false; 01864 } 01865 01866 // update true distance 01867 // trueDistance_ += GetDistance() - distanceBefore; 01868 trueDistance_ = distance; 01869 01870 return ret; 01871 }
nDescriptor & gCycleExtrapolator::CreatorDescriptor | ( | void | ) | const [private, virtual] |
Implements nNetObject.
Definition at line 1881 of file gCycle.cpp.
References cycle_init, and tASSERT.
01881 { 01882 // should never be called 01883 tASSERT( 0 ); 01884 return cycle_init; 01885 }
const gCycleMovement* gCycleExtrapolator::parent_ [private] |
Definition at line 113 of file gCycle.h.
Referenced by CopyFrom(), EdgeIsDangerous(), and TimestepCore().