Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2008, 8:55:40 PM (16 years ago)
Author:
rgrieder
Message:
  • Handled translate, rotate, yaw, pitch, roll, lookAt and setDirection internally in WE. That only leaves setPosition and setOrientation to be pure virtual.
  • Removed loads of redundant and now obsolete code in MobileEntity and StaticEntity
  • Removed OgreSceneNode.h from WorldEntity in debug builds. getPosition, getOrientation and getScale3D are only inline in release mode. That should speed up dev builds a lot (the include is about 8300 line without Vector3, Quaternion, etc.)

Important:

  • Fixed a bug or introduced one: the lookAt(…) function in WE had default TransformSpace "TS_LOCAL", but that makes no sense the way I see it. Consider a SpaceShip and you would like it to face an asteroid. Then TS_LOCAL would yield weird results. The XMLPort attribute "lookAt" used the default value. That's where the bug might have been fixed or (I don't believe so) introduced.
Location:
code/branches/physics/src/orxonox/objects/worldentities
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/orxonox/objects/worldentities/MobileEntity.cc

    r2408 r2426  
    3030#include "MobileEntity.h"
    3131
     32#include <OgreSceneNode.h>
    3233#include "BulletDynamics/Dynamics/btRigidBody.h"
    3334
     
    117118    }
    118119
    119     void MobileEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
    120     {
    121         if (this->isDynamic())
    122         {
    123             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot translate physical object relative \
    124                                                           to any other space than TS_LOCAL.");
    125             this->physicalBody_->translate(btVector3(distance.x, distance.y, distance.z));
    126         }
    127 
    128         this->node_->translate(distance, relativeTo);
    129         positionChanged(false);
    130     }
    131 
    132120    void MobileEntity::setOrientation(const Quaternion& orientation)
    133121    {
     
    140128
    141129        this->node_->setOrientation(orientation);
    142         orientationChanged(false);
    143     }
    144 
    145     void MobileEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
    146     {
    147         if (this->isDynamic())
    148         {
    149             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot rotate physical object relative \
    150                                                           to any other space than TS_LOCAL.");
    151             btTransform transf = this->physicalBody_->getWorldTransform();
    152             this->physicalBody_->setWorldTransform(transf * btTransform(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)));
    153         }
    154 
    155         this->node_->rotate(rotation, relativeTo);
    156         orientationChanged(false);
    157     }
    158 
    159     void MobileEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    160     {
    161         if (this->isDynamic())
    162         {
    163             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot yaw physical object relative \
    164                                                           to any other space than TS_LOCAL.");
    165             btTransform transf = this->physicalBody_->getWorldTransform();
    166             btTransform rotation(btQuaternion(angle.valueRadians(), 0.0f, 0.0f));
    167             this->physicalBody_->setWorldTransform(transf * rotation);
    168         }
    169 
    170         this->node_->yaw(angle, relativeTo);
    171         orientationChanged(false);
    172     }
    173 
    174     void MobileEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    175     {
    176         if (this->isDynamic())
    177         {
    178             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot pitch physical object relative \
    179                                                           to any other space than TS_LOCAL.");
    180             btTransform transf = this->physicalBody_->getWorldTransform();
    181             btTransform rotation(btQuaternion(0.0f, angle.valueRadians(), 0.0f));
    182             this->physicalBody_->setWorldTransform(transf * rotation);
    183         }
    184 
    185         this->node_->pitch(angle, relativeTo);
    186         orientationChanged(false);
    187     }
    188 
    189     void MobileEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    190     {
    191         if (this->isDynamic())
    192         {
    193             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot roll physical object relative \
    194                                                           to any other space than TS_LOCAL.");
    195             btTransform transf = this->physicalBody_->getWorldTransform();
    196             btTransform rotation(btQuaternion(angle.valueRadians(), 0.0f, 0.0f));
    197             this->physicalBody_->setWorldTransform(transf * rotation);
    198         }
    199 
    200         this->node_->roll(angle, relativeTo);
    201         orientationChanged(false);
    202     }
    203 
    204     void MobileEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    205     {
    206         if (this->isDynamic())
    207         {
    208             ThrowException(NotImplemented, "ControllableEntity::lookAt() is not yet supported for physical objects.");
    209             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \
    210                                                           to any other space than TS_LOCAL.");
    211         }
    212 
    213         this->node_->lookAt(target, relativeTo, localDirectionVector);
    214         orientationChanged(false);
    215     }
    216 
    217     void MobileEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    218     {
    219         if (this->isDynamic())
    220         {
    221             ThrowException(NotImplemented, "ControllableEntity::setDirection() is not yet supported for physical objects.");
    222             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \
    223                                                           to any other space than TS_LOCAL.");
    224         }
    225 
    226         this->node_->setDirection(direction, relativeTo, localDirectionVector);
    227130        orientationChanged(false);
    228131    }
  • code/branches/physics/src/orxonox/objects/worldentities/MobileEntity.h

    r2408 r2426  
    4848
    4949            using WorldEntity::setPosition;
    50             using WorldEntity::translate;
    5150            using WorldEntity::setOrientation;
    52             using WorldEntity::rotate;
    53             using WorldEntity::yaw;
    54             using WorldEntity::pitch;
    55             using WorldEntity::roll;
    56             using WorldEntity::lookAt;
    57             using WorldEntity::setDirection;
    5851
    5952            void setPosition(const Vector3& position);
    60             void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    6153            void setOrientation(const Quaternion& orientation);
    62             void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    63             void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    64             void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    65             void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    66             void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    67             void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    6854
    6955            void setVelocity(const Vector3& velocity);
  • code/branches/physics/src/orxonox/objects/worldentities/StaticEntity.cc

    r2423 r2426  
    3131#include "StaticEntity.h"
    3232
     33#include <OgreSceneNode.h>
    3334#include "BulletDynamics/Dynamics/btRigidBody.h"
    3435
     
    7273    }
    7374
    74     void StaticEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
    75     {
    76         if (this->addedToPhysicalWorld())
    77             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    78         if (this->isStatic())
    79         {
    80             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot translate physical object relative \
    81                                                           to any other space than TS_LOCAL.");
    82             this->physicalBody_->translate(btVector3(distance.x, distance.y, distance.z));
    83         }
    84 
    85         this->node_->translate(distance, relativeTo);
    86     }
    87 
    8875    void StaticEntity::setOrientation(const Quaternion& orientation)
    8976    {
     
    9885
    9986        this->node_->setOrientation(orientation);
    100     }
    101 
    102     void StaticEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
    103     {
    104         if (this->addedToPhysicalWorld())
    105             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    106         if (this->isStatic())
    107         {
    108             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot rotate physical object relative \
    109                                                           to any other space than TS_LOCAL.");
    110             btTransform transf = this->physicalBody_->getWorldTransform();
    111             this->physicalBody_->setWorldTransform(transf * btTransform(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)));
    112         }
    113 
    114         this->node_->rotate(rotation, relativeTo);
    115     }
    116 
    117     void StaticEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    118     {
    119         if (this->addedToPhysicalWorld())
    120             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    121         if (this->isStatic())
    122         {
    123             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot yaw physical object relative \
    124                                                           to any other space than TS_LOCAL.");
    125             btTransform transf = this->physicalBody_->getWorldTransform();
    126             btTransform rotation(btQuaternion(angle.valueRadians(), 0.0f, 0.0f));
    127             this->physicalBody_->setWorldTransform(transf * rotation);
    128         }
    129 
    130         this->node_->yaw(angle, relativeTo);
    131     }
    132 
    133     void StaticEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    134     {
    135         if (this->addedToPhysicalWorld())
    136             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    137         if (this->isStatic())
    138         {
    139             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot pitch physical object relative \
    140                                                           to any other space than TS_LOCAL.");
    141             btTransform transf = this->physicalBody_->getWorldTransform();
    142             btTransform rotation(btQuaternion(0.0f, angle.valueRadians(), 0.0f));
    143             this->physicalBody_->setWorldTransform(transf * rotation);
    144         }
    145 
    146         this->node_->pitch(angle, relativeTo);
    147     }
    148 
    149     void StaticEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    150     {
    151         if (this->addedToPhysicalWorld())
    152             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    153         if (this->isStatic())
    154         {
    155             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot roll physical object relative \
    156                                                           to any other space than TS_LOCAL.");
    157             btTransform transf = this->physicalBody_->getWorldTransform();
    158             btTransform rotation(btQuaternion(angle.valueRadians(), 0.0f, 0.0f));
    159             this->physicalBody_->setWorldTransform(transf * rotation);
    160         }
    161 
    162         this->node_->roll(angle, relativeTo);
    163     }
    164 
    165     void StaticEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    166     {
    167         if (this->addedToPhysicalWorld())
    168             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    169         if (this->isStatic())
    170         {
    171             ThrowException(NotImplemented, "ControllableEntity::lookAt() is not yet supported for physical objects.");
    172             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \
    173                                                           to any other space than TS_LOCAL.");
    174         }
    175 
    176         this->node_->lookAt(target, relativeTo, localDirectionVector);
    177     }
    178 
    179     void StaticEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    180     {
    181         if (this->addedToPhysicalWorld())
    182             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    183         if (this->isStatic())
    184         {
    185             ThrowException(NotImplemented, "ControllableEntity::setDirection() is not yet supported for physical objects.");
    186             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \
    187                                                           to any other space than TS_LOCAL.");
    188         }
    189 
    190         this->node_->setDirection(direction, relativeTo, localDirectionVector);
    19187    }
    19288
  • code/branches/physics/src/orxonox/objects/worldentities/StaticEntity.h

    r2374 r2426  
    4545
    4646            using WorldEntity::setPosition;
    47             using WorldEntity::translate;
    4847            using WorldEntity::setOrientation;
    49             using WorldEntity::rotate;
    50             using WorldEntity::yaw;
    51             using WorldEntity::pitch;
    52             using WorldEntity::roll;
    53             using WorldEntity::lookAt;
    54             using WorldEntity::setDirection;
    5548
    5649            void setPosition(const Vector3& position);
    57             void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    5850            void setOrientation(const Quaternion& orientation);
    59             void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    60             void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    61             void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    62             void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    63             void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    64             void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    6551
    6652        private:
    6753            bool isCollisionTypeLegal(CollisionType type) const;
    6854
     55            // network callbacks
    6956            inline void positionChanged()
    7057                { this->setPosition(this->getPosition()); }
  • code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.cc

    r2423 r2426  
    3232
    3333#include <cassert>
     34#include <OgreSceneNode.h>
    3435#include <OgreSceneManager.h>
    3536#include "BulletDynamics/Dynamics/btRigidBody.h"
     
    249250    }
    250251
     252    void WorldEntity::attachOgreObject(Ogre::MovableObject* object)
     253    {
     254        this->node_->attachObject(object);
     255    }
     256
     257    void WorldEntity::detachOgreObject(Ogre::MovableObject* object)
     258    {
     259        this->node_->detachObject(object);
     260    }
     261
     262    Ogre::MovableObject* WorldEntity::detachOgreObject(const Ogre::String& name)
     263    {
     264        return this->node_->detachObject(name);
     265    }
     266
    251267    void WorldEntity::attachCollisionShape(CollisionShape* shape)
    252268    {
     
    289305    }
    290306
     307#ifndef _NDEBUG
     308    const Vector3& WorldEntity::getPosition() const
     309    {
     310        return this->node_->getPosition();
     311    }
     312
     313    const Quaternion& WorldEntity::getOrientation() const
     314    {
     315        return this->node_->getOrientation();
     316    }
     317
     318    const Vector3& WorldEntity::getScale3D() const
     319    {
     320        return this->node_->getScale();
     321    }
     322#endif
     323
     324    const Vector3& WorldEntity::getWorldPosition() const
     325    {
     326        return this->node_->_getDerivedPosition();
     327    }
     328
     329    const Quaternion& WorldEntity::getWorldOrientation() const
     330    {
     331        return this->node_->_getDerivedOrientation();
     332    }
     333
     334    void WorldEntity::translate(const Vector3& distance, TransformSpace::Space relativeTo)
     335    {
     336        switch (relativeTo)
     337        {
     338        case TransformSpace::Local:
     339            // position is relative to parent so transform downwards
     340            this->setPosition(this->getPosition() + this->getOrientation() * distance);
     341            break;
     342        case TransformSpace::Parent:
     343            this->setPosition(this->getPosition() + distance);
     344            break;
     345        case TransformSpace::World:
     346            // position is relative to parent so transform upwards
     347            if (this->node_->getParent())
     348                setPosition(getPosition() + (node_->getParent()->_getDerivedOrientation().Inverse() * distance)
     349                    / node_->getParent()->_getDerivedScale());
     350            else
     351                this->setPosition(this->getPosition() + distance);
     352            break;
     353        }
     354    }
     355
     356    void WorldEntity::rotate(const Quaternion& rotation, TransformSpace::Space relativeTo)
     357    {
     358        switch(relativeTo)
     359        {
     360        case TransformSpace::Local:
     361            this->setOrientation(this->getOrientation() * rotation);
     362            break;
     363        case TransformSpace::Parent:
     364            // Rotations are normally relative to local axes, transform up
     365            this->setOrientation(rotation * this->getOrientation());
     366            break;
     367        case TransformSpace::World:
     368            // Rotations are normally relative to local axes, transform up
     369            this->setOrientation(this->getOrientation() * this->getWorldOrientation().Inverse()
     370                * rotation * this->getWorldOrientation());
     371            break;
     372        }
     373    }
     374
     375    void WorldEntity::lookAt(const Vector3& target, TransformSpace::Space relativeTo, const Vector3& localDirectionVector)
     376    {
     377        Vector3 origin;
     378        switch (relativeTo)
     379        {
     380        case TransformSpace::Local:
     381            origin = Vector3::ZERO;
     382            break;
     383        case TransformSpace::Parent:
     384            origin = this->getPosition();
     385            break;
     386        case TransformSpace::World:
     387            origin = this->getWorldPosition();
     388            break;
     389        }
     390        this->setDirection(target - origin, relativeTo, localDirectionVector);
     391    }
     392
     393    void WorldEntity::setDirection(const Vector3& direction, TransformSpace::Space relativeTo, const Vector3& localDirectionVector)
     394    {
     395        Quaternion savedOrientation(this->getOrientation());
     396        Ogre::Node::TransformSpace ogreRelativeTo;
     397        switch (relativeTo)
     398        {
     399        case TransformSpace::Local:
     400            ogreRelativeTo = Ogre::Node::TS_LOCAL; break;
     401        case TransformSpace::Parent:
     402            ogreRelativeTo = Ogre::Node::TS_PARENT; break;
     403        case TransformSpace::World:
     404            ogreRelativeTo = Ogre::Node::TS_WORLD; break;
     405        }
     406        this->node_->setDirection(direction, ogreRelativeTo, localDirectionVector);
     407        Quaternion newOrientation(this->node_->getOrientation());
     408        this->node_->setOrientation(savedOrientation);
     409        this->setOrientation(newOrientation);
     410    }
     411
    291412    void WorldEntity::setScale3D(const Vector3& scale)
    292413    {
     
    295416
    296417        this->node_->setScale(scale);
    297     }
    298 
    299     void WorldEntity::scale3D(const Vector3& scale)
    300     {
    301         if (this->hasPhysics())
    302             ThrowException(NotImplemented, "Cannot set the scale of a physical object: Not yet implemented.");
    303 
    304         this->node_->scale(scale);
    305418    }
    306419
  • code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.h

    r2423 r2426  
    3333#include "OrxonoxPrereqs.h"
    3434
    35 #define OGRE_FORCE_ANGLE_TYPES
     35#ifdef _NDEBUG
    3636#include <OgreSceneNode.h>
     37#else
     38#include <OgrePrerequisites.h>
     39#endif
    3740#include "LinearMath/btMotionState.h"
    3841
     
    6568            inline void setPosition(float x, float y, float z)
    6669                { this->setPosition(Vector3(x, y, z)); }
    67             inline const Vector3& getPosition() const
    68                 { return this->node_->getPosition(); }
    69             inline const Vector3& getWorldPosition() const
    70                 { return this->node_->getWorldPosition(); }
    71 
    72             virtual void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    73             inline void translate(float x, float y, float z, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
     70            const Vector3& getPosition() const;
     71            const Vector3& getWorldPosition() const;
     72
     73            void translate(const Vector3& distance, TransformSpace::Space relativeTo = TransformSpace::Parent);
     74            inline void translate(float x, float y, float z, TransformSpace::Space relativeTo = TransformSpace::Parent)
    7475                { this->translate(Vector3(x, y, z), relativeTo); }
    7576
     
    8182            inline void setOrientation(const Vector3& axis, const Degree& angle)
    8283                { this->setOrientation(Quaternion(angle, axis)); }
    83             inline const Quaternion& getOrientation() const
    84                 { return this->node_->getOrientation(); }
    85             inline const Quaternion& getWorldOrientation() const
    86                 { return this->node_->getWorldOrientation(); }
    87 
    88             virtual void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    89             inline void rotate(const Vector3& axis, const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
     84            const Quaternion& getOrientation() const;
     85            const Quaternion& getWorldOrientation() const;
     86
     87            void rotate(const Quaternion& rotation, TransformSpace::Space relativeTo = TransformSpace::Local);
     88            inline void rotate(const Vector3& axis, const Degree& angle, TransformSpace::Space relativeTo = TransformSpace::Local)
    9089                { this->rotate(Quaternion(angle, axis), relativeTo); }
    91             inline void rotate(const Vector3& axis, const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    92                 { this->rotate(Quaternion(angle, axis), relativeTo); }
    93 
    94             virtual void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    95             inline void yaw(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    96                 { this->yaw(Degree(angle), relativeTo); }
    97             virtual void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    98             inline void pitch(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    99                 { this->pitch(Degree(angle), relativeTo); }
    100             virtual void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    101             inline void roll(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    102                 { this->roll(Degree(angle), relativeTo); }
    103 
    104             virtual void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) = 0;
    105             virtual void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) = 0;
    106             inline void setDirection(float x, float y, float z, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
     90
     91            inline void yaw(const Degree& angle, TransformSpace::Space relativeTo = TransformSpace::Local)
     92                { this->rotate(Quaternion(angle, Vector3::UNIT_Y), relativeTo); }
     93            inline void pitch(const Degree& angle, TransformSpace::Space relativeTo = TransformSpace::Local)
     94                { this->rotate(Quaternion(angle, Vector3::UNIT_X), relativeTo); }
     95            inline void roll(const Degree& angle, TransformSpace::Space relativeTo = TransformSpace::Local)
     96                { this->rotate(Quaternion(angle, Vector3::UNIT_Z), relativeTo); }
     97
     98            void lookAt(const Vector3& target, TransformSpace::Space relativeTo = TransformSpace::Parent, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
     99            void setDirection(const Vector3& direction, TransformSpace::Space relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
     100            inline void setDirection(float x, float y, float z, TransformSpace::Space relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
    107101                { this->setDirection(Vector3(x, y, z), relativeTo, localDirectionVector); }
    108102
     
    110104            inline void setScale3D(float x, float y, float z)
    111105                { this->setScale3D(Vector3(x, y, z)); }
    112             inline const Vector3& getScale3D(void) const
    113                 { return this->node_->getScale(); }
     106            const Vector3& getScale3D(void) const;
    114107
    115108            void setScale(float scale)
     
    118111                { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; }
    119112
    120             virtual void scale3D(const Vector3& scale);
     113            inline void scale3D(const Vector3& scale)
     114                { this->setScale3D(this->getScale3D() * scale); }
    121115            inline void scale3D(float x, float y, float z)
    122116                { this->scale3D(Vector3(x, y, z)); }
     
    130124                { return this->children_; }
    131125
    132             inline void attachOgreObject(Ogre::MovableObject* object)
    133                 { this->node_->attachObject(object); }
    134             inline void detachOgreObject(Ogre::MovableObject* object)
    135                 { this->node_->detachObject(object); }
    136             inline Ogre::MovableObject* detachOgreObject(const Ogre::String& name)
    137                 { return this->node_->detachObject(name); }
     126            void attachOgreObject(Ogre::MovableObject* object);
     127            void detachOgreObject(Ogre::MovableObject* object);
     128            Ogre::MovableObject* detachOgreObject(const Ogre::String& name);
    138129
    139130            inline void attachToParent(WorldEntity* parent)
     
    241232            btScalar                     childrenMass_;
    242233    };
     234
     235    // Inline heavily used functions for release builds. In debug, we better avoid including OgreSceneNode here.
     236#ifdef _NDEBUG
     237    inline const Vector3& WorldEntity::getPosition() const
     238        { return this->node_->getPosition(); }
     239    inline const Quaternion& WorldEntity::getOrientation() const
     240        { return this->node_->getrOrientation(); }
     241    inline const Vector3& WorldEntity::getScale3D(void) const
     242        { return this->node_->getScale(); }
     243#endif
    243244}
    244245
Note: See TracChangeset for help on using the changeset viewer.