1
1
forked from 0ad/0ad

mouse_x/y => g_mouse_x/y

This was SVN commit r1767.
This commit is contained in:
janwas 2005-01-23 17:35:36 +00:00
parent e8121ca394
commit d29833e4ed
5 changed files with 29 additions and 29 deletions

View File

@ -16,7 +16,7 @@
#include "Frustum.h"
#include "Matrix3D.h"
extern int mouse_x, mouse_y;
extern int g_mouse_x, g_mouse_y;
//view port
struct SViewPort
@ -67,7 +67,7 @@ class CCamera
// BuildCameraRay: as previous, using global mouse position
void BuildCameraRay( CVector3D& origin, CVector3D& dir )
{
BuildCameraRay( mouse_x, mouse_y, origin, dir );
BuildCameraRay( g_mouse_x, g_mouse_y, origin, dir );
}
// General helpers that seem to fit here
@ -77,7 +77,7 @@ class CCamera
// Get the point on the terrain corresponding to pixel (px,py) (or the mouse coordinates)
CVector3D GetWorldCoordinates( int px, int py );
CVector3D GetWorldCoordinates() { return( GetWorldCoordinates( mouse_x, mouse_y ) ); }
CVector3D GetWorldCoordinates() { return( GetWorldCoordinates( g_mouse_x, g_mouse_y ) ); }
// Get the point on the terrain the camera is pointing towards
CVector3D GetFocus();

View File

@ -251,10 +251,10 @@ void CGameView::Update(float DeltaTime)
// Calculate mouse movement
static int mouse_last_x = 0;
static int mouse_last_y = 0;
int mouse_dx = mouse_x - mouse_last_x;
int mouse_dy = mouse_y - mouse_last_y;
mouse_last_x = mouse_x;
mouse_last_y = mouse_y;
int mouse_dx = g_mouse_x - mouse_last_x;
int mouse_dy = g_mouse_y - mouse_last_y;
mouse_last_x = g_mouse_x;
mouse_last_y = g_mouse_y;
// Miscellaneous vectors
CVector3D forwards = m_Camera.m_Orientation.GetIn();
@ -409,14 +409,14 @@ void CGameView::Update(float DeltaTime)
if( !hotkeys[HOTKEY_CAMERA_ROTATE] && !hotkeys[HOTKEY_CAMERA_ROTATE_ABOUT_TARGET] )
{
if (mouse_x >= g_xres-2 && mouse_x < g_xres)
if (g_mouse_x >= g_xres-2 && g_mouse_x < g_xres)
m_Camera.m_Orientation.Translate(rightwards * (m_ViewScrollSpeed * DeltaTime));
else if (mouse_x <= 3 && mouse_x >= 0)
else if (g_mouse_x <= 3 && g_mouse_x >= 0)
m_Camera.m_Orientation.Translate(-rightwards * (m_ViewScrollSpeed * DeltaTime));
if (mouse_y >= g_yres-2 && mouse_y < g_yres)
if (g_mouse_y >= g_yres-2 && g_mouse_y < g_yres)
m_Camera.m_Orientation.Translate(-forwards_horizontal * (m_ViewScrollSpeed * DeltaTime));
else if (mouse_y <= 3 && mouse_y >= 0)
else if (g_mouse_y <= 3 && g_mouse_y >= 0)
m_Camera.m_Orientation.Translate(forwards_horizontal * (m_ViewScrollSpeed * DeltaTime));
}
@ -479,18 +479,18 @@ Just commented out to make it more obvious it's not in use.
m_Camera.m_Orientation.Translate(position*-1);
// Sideways rotation
m_Camera.m_Orientation.RotateY(m_ViewRotateSpeed*(float)(mouse_x-mouse_last_x));
m_Camera.m_Orientation.RotateY(m_ViewRotateSpeed*(float)(g_mouse_x-mouse_last_x));
// Up/down rotation
CQuaternion temp;
temp.FromAxisAngle(rightwards, m_ViewRotateSpeed*(float)(mouse_y-mouse_last_y));
temp.FromAxisAngle(rightwards, m_ViewRotateSpeed*(float)(g_mouse_y-mouse_last_y));
m_Camera.m_Orientation.Rotate(temp);
// Retranslate back to the right position
m_Camera.m_Orientation.Translate(position);
}
mouse_last_x = mouse_x;
mouse_last_y = mouse_y;
mouse_last_x = g_mouse_x;
mouse_last_y = g_mouse_y;
// Calculate the necessary vectors for movement
@ -500,14 +500,14 @@ Just commented out to make it more obvious it's not in use.
// Move when desirable
if (mouse_x >= g_xres-2)
if (g_mouse_x >= g_xres-2)
m_Camera.m_Orientation.Translate(rightwards);
else if (mouse_x <= 3)
else if (g_mouse_x <= 3)
m_Camera.m_Orientation.Translate(-rightwards);
if (mouse_y >= g_yres-2)
if (g_mouse_y >= g_yres-2)
m_Camera.m_Orientation.Translate(forwards_horizontal);
else if (mouse_y <= 3)
else if (g_mouse_y <= 3)
m_Camera.m_Orientation.Translate(-forwards_horizontal);
// Smoothed height-changing (move a certain percentage towards the desired height every frame)
@ -529,14 +529,14 @@ Just commented out to make it more obvious it's not in use.
const CVector3D Right(dx,0, dx);
const CVector3D Up (dx,0,-dx);
if (mouse_x >= g_xres-2)
if (g_mouse_x >= g_xres-2)
m_Camera.m_Orientation.Translate(Right);
if (mouse_x <= 3)
if (g_mouse_x <= 3)
m_Camera.m_Orientation.Translate(Right*-1);
if (mouse_y >= g_yres-2)
if (g_mouse_y >= g_yres-2)
m_Camera.m_Orientation.Translate(Up);
if (mouse_y <= 3)
if (g_mouse_y <= 3)
m_Camera.m_Orientation.Translate(Up*-1);
/*

View File

@ -62,7 +62,7 @@ public:
virtual void HandleMessage(const SGUIMessage &Message);
/**
* Set m_Pos with mouse_x/y input, i.e. when draggin.
* Set m_Pos with g_mouse_x/y input, i.e. when draggin.
*/
virtual void SetPosFromMousePos(const CPos &mouse);

