Changeset 1600 for trunk/test


Ignore:
Timestamp:
Jul 8, 2012, 9:04:46 PM (8 years ago)
Author:
touky
Message:

Added Cylinder primitives.
Added several delete/destructor, speeds up exit & saves memory.

Location:
trunk/test
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/BtPhysTest.cpp

    r1593 r1600  
    323323{
    324324        Ticker::Unref(m_camera);
     325        Ticker::Unref(m_ground_object);
     326        while (m_physobj_list.Count())
     327        {
     328                PhysicsObject* CurPop = m_physobj_list.Last();
     329                m_physobj_list.Pop();
     330                Ticker::Unref(CurPop);
     331        }
    325332
    326333#if 0
  • trunk/test/PhysicObject.h

    r1599 r1600  
    6363                MeshRand << "[sc#aad scb#aad ad16 2 0 rx180 ty-1 ac16 2 2 0 0 0]";
    6464
     65                int CylLimit = MeshRand.Count();
     66
     67                MeshRand << "[sc#add scb#add ad16 2 0 rx180 ty-1 my ac16 2 2 2 0 0]";
     68                MeshRand << "[sc#dad scb#dad ad16 2 0 rx180 ty-1 my ac16 2 2 2 0 0]";
     69                MeshRand << "[sc#dda scb#dda ad16 2 0 rx180 ty-1 my ac16 2 2 2 0 0]";
     70                MeshRand << "[sc#daa scb#daa ad16 2 0 rx180 ty-1 my ac16 2 2 2 0 0]";
     71                MeshRand << "[sc#ada scb#ada ad16 2 0 rx180 ty-1 my ac16 2 2 2 0 0]";
     72                MeshRand << "[sc#aad scb#aad ad16 2 0 rx180 ty-1 my ac16 2 2 2 0 0]";
     73
    6574                int RandValue = (int)(lol::RandF() * (MeshRand.Count() - 1));
    6675
    6776                m_mesh.Compile(MeshRand[RandValue]);
    6877                vec3 BoxSize = vec3(2.0f);
    69                 if (RandValue >= SphereLimit && RandValue < ConeLimit)
     78                if (RandValue < SphereLimit)
     79                        m_physics.SetShapeToBox(BoxSize);
     80                else if (RandValue < ConeLimit)
    7081                        m_physics.SetShapeToSphere(BoxSize.x);
    71                 else if (RandValue >= ConeLimit)
     82                else if (RandValue < CylLimit)
    7283                        m_physics.SetShapeToCone(BoxSize.x, BoxSize.y);
    7384                else
    74                         m_physics.SetShapeToBox(BoxSize);
     85                        m_physics.SetShapeToCylinder(BoxSize);
     86
    7587                m_physics.SetMass(base_mass);
    7688                m_physics.SetBaseTransform(base_location);
  • trunk/test/Physics/EasyPhysics.cpp

    r1599 r1600  
    4141}
    4242
     43EasyPhysics::~EasyPhysics()
     44{
     45        delete m_collision_object;
     46        delete m_collision_shape;
     47        delete m_motion_state;
     48}
     49
    4350//-------------------------------------------------------------------------
    4451//Set Shape functions
     
    7885        SetShapeTo(new btConeShape(     radius * LOL2BT_UNIT,
    7986                                                                height * LOL2BT_UNIT));
     87}
     88
     89void EasyPhysics::SetShapeToCylinder(lol::vec3& cyl_size)
     90{
     91        vec3 new_cyl_size = cyl_size * LOL2BT_UNIT;
     92        new_cyl_size.y *= LOL2BT_SIZE;
     93        SetShapeTo(new btCylinderShape(LOL2BT_VEC3(new_cyl_size)));
    8094}
    8195
  • trunk/test/Physics/EasyPhysics.h

    r1599 r1600  
    3535public:
    3636        EasyPhysics();
     37        ~EasyPhysics();
    3738
    3839        void SetShapeToBox(lol::vec3& box_size);
    3940        void SetShapeToSphere(float radius);
    4041        void SetShapeToCone(float radius, float height);
     42        void SetShapeToCylinder(lol::vec3& cyl_size);
     43
    4144        void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f)));
    4245        void SetMass(float mass);
  • trunk/test/Physics/LolPhysics.h

    r1591 r1600  
    3333        {
    3434        }
    35         ~Simulation() { }
     35        ~Simulation()
     36        {
     37                ExitContext();
     38        }
    3639
    3740        char const *GetName() { return "<Simulation>"; }
     
    7376        void ExitContext()
    7477        {
     78                delete m_dynamics_world;
     79                delete m_solver;
     80                delete m_dispatcher;
     81                delete m_collision_configuration;
    7582                delete m_broadphase;
    76                 delete m_collision_configuration;
    77                 delete m_dispatcher;
    78                 delete m_solver;
    79                 delete m_dynamics_world;
    8083        }
    8184
Note: See TracChangeset for help on using the changeset viewer.