Public Member Functions | |
gHitData () | |
bool | Hit () const |
void | AddHit (const eCoord &origin, const eCoord &dir, const gSensor &sensor, int winding) |
Public Attributes | |
const eHalfEdge * | edge |
gSensorWallType | wallType |
int | lr |
REAL | distance |
gCycle * | otherCycle |
REAL | driveDistance |
int | windingNumber |
Definition at line 591 of file gAIBase.cpp.
gHitData::gHitData | ( | ) | [inline] |
Definition at line 603 of file gAIBase.cpp.
00603 :edge(NULL), wallType(gSENSOR_NONE), otherCycle(NULL){}
bool gHitData::Hit | ( | ) | const [inline] |
void gHitData::AddHit | ( | const eCoord & | origin, | |
const eCoord & | dir, | |||
const gSensor & | sensor, | |||
int | winding | |||
) | [inline] |
Definition at line 607 of file gAIBase.cpp.
References eSensor::before_hit, gPlayerWall::Cycle(), EPS, eSensor::lr, gPlayerWall::Pos(), REAL, gSensor::type, and gPlayerWall::WindingNumber().
00608 { 00609 if (!sensor.ehit) 00610 return; // no hit, nothing to do 00611 00612 /* 00613 REAL otherDist = eCoord::F(*sensor.ehit->Point(), dir) 00614 - eCoord::F(origin, dir); 00615 00616 { 00617 REAL otherDist2 = eCoord::F(*sensor.ehit->Other()->Point(), dir) 00618 - eCoord::F(origin, dir); 00619 if (otherDist2 < otherDist) 00620 otherDist = otherDist2; 00621 } 00622 */ 00623 REAL otherDist = eCoord::F( dir, sensor.before_hit - origin ); 00624 00625 if (otherDist < EPS) 00626 return; // the new hit is a wall we apparently drive along; nothing to do 00627 00628 if (Hit() && distance < otherDist) 00629 return; // the hit that is already stored is more relevant. Ignore the new hit. 00630 00631 // copy the relevant data 00632 edge = sensor.ehit; 00633 wallType = sensor.type; 00634 lr = sensor.lr; 00635 distance = otherDist; 00636 00637 REAL alpha = edge->Ratio(sensor.before_hit); 00638 00639 // get the extra information from the wall we hit: 00640 gPlayerWall *w = dynamic_cast<gPlayerWall*>(edge->GetWall()); 00641 if (!w) 00642 { 00643 alpha = 1-alpha; 00644 w = dynamic_cast<gPlayerWall*>(edge->Other()->GetWall()); 00645 } 00646 00647 if (w) 00648 { 00649 otherCycle = w->Cycle(); 00650 driveDistance = w->Pos(alpha); 00651 windingNumber = w->WindingNumber() - winding; 00652 } 00653 }
const eHalfEdge* gHitData::edge |
Definition at line 594 of file gAIBase.cpp.
Referenced by gAIPlayer::EmergencySurvive(), gAIPlayer::ThinkSurvive(), and gAIPlayer::ThinkTrace().
int gHitData::lr |
Definition at line 595 of file gAIBase.cpp.
Referenced by gAISensor::DetectLoop(), and gAIPlayer::EmergencySurvive().
Definition at line 596 of file gAIBase.cpp.
Definition at line 599 of file gAIBase.cpp.
Referenced by gAISensor::DetectLoop(), and gAIPlayer::EmergencySurvive().