Index: code/trunk/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDNavigation.cc	(revision 11022)
+++ code/trunk/src/modules/overlays/hud/HUDNavigation.cc	(revision 11023)
@@ -367,46 +367,55 @@
                     // Object is in view
 
-
-
-
                     //calculate the health of the actual selected radarViewable (relativHealthScale: while (0) is no health left, (1) is the initial health)
-                    Pawn* pawnPtr = (Pawn*) (it->first->getWorldEntity());
-                    float health = pawnPtr->getHealth();
-                    float initHealth = pawnPtr->getMaxHealth();
-                    float relativHealthScale = health/initHealth;
-
-                    //integer values from 0 to 10 (0 is no health and 10 is full health)
-                    int discreteHealthScale = (int)(10*relativHealthScale);
-
-                    //calculate the HealthLevel (= OponentLevel or Strength) there are 5 Levels
-                    //Level 1, Level 2,... , Level 5
-                    int HealthLevel = 1;
-
-                    if(initHealth < 200)
-                        HealthLevel = 1;
-                    if(200 <= initHealth && initHealth < 500)
-                        HealthLevel = 2;
-                    if(500 <= initHealth && initHealth < 1000)
-                        HealthLevel = 3;
-                    if(1000 <= initHealth && initHealth < 2500)
-                        HealthLevel = 4;
-                    if(2500 <= initHealth)
-                        HealthLevel = 5;
-
-
-
-                    // Change material only if outOfView changed
-                    if (it->second.wasOutOfView_)
-                    {
-                        //it->second.panel_->setMaterialName("Orxonox/NavTDC");
-                        it->second.panel_->setMaterialName(TextureGenerator::getMaterialName("tdc.png", it->first->getRadarObjectColour()));
-                        it->second.panel_->setDimensions(this->navMarkerSize_ * this->getActualSize().x, this->navMarkerSize_ * this->getActualSize().y);
-                        it->second.target_->setDimensions(this->aimMarkerSize_ * this->getActualSize().x, this->aimMarkerSize_ * this->getActualSize().y);
-
-
-                        //it->second.health_->setMaterialName(TextureGenerator::getMaterialName("bar2_1.png", it->first->getRadarObjectColour()));
-                        it->second.health_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour()));
-                        it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x , 0.75f*this->healthMarkerSize_ * this->getActualSize().y);
-                        it->second.wasOutOfView_ = false;
+                    const Pawn* pawnPtr = orxonox_cast<const Pawn*>(it->first->getWorldEntity());
+                    if (pawnPtr)
+                    {
+                        float health = pawnPtr->getHealth();
+                        float initHealth = pawnPtr->getMaxHealth();
+                        float relativHealthScale = health/initHealth;
+
+                        //integer values from 0 to 10 (0 is no health and 10 is full health)
+                        int discreteHealthScale = (int)(10*relativHealthScale);
+
+                        //calculate the HealthLevel (= OponentLevel or Strength) there are 5 Levels
+                        //Level 1, Level 2,... , Level 5
+                        int HealthLevel = 1;
+
+                        if(initHealth < 200)
+                            HealthLevel = 1;
+                        if(200 <= initHealth && initHealth < 500)
+                            HealthLevel = 2;
+                        if(500 <= initHealth && initHealth < 1000)
+                            HealthLevel = 3;
+                        if(1000 <= initHealth && initHealth < 2500)
+                            HealthLevel = 4;
+                        if(2500 <= initHealth)
+                            HealthLevel = 5;
+
+                        // Change material only if outOfView changed
+                        if (it->second.wasOutOfView_)
+                        {
+                            //it->second.health_->setMaterialName(TextureGenerator::getMaterialName("bar2_1.png", it->first->getRadarObjectColour()));
+                            it->second.health_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour()));
+                            it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x , 0.75f*this->healthMarkerSize_ * this->getActualSize().y);
+
+                            // because as soon as relative health drops below 10% (0.1) the descrete value is 0 but as long as the
+                            // spaceship is still intact there should be at least one part of the bar left.
+                            if(1<=discreteHealthScale){
+                                it->second.health_->setTiling((float)discreteHealthScale , 1 ,0);
+                                it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x *0.1f*discreteHealthScale, 0.75f*this->healthMarkerSize_ * this->getActualSize().y);
+                            }
+
+                            //healthLevel
+                            it->second.healthLevel_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour()));
+                            it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * this->getActualSize().x , 0.75f*this->healthLevelMarkerSize_ * this->getActualSize().y);
+                            it->second.healthLevel_->setTiling((float)HealthLevel , 1 ,0);
+                            it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * this->getActualSize().x *0.1f*HealthLevel, 0.25f*this->healthLevelMarkerSize_ * this->getActualSize().y);
+                        }
+
+                        // sets Position and Dimensions (amount) health
+                        it->second.health_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
+                        it->second.health_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f);
+                        it->second.health_->setTop((-pos.y + 1.04f - it->second.panel_->getHeight()) * 0.5f);
 
                         // because as soon as relative health drops below 10% (0.1) the descrete value is 0 but as long as the
