Changeset 2452
- Timestamp:
- Dec 14, 2008, 10:53:44 PM (16 years ago)
- Location:
- code/branches/physics_merge/src/orxonox/objects
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics_merge/src/orxonox/objects/collisionshapes/CollisionShape.cc
r2445 r2452 108 108 } 109 109 110 btVector3 CollisionShape::getLocalInertia(btScalar mass) const110 void CollisionShape::calculateLocalInertia(btScalar mass, btVector3& inertia) const 111 111 { 112 btVector3 inertia(0, 0, 0);113 112 if (this->collisionShape_) 114 113 this->collisionShape_->calculateLocalInertia(mass, inertia); 115 return inertia; 114 else 115 inertia.setValue(0, 0, 0); 116 116 } 117 117 } -
code/branches/physics_merge/src/orxonox/objects/collisionshapes/CollisionShape.h
r2445 r2452 66 66 { return this->scale_; } 67 67 68 btVector3 getLocalInertia(float mass) const;68 void calculateLocalInertia(float mass, btVector3& inertia) const; 69 69 70 70 inline btCollisionShape* getCollisionShape() const -
code/branches/physics_merge/src/orxonox/objects/worldentities/MobileEntity.cc
r2442 r2452 51 51 this->angularAcceleration_ = Vector3::ZERO; 52 52 this->angularVelocity_ = Vector3::ZERO; 53 54 this->registerVariables();55 53 } 56 54 … … 66 64 XMLPortParamTemplate(MobileEntity, "rotationaxis", setRotationAxis, getRotationAxis, xmlelement, mode, const Vector3&); 67 65 XMLPortParam(MobileEntity, "rotationrate", setRotationRate, getRotationRate, xmlelement, mode); 68 }69 70 void MobileEntity::registerVariables()71 {72 66 } 73 67 -
code/branches/physics_merge/src/orxonox/objects/worldentities/MobileEntity.h
r2442 r2452 45 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 46 virtual void tick(float dt); 47 void registerVariables();48 47 49 48 virtual void setPosition(const Vector3& position); -
code/branches/physics_merge/src/orxonox/objects/worldentities/WorldEntity.cc
r2446 r2452 605 605 void WorldEntity::recalculateMassProps() 606 606 { 607 // Store local inertia for faster access. Evaluates to (0,0,0) if there is no collision shape. 608 float totalMass = this->mass_ + this->childrenMass_; 609 this->collisionShape_->calculateLocalInertia(totalMass, this->localInertia_); 607 610 if (this->hasPhysics()) 608 611 { … … 616 619 // Use default values to avoid very large or very small values 617 620 CCOUT(4) << "Warning: Setting the internal physical mass to 1.0 because mass_ is 0.0." << std::endl; 618 this->physicalBody_->setMassProps(1.0f, this->collisionShape_->getLocalInertia(1.0f)); 621 btVector3 inertia(0, 0, 0); 622 this->collisionShape_->calculateLocalInertia(1.0f, inertia); 623 this->physicalBody_->setMassProps(1.0f, inertia); 619 624 } 620 625 else 621 626 { 622 float mass = this->mass_ + this->childrenMass_; 623 this->physicalBody_->setMassProps(mass, this->collisionShape_->getLocalInertia(mass)); 627 this->physicalBody_->setMassProps(totalMass, this->localInertia_); 624 628 } 625 629 } -
code/branches/physics_merge/src/orxonox/objects/worldentities/WorldEntity.h
r2442 r2452 199 199 inline float getTotalMass() const 200 200 { return this->mass_ + this->childrenMass_; } 201 202 inline const btVector3& getLocalInertia() const 203 { return this->localInertia_; } 201 204 202 205 inline void setRestitution(float restitution) … … 269 272 CompoundCollisionShape* collisionShape_; 270 273 btScalar mass_; 274 btVector3 localInertia_; 271 275 btScalar restitution_; 272 276 btScalar angularFactor_;
Note: See TracChangeset
for help on using the changeset viewer.