Moved the camera debug parameter from UserConfig to a static value
in camera. Added proper names for the debug modes instead of int.
This commit is contained in:
parent
ef1e5da4bc
commit
f59ea0f258
@ -521,11 +521,6 @@ namespace UserConfigParams
|
||||
/** True if check structures should be debugged. */
|
||||
PARAM_PREFIX bool m_check_debug PARAM_DEFAULT( false );
|
||||
|
||||
/** Special debug camera: 0: normal camera; 1: being high over the kart;
|
||||
2: on ground level; 3: free first person camera;
|
||||
4: straight behind kart */
|
||||
PARAM_PREFIX int m_camera_debug PARAM_DEFAULT( false );
|
||||
|
||||
/** True if physics debugging should be enabled. */
|
||||
PARAM_PREFIX bool m_physics_debug PARAM_DEFAULT( false );
|
||||
|
||||
|
@ -45,6 +45,7 @@ AlignedArray<Camera::EndCameraInformation> Camera::m_end_cameras;
|
||||
std::vector<Camera*> Camera::m_all_cameras;
|
||||
|
||||
Camera* Camera::s_active_camera = NULL;
|
||||
Camera::DebugMode Camera::m_debug_mode = Camera::CM_DEBUG_NONE;
|
||||
|
||||
// ============================================================================
|
||||
Camera::Camera(int camera_index, AbstractKart* kart) : m_kart(NULL)
|
||||
@ -453,13 +454,13 @@ void Camera::getCameraSettings(float *above_kart, float *cam_angle,
|
||||
case CM_NORMAL:
|
||||
case CM_FALLING:
|
||||
{
|
||||
if(UserConfigParams::m_camera_debug==2)
|
||||
if(m_debug_mode==CM_DEBUG_GROUND)
|
||||
{
|
||||
*above_kart = 0;
|
||||
*cam_angle = 0;
|
||||
*distance = -m_kart->getKartModel()->getLength()-1.0f;
|
||||
}
|
||||
else if(UserConfigParams::m_camera_debug==4)
|
||||
else if(m_debug_mode==CM_DEBUG_BEHIND_KART)
|
||||
{
|
||||
*above_kart = 0;
|
||||
*cam_angle = 0;
|
||||
@ -548,20 +549,20 @@ void Camera::update(float dt)
|
||||
float above_kart, cam_angle, side_way, distance;
|
||||
bool smoothing;
|
||||
|
||||
// To view inside tunnels in top mode, increase near value
|
||||
m_camera->setNearValue(m_debug_mode==CM_DEBUG_TOP_OF_KART ? 27.0f : 1.0f);
|
||||
|
||||
// The following settings give a debug camera which shows the track from
|
||||
// high above the kart straight down.
|
||||
if (UserConfigParams::m_camera_debug==1)
|
||||
if (m_debug_mode==CM_DEBUG_TOP_OF_KART)
|
||||
{
|
||||
core::vector3df xyz = m_kart->getXYZ().toIrrVector();
|
||||
m_camera->setTarget(xyz);
|
||||
xyz.Y = xyz.Y+55;
|
||||
xyz.Z -= 5.0f;
|
||||
m_camera->setPosition(xyz);
|
||||
// To view inside tunnels (FIXME 27>15 why??? makes no sense
|
||||
// - the kart should not be visible, but it works)
|
||||
m_camera->setNearValue(27.0);
|
||||
}
|
||||
else if (UserConfigParams::m_camera_debug==5)
|
||||
else if (m_debug_mode==CM_DEBUG_SIDE_OF_KART)
|
||||
{
|
||||
core::vector3df xyz = m_kart->getXYZ().toIrrVector();
|
||||
Vec3 offset(3, 0, 0);
|
||||
@ -570,7 +571,7 @@ void Camera::update(float dt)
|
||||
m_camera->setPosition(offset.toIrrVector());
|
||||
}
|
||||
// Update the first person camera
|
||||
else if (UserConfigParams::m_camera_debug == 3)
|
||||
else if (m_debug_mode == CM_DEBUG_FPS)
|
||||
{
|
||||
vector3df direction(m_camera->getTarget() - m_camera->getPosition());
|
||||
vector3df up(m_camera->getUpVector());
|
||||
@ -729,7 +730,7 @@ void Camera::positionCamera(float dt, float above_kart, float cam_angle,
|
||||
{
|
||||
Vec3 wanted_position;
|
||||
Vec3 wanted_target = m_kart->getXYZ();
|
||||
if(UserConfigParams::m_camera_debug==2)
|
||||
if(m_debug_mode==CM_DEBUG_GROUND)
|
||||
{
|
||||
const btWheelInfo &w = m_kart->getVehicle()->getWheelInfo(2);
|
||||
wanted_target.setY(w.m_raycastInfo.m_contactPointWS.getY());
|
||||
@ -749,7 +750,7 @@ void Camera::positionCamera(float dt, float above_kart, float cam_angle,
|
||||
btQuaternion q(m_kart->getSkidding()->getVisualSkidRotation(), 0, 0);
|
||||
t.setBasis(t.getBasis() * btMatrix3x3(q));
|
||||
}
|
||||
if (UserConfigParams::m_camera_debug == 2)
|
||||
if (m_debug_mode == CM_DEBUG_GROUND)
|
||||
{
|
||||
wanted_position = t(relative_position);
|
||||
// Make sure that the Y position is a the same height as the wheel.
|
||||
@ -758,7 +759,7 @@ void Camera::positionCamera(float dt, float above_kart, float cam_angle,
|
||||
else
|
||||
wanted_position = t(relative_position);
|
||||
|
||||
if (smoothing && UserConfigParams::m_camera_debug==0)
|
||||
if (smoothing && !isDebug())
|
||||
{
|
||||
smoothMoveCamera(dt);
|
||||
}
|
||||
|
@ -51,18 +51,33 @@ class Camera : public NoCopy
|
||||
{
|
||||
public:
|
||||
enum Mode {
|
||||
CM_NORMAL, //!< Normal camera mode
|
||||
CM_CLOSEUP, //!< Closer to kart
|
||||
CM_REVERSE, //!< Looking backwards
|
||||
CM_LEADER_MODE, //!< for deleted player karts in follow the leader
|
||||
CM_FINAL, //!< Final camera
|
||||
CM_NORMAL, //!< Normal camera mode
|
||||
CM_CLOSEUP, //!< Closer to kart
|
||||
CM_REVERSE, //!< Looking backwards
|
||||
CM_LEADER_MODE, //!< for deleted player karts in follow the leader
|
||||
CM_FINAL, //!< Final camera
|
||||
CM_SIMPLE_REPLAY,
|
||||
CM_FALLING
|
||||
};
|
||||
}; // Mode
|
||||
|
||||
enum DebugMode {
|
||||
CM_DEBUG_NONE,
|
||||
CM_DEBUG_TOP_OF_KART, //!< Camera hovering over kart
|
||||
CM_DEBUG_GROUND, //!< Camera at ground level, wheel debugging
|
||||
CM_DEBUG_FPS, //!< FPS Camera
|
||||
CM_DEBUG_BEHIND_KART, //!< Camera straight behind kart
|
||||
CM_DEBUG_SIDE_OF_KART,//!< Camera to the right of the kart
|
||||
}; // DebugMode
|
||||
|
||||
|
||||
private:
|
||||
static Camera* s_active_camera;
|
||||
|
||||
/** Special debug camera: 0: normal camera; 1: being high over the kart;
|
||||
2: on ground level; 3: free first person camera;
|
||||
4: straight behind kart */
|
||||
static DebugMode m_debug_mode;
|
||||
|
||||
/** The camera scene node. */
|
||||
scene::ICameraSceneNode *m_camera;
|
||||
/** The project-view matrix of the previous frame, used for the blur shader. */
|
||||
@ -267,16 +282,25 @@ public:
|
||||
|
||||
static void readEndCamera(const XMLNode &root);
|
||||
static void clearEndCameras();
|
||||
void setMode (Mode mode_); /** Set the camera to the given mode */
|
||||
// ------------------------------------------------------------------------
|
||||
static void setDebugMode(DebugMode debug_mode) { m_debug_mode = debug_mode;}
|
||||
// ------------------------------------------------------------------------
|
||||
static bool isDebug() { return m_debug_mode != CM_DEBUG_NONE; }
|
||||
// ------------------------------------------------------------------------
|
||||
static bool isFPS() { return m_debug_mode == CM_DEBUG_FPS; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void setMode(Mode mode); /** Set the camera to the given mode */
|
||||
Mode getMode();
|
||||
/** Returns the camera index (or player kart index, which is the same). */
|
||||
int getIndex() const {return m_index;}
|
||||
void reset ();
|
||||
void reset();
|
||||
void setInitialTransform();
|
||||
void activate(bool alsoActivateInIrrlicht=true);
|
||||
void update (float dt);
|
||||
void update(float dt);
|
||||
void setKart(AbstractKart *new_kart);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the camera index (or player kart index, which is the same). */
|
||||
int getIndex() const {return m_index;}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the project-view matrix of the previous frame. */
|
||||
core::matrix4 getPreviousPVMatrix() const { return m_previous_pv_matrix; }
|
||||
|
@ -174,89 +174,97 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
// Moving the first person camera
|
||||
case KEY_KEY_W:
|
||||
{
|
||||
if (!world || !UserConfigParams::m_artist_debug_mode ||
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.Z = value ? cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
if (world && UserConfigParams::m_artist_debug_mode &&
|
||||
Camera::isFPS() )
|
||||
{
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.Z = value ? cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KEY_KEY_S:
|
||||
{
|
||||
if (!world || !UserConfigParams::m_artist_debug_mode ||
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.Z = value ? -cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
if (world && UserConfigParams::m_artist_debug_mode &&
|
||||
Camera::isFPS() )
|
||||
{
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.Z = value ? -cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KEY_KEY_D:
|
||||
{
|
||||
if (!world || !UserConfigParams::m_artist_debug_mode ||
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.X = value ? -cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
if (world && !UserConfigParams::m_artist_debug_mode &&
|
||||
Camera::isFPS() )
|
||||
{
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.X = value ? -cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KEY_KEY_A:
|
||||
{
|
||||
if (!world || !UserConfigParams::m_artist_debug_mode ||
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.X = value ? cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
if (world && UserConfigParams::m_artist_debug_mode &&
|
||||
Camera::isFPS() )
|
||||
{
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.X = value ? cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KEY_KEY_R:
|
||||
{
|
||||
if (!world || !UserConfigParams::m_artist_debug_mode ||
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.Y = value ? cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
if (world && UserConfigParams::m_artist_debug_mode &&
|
||||
Camera::isFPS() )
|
||||
{
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.Y = value ? cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KEY_KEY_F:
|
||||
{
|
||||
if (!world || !UserConfigParams::m_artist_debug_mode ||
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.Y = value ? -cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
if (world && UserConfigParams::m_artist_debug_mode &&
|
||||
Camera::isFPS() )
|
||||
{
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
core::vector3df vel(cam->getLinearVelocity());
|
||||
vel.Y = value ? -cam->getMaximumVelocity() : 0;
|
||||
cam->setLinearVelocity(vel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Rotating the first person camera
|
||||
case KEY_KEY_Q:
|
||||
{
|
||||
if (!world || !UserConfigParams::m_artist_debug_mode ||
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *active_cam = Camera::getActiveCamera();
|
||||
active_cam->setAngularVelocity(value ?
|
||||
UserConfigParams::m_fpscam_max_angular_velocity : 0.0f);
|
||||
if (world && UserConfigParams::m_artist_debug_mode &&
|
||||
Camera::isFPS() )
|
||||
{
|
||||
Camera *active_cam = Camera::getActiveCamera();
|
||||
active_cam->setAngularVelocity(value ?
|
||||
UserConfigParams::m_fpscam_max_angular_velocity : 0.0f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KEY_KEY_E:
|
||||
{
|
||||
if (!world || !UserConfigParams::m_artist_debug_mode ||
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *active_cam = Camera::getActiveCamera();
|
||||
active_cam->setAngularVelocity(value ?
|
||||
-UserConfigParams::m_fpscam_max_angular_velocity : 0);
|
||||
if (world && UserConfigParams::m_artist_debug_mode &&
|
||||
Camera::isFPS() )
|
||||
{
|
||||
Camera *active_cam = Camera::getActiveCamera();
|
||||
active_cam->setAngularVelocity(value ?
|
||||
-UserConfigParams::m_fpscam_max_angular_velocity : 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1001,7 +1009,7 @@ EventPropagation InputManager::input(const SEvent& event)
|
||||
|
||||
if (type == EMIE_MOUSE_MOVED)
|
||||
{
|
||||
if (UserConfigParams::m_camera_debug == 3)
|
||||
if (Camera::isFPS())
|
||||
{
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
// Center of the screen
|
||||
@ -1056,7 +1064,7 @@ EventPropagation InputManager::input(const SEvent& event)
|
||||
}
|
||||
else if (type == EMIE_MOUSE_WHEEL)
|
||||
{
|
||||
if (UserConfigParams::m_camera_debug == 3)
|
||||
if (Camera::isFPS())
|
||||
{
|
||||
// Use scrolling to change the maximum speed
|
||||
// Only test if it's more or less than 0 as it seems to be not
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "karts/controller/ai_base_controller.hpp"
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "karts/controller/ai_properties.hpp"
|
||||
@ -65,7 +66,7 @@ void AIBaseController::update(float dt)
|
||||
void AIBaseController::setControllerName(const std::string &name)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if(m_ai_debug && !UserConfigParams::m_camera_debug)
|
||||
if(m_ai_debug && !Camera::isDebug())
|
||||
m_kart->setOnScreenText(core::stringw(name.c_str()).c_str());
|
||||
#endif
|
||||
Controller::setControllerName(name);
|
||||
|
@ -150,6 +150,7 @@
|
||||
#include "config/player_profile.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/graphics_restrictions.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
@ -763,11 +764,11 @@ int handleCmdLine()
|
||||
if(UserConfigParams::m_artist_debug_mode)
|
||||
{
|
||||
if(CommandLine::has("--camera-wheel-debug"))
|
||||
UserConfigParams::m_camera_debug=2;
|
||||
Camera::setDebugMode(Camera::CM_DEBUG_GROUND);
|
||||
if(CommandLine::has("--camera-debug"))
|
||||
UserConfigParams::m_camera_debug=1;
|
||||
Camera::setDebugMode(Camera::CM_DEBUG_TOP_OF_KART);
|
||||
if(CommandLine::has("--camera-kart-debug"))
|
||||
UserConfigParams::m_camera_debug=4;
|
||||
Camera::setDebugMode(Camera::CM_DEBUG_BEHIND_KART);
|
||||
if(CommandLine::has("--physics-debug"))
|
||||
UserConfigParams::m_physics_debug=1;
|
||||
if(CommandLine::has("--check-debug"))
|
||||
|
@ -1761,7 +1761,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
|
||||
// It's important to execute this BEFORE the code that creates the skycube,
|
||||
// otherwise the skycube node could be modified to have fog enabled, which
|
||||
// we don't want
|
||||
if (m_use_fog && !UserConfigParams::m_camera_debug && !CVS->isGLSL())
|
||||
if (m_use_fog && !Camera::isDebug() && !CVS->isGLSL())
|
||||
{
|
||||
/* NOTE: if LINEAR type, density does not matter, if EXP or EXP2, start
|
||||
and end do not matter */
|
||||
|
@ -440,27 +440,27 @@ bool handleContextMenuAction(s32 cmdID)
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_TOP)
|
||||
{
|
||||
UserConfigParams::m_camera_debug = 1;
|
||||
Camera::setDebugMode(Camera::CM_DEBUG_TOP_OF_KART);
|
||||
irr_driver->getDevice()->getCursorControl()->setVisible(true);
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_WHEEL)
|
||||
{
|
||||
UserConfigParams::m_camera_debug = 2;
|
||||
Camera::setDebugMode(Camera::CM_DEBUG_GROUND);
|
||||
irr_driver->getDevice()->getCursorControl()->setVisible(true);
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_BEHIND_KART)
|
||||
{
|
||||
UserConfigParams::m_camera_debug = 4;
|
||||
Camera::setDebugMode(Camera::CM_DEBUG_BEHIND_KART);
|
||||
irr_driver->getDevice()->getCursorControl()->setVisible(true);
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_SIDE_OF_KART)
|
||||
{
|
||||
UserConfigParams::m_camera_debug = 5;
|
||||
Camera::setDebugMode(Camera::CM_DEBUG_SIDE_OF_KART);
|
||||
irr_driver->getDevice()->getCursorControl()->setVisible(true);
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_FREE)
|
||||
{
|
||||
UserConfigParams::m_camera_debug = 3;
|
||||
Camera::setDebugMode(Camera::CM_DEBUG_FPS);
|
||||
irr_driver->getDevice()->getCursorControl()->setVisible(false);
|
||||
// Reset camera rotation
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
@ -469,7 +469,7 @@ bool handleContextMenuAction(s32 cmdID)
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_NORMAL)
|
||||
{
|
||||
UserConfigParams::m_camera_debug = 0;
|
||||
Camera::setDebugMode(Camera::CM_DEBUG_NONE);
|
||||
irr_driver->getDevice()->getCursorControl()->setVisible(true);
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_SMOOTH)
|
||||
|
Loading…
Reference in New Issue
Block a user