Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 8, 2011, 11:45:32 PM (14 years ago)
Author:
dafrick
Message:

Documenting collision shapes in an effort to understand them and implement scaling.
Scaling is however not working yet, and thus not yet enabled.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup/src/modules/objects/collisionshapes/BoxCollisionShape.h

    r7601 r8422  
    4343namespace orxonox
    4444{
     45
     46    /**
     47    @brief
     48        Wrapper for the bullet box collision shape class btBoxShape.
     49
     50    @author
     51        Reto Grieder
     52
     53    @ingroup Collisionshapes
     54    */
    4555    class _ObjectsExport BoxCollisionShape : public CollisionShape
    4656    {
     
    5161            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5262
    53             inline void setHalfExtents(const Vector3& extents)
    54                 { this->halfExtents_ = extents; updateShape(); }
     63            /**
     64            @brief Set the half extents of the BoxCollisionShape.
     65                   If the half extent changes, this causes the internal collision shape to be recreated.
     66            @param extents A vector with the half extents.
     67                   The x-component is half the length, the y-component is half the height and the z-component is half the width.
     68            @return Returns true if the half extent has changed, false if not.
     69            */
     70            inline bool setHalfExtents(const Vector3& extents)
     71                { if(this->halfExtents_ == extents) return false; this->halfExtents_ = extents; updateShape(); return true; }
     72            /**
     73            @brief Get the half extents of the BoxCollisionShape.
     74            @return Returns a vector containing the half extents.
     75            */
    5576            inline const Vector3& getHalfExtents() const
    5677                { return halfExtents_;}
    5778
    58             inline void setWidth(float value)
    59                 { this->halfExtents_.z = value / 2; updateShape(); }
     79            /**
     80            @brief Set the width of the BoxCollisionShape.
     81                   If the width changes, this causes the internal collision shape to be recreated.
     82            @param value The width to be set.
     83            @return Returns true if the width has changed, false if not.
     84            */
     85            inline bool setWidth(float value)
     86                { if(this->halfExtents_.z == value/2.0f) return false; this->halfExtents_.z = value / 2.0f; updateShape(); return true; }
     87            /**
     88            @brief Get the width of the BoxCollisionShape.
     89            @return Returns the width of the BoxCollisionShape.
     90            */
    6091            inline float getWidth() const
    61                 { return this->halfExtents_.z * 2; }
     92                { return this->halfExtents_.z * 2.0f; }
    6293
    63             inline void setHeight(float value)
    64                 { this->halfExtents_.y = value / 2; updateShape(); }
     94            /**
     95            @brief Set the height of the BoxCollisionShape.
     96                   If the height changes, this causes the internal collision shape to be recreated.
     97            @param value The height to be set.
     98            @return Returns true if the height has changed, false if not.
     99            */
     100            inline bool setHeight(float value)
     101                { if(this->halfExtents_.y == value/2.0f) return false; this->halfExtents_.y = value / 2.0f; updateShape(); return true; }
     102            /**
     103            @brief Get the height of the BoxCollisionShape.
     104            @return Returns the height of the BoxCollisionShape.
     105            */
    65106            inline float getHeight() const
    66                 { return this->halfExtents_.y * 2; }
     107                { return this->halfExtents_.y * 2.0f; }
    67108
    68             inline void setLength(float value)
    69                 { this->halfExtents_.x = value / 2; updateShape(); }
     109            /**
     110            @brief Set the length of the BoxCollisionShape.
     111                   If the length changes, this causes the internal collision shape to be recreated.
     112            @param value The length to be set.
     113            @return Returns true if the length has changed, false if not.
     114            */
     115            inline bool setLength(float value)
     116                { if(this->halfExtents_.x == value/2.0f) return false; this->halfExtents_.x = value / 2.0f; updateShape(); return true; }
     117            /**
     118            @brief Get the length of the BoxCollisionShape.
     119            @return Returns the length of the BoxCollisionShape.
     120            */
    70121            inline float getLength() const
    71                 { return this->halfExtents_.x * 2; }
     122                { return this->halfExtents_.x * 2.0f; }
     123
     124            virtual void changedScale(); // Is called when the scale of the BoxCollisionShape has changed.
    72125
    73126        private:
    74127            void registerVariables();
    75128
    76             btCollisionShape* createNewShape() const;
     129            btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the BoxCollisionShape.
    77130
    78             Vector3 halfExtents_;
     131            Vector3 halfExtents_; //!< The half extents of the BoxCollisionShape. The x-component is half the length, the y-component is half the height and the z-component is half the width.
    79132     };
    80133}
Note: See TracChangeset for help on using the changeset viewer.