Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/graphics/Light.cc

    r9667 r11071  
    3131#include <OgreSceneManager.h>
    3232#include <OgreLight.h>
    33 #include <boost/static_assert.hpp>
    3433
    3534#include "util/StringUtils.h"
     
    4544
    4645    // Be sure we don't do bad conversions
    47     BOOST_STATIC_ASSERT((int)Ogre::Light::LT_POINT       == (int)Light::Point);
    48     BOOST_STATIC_ASSERT((int)Ogre::Light::LT_DIRECTIONAL == (int)Light::Directional);
    49     BOOST_STATIC_ASSERT((int)Ogre::Light::LT_SPOTLIGHT   == (int)Light::Spotlight);
     46    static_assert((int)Ogre::Light::LT_POINT       == (int)Light::Type::Point,       "check enum");
     47    static_assert((int)Ogre::Light::LT_DIRECTIONAL == (int)Light::Type::Directional, "check enum");
     48    static_assert((int)Ogre::Light::LT_SPOTLIGHT   == (int)Light::Type::Spotlight,   "check enum");
    5049
    5150    Light::Light(Context* context) : StaticEntity(context)
     
    5352        RegisterObject(Light);
    5453
    55         this->light_ = 0;
     54        this->light_ = nullptr;
    5655        this->diffuse_ = ColourValue::White;
    5756        this->specular_ = ColourValue::White;
    58         this->type_ = Light::Point;
     57        this->type_ = Type::Point;
    5958        this->attenuation_ = Vector4(100000, 1, 0, 0);
    6059        this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f);
     
    106105    void Light::registerVariables()
    107106    {
    108         registerVariable((int&)this->type_,     VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateType));
     107        registerVariable(this->type_,           VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateType));
    109108        registerVariable(this->diffuse_,        VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour));
    110109        registerVariable(this->specular_,       VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateSpecularColour));
     
    127126    void Light::updateAttenuation()
    128127    {
    129         if (this->light_ && this->type_ != Light::Directional)
     128        if (this->light_ && this->type_ != Type::Directional)
    130129            this->light_->setAttenuation(this->attenuation_.x, this->attenuation_.y, this->attenuation_.z, this->attenuation_.w);
    131130    }
     
    133132    void Light::updateSpotlightRange()
    134133    {
    135         if (this->light_ && this->type_ == Light::Spotlight)
     134        if (this->light_ && this->type_ == Type::Spotlight)
    136135            this->light_->setSpotlightRange(Degree(this->spotlightRange_.x), Degree(this->spotlightRange_.y), this->spotlightRange_.z);
    137136    }
     
    140139    {
    141140        if (type == "point")
    142             this->setType(Light::Point);
     141            this->setType(Type::Point);
    143142        else if (type == "directional")
    144             this->setType(Light::Directional);
     143            this->setType(Type::Directional);
    145144        else if (type == "spotlight")
    146             this->setType(Light::Spotlight);
     145            this->setType(Type::Spotlight);
    147146        else
    148             this->setType(Light::Point);
     147            this->setType(Type::Point);
    149148    }
    150149
     
    153152        switch (this->type_)
    154153        {
    155             case Light::Directional:
     154            case Type::Directional:
    156155                return "directional";
    157             case Light::Spotlight:
     156            case Type::Spotlight:
    158157                return "spotlight";
    159             case Light::Point:
     158            case Type::Point:
    160159            default:
    161160                return "point";
     
    169168            this->light_->setType(static_cast<Ogre::Light::LightTypes>(this->type_));
    170169
    171             if (this->type_ != Light::Directional)
     170            if (this->type_ != Type::Directional)
    172171                this->updateAttenuation();
    173             if (this->type_ == Light::Spotlight)
     172            if (this->type_ == Type::Spotlight)
    174173                this->updateSpotlightRange();
    175174        }
Note: See TracChangeset for help on using the changeset viewer.