Fixed camera handling (pitch) on steep declines.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1152 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
2dc270a3cc
commit
803db6bfb6
@ -62,6 +62,7 @@ Camera::setScreenPosition ( int numPlayers, int pos )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_LastPitch = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -90,7 +91,7 @@ Camera::setMode(Mode mode_)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Camera::update ()
|
void Camera::update (float dt)
|
||||||
{
|
{
|
||||||
// Update the camera
|
// Update the camera
|
||||||
if ( m_which_kart >= int(world->getNumKarts()) || m_which_kart < 0 ) m_which_kart = 0 ;
|
if ( m_which_kart >= int(world->getNumKarts()) || m_which_kart < 0 ) m_which_kart = 0 ;
|
||||||
@ -99,7 +100,18 @@ void Camera::update ()
|
|||||||
sgCopyCoord(&kartcoord, world->getPlayerKart(m_which_kart)->getCoord());
|
sgCopyCoord(&kartcoord, world->getPlayerKart(m_which_kart)->getCoord());
|
||||||
|
|
||||||
kartcoord.hpr[2] = 0;
|
kartcoord.hpr[2] = 0;
|
||||||
kartcoord.hpr[1] = 0;
|
|
||||||
|
// If the car angle is 'significantly' different from the camera angle,
|
||||||
|
// start adjusting the camera. This helps with steep declines, where
|
||||||
|
// otherwise the track is not visible anymore.
|
||||||
|
if(fabsf(kartcoord.hpr[1]-m_LastPitch)>1.0f) {
|
||||||
|
kartcoord.hpr[1] = m_LastPitch + (kartcoord.hpr[1]-m_LastPitch)*2.0f*dt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
kartcoord.hpr[1]=m_LastPitch;
|
||||||
|
}
|
||||||
|
m_LastPitch = kartcoord.hpr[1];
|
||||||
|
|
||||||
if (m_mode == CM_SIMPLE_REPLAY)
|
if (m_mode == CM_SIMPLE_REPLAY)
|
||||||
kartcoord.hpr[0] = 0;
|
kartcoord.hpr[0] = 0;
|
||||||
|
@ -40,6 +40,7 @@ protected:
|
|||||||
Mode m_mode;
|
Mode m_mode;
|
||||||
float m_last_steer_offset;
|
float m_last_steer_offset;
|
||||||
float m_x, m_y, m_w, m_h ;
|
float m_x, m_y, m_w, m_h ;
|
||||||
|
float m_LastPitch;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Camera ( int numPlayers, int id ) ;
|
Camera ( int numPlayers, int id ) ;
|
||||||
@ -49,7 +50,7 @@ public:
|
|||||||
|
|
||||||
void setScreenPosition ( int numPlayers, int pos ) ;
|
void setScreenPosition ( int numPlayers, int pos ) ;
|
||||||
|
|
||||||
void update () ;
|
void update (float dt) ;
|
||||||
void apply () ;
|
void apply () ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ void GameManager::run()
|
|||||||
|
|
||||||
if (race_manager->raceIsActive())
|
if (race_manager->raceIsActive())
|
||||||
{
|
{
|
||||||
scene->draw();
|
scene->draw((m_curr_time - m_prev_time ) * 0.001);
|
||||||
if ( world->getPhase() != World::LIMBO_PHASE)
|
if ( world->getPhase() != World::LIMBO_PHASE)
|
||||||
{
|
{
|
||||||
world->update((m_curr_time - m_prev_time ) * 0.001);
|
world->update((m_curr_time - m_prev_time ) * 0.001);
|
||||||
|
@ -83,7 +83,7 @@ void Scene::remove(ssgEntity *kid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Scene::draw()
|
void Scene::draw(float dt)
|
||||||
{
|
{
|
||||||
glEnable ( GL_DEPTH_TEST ) ;
|
glEnable ( GL_DEPTH_TEST ) ;
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ void Scene::draw()
|
|||||||
|
|
||||||
for (Cameras::iterator i = m_cameras.begin(); i != m_cameras.end(); ++i)
|
for (Cameras::iterator i = m_cameras.begin(); i != m_cameras.end(); ++i)
|
||||||
{
|
{
|
||||||
(*i)->update();
|
(*i)->update(dt);
|
||||||
(*i) -> apply () ;
|
(*i) -> apply () ;
|
||||||
|
|
||||||
#ifdef BULLET
|
#ifdef BULLET
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
void add(ssgEntity *kid);
|
void add(ssgEntity *kid);
|
||||||
void remove(ssgEntity *kid);
|
void remove(ssgEntity *kid);
|
||||||
void draw();
|
void draw(float dt);
|
||||||
void set_race_cameras(int num_players);
|
void set_race_cameras(int num_players);
|
||||||
|
|
||||||
//TODO: add camera
|
//TODO: add camera
|
||||||
|
Loading…
Reference in New Issue
Block a user