Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1558 for code/trunk/src/core


Ignore:
Timestamp:
Jun 7, 2008, 2:06:41 AM (16 years ago)
Author:
landauf
Message:

added support for isVisible() and isActive() to all objects.
those functions are provided by BaseObject, combined with virtual functions changedVisibility and changedActivity respectively.
use them, to make orxonox scriptable, say: to change the state of objects with 2 simple functions instead of changing all meshes and emitters and billboards of an object. don't forget to pass calls to changedVisibility and changedActivity to the parent class.

additionally there is a new function, isInitialized(), provided by BaseObject too. this returns true if the constructor of BaseObject passed the object registration. this allows you, to check whether an object was properly initialized or if the constructor returned (as this is the case while creating the class hierarchy). use isInitialized() in your destructor before deleting something.

Location:
code/trunk/src/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/core/BaseObject.cc

    r1505 r1558  
    4646    */
    4747    BaseObject::BaseObject() :
    48       bActive_(true),
    49       bVisible_(true),
    50       level_(0),
    51       namespace_(0)
     48        bInitialized_(false),
     49        bActive_(true),
     50        bVisible_(true),
     51        level_(0),
     52        namespace_(0)
    5253    {
    5354        RegisterRootObject(BaseObject);
     55
     56        this->bInitialized_ = true;
    5457    }
    5558
  • code/trunk/src/core/BaseObject.h

    r1505 r1558  
    4747    class _CoreExport BaseObject : virtual public OrxonoxClass
    4848    {
     49        friend class WorldEntity;
     50
    4951        public:
    5052            BaseObject();
     
    5254            virtual void loadParams(TiXmlElement* xmlElem);
    5355            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     56
     57            /** @brief Returns if the object was initialized (passed the object registration). @return True was the object is initialized */
     58            inline bool isInitialized() const { return this->bInitialized_; }
    5459
    5560            /** @brief Sets the name of the object. @param name The name */
     
    6368            inline void setActivity(bool bActive) { this->bActive_ = bActive; this->changedActivity(); }
    6469            /** @brief Returns the state of the objects activity. @return The state of the activity */
    65             inline const bool isActive() const { return this->bActive_; }
     70            inline bool isActive() const { return this->bActive_; }
    6671            /** @brief This function gets called if the activity of the object changes. */
    6772            virtual void changedActivity() {}
     
    7075            inline void setVisibility(bool bVisible) { this->bVisible_ = bVisible; this->changedVisibility(); }
    7176            /** @brief Returns the state of the objects visibility. @return The state of the visibility */
    72             inline const bool isVisible() const { return this->bVisible_; }
     77            inline bool isVisible() const { return this->bVisible_; }
    7378            /** @brief This function gets called if the visibility of the object changes. */
    7479            virtual void changedVisibility() {}
     
    9095        private:
    9196            std::string name_;                          //!< The name of the object
     97            bool bInitialized_;                         //!< True if the object was initialized (passed the object registration)
    9298            bool bActive_;                              //!< True = the object is active
    9399            bool bVisible_;                             //!< True = the object is visible
Note: See TracChangeset for help on using the changeset viewer.