Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2008, 10:53:44 PM (17 years ago)
Author:
rgrieder
Message:

Minor changes and added localInertia_ to worldentity for faster access.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics_merge/src/orxonox/objects/worldentities/WorldEntity.cc

    r2446 r2452  
    605605    void WorldEntity::recalculateMassProps()
    606606    {
     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_);
    607610        if (this->hasPhysics())
    608611        {
     
    616619                // Use default values to avoid very large or very small values
    617620                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);
    619624            }
    620625            else
    621626            {
    622                 float mass = this->mass_ + this->childrenMass_;
    623                 this->physicalBody_->setMassProps(mass, this->collisionShape_->getLocalInertia(mass));
     627                this->physicalBody_->setMassProps(totalMass, this->localInertia_);
    624628            }
    625629        }
Note: See TracChangeset for help on using the changeset viewer.