Avoid handling of camera in no graphics STK
This commit is contained in:
@@ -70,9 +70,13 @@ LocalPlayerController::LocalPlayerController(AbstractKart *kart,
|
||||
|
||||
// Keep a pointer to the camera to remove the need to search for
|
||||
// the right camera once per frame later.
|
||||
Camera *camera = Camera::createCamera(kart, local_player_id);
|
||||
m_camera_index = -1;
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
{
|
||||
Camera *camera = Camera::createCamera(kart, local_player_id);
|
||||
m_camera_index = camera->getIndex();
|
||||
}
|
||||
|
||||
m_camera_index = camera->getIndex();
|
||||
m_wee_sound = SFXManager::get()->createSoundSource("wee");
|
||||
m_bzzt_sound = SFXManager::get()->getBuffer("bzzt");
|
||||
m_ugh_sound = SFXManager::get()->getBuffer("ugh");
|
||||
@@ -245,8 +249,10 @@ void LocalPlayerController::update(int ticks)
|
||||
// look backward when the player requests or
|
||||
// if automatic reverse camera is active
|
||||
#ifndef SERVER_ONLY
|
||||
Camera *camera = Camera::getCamera(m_camera_index);
|
||||
if (camera->getType() != Camera::CM_TYPE_END)
|
||||
Camera *camera = NULL;
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
camera = Camera::getCamera(m_camera_index);
|
||||
if (camera && camera->getType() != Camera::CM_TYPE_END)
|
||||
{
|
||||
if (m_controls->getLookBack() || (UserConfigParams::m_reverse_look_threshold > 0 &&
|
||||
m_kart->getSpeed() < -UserConfigParams::m_reverse_look_threshold))
|
||||
@@ -340,7 +346,8 @@ void LocalPlayerController::setPosition(int p)
|
||||
void LocalPlayerController::finishedRace(float time)
|
||||
{
|
||||
// This will implicitly trigger setting the first end camera to be active
|
||||
Camera::changeCamera(m_camera_index, Camera::CM_TYPE_END);
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
Camera::changeCamera(m_camera_index, Camera::CM_TYPE_END);
|
||||
} // finishedRace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -361,7 +368,8 @@ void LocalPlayerController::handleZipper(bool play_sound)
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
// Apply the motion blur according to the speed of the kart
|
||||
irr_driver->giveBoost(m_camera_index);
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
irr_driver->giveBoost(m_camera_index);
|
||||
#endif
|
||||
|
||||
} // handleZipper
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "karts/controller/network_ai_controller.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/controller/kart_control.hpp"
|
||||
#include "karts/controller/skidding_ai.hpp"
|
||||
@@ -37,7 +38,8 @@ NetworkAIController::NetworkAIController(AbstractKart *kart,
|
||||
m_ai_controller = ai;
|
||||
m_ai_controls = new KartControl;
|
||||
// We only need camera for real AI instance for debugging view
|
||||
if (NetworkConfig::get()->isNetworkAIInstance())
|
||||
if (!GUIEngine::isNoGraphics() &&
|
||||
NetworkConfig::get()->isNetworkAIInstance())
|
||||
Camera::createCamera(kart, local_player_id);
|
||||
ai->setControls(m_ai_controls);
|
||||
} // NetworkAIController
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/stars.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "items/attachment.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
@@ -163,7 +164,7 @@ ExplosionAnimation::~ExplosionAnimation()
|
||||
m_kart->getBody()->setAngularVelocity(btVector3(0,0,0));
|
||||
// Don't reset spectate camera
|
||||
auto cl = LobbyProtocol::get<ClientLobby>();
|
||||
if (!cl || !cl->isSpectator())
|
||||
if (!GUIEngine::isNoGraphics() && (!cl || !cl->isSpectator()))
|
||||
{
|
||||
for (unsigned i = 0; i < Camera::getNumCameras(); i++)
|
||||
{
|
||||
|
||||
@@ -119,7 +119,8 @@ std::shared_ptr<AbstractKart> ProfileWorld::createKart
|
||||
|
||||
// Create a camera for the last kart (since this way more of the
|
||||
// karts can be seen.
|
||||
if (index == (int)race_manager->getNumberOfKarts()-1)
|
||||
if (!GUIEngine::isNoGraphics() &&
|
||||
index == (int)race_manager->getNumberOfKarts()-1)
|
||||
{
|
||||
// The camera keeps track of all cameras and will free them
|
||||
Camera::createCamera(new_kart.get(), local_player_id);
|
||||
|
||||
@@ -372,7 +372,8 @@ void World::reset(bool restart)
|
||||
}
|
||||
}
|
||||
|
||||
Camera::resetAllCameras();
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
Camera::resetAllCameras();
|
||||
|
||||
if(race_manager->hasGhostKarts())
|
||||
ReplayPlay::get()->reset();
|
||||
@@ -628,7 +629,8 @@ World::~World()
|
||||
race_manager->setTimeTarget(0.0f);
|
||||
race_manager->setSpareTireKartNum(0);
|
||||
|
||||
Camera::removeAllCameras();
|
||||
if (!GUIEngine::isNoGraphics())
|
||||
Camera::removeAllCameras();
|
||||
|
||||
// In case that the track is not found, Physics was not instantiated,
|
||||
// but kill handles this correctly.
|
||||
|
||||
Reference in New Issue
Block a user