Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 4, 2011, 3:15:41 PM (13 years ago)
Author:
jo
Message:

Radar & Navigation tweaks: Radar is now hiding 'radar invisible' objects in the same way as the navigation markers are hidden. New 'feature': objects that are too far away are not displayed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai2/src/modules/overlays/hud/HUDRadar.cc

    r7880 r8874  
    6464        this->shapeMaterials_[RadarViewable::Triangle] = "RadarTriangle.png";
    6565        this->shapeMaterials_[RadarViewable::Square]   = "RadarSquare.png";
    66 
     66        this->setDetectionLimit( 10000.0f );
    6767        this->owner_ = 0;
    6868    }
     
    9494        if (object == dynamic_cast<RadarViewable*>(this->owner_))
    9595            return;
     96        if( showObject(object) == false ) //do not show objects that are "invisible" or "radar invisible"
     97            return;
    9698
    9799        // Make sure the object hasn't been added yet
     
    123125    void HUDRadar::objectChanged( RadarViewable* rv )
    124126    {
    125         if (rv == dynamic_cast<RadarViewable*>(this->owner_))
    126             return;
     127        if(rv == dynamic_cast<RadarViewable*>(this->owner_)) //case: player changed
     128            return;
     129        if( showObject(rv) == false ) //case: (radar) invisible object changed
     130            return;
     131        if( this->radarObjects_.find(rv) == this->radarObjects_.end() ) // if (radar) invisibility becomes (radar) visible
     132            this->addObject(rv);
    127133        assert( this->radarObjects_.find(rv) != this->radarObjects_.end() );
    128134        Ogre::PanelOverlayElement* panel = this->radarObjects_[rv];
     
    172178            coord *= math::pi / 3.5f; // small adjustment to make it fit the texture
    173179            it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f);
    174             it->second->show();
     180            if( distance < detectionLimit_ || detectionLimit_ < 0 )
     181                it->second->show();
     182            else
     183                it->second->hide();
    175184
    176185            // if this object is in focus, then set the focus marker
     
    184193    }
    185194
     195    bool HUDRadar::showObject(RadarViewable* rv)
     196    {
     197        if ( rv == dynamic_cast<RadarViewable*> ( this->getOwner() ) )
     198            return false;
     199        assert( rv->getWorldEntity() );
     200        if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false )
     201            return false;
     202        return true;
     203    }
     204
     205
    186206    void HUDRadar::changedOwner()
    187207    {
Note: See TracChangeset for help on using the changeset viewer.