Performance: cache TCAS nodes on AI aircraft
Removes some remaining hot property lookups each frame
This commit is contained in:
parent
421a5601c1
commit
8b25244d90
2 changed files with 10 additions and 7 deletions
|
@ -105,6 +105,9 @@ FGAIAircraft::FGAIAircraft(FGAISchedule *ref) :
|
|||
|
||||
trackCache.remainingLength = 0;
|
||||
trackCache.startWptName = "-";
|
||||
|
||||
tcasThreatNode = props->getNode("tcas/threat-level", true);
|
||||
tcasRANode = props->getNode("tcas/ra-sense", true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -443,15 +446,13 @@ void FGAIAircraft::assertSpeed(double speed)
|
|||
|
||||
void FGAIAircraft::checkTcas(void)
|
||||
{
|
||||
if (props->getIntValue("tcas/threat-level",0)==3)
|
||||
if (tcasThreatNode->getIntValue()==3)
|
||||
{
|
||||
int RASense = props->getIntValue("tcas/ra-sense",0);
|
||||
if ((RASense>0)&&(tgt_vs<4000))
|
||||
const int RASense = tcasRANode->getIntValue();
|
||||
if ((RASense>0)&&(tgt_vs<4000)) {
|
||||
// upward RA: climb!
|
||||
tgt_vs = 4000;
|
||||
else
|
||||
if (RASense<0)
|
||||
{
|
||||
} else if (RASense<0) {
|
||||
// downward RA: descend!
|
||||
if (altitude_ft < 1000)
|
||||
{
|
||||
|
|
|
@ -132,7 +132,9 @@ private:
|
|||
|
||||
bool use_perf_vs;
|
||||
SGPropertyNode_ptr refuel_node;
|
||||
|
||||
SGPropertyNode_ptr tcasThreatNode;
|
||||
SGPropertyNode_ptr tcasRANode;
|
||||
|
||||
// helpers for Run
|
||||
//TODO sort out which ones are better protected virtuals to allow
|
||||
//subclasses to override specific behaviour
|
||||
|
|
Loading…
Add table
Reference in a new issue