View File

@ -159,7 +159,7 @@ public:
virtual void HandleMessage(const SGUIMessage &Message)=0;
/**
* Set m_Pos with mouse_x/y input, i.e. when draggin.
* Set m_Pos with g_mouse_x/y input, i.e. when draggin.
*/
virtual void SetPosFromMousePos(const CPos &mouse)=0;

View File

@ -94,7 +94,7 @@ extern int conInputHandler(const SDL_Event* ev);
bool keys[SDLK_LAST];
bool mouseButtons[5];
int mouse_x=50, mouse_y=50;
int g_mouse_x=50, g_mouse_y=50;
int g_xres, g_yres;
int g_bpp;
@ -232,7 +232,7 @@ debug_out("SYS DETECT TIME %g\n\n", t2-t1);
fprintf(f, "\n");
// .. memory
fprintf(f, "%lu MB RAM; %lu MB free\n", tot_mem/MB, avl_mem/MB);
fprintf(f, "%lu MB RAM; %lu MB free\n", tot_mem/MiB, avl_mem/MiB);
// .. graphics card
fprintf(f, "%s\n", gfx_card);
@ -356,8 +356,8 @@ static int handler(const SDL_Event* ev)
break;
case SDL_MOUSEMOTION:
mouse_x = ev->motion.x;
mouse_y = ev->motion.y;
g_mouse_x = ev->motion.x;
g_mouse_y = ev->motion.y;
break;
case SDL_KEYDOWN: