Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 2, 2008, 4:59:36 PM (17 years ago)
Author:
rgrieder
Message:
  • More dealings with not yet implemented scaling of physical objects.
  • Clearer handling of masses specified by setMass() (also taking into account mass of child WE)
  • Now calculating the inertia tensor as well according to mass and collisionShape
  • Bugfix when calling Bullet solver
File:
1 edited

Legend:

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

    r2304 r2306  
    108108                { this->setDirection(Vector3(x, y, z), relativeTo, localDirectionVector); }
    109109
    110             void setScale3D(const Vector3& scale);
     110            virtual void setScale3D(const Vector3& scale);
    111111            inline void setScale3D(float x, float y, float z)
    112112                { this->setScale3D(Vector3(x, y, z)); }
     
    119119                { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; }
    120120
    121             void scale3D(const Vector3& scale);
     121            virtual void scale3D(const Vector3& scale);
    122122            inline void scale3D(float x, float y, float z)
    123123                { this->scale3D(Vector3(x, y, z)); }
     
    182182            };
    183183
    184             bool hasPhysics() const { return getCollisionType() != None; }
    185 
    186             CollisionType getCollisionType() const { return this->collisionType_; }
    187             void setCollisionType(CollisionType type);
    188 
    189             void setCollisionTypeStr(const std::string& type);
    190             std::string getCollisionTypeStr() const;
    191 
     184            bool hasPhysics()  const { return getCollisionType() != None     ; }
    192185            bool isStatic()    const { return getCollisionType() == Static   ; }
    193186            bool isKinematic() const { return getCollisionType() == Kinematic; }
    194187            bool isDynamic()   const { return getCollisionType() == Dynamic  ; }
    195188
     189            inline CollisionType getCollisionType() const
     190                { return this->collisionType_; }
     191            void setCollisionType(CollisionType type);
     192
     193            void setCollisionTypeStr(const std::string& type);
     194            std::string getCollisionTypeStr() const;
     195
    196196            void setMass(float mass);
    197197            inline float getMass() const
     
    201201            CollisionShape* getAttachedCollisionShape(unsigned int index) const;
    202202
    203             CollisionShape* getCollisionShape() { return this->collisionShape_; }
    204             btRigidBody* getPhysicalBody() { return this->physicalBody_; }
     203            inline CollisionShape* getCollisionShape()
     204                { return this->collisionShape_; }
     205            inline btRigidBody* getPhysicalBody()
     206                { return this->physicalBody_; }
    205207
    206208        protected:
    207             //virtual btCollisionShape* getCollisionShape() = 0;
    208             //virtual void attachPhysicalObject(WorldEntity* object);
    209 
    210209            virtual bool isCollisionTypeLegal(CollisionType type) const = 0;
     210
     211            btRigidBody*  physicalBody_;
     212
     213        private:
     214            void updateCollisionType();
     215            void mergeCollisionShape(CollisionShape* shape);
     216            void internalSetMassProps();
     217            btVector3 getLocalInertia(btScalar mass) const;
    211218            bool checkPhysics() const;
    212             void updateCollisionType();
    213 
    214             btRigidBody*  physicalBody_;
    215 
    216         private:
    217             void mergeCollisionShape(CollisionShape* shape);
    218219
    219220            CollisionType                collisionType_;
     
    221222            CollisionShape*              collisionShape_;
    222223            btScalar                     mass_;
     224            btScalar                     childMass_;
    223225    };
    224226}
Note: See TracChangeset for help on using the changeset viewer.