Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8874 for code/branches/ai2/src


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.

Location:
code/branches/ai2/src/modules/overlays/hud
Files:
4 edited

Legend:

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

    r8706 r8874  
    6363{
    6464  SetConfigValue(markerLimit_, 3);
     65
    6566}
    6667
     
    7778    setTextSize ( 0.05f );
    7879    setNavMarkerSize ( 0.05f );
     80    setDetectionLimit( 10000.0f );
    7981}
    8082
     
    9597    SUPER ( HUDNavigation, XMLPort, xmlelement, mode );
    9698
    97     XMLPortParam ( HUDNavigation, "font",          setFont,          getFont,          xmlelement, mode );
    98     XMLPortParam ( HUDNavigation, "textSize",      setTextSize,      getTextSize,      xmlelement, mode );
    99     XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode );
     99    XMLPortParam ( HUDNavigation, "font",           setFont,           getFont,           xmlelement, mode );
     100    XMLPortParam ( HUDNavigation, "textSize",       setTextSize,       getTextSize,       xmlelement, mode );
     101    XMLPortParam ( HUDNavigation, "navMarkerSize",  setNavMarkerSize,  getNavMarkerSize,  xmlelement, mode );
     102    XMLPortParam ( HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode );
    100103}
    101104
     
    161164
    162165    unsigned int markerCount_ = 0;
    163 
     166    bool closeEnough_ = false; //inly display objects that are close enough to be relevant for the player
    164167//         for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it)
    165168    for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt )
    166169    {
    167170        ObjectMap::iterator it = activeObjectList_.find ( listIt->first );
    168 
    169         if ( markerCount_ < markerLimit_ )
     171        if( detectionLimit_ < 0 )
     172            closeEnough_ = true ;
     173        else
     174            closeEnough_ = listIt->second < detectionLimit_ ;
     175        if ( markerCount_ < markerLimit_ && closeEnough_ ) // display on HUD íf statement is true
    170176        {
    171177
     
    277283            it->second.text_->show();
    278284        }
    279         else
     285        else // do not display on HUD
    280286        {
    281287            it->second.panel_->hide();
     
    309315void HUDNavigation::addObject ( RadarViewable* object )
    310316{
    311     if( showObject(object)==false )
     317    if( showObject(object) == false )
    312318        return;
    313319
     
    396402        return false;
    397403    assert( rv->getWorldEntity() );
    398     if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false )
     404    if ( rv->getWorldEntity()->isVisible() == false || rv->getRadarVisibility() == false )
    399405        return false;
    400406    return true;
  • code/branches/ai2/src/modules/overlays/hud/HUDNavigation.h

    r7401 r8874  
    8585    { return navMarkerSize_; }
    8686
     87    void setDetectionLimit( float limit )
     88    { this->detectionLimit_ = limit; }
     89    float getDetectionLimit() const
     90    { return this->detectionLimit_; }
     91
    8792    void setTextSize ( float size );
    8893    float getTextSize() const;
     
    102107    float textSize_;
    103108
    104     unsigned int markerLimit_;; //TODO: is it possible to set this over the console and/or the IG-Setting
    105 
    106 
     109    unsigned int markerLimit_; //TODO: is it possible to set this over the console and/or the IG-Setting
     110    float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value.
     111                           //!< In order to bypass this behaviour, set a negative detectionLimit_. Then the detection range is "infinite".
    107112};
    108113}
  • 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    {
  • code/branches/ai2/src/modules/overlays/hud/HUDRadar.h

    r7880 r8874  
    5757        void setHalfDotSizeDistance(float distance) { this->halfDotSizeDistance_ = distance; }
    5858
     59        void setDetectionLimit( float limit )
     60        { this->detectionLimit_ = limit; }
     61        float getDetectionLimit() const
     62        { return this->detectionLimit_; }
     63
    5964        float getMaximumDotSize() const { return this->maximumDotSize_; }
    6065        void setMaximumDotSize(float size) { this->maximumDotSize_ = size; }
     
    6974        virtual void objectChanged( RadarViewable* rv );
    7075        void radarTick(float dt);
     76        bool showObject( RadarViewable* rv ); //!< Do not display an object on radar, if showObject(.) is false.
    7177
    7278        void gatherObjects();
     
    8389
    8490        float sensitivity_;
    85 
     91        float detectionLimit_;
    8692        ControllableEntity* owner_;
    8793    };
Note: See TracChangeset for help on using the changeset viewer.