Automatically switch to camera 0 when the lap line is crossed. This

improved handling of end cameras for reverse mode (otherwise one
additional end camera would need to be defined to be used just
when the lap line is crossed).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/reverse_mode@10850 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-02-15 05:23:21 +00:00
parent 4967ca992a
commit 94be2cfec2
4 changed files with 26 additions and 11 deletions

View File

@ -225,12 +225,8 @@ void Camera::setMode(Mode mode)
{
m_next_end_camera = m_end_cameras.size()>1 ? 1 : 0;
m_current_end_camera = 0;
if(m_end_cameras.size()>0 &&
m_end_cameras[0].m_type==EndCameraInformation::EC_STATIC_FOLLOW_KART)
{
m_camera->setPosition(m_end_cameras[0].m_position.toIrrVector());
m_camera->setTarget(m_kart->getXYZ().toIrrVector());
}
m_camera->setFOV(m_fov);
handleEndCamera(0);
} // mode==CM_FINAL
m_mode = mode;
@ -496,7 +492,8 @@ void Camera::positionCamera(float dt, float above_kart, float cam_angle,
if (race_manager->getNumLocalPlayers() < 2)
{
sfx_manager->positionListener(m_camera->getPosition(), wanted_target - m_camera->getPosition());
sfx_manager->positionListener(m_camera->getPosition(),
wanted_target - m_camera->getPosition());
}
}

View File

@ -134,6 +134,18 @@ void EndController::reset()
}
} // reset
//-----------------------------------------------------------------------------
/** Callback when a new lap is triggered. It is used to switch to the first
* end camera (which is esp. useful in fixing up end cameras in reverse mode,
* since otherwise the switch to the first end camera usually happens way too
* late)
*/
void EndController::newLap(int lap)
{
// This will implicitely trigger setting the first end camera to be active.
m_kart->getCamera()->setMode(Camera::CM_FINAL);
} // newLap
//-----------------------------------------------------------------------------
/** The end controller must forward 'fire' presses to the race gui.
*/

View File

@ -86,6 +86,7 @@ public:
* to the right player. */
virtual bool isPlayerController () const {return m_player!=NULL;}
virtual void action (PlayerAction action, int value);
virtual void newLap (int lap);
}; // EndKart

View File

@ -216,10 +216,15 @@ void LinearWorld::newLap(unsigned int kart_index)
KartInfo &kart_info = m_kart_info[kart_index];
Kart *kart = m_karts[kart_index];
// Don't do anything if a kart that has already finished the race
// crosses the start line again. This avoids 'fastest lap' messages
// if the end controller does a fastest lap.
if(kart->hasFinishedRace()) return;
// Only update the kart controller if a kart that has already finished
// the race crosses the start line again. This avoids 'fastest lap'
// messages if the end controller does a fastest lap, but especially
// allows the end controller to switch end cameras
if(kart->hasFinishedRace())
{
kart->getController()->newLap(kart_info.m_race_lap);
return;
}
const int lap_count = race_manager->getNumLaps();