void KinematicCharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar dt)
{
	//	printf("playerStep(): ");
	//	printf("  dt = %f", dt);

	// quick check...
	if (!m_useWalkDirection && (m_velocityTimeInterval <= 0.0 || m_walkDirection.fuzzyZero())) {
		//		printf("\n");
		return;		// no motion
	}

	m_wasOnGround = onGround();

	// Update fall velocity.
	m_verticalVelocity -= m_gravity * dt;
	if (m_verticalVelocity > 0.0 && m_verticalVelocity > m_jumpSpeed)
	{
		m_verticalVelocity = m_jumpSpeed;
	}
	if (m_verticalVelocity < 0.0 && btFabs(m_verticalVelocity) > btFabs(m_fallSpeed))
	{
		m_verticalVelocity = -btFabs(m_fallSpeed);
	}
	m_verticalOffset = m_verticalVelocity * dt;


	btTransform xform;
	xform = m_ghostObject->getWorldTransform();

	//	printf("walkDirection(%f,%f,%f)\n",walkDirection[0],walkDirection[1],walkDirection[2]);
	//	printf("walkSpeed=%f\n",walkSpeed);

	stepUp(collisionWorld);
	if (m_useWalkDirection) {
		stepForwardAndStrafe(collisionWorld, m_walkDirection);
	}
	else {
		//printf("  time: %f", m_velocityTimeInterval);
		// still have some time left for moving!
		btScalar dtMoving =
			(dt < m_velocityTimeInterval) ? dt : m_velocityTimeInterval;
		m_velocityTimeInterval -= dt;

		// how far will we move while we are moving?
		btVector3 move = m_walkDirection * dtMoving;

		//printf("  dtMoving: %f", dtMoving);

		// okay, step
		stepForwardAndStrafe(collisionWorld, move);
	}
	stepDown(collisionWorld, dt);

	// printf("\n");

	xform.setOrigin(m_currentPosition);
	m_ghostObject->setWorldTransform(xform);
}
void btKinematicCharacterController::playerStep (  btCollisionWorld* collisionWorld, btScalar dt)
{
//	printf("playerStep(): ");
//	printf("  dt = %f", dt);

	// quick check...
	if (!m_useWalkDirection && m_velocityTimeInterval <= 0.0) {
//		printf("\n");
		return;		// no motion
	}

	btTransform xform;
	xform = m_ghostObject->getWorldTransform ();

//	printf("walkDirection(%f,%f,%f)\n",walkDirection[0],walkDirection[1],walkDirection[2]);
//	printf("walkSpeed=%f\n",walkSpeed);

	stepUp (collisionWorld);
	if (m_useWalkDirection) {
		stepForwardAndStrafe (collisionWorld, m_walkDirection);
	} else {
		//printf("  time: %f", m_velocityTimeInterval);
		// still have some time left for moving!
		btScalar dtMoving =
		   (dt < m_velocityTimeInterval) ? dt : m_velocityTimeInterval;
		m_velocityTimeInterval -= dt;

		// how far will we move while we are moving?
		btVector3 move = m_walkDirection * dtMoving;

		// printf("  dtMoving: %f", dtMoving);

		// okay, step
		stepForwardAndStrafe(collisionWorld, move);
	}
	stepDown (collisionWorld, dt);

	// printf("\n");

	xform.setOrigin (m_currentPosition);
	m_ghostObject->setWorldTransform (xform);
}
    //-----------------------------------------------------------------------
    //                         p l a y e r S t e p
    //-----------------------------------------------------------------------
    void TKinematicCharacterTest::playerStep ( btCollisionWorld* collisionWorld, btScalar dt)
    {
        // btKinematicCharacterController::playerStep(collisionWorld, dt);

        btTransform xform;
        xform = m_ghostObject->getWorldTransform ();

        stepUp (collisionWorld);
        stepForwardAndStrafe (collisionWorld, m_walkDirection);
        stepDown (collisionWorld, dt);

        xform.setOrigin (m_currentPosition);
        m_ghostObject->setWorldTransform (xform);

    }
void btKinematicCharacterController::playerStep( btCollisionWorld* collisionWorld, btScalar dt )
{
    BT_PROFILE( "playerStep" );

    if( !m_useWalkDirection && m_velocityTimeInterval <= btScalar( 0.0 ) )
        return;

    bool wasOnGround = onGround();

    // Handle the gravity
    //
    m_verticalVelocity -= m_gravity * dt;

    if( m_verticalVelocity > 0.0 && m_verticalVelocity > m_jumpSpeed )
        m_verticalVelocity = m_jumpSpeed;

    if( m_verticalVelocity < 0.0 && btFabs( m_verticalVelocity ) > btFabs( m_fallSpeed ) )
        m_verticalVelocity = -btFabs( m_fallSpeed );

    m_verticalOffset = m_verticalVelocity * dt;

    // This forced stepping up can cause problems when the character
    // walks (jump in fact...) under too low ceilings.
    //
    btVector3 currentPosition = externalGhostObject->getWorldTransform().getOrigin();
    btScalar currentStepOffset;

    currentPosition = stepUp( collisionWorld, currentPosition, currentStepOffset );

    // Move in the air and slide against the walls ignoring the stair steps.
    //
    if( m_useWalkDirection )
        currentPosition = stepForwardAndStrafe( collisionWorld, currentPosition, m_walkDirection );

    else
    {
        btScalar dtMoving = ( dt < m_velocityTimeInterval ) ? dt : m_velocityTimeInterval;
        m_velocityTimeInterval -= dt;

        // How far will we move while we are moving ?
        //
        btVector3 moveDirection = m_walkDirection * dtMoving;

        currentPosition = stepForwardAndStrafe( collisionWorld, currentPosition, moveDirection );
    }

    // Finally find the ground.
    //
    currentStepOffset = addFallOffset( wasOnGround, currentStepOffset, dt );

    currentPosition = stepDown( collisionWorld, currentPosition, currentStepOffset );

    // Apply the new position to the collision objects.
    //
    btTransform tranform;
    tranform = externalGhostObject->getWorldTransform();
    tranform.setOrigin( currentPosition );

    externalGhostObject->setWorldTransform( tranform );
    internalGhostObject->setWorldTransform( tranform );
}