Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 11:33:58 PM (17 years ago)
Author:
rgrieder
Message:
  • Fixed issues with CollisionShape loading, handling and synchronisation.
  • Added eol-style native to PlaneCollisionShape
  • Unified treatment of configuring btCollisionShapes when parameters change
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/orxonox/objects/worldentities/collisionshapes/PlaneCollisionShape.cc

    • Property svn:eol-style set to native
    r2374 r2403  
    4242        RegisterObject(PlaneCollisionShape);
    4343
    44         this->planeShape_ = new btStaticPlaneShape(btVector3(1, 1, 1), 0);
    45         this->collisionShape_ = this->planeShape_;
    46         this->planeNormal_ = Vector3(1, 1, 1);
    47         this->planeOffset_ = 0.0f;
     44        this->normal_ = Vector3(0, 1, 0);
     45        this->offset_ = 0.0f;
     46        updatePlane();
     47
     48        this->registerVariables();
    4849    }
    4950
     
    5152    {
    5253        if (this->isInitialized())
    53             delete this->planeShape_;
     54            delete this->collisionShape_;
    5455    }
    5556
    5657    void PlaneCollisionShape::registerVariables()
    5758    {
    58         REGISTERDATA(this->planeNormal_, network::direction::toclient, new network::NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::planeNormalChanged));
    59         REGISTERDATA(this->planeOffset_, network::direction::toclient, new network::NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::planeOffsetChanged));
     59        REGISTERDATA(this->normal_, network::direction::toclient, new network::NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::updatePlane));
     60        REGISTERDATA(this->offset_, network::direction::toclient, new network::NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::updatePlane));
    6061    }
    6162
     
    6465        SUPER(PlaneCollisionShape, XMLPort, xmlelement, mode);
    6566
    66         XMLPortParam(PlaneCollisionShape, "planeNormal", setNormal, getNormal, xmlelement, mode);
    67         XMLPortParam(PlaneCollisionShape, "planeOffset", setOffset, getOffset, xmlelement, mode);   
     67        XMLPortParam(PlaneCollisionShape, "normal", setNormal, getNormal, xmlelement, mode);
     68        XMLPortParam(PlaneCollisionShape, "offset", setOffset, getOffset, xmlelement, mode);   
    6869    }
    6970
    70     void PlaneCollisionShape::setNormal(const Vector3& normal)
     71    void PlaneCollisionShape::updatePlane()
    7172    {
    72         delete this->planeShape_;
    73         this->planeNormal_ = normal;
    74         this->planeShape_ = new btStaticPlaneShape(omni_cast<btVector3>(normal), this->planeOffset_);
    75         this->collisionShape_ = this->planeShape_;
    76     }
    77 
    78     void PlaneCollisionShape::setOffset(float offset)
    79     {
    80         delete this->planeShape_;
    81         this->planeOffset_ = offset;
    82         this->planeShape_ = new btStaticPlaneShape(omni_cast<btVector3>(this->planeNormal_), offset);
    83         this->collisionShape_ = this->planeShape_;
     73        if (this->collisionShape_)
     74            delete this->collisionShape_;
     75        this->collisionShape_ = new btStaticPlaneShape(omni_cast<btVector3>(this->normal_), this->offset_);
    8476    }
    8577}
Note: See TracChangeset for help on using the changeset viewer.