Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2008, 4:14:36 PM (15 years ago)
Author:
rgrieder
Message:
  • Added detach functions to CollisionShapes
  • Added update functions across the CollisionShape hierarchy so that when you change the radius of a sphere, everything up to the WE gets updated.
  • Setting the btCollisionShape at run time doesn't work after all, fixed that (you can still do it, just a question of internals)
  • Improved network synchronisation
  • new WE function: addedToPhysicalWorld() to check whether we can still perform operations that are disallowed at run time (esp. StaticEntity)

Conclusively, I can say that right now, all operations considering physics should be handled automatically, bugs not withstanding.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.h

    r2407 r2423  
    3535#define OGRE_FORCE_ANGLE_TYPES
    3636#include <OgreSceneNode.h>
    37 
    3837#include "LinearMath/btMotionState.h"
    3938
     
    126125
    127126            void attach(WorldEntity* object);
    128 //            void attachAsdf(BlinkingBillboard* object);
    129127            void detach(WorldEntity* object);
    130128            WorldEntity* getAttachedObject(unsigned int index) const;
    131 //            BlinkingBillboard* getAttachedAsdfObject(unsigned int index) const;
    132129            inline const std::set<WorldEntity*>& getAttachedObjects() const
    133130                { return this->children_; }
     
    146143            inline WorldEntity* getParent() const
    147144                { return this->parent_; }
     145
     146            void notifyChildPropsChanged();
    148147
    149148        protected:
     
    185184            };
    186185
    187             bool hasPhysics()  const { return getCollisionType() != None     ; }
    188             bool isStatic()    const { return getCollisionType() == Static   ; }
    189             bool isKinematic() const { return getCollisionType() == Kinematic; }
    190             bool isDynamic()   const { return getCollisionType() == Dynamic  ; }
    191             bool isPhysicsRunning() const;
     186            bool hasPhysics()       const { return getCollisionType() != None     ; }
     187            bool isStatic()         const { return getCollisionType() == Static   ; }
     188            bool isKinematic()      const { return getCollisionType() == Kinematic; }
     189            bool isDynamic()        const { return getCollisionType() == Dynamic  ; }
     190            bool isPhysicsActive()  const { return this->bPhysicsActive_; }
     191            bool addedToPhysicalWorld() const;
     192
     193            void activatePhysics();
     194            void deactivatePhysics();
    192195
    193196            inline CollisionType getCollisionType() const
     
    201204            inline float getMass() const
    202205                { return this->mass_; }
    203 
    204             void attachCollisionShape(CollisionShape* shape, bool bWorldEntityRoot = false);
     206            inline float getTotalMass() const
     207                { return this->mass_ + this->childrenMass_; }
     208
     209            void attachCollisionShape(CollisionShape* shape);
     210            void detachCollisionShape(CollisionShape* shape);
    205211            CollisionShape* getAttachedCollisionShape(unsigned int index) const;
    206212
     
    210216                { return this->physicalBody_; }
    211217
     218            void notifyCollisionShapeChanged();
     219            void notifyChildMassChanged();
     220
    212221        protected:
    213222            virtual bool isCollisionTypeLegal(CollisionType type) const = 0;
     
    217226        private:
    218227            void updateCollisionType();
    219             void mergeCollisionShape(CollisionShape* shape);
    220             void internalSetMassProps();
    221             btVector3 getLocalInertia(btScalar mass) const;
    222             bool checkPhysics() const;
    223             void addToPhysicalWorld() const;
    224             void removeFromPhysicalWorld() const;
     228            void recalculatePhysicsProps();
    225229
    226230            // network callbacks
    227231            void collisionTypeChanged();
    228232            void massChanged();
     233            void physicsActivityChanged();
    229234
    230235            CollisionType                collisionType_;
    231236            CollisionType                collisionTypeSynchronised_;
     237            bool                         bPhysicsActive_;
     238            bool                         bPhysicsActiveSynchronised_;
    232239            CompoundCollisionShape*      collisionShape_;
    233240            btScalar                     mass_;
    234             btScalar                     childMass_;
     241            btScalar                     childrenMass_;
    235242    };
    236243}
Note: See TracChangeset for help on using the changeset viewer.