Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 20, 2009, 9:20:47 AM (16 years ago)
Author:
rgrieder
Message:

Merged pch branch back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/util/Math.h

    r2872 r3196  
    3737#include "UtilPrereqs.h"
    3838
    39 #include <ostream>
    4039#include <string>
    4140#include <cmath>
    42 #include <boost/static_assert.hpp>
    4341
    4442#include <OgreMath.h>
     
    4644#include <OgreVector3.h>
    4745#include <OgreVector4.h>
    48 #include <OgreMatrix3.h>
    49 #include <OgreMatrix4.h>
    5046#include <OgreQuaternion.h>
    5147#include <OgreColourValue.h>
     
    5854namespace orxonox
    5955{
    60     using Ogre::Radian;
    61     using Ogre::Degree;
    62     using Ogre::Vector2;
    63     using Ogre::Vector3;
    64     using Ogre::Vector4;
    65     using Ogre::Matrix3;
    66     using Ogre::Matrix4;
    67     using Ogre::Quaternion;
    68     using Ogre::ColourValue;
    69 
    70     // Also define our own transform space enum
    71     namespace TransformSpace
    72     {
    73         /**
    74         @brief
    75             Enumeration denoting the spaces which a transform can be relative to.
    76         */
    77         enum Enum
    78         {
    79             //! Transform is relative to the local space
    80             Local,
    81             //! Transform is relative to the space of the parent node
    82             Parent,
    83             //! Transform is relative to world space
    84             World
    85         };
    86     }
    87 
    8856    _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian);
    8957    _UtilExport std::istream& operator>>(std::istream& in, orxonox::Radian& radian);
     
    217185    template <> inline orxonox::Quaternion  zeroise<orxonox::Quaternion>()  { return orxonox::Quaternion (0, 0, 0, 0); }
    218186
     187    //! Provides zero value symbols that can be returned as reference
     188    template <typename T>
     189    struct NilValue
     190    {
     191        inline operator const T&() const
     192        {
     193            return value;
     194        }
     195        static T value;
     196    };
     197    template <typename T>
     198    T NilValue<T>::value = zeroise<T>();
     199
    219200    /**
    220201        @brief Interpolates between two values for a time between 0 and 1.
     
    225206    */
    226207    template <typename T>
    227     T interpolate(float time, const T& start, const T& end)
     208    inline T interpolate(float time, const T& start, const T& end)
    228209    {
    229210        return time * (end - start) + start;
     
    238219    */
    239220    template <typename T>
    240     T interpolateSmooth(float time, const T& start, const T& end)
     221    inline T interpolateSmooth(float time, const T& start, const T& end)
    241222    {
    242223        return (-2 * (end - start) * cube(time)) + (3 * (end - start) * square(time)) + start;
     
    248229    inline float rnd()
    249230    {
    250         return rand() / (RAND_MAX + 1.0);
     231        return rand() / (RAND_MAX + 1.0f);
    251232    }
    252233
     
    275256    inline float rndsgn()
    276257    {
    277         return ((rand() & 0x2) - 1); // rand() & 0x2 is either 2 or 0
     258        return static_cast<float>((rand() & 0x2) - 1); // rand() & 0x2 is either 2 or 0
    278259    }
    279260
     
    283264    {
    284265    public:
    285       IntVector2() : x(0), y(0) { }
    286       IntVector2(int _x, int _y) : x(_x), y(_y) { }
    287       int x;
    288       int y;
     266        IntVector2() : x(0), y(0) { }
     267        IntVector2(int _x, int _y) : x(_x), y(_y) { }
     268        int x;
     269        int y;
    289270    };
    290271
     
    292273    {
    293274    public:
    294       IntVector3() : x(0), y(0), z(0) { }
    295       IntVector3(int _x, int _y, int _z) : x(_x), y(_y), z(_z) { }
    296       int x;
    297       int y;
    298       int z;
     275        IntVector3() : x(0), y(0), z(0) { }
     276        IntVector3(int _x, int _y, int _z) : x(_x), y(_y), z(_z) { }
     277        int x;
     278        int y;
     279        int z;
    299280    };
    300281}
Note: See TracChangeset for help on using the changeset viewer.