Ignore:
Timestamp:
Jul 15, 2012, 1:17:00 PM (10 years ago)
Author:
touky
Message:

Added Collision group & mask support.
+ weird racist test : the primitives only collide with their same type.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Physics/EasyPhysics.cpp

    r1630 r1631  
    3737        m_motion_state(NULL),
    3838        m_mass(.0f),
    39         m_local_inertia(btVector3(.0f, .0f, .0f))
     39        m_local_inertia(btVector3(.0f, .0f, .0f)),
     40        m_collision_group(1),
     41        m_collision_mask(1)
    4042{
    4143}
     
    99101        SetShapeTo(new btCapsuleShape(  radius * LOL2BT_UNIT * LOL2BT_SIZE,
    100102                                                                        height * LOL2BT_UNIT * LOL2BT_SIZE));
     103}
     104
     105//-------------------------------------------------------------------------
     106//Bullet collision channel setup
     107//--
     108void EasyPhysics::CustomSetCollisionChannel(int NewGroup, int NewMask)
     109{
     110        if (m_rigid_body)
     111                m_rigid_body->setCollisionFlags(m_collision_mask);
    101112}
    102113
     
    158169        if (m_rigid_body)
    159170        {
    160                 dynamics_world->addRigidBody(m_rigid_body);
     171                dynamics_world->addRigidBody(m_rigid_body, m_collision_group, m_collision_mask);
    161172                if (m_mass != .0f)
    162173                        current_simulation->AddToDynamic(this);
     
    165176        }
    166177        else
    167                 dynamics_world->addCollisionObject(m_collision_object);
     178                dynamics_world->addCollisionObject(m_collision_object, m_collision_group, m_collision_mask);
    168179}
    169180
Note: See TracChangeset for help on using the changeset viewer.