Properly set the camera type in the constructor (which previously

was always 'CM_TYPE_NORMAL'). Fixes #2576.
This commit is contained in:
hiker 2016-07-25 17:45:24 +10:00
parent c64733e3d0
commit ba3497bb81
7 changed files with 23 additions and 11 deletions

View File

@ -73,7 +73,8 @@ Camera* Camera::createCamera(unsigned int index, CameraType type,
Camera *camera = NULL; Camera *camera = NULL;
switch (type) switch (type)
{ {
case CM_TYPE_NORMAL: camera = new CameraNormal(index, kart); break; case CM_TYPE_NORMAL: camera = new CameraNormal(CM_TYPE_NORMAL, index, kart);
break;
case CM_TYPE_DEBUG: camera = new CameraDebug (index, kart); break; case CM_TYPE_DEBUG: camera = new CameraDebug (index, kart); break;
case CM_TYPE_FPS: camera = new CameraFPS (index, kart); break; case CM_TYPE_FPS: camera = new CameraFPS (index, kart); break;
case CM_TYPE_END: camera = new CameraEnd (index, kart); break; case CM_TYPE_END: camera = new CameraEnd (index, kart); break;
@ -112,10 +113,11 @@ void Camera::resetAllCameras()
} // resetAllCameras } // resetAllCameras
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
Camera::Camera(int camera_index, AbstractKart* kart) : m_kart(NULL) Camera::Camera(CameraType type, int camera_index, AbstractKart* kart)
: m_kart(NULL)
{ {
m_mode = CM_NORMAL; m_mode = CM_NORMAL;
m_type = CameraType::CM_TYPE_NORMAL; m_type = type;
m_index = camera_index; m_index = camera_index;
m_original_kart = kart; m_original_kart = kart;
m_camera = irr_driver->addCameraSceneNode(); m_camera = irr_driver->addCameraSceneNode();

View File

@ -128,7 +128,7 @@ protected:
static Camera* createCamera(unsigned int index, CameraType type, static Camera* createCamera(unsigned int index, CameraType type,
AbstractKart* kart); AbstractKart* kart);
Camera(int camera_index, AbstractKart* kart); Camera(CameraType type, int camera_index, AbstractKart* kart);
virtual ~Camera(); virtual ~Camera();
virtual void reset(); virtual void reset();
public: public:

View File

@ -32,7 +32,7 @@ CameraDebug::CameraDebugType CameraDebug::m_default_debug_Type =
// ============================================================================ // ============================================================================
CameraDebug::CameraDebug(int camera_index, AbstractKart* kart) CameraDebug::CameraDebug(int camera_index, AbstractKart* kart)
: CameraNormal(camera_index, kart) : CameraNormal(Camera::CM_TYPE_DEBUG, camera_index, kart)
{ {
reset(); reset();
} // Camera } // Camera

View File

@ -27,7 +27,7 @@
AlignedArray<CameraEnd::EndCameraInformation> CameraEnd::m_end_cameras; AlignedArray<CameraEnd::EndCameraInformation> CameraEnd::m_end_cameras;
// ============================================================================ // ============================================================================
CameraEnd::CameraEnd(int camera_index, AbstractKart* kart) CameraEnd::CameraEnd(int camera_index, AbstractKart* kart)
: CameraNormal(camera_index, kart) : CameraNormal(Camera::CM_TYPE_END, camera_index, kart)
{ {
reset(); reset();
if(m_end_cameras.size()>0) if(m_end_cameras.size()>0)

View File

@ -30,7 +30,7 @@ using namespace irr;
// ============================================================================ // ============================================================================
CameraFPS::CameraFPS(int camera_index, AbstractKart* kart) CameraFPS::CameraFPS(int camera_index, AbstractKart* kart)
: Camera(camera_index, kart) : Camera(Camera::CM_TYPE_FPS, camera_index, kart)
{ {
m_attached = false; m_attached = false;

View File

@ -28,8 +28,17 @@
#include "tracks/track.hpp" #include "tracks/track.hpp"
// ============================================================================ // ============================================================================
CameraNormal::CameraNormal(int camera_index, AbstractKart* kart) /** Constructor for the normal camera. This is the only camera constructor
: Camera(camera_index, kart) * except for the base class that takes a camera type as parameter. This is
* because debug and end camera use the normal camera as their base class.
* \param type The type of the camera that is created (can be CM_TYPE_END
* or CM_TYPE_DEBUG).
* \param camera_index Index of this camera.
* \param Kart Pointer to the kart for which this camera is used.
*/
CameraNormal::CameraNormal(Camera::CameraType type, int camera_index,
AbstractKart* kart)
: Camera(type, camera_index, kart)
{ {
m_distance = kart ? kart->getKartProperties()->getCameraDistance() : 1000.0f; m_distance = kart ? kart->getKartProperties()->getCameraDistance() : 1000.0f;
m_ambient_light = World::getWorld()->getTrack()->getDefaultAmbientColor(); m_ambient_light = World::getWorld()->getTrack()->getDefaultAmbientColor();

View File

@ -61,7 +61,8 @@ private:
friend class Camera; friend class Camera;
friend class CameraDebug; friend class CameraDebug;
friend class CameraEnd; friend class CameraEnd;
CameraNormal(int camera_index, AbstractKart* kart); CameraNormal(Camera::CameraType type, int camera_index,
AbstractKart* kart);
virtual ~CameraNormal() {} virtual ~CameraNormal() {}
public: public:
bool isDebug() { return false; } bool isDebug() { return false; }