Ignore:
Timestamp:
Sep 7, 2012, 5:00:31 PM (9 years ago)
Author:
lolbot
Message:

fixed 23 files out of 277:

  • fixed 1270 CR characters
  • fixed 56 trailing spaces
  • fixed 5085 tabs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Physics/Src/EasyCharacterController.cpp

    r1870 r1888  
    3939btGhostObject* EasyCharacterController::GetGhostObjectInstance()
    4040{
    41         return new btPairCachingGhostObject();
     41    return new btPairCachingGhostObject();
    4242}
    4343
     
    4545void EasyCharacterController::InitBodyToGhost()
    4646{
    47         EasyPhysic::InitBodyToGhost();
     47    EasyPhysic::InitBodyToGhost();
    4848
    49         m_pair_caching_object = (btPairCachingGhostObject*)m_ghost_object;
    50         m_ghost_object->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT | m_ghost_object->getCollisionFlags());
     49    m_pair_caching_object = (btPairCachingGhostObject*)m_ghost_object;
     50    m_ghost_object->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT | m_ghost_object->getCollisionFlags());
    5151}
    5252
     
    5454void EasyCharacterController::AddToSimulation(class Simulation* current_simulation)
    5555{
    56         EasyPhysic::AddToSimulation(current_simulation);
     56    EasyPhysic::AddToSimulation(current_simulation);
    5757
    58         btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld();
    59         if (dynamics_world)
    60         {
    61                 if (m_character)
    62                         delete m_character;
     58    btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld();
     59    if (dynamics_world)
     60    {
     61        if (m_character)
     62            delete m_character;
    6363
    64                 //m_character = new btKinematicCharacterController(m_pair_caching_object, m_convex_shape, m_step_height, m_up_axis);
    65                 m_character = new BulletKinematicCharacterController(m_pair_caching_object, m_convex_shape, m_step_height, m_up_axis);
     64        //m_character = new btKinematicCharacterController(m_pair_caching_object, m_convex_shape, m_step_height, m_up_axis);
     65        m_character = new BulletKinematicCharacterController(m_pair_caching_object, m_convex_shape, m_step_height, m_up_axis);
    6666
    67                 //Deactivate Character controller basic behaviour.
    68                 //m_character->setGravity(.0f);
    69                 //m_character->setFallSpeed(.0f);
     67        //Deactivate Character controller basic behaviour.
     68        //m_character->setGravity(.0f);
     69        //m_character->setFallSpeed(.0f);
    7070
    71                 dynamics_world->addAction(m_character);
    72                 current_simulation->ObjectRegistration(true, this, Simulation::EEPT_CharacterController);
    73                 Ticker::Ref(this);
    74         }
     71        dynamics_world->addAction(m_character);
     72        current_simulation->ObjectRegistration(true, this, Simulation::EEPT_CharacterController);
     73        Ticker::Ref(this);
     74    }
    7575}
    7676
     
    7878void EasyCharacterController::RemoveFromSimulation(class Simulation* current_simulation)
    7979{
    80         EasyPhysic::RemoveFromSimulation(current_simulation);
     80    EasyPhysic::RemoveFromSimulation(current_simulation);
    8181
    82         btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld();
    83         if (dynamics_world)
    84         {
    85                 if (m_character)
    86                 {
    87                         dynamics_world->removeAction(m_character);
    88                         current_simulation->ObjectRegistration(false, this, Simulation::EEPT_CharacterController);
    89                         Ticker::Unref(this);
    90                 }
    91         }
     82    btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld();
     83    if (dynamics_world)
     84    {
     85        if (m_character)
     86        {
     87            dynamics_world->removeAction(m_character);
     88            current_simulation->ObjectRegistration(false, this, Simulation::EEPT_CharacterController);
     89            Ticker::Unref(this);
     90        }
     91    }
    9292}
    9393
    9494void EasyCharacterController::Jump()
    9595{
    96         m_character->Jump();
     96    m_character->Jump();
    9797}
    9898
     
    100100void EasyCharacterController::SetMovementForFrame(vec3 const &MoveQuantity)
    101101{
    102         m_frame_cached_movement = MoveQuantity;
     102    m_frame_cached_movement = MoveQuantity;
    103103}
    104104
     
    108108void EasyCharacterController::SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation)
    109109{
    110         if (m_base_is_updating)
    111         {
    112                 m_base_cached_movement = base_location - m_local_to_world.v3.xyz;
    113                 m_local_to_world = lol::mat4::translate(m_local_to_world.v3.xyz) * lol::mat4(base_rotation);
    114                 if (m_ghost_object)
    115                         m_ghost_object->setWorldTransform(btTransform(LOL2BT_QUAT(base_rotation), LOL2BT_VEC3(LOL2BT_UNIT * m_local_to_world.v3.xyz)));
    116         }
    117         else
    118                 EasyPhysic::SetTransform(base_location, base_rotation);
     110    if (m_base_is_updating)
     111    {
     112        m_base_cached_movement = base_location - m_local_to_world.v3.xyz;
     113        m_local_to_world = lol::mat4::translate(m_local_to_world.v3.xyz) * lol::mat4(base_rotation);
     114        if (m_ghost_object)
     115            m_ghost_object->setWorldTransform(btTransform(LOL2BT_QUAT(base_rotation), LOL2BT_VEC3(LOL2BT_UNIT * m_local_to_world.v3.xyz)));
     116    }
     117    else
     118        EasyPhysic::SetTransform(base_location, base_rotation);
    119119}
    120120
     
    122122void EasyCharacterController::BaseTransformChanged(const lol::mat4& PreviousMatrix, const lol::mat4& NewMatrix)
    123123{
    124         m_base_is_updating = true;
    125         EasyPhysic::BaseTransformChanged(PreviousMatrix, NewMatrix);
    126         m_base_is_updating = false;
     124    m_base_is_updating = true;
     125    EasyPhysic::BaseTransformChanged(PreviousMatrix, NewMatrix);
     126    m_base_is_updating = false;
    127127}
    128128
     
    130130char const *EasyCharacterController::GetName()
    131131{
    132         return "<EasyCharacterController>";
     132    return "<EasyCharacterController>";
    133133}
    134134
     
    136136void EasyCharacterController::TickGame(float seconds)
    137137{
    138         Entity::TickGame(seconds);
     138    Entity::TickGame(seconds);
    139139
    140         //Send final velocity in Bullet
    141         {
    142                 int IterationsNb = (int)(seconds / m_owner_simulation->m_timestep);
    143                 float NewSeconds = IterationsNb * m_owner_simulation->m_timestep;
    144                 m_character->SetVelocityForTimeInterval((m_base_cached_movement + m_frame_cached_movement) / NewSeconds, NewSeconds);
    145                 m_base_cached_movement = vec3(.0f);
    146         }
     140    //Send final velocity in Bullet
     141    {
     142        int IterationsNb = (int)(seconds / m_owner_simulation->m_timestep);
     143        float NewSeconds = IterationsNb * m_owner_simulation->m_timestep;
     144        m_character->SetVelocityForTimeInterval((m_base_cached_movement + m_frame_cached_movement) / NewSeconds, NewSeconds);
     145        m_base_cached_movement = vec3(.0f);
     146    }
    147147}
    148148
Note: See TracChangeset for help on using the changeset viewer.