@@ -417,39 +426,28 @@
                         }
 
-
-
-                        //healthLevel
+                        //sets Position and Dimensions (level) of healthLevel
                         it->second.healthLevel_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour()));
-                        it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * this->getActualSize().x , 0.75f*this->healthLevelMarkerSize_ * this->getActualSize().y);
-                        it->second.wasOutOfView_ = false;
+                        it->second.healthLevel_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
+                        it->second.healthLevel_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f);
+                        it->second.healthLevel_->setTop((-pos.y + 1.125f - it->second.panel_->getHeight()) * 0.5f);
+
                         it->second.healthLevel_->setTiling((float)HealthLevel , 1 ,0);
                         it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * this->getActualSize().x *0.1f*HealthLevel, 0.25f*this->healthLevelMarkerSize_ * this->getActualSize().y);
-                    }
-
-
-
-                    // sets Position and Dimensions (amount) health
-                    it->second.health_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
-                    it->second.health_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f);
-                    it->second.health_->setTop((-pos.y + 1.04f - it->second.panel_->getHeight()) * 0.5f);
-
-
-                    // because as soon as relative health drops below 10% (0.1) the descrete value is 0 but as long as the
-                    // spaceship is still intact there should be at least one part of the bar left.
-                    if(1<=discreteHealthScale){
-                    it->second.health_->setTiling((float)discreteHealthScale , 1 ,0);
-                    it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x *0.1f*discreteHealthScale, 0.75f*this->healthMarkerSize_ * this->getActualSize().y);
-                    }
-
-
-                    //sets Position and Dimensions (level) of healthLevel
-                    it->second.healthLevel_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour()));
-                    it->second.healthLevel_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
-                    it->second.healthLevel_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f);
-                    it->second.healthLevel_->setTop((-pos.y + 1.125f - it->second.panel_->getHeight()) * 0.5f);
-
-                    it->second.healthLevel_->setTiling((float)HealthLevel , 1 ,0);
-                    it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * this->getActualSize().x *0.1f*HealthLevel, 0.25f*this->healthLevelMarkerSize_ * this->getActualSize().y);
-
+
+                        // Make sure the overlays are shown
+                        it->second.health_->show();
+                        it->second.healthLevel_->show();
+                    }
+
+
+                    // Change material only if outOfView changed
+                    if (it->second.wasOutOfView_)
+                    {
+                        //it->second.panel_->setMaterialName("Orxonox/NavTDC");
+                        it->second.panel_->setMaterialName(TextureGenerator::getMaterialName("tdc.png", it->first->getRadarObjectColour()));
+                        it->second.panel_->setDimensions(this->navMarkerSize_ * this->getActualSize().x, this->navMarkerSize_ * this->getActualSize().y);
+                        it->second.target_->setDimensions(this->aimMarkerSize_ * this->getActualSize().x, this->aimMarkerSize_ * this->getActualSize().y);
+                        it->second.wasOutOfView_ = false;
+                    }
 
                     // Position marker
@@ -462,10 +460,5 @@
                     it->second.text_->setTop((-pos.y + 1.0f + it->second.panel_->getHeight()) * 0.5f);
 
-
-
-
                     // Make sure the overlays are shown
-                    it->second.health_->show();
-                    it->second.healthLevel_->show();
                     it->second.panel_->show();
                     it->second.text_->show();
