Page MenuHome

spaceball.patch

spaceball.patch

Index: intern/ghost/GHOST_C-api.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/GHOST_C-api.h,v
retrieving revision 1.6
diff -u -r1.6 GHOST_C-api.h
--- intern/ghost/GHOST_C-api.h 26 Dec 2003 20:12:40 -0000 1.6
+++ intern/ghost/GHOST_C-api.h 30 Dec 2005 21:34:08 -0000
@@ -264,7 +264,15 @@
extern GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle,
GHOST_EventConsumerHandle consumerhandle);
+/***************************************************************************************
+ ** Spaceball management functionality
+ ***************************************************************************************/
+/**
+ * Open the spaceball
+ */
+extern void GHOST_OpenSpaceball(GHOST_SystemHandle systemhandle,
+ GHOST_WindowHandle windowhandle);
/***************************************************************************************
** Cursor management functionality
Index: intern/ghost/GHOST_ISystem.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/GHOST_ISystem.h,v
retrieving revision 1.7
diff -u -r1.7 GHOST_ISystem.h
--- intern/ghost/GHOST_ISystem.h 24 Jan 2003 05:32:14 -0000 1.7
+++ intern/ghost/GHOST_ISystem.h 30 Dec 2005 21:38:22 -0000
@@ -296,6 +296,16 @@
virtual GHOST_TSuccess addEventConsumer(GHOST_IEventConsumer* consumer) = 0;
/***************************************************************************************
+ ** Spaceball management functionality
+ ***************************************************************************************/
+
+ /**
+ * Starts the Spaceball manager
+ */
+ virtual void openSpaceball(GHOST_IWindow*) = 0;
+
+
+ /***************************************************************************************
** Cursor management functionality
***************************************************************************************/
Index: intern/ghost/GHOST_Types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/GHOST_Types.h,v
retrieving revision 1.12
diff -u -r1.12 GHOST_Types.h
--- intern/ghost/GHOST_Types.h 29 Mar 2005 14:27:20 -0000 1.12
+++ intern/ghost/GHOST_Types.h 30 Dec 2005 21:41:16 -0000
@@ -131,6 +131,8 @@
GHOST_kEventWindowUpdate,
GHOST_kEventWindowSize,
+ GHOST_kEventSpaceballMotion, /// Spaceball motion event
+
GHOST_kNumEventTypes
} GHOST_TEventType;
@@ -321,6 +323,13 @@
/** Displacement of a mouse wheel. */
GHOST_TInt32 z;
} GHOST_TEventWheelData;
+
+typedef struct {
+ /** Spaceball data */
+ float tx, ty, tz; /** -x left, +y up, +z forward */
+ float rx, ry, rz;
+ float dt;
+} GHOST_TEventSpaceballData;
typedef struct {
/** The key code. */
Index: intern/ghost/intern/GHOST_C-api.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_C-api.cpp,v
retrieving revision 1.4
diff -u -r1.4 GHOST_C-api.cpp
--- intern/ghost/intern/GHOST_C-api.cpp 26 Dec 2003 20:12:40 -0000 1.4
+++ intern/ghost/intern/GHOST_C-api.cpp 30 Dec 2005 21:36:10 -0000
@@ -260,6 +260,13 @@
}
+void GHOST_OpenSpaceball(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle)
+{
+ GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+
+ system->openSpaceball((GHOST_IWindow*) windowhandle);
+}
+
GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle)
{
Index: intern/ghost/intern/GHOST_System.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_System.cpp,v
retrieving revision 1.5
diff -u -r1.5 GHOST_System.cpp
--- intern/ghost/intern/GHOST_System.cpp 1 Jan 2003 21:30:39 -0000 1.5
+++ intern/ghost/intern/GHOST_System.cpp 30 Dec 2005 22:30:28 -0000
@@ -47,13 +47,14 @@
#include "GHOST_DisplayManager.h"
#include "GHOST_EventManager.h"
+#include "GHOST_SpaceballManager.h"
#include "GHOST_TimerTask.h"
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
GHOST_System::GHOST_System()
-: m_displayManager(0), m_timerManager(0), m_windowManager(0), m_eventManager(0)
+: m_displayManager(0), m_timerManager(0), m_windowManager(0), m_eventManager(0), m_spaceballManager(0)
{
}
@@ -240,6 +241,12 @@
}
+void GHOST_System::openSpaceball(GHOST_IWindow* w)
+{
+ m_spaceballManager->spaceballOpen(w);
+}
+
+
GHOST_TSuccess GHOST_System::getModifierKeyState(GHOST_TModifierKeyMask mask, bool& isDown) const
{
GHOST_ModifierKeys keys;
@@ -271,6 +278,7 @@
m_timerManager = new GHOST_TimerManager ();
m_windowManager = new GHOST_WindowManager ();
m_eventManager = new GHOST_EventManager ();
+ m_spaceballManager = new GHOST_SpaceballManager();
#ifdef GHOST_DEBUG
if (m_eventManager) {
m_eventManager->addConsumer(&m_eventPrinter);
@@ -306,6 +314,10 @@
delete m_eventManager;
m_eventManager = 0;
}
+ if (m_spaceballManager) {
+ delete m_spaceballManager;
+ m_spaceballManager = 0;
+ }
return GHOST_kSuccess;
}
Index: intern/ghost/intern/GHOST_System.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_System.h,v
retrieving revision 1.6
diff -u -r1.6 GHOST_System.h
--- intern/ghost/intern/GHOST_System.h 28 Dec 2002 22:26:45 -0000 1.6
+++ intern/ghost/intern/GHOST_System.h 30 Dec 2005 22:51:10 -0000
@@ -51,6 +51,7 @@
class GHOST_TimerManager;
class GHOST_Window;
class GHOST_WindowManager;
+class GHOST_SpaceballManager;
/**
* Implementation of platform independent functionality of the GHOST_ISystem
@@ -184,6 +185,18 @@
*/
virtual GHOST_TSuccess addEventConsumer(GHOST_IEventConsumer* consumer);
+
+
+ /***************************************************************************************
+ ** Spaceball management functionality
+ ***************************************************************************************/
+
+ /** Inherited from GHOST_ISystem
+ * Opens the spaceball manager
+ */
+ virtual void openSpaceball(GHOST_IWindow*);
+
+
/***************************************************************************************
** Cursor management functionality
***************************************************************************************/
@@ -237,13 +250,19 @@
*/
virtual inline GHOST_EventManager* getEventManager() const;
- /**
+ /**
* Returns a pointer to our window manager.
* @return A pointer to our window manager.
- */
+ */
virtual inline GHOST_WindowManager* getWindowManager() const;
/**
+ * Returns a pointer to our spaceball manager.
+ * @return A pointer to our spaceball manager.
+ */
+ virtual inline GHOST_SpaceballManager* getSpaceballManager() const;
+
+ /**
* Returns the state of all modifier keys.
* @param keys The state of all modifier keys (true == pressed).
* @return Indication of success.
@@ -290,6 +309,9 @@
/** The event manager. */
GHOST_EventManager* m_eventManager;
+ /** The spaceball manager */
+ GHOST_SpaceballManager* m_spaceballManager;
+
/** Prints all the events. */
#ifdef GHOST_DEBUG
GHOST_EventPrinter m_eventPrinter;
@@ -312,6 +334,11 @@
inline GHOST_WindowManager* GHOST_System::getWindowManager() const
{
return m_windowManager;
+}
+
+inline GHOST_SpaceballManager* GHOST_System::getSpaceballManager() const
+{
+ return m_spaceballManager;
}
#endif // _GHOST_SYSTEM_H_
Index: intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_SystemWin32.cpp,v
retrieving revision 1.10
diff -u -r1.10 GHOST_SystemWin32.cpp
--- intern/ghost/intern/GHOST_SystemWin32.cpp 7 Nov 2004 16:30:19 -0000 1.10
+++ intern/ghost/intern/GHOST_SystemWin32.cpp 30 Dec 2005 22:53:30 -0000
@@ -64,6 +64,8 @@
#include "GHOST_EventCursor.h"
#include "GHOST_EventKey.h"
#include "GHOST_EventWheel.h"
+#include "GHOST_SpaceballManager.h"
+#include "GHOST_EventSpaceball.h"
#include "GHOST_TimerTask.h"
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
@@ -524,7 +526,18 @@
if (hwnd) {
GHOST_WindowWin32* window = (GHOST_WindowWin32*)::GetWindowLong(hwnd, GWL_USERDATA);
if (window) {
- switch (msg) {
+
+ /* Give spaceball manager a chance to process its own events before
+ * letting the regular windows event handlers run. This is because the spaceball
+ * control panel might be supplying "fake" events such as wheel mouse events
+ * which we don't want since we're handling everything here.
+ */
+ GHOST_TEventSpaceballData* sbevent = system->getSpaceballManager()->handle(msg, (unsigned int*)wParam, (unsigned long*)lParam);
+ if (sbevent != 0)
+ {
+ system->pushEvent(new GHOST_EventSpaceball(system->getMilliSeconds(), GHOST_kEventSpaceballMotion, window, *sbevent));
+ }
+ else switch (msg) {
////////////////////////////////////////////////////////////////////////
// Keyboard events, processed
////////////////////////////////////////////////////////////////////////
@@ -703,6 +716,7 @@
*/
break;
+
////////////////////////////////////////////////////////////////////////
// Window events, processed
////////////////////////////////////////////////////////////////////////
Index: intern/ghost/intern/GHOST_WindowWin32.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_WindowWin32.h,v
retrieving revision 1.8
diff -u -r1.8 GHOST_WindowWin32.h
--- intern/ghost/intern/GHOST_WindowWin32.h 26 Dec 2003 22:41:51 -0000 1.8
+++ intern/ghost/intern/GHOST_WindowWin32.h 30 Dec 2005 21:53:24 -0000
@@ -216,6 +216,12 @@
*/
void loadCursor(bool visible, GHOST_TStandardCursor cursorShape) const;
+ /**
+ * Returns the HWND of the window. Needed to initialize the
+ * spaceball driver on Windows.
+ * @Returns the HWND of the window
+ */
+ HWND getHWND() const { return m_hWnd; }
protected:
/**
Index: source/blender/include/mydevice.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/mydevice.h,v
retrieving revision 1.20
diff -u -r1.20 mydevice.h
--- source/blender/include/mydevice.h 20 Nov 2005 21:29:09 -0000 1.20
+++ source/blender/include/mydevice.h 30 Dec 2005 22:01:08 -0000
@@ -70,6 +70,9 @@
#define WINQUIT 0x018 /* signal from user that app is to go away */
#define Q_FIRSTTIME 0x019 /* on startup */
+/* Spaceball : 500 */
+#define SPACEBALLMOTION 500
+
/* standard keyboard */
#define AKEY 'a'
Index: source/blender/src/editscreen.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editscreen.c,v
retrieving revision 1.120
diff -u -r1.120 editscreen.c
--- source/blender/src/editscreen.c 28 Nov 2005 22:49:23 -0000 1.120
+++ source/blender/src/editscreen.c 30 Dec 2005 23:04:48 -0000
@@ -1988,6 +1988,8 @@
/* ************ SCREEN MANAGEMENT ************** */
+/* BIF_wait_for_statechange waits for the window handler to invoke add_to_mainqueue */
+
static int statechanged= 0;
void BIF_wait_for_statechange(void)
{
@@ -2018,6 +2020,11 @@
winlay_process_events(0);
return window_get_mbut(mainwin);
}
+short getspaceball(short *sbval)
+{
+ winlay_process_events(0);
+ return window_get_spaceball(mainwin, sbval);
+}
void add_to_mainqueue(Window *win, void *user_data, short evt, short val, char ascii)
{
@@ -2088,11 +2095,12 @@
}
window_set_handler(mainwin, add_to_mainqueue, NULL);
+ window_open_spaceball(mainwin); /* needs to occur once the mainwin handler is set */
init_mainwin();
mywinset(1);
/* for visual speed, but still needed? */
- glClearColor(.55, .55, .55, 0.0);
+ glClearColor(0.55f, 0.55f, 0.55f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
window_swap_buffers(mainwin);
Index: source/blender/src/ghostwinlay.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/ghostwinlay.c,v
retrieving revision 1.41
diff -u -r1.41 ghostwinlay.c
--- source/blender/src/ghostwinlay.c 28 Nov 2005 13:50:44 -0000 1.41
+++ source/blender/src/ghostwinlay.c 30 Dec 2005 22:06:12 -0000
@@ -60,6 +60,8 @@
#include "winlay.h"
+#include <math.h>
+
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <Carbon/Carbon.h>
@@ -92,6 +94,9 @@
*/
int faked_mbut;
+ /* Last known spaceball state */
+ short spaceball[7]; /* spaceball data */
+
GHOST_TimerTaskHandle timer;
int timer_event;
};
@@ -203,6 +208,7 @@
}
}
+
static int convert_key(GHOST_TKey key) {
if (key>=GHOST_kKeyA && key<=GHOST_kKeyZ) {
return (AKEY + ((int) key - GHOST_kKeyA));
@@ -316,6 +322,7 @@
Window *window_open(char *title, int posx, int posy, int sizex, int sizey, int start_maximized)
{
+ int i;
GHOST_WindowHandle ghostwin;
GHOST_TWindowState inital_state;
int scr_w, scr_h;
@@ -359,8 +366,9 @@
win->lmouse[0]= win->size[0]/2;
win->lmouse[1]= win->size[1]/2;
-
-
+
+ for (i = 0; i < 7; ++i)
+ win->spaceball[i] = 0;
} else {
GHOST_DisposeWindow(g_system, ghostwin);
}
@@ -509,6 +517,31 @@
}
switch (type) {
+
+ case GHOST_kEventSpaceballMotion: {
+ // update spaceball data, and dispatch motion event
+ GHOST_TEventSpaceballData *sb= data;
+
+ win->spaceball[0] = sb->tx * 255;
+ win->spaceball[1] = sb->ty * 255;
+ win->spaceball[2] = sb->tz * 255;
+ win->spaceball[3] = sb->rx * 255;
+ win->spaceball[4] = sb->ry * 255;
+ win->spaceball[5] = sb->rz * 255;
+ win->spaceball[6] = sb->dt * 255;
+
+ // start interaction for larger than teeny-tiny motions
+ if ((fabsf(sb->tx) > 0.03f) ||
+ (fabsf(sb->ty) > 0.03f) ||
+ (fabsf(sb->tz) > 0.03f) ||
+ (fabsf(sb->rx) > 0.03f) ||
+ (fabsf(sb->ry) > 0.03f) ||
+ (fabsf(sb->rz) > 0.03f)) {
+ window_handle(win, SPACEBALLMOTION, sb->dt * 255);
+ }
+ break;
+ }
+
case GHOST_kEventCursorMove: {
if(win->active == 1) {
GHOST_TEventCursorData *cd= data;
@@ -704,6 +737,13 @@
mval[1]= win->lmouse[1];
}
+void window_get_spaceball(Window* win, short* sbval) {
+ int i;
+ for (i = 0; i < 7; ++i) {
+ *sbval++ = win->spaceball[i];
+ }
+}
+
void window_get_position(Window *win, int *posx_r, int *posy_r) {
*posx_r= win->position[0];
*posy_r= win->position[1];
@@ -784,4 +824,9 @@
Window *winlay_get_active_window(void) {
return active_gl_window;
+}
+
+void window_open_spaceball(Window* win)
+{
+ GHOST_OpenSpaceball(g_system, win->ghostwin);
}
Index: source/blender/src/space.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/space.c,v
retrieving revision 1.320
diff -u -r1.320 space.c
--- source/blender/src/space.c 5 Dec 2005 11:46:40 -0000 1.320
+++ source/blender/src/space.c 30 Dec 2005 23:06:48 -0000
@@ -1014,6 +1014,10 @@
doredraw= 1;
break;
+
+ case SPACEBALLMOTION:
+ viewmove(0);
+ break;
case ONEKEY:
if(G.qual==LR_CTRLKEY) {
Index: source/blender/src/view.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/view.c,v
retrieving revision 1.60
diff -u -r1.60 view.c
--- source/blender/src/view.c 28 Nov 2005 16:59:12 -0000 1.60
+++ source/blender/src/view.c 30 Dec 2005 22:12:02 -0000
@@ -85,6 +85,8 @@
/* Modules used */
#include "render.h" /* R. stuff for ogl view render */
+#include "PIL_time.h"
+
#define TRACKBALLSIZE (1.1)
#define BL_NEAR_CLIP 0.001
@@ -528,6 +530,7 @@
void viewmove(int mode)
{
+ int i, spaceballing;
Object *ob = OBACT;
float firstvec[3], newvec[3], dvec[3];
float reverse, oldquat[4], q1[4], si, phi, dist0;
@@ -535,6 +538,10 @@
int firsttime=1;
short mvalball[2], mval[2], mvalo[2];
short use_sel = 0;
+ double timeout, frametime, oneframe, oneframeo;
+
+ /* spaceball data copy here while viewmove-ing */
+ short sbval[7], sbvalo[7];
/* sometimes this routine is called from headerbuttons */
areawinset(curarea->win);
@@ -547,34 +554,53 @@
mvalball[0]= mvalo[0]; /* needed for turntable to work */
mvalball[1]= mvalo[1];
dist0= G.vd->dist;
-
+
+ getspaceball(sbvalo);
+ getspaceball(sbval);
+
calctrackballvec(&curarea->winrct, mvalo, firstvec);
/* cumultime(0); */
-
if (G.obedit==NULL && ob && !(ob->flag & OB_POSEMODE) && U.uiflag & USER_ORBIT_SELECTION) {
use_sel = 1;
- VECCOPY(ofs, G.vd->ofs);
- if (ob) {
- obofs[0] = -ob->obmat[3][0];
- obofs[1] = -ob->obmat[3][1];
- obofs[2] = -ob->obmat[3][2];
- }
- else {
- VECCOPY(obofs, ofs);
- }
+ }
+
+ /* spaceball needs ofs & obofs no matter what */
+ VECCOPY(ofs, G.vd->ofs);
+ if (ob) {
+ obofs[0] = -ob->obmat[3][0];
+ obofs[1] = -ob->obmat[3][1];
+ obofs[2] = -ob->obmat[3][2];
+ }
+ else {
+ VECCOPY(obofs, ofs);
}
reverse= 1.0f;
if (G.vd->persmat[2][1] < 0.0f)
reverse= -1.0f;
+ /* remember when we started */
+ timeout = PIL_check_seconds_timer();
+ frametime = 1.0f/60.0f; /* do first frame as if 60Hz */
+ oneframeo = timeout - frametime;
+
while(TRUE) {
+ float sbadjust;
+ oneframe = PIL_check_seconds_timer();
+ frametime = (oneframe - oneframeo);
+ sbadjust = 100 * frametime; /* normalize spaceball adjustments to 100Hz for framerate independence */
+
getmouseco_sc(mval);
-
+ getspaceball(sbval);
+
+
// if playanim = alt+A, screenhandlers are for animated UI, python, etc
- if(mval[0]!=mvalo[0] || mval[1]!=mvalo[1] || (G.f & G_PLAYANIM) || do_screenhandlers(G.curscreen)) {
-
+ if(mval[0]!=mvalo[0] || mval[1]!=mvalo[1]
+ || sbval[0]!=sbvalo[0] || sbval[1]!=sbvalo[1] || sbval[2]!=sbvalo[2]
+ || sbval[3]!=sbvalo[3] || sbval[4]!=sbvalo[4] || sbval[5]!=sbvalo[5]
+ || (G.f & G_PLAYANIM) || do_screenhandlers(G.curscreen)) {
+
if(firsttime) {
firsttime= 0;
@@ -591,8 +617,96 @@
}
}
-
- if(mode==0) { /* view rotate */
+ /* spaceball pan */
+ spaceballing = 0;
+ if (sbval[0]!=sbvalo[0] || sbval[1]!=sbvalo[1]) {
+ window_to_3d(dvec,
+ sbadjust * 0.1f/255.0f * sbval[0] * curarea->winx,
+ sbadjust * 0.1f/255.0f * sbval[1] * curarea->winy);
+ VecAddf(G.vd->ofs, G.vd->ofs, dvec);
+ timeout = PIL_check_seconds_timer() + 0.1f; // reset timeout timer to 1/10s
+ spaceballing = 1;
+ }
+
+ /* spaceball dolly */
+ if (sbval[2]!=sbvalo[2]) {
+ float len = sbadjust * 0.1f/255.0f * sbval[2];
+ if (sbval[2] < 0) {
+ if(G.vd->persp==2) {
+ G.vd->camzoom+= 10.0f * -len;
+ if(G.vd->camzoom>300)
+ G.vd->camzoom= 300;
+ }
+ else if(G.vd->dist> 0.001*G.vd->grid)
+ G.vd->dist*=(1.0 + len); /* len is -ve, so *= <1 */
+ }
+ else if (sbval[2] > 0) {
+ if(G.vd->persp==2) {
+ G.vd->camzoom-= 10.0f * len;
+ if(G.vd->camzoom<-30)
+ G.vd->camzoom= -30;
+ }
+ else if(G.vd->dist<10.0*G.vd->far)
+ G.vd->dist*= 1.0 + len; /* len is +ve, so *= >1 */
+ }
+ timeout = PIL_check_seconds_timer() + 0.1f; /* reset timeout */
+ spaceballing = 1;
+ }
+
+ /* spaceball turntable */
+ if (sbval[3]!=sbvalo[3] || sbval[4]!=sbvalo[4]) {
+ /* Modified from turntable view code below */
+ float m[3][3];
+ float m_inv[3][3];
+ float xvec[3] = {1,0,0};
+ /* Sensitivity will control how fast the viewport rotates. 0.0025 was
+ obtained experimentally by tweaking until the author didn't get dizzy watching. */
+ /* Perhaps this should be a configurable user parameter. */
+ const float sensitivity = 0.00125;
+
+ /* Get the 3x3 matrix and its inverse from the quaternion */
+ QuatToMat3(G.vd->viewquat, m);
+ Mat3Inv(m_inv,m);
+
+ /* Determine the direction of the x vector (for rotating up and down) */
+ /* This can likely be compuated directly from the quaternion. */
+ Mat3MulVecfl(m_inv,xvec);
+
+ /* Perform the up/down rotation */
+ phi = sbadjust * sensitivity * 0.5f * sbval[3]; /* spin vertically half as fast as horizontally */
+ si = sin(phi);
+ q1[0] = cos(phi);
+ q1[1] = si * xvec[0];
+ q1[2] = si * xvec[1];
+ q1[3] = si * xvec[2];
+ QuatMul(G.vd->viewquat, G.vd->viewquat, q1);
+
+ if (1 || use_sel) {
+ QuatConj(q1); /* conj == inv for unit quat */
+ VecSubf(G.vd->ofs, G.vd->ofs, obofs);
+ QuatMulVecf(q1, G.vd->ofs);
+ VecAddf(G.vd->ofs, G.vd->ofs, obofs);
+ }
+
+ /* Perform the orbital rotation */
+ phi = sbadjust * sensitivity * reverse * sbval[4]; /* twist the knob, y axis */
+ q1[0] = cos(phi);
+ q1[1] = q1[2] = 0.0;
+ q1[3] = sin(phi);
+ QuatMul(G.vd->viewquat, G.vd->viewquat, q1);
+
+ if (1 || use_sel) {
+ QuatConj(q1);
+ VecSubf(G.vd->ofs, G.vd->ofs, obofs);
+ QuatMulVecf(q1, G.vd->ofs);
+ VecAddf(G.vd->ofs, G.vd->ofs, obofs);
+ }
+ timeout = PIL_check_seconds_timer() + 0.1f; /* reset timeout */
+ spaceballing = 1;
+ }
+ /* don't let mouse rotate if the spaceball is twisted by the user */
+ if (!spaceballing)
+ if(mode==0) { /* view rotate */
if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 1;
if (U.flag & USER_TRACKBALL) mvalball[0]= mval[0];
@@ -740,9 +854,6 @@
mval[1]= mvalo[1]; /* preserve first value */
mval[0]= mvalo[0];
}
-
- mvalo[0]= mval[0];
- mvalo[1]= mval[1];
if(G.f & G_PLAYANIM) inner_play_anim_loop(0, 0);
if(G.f & G_SIMULATION) break;
@@ -758,9 +869,40 @@
BIF_wait_for_statechange();
}
-
- /* this in the end, otherwise get_mbut does not work on a PC... */
- if( !(get_mbut() & (L_MOUSE|M_MOUSE))) break;
+
+ /* don't break out of loop if spaceball active */
+
+ mvalo[0]= mval[0];
+ mvalo[1]= mval[1];
+ for (i = 0; i < 7; ++i) {
+ sbvalo[i] = sbval[i];
+ }
+
+ {
+ int gotSpaceball = 1;
+ double currseconds = PIL_check_seconds_timer();
+
+ /* wait 1/10 of a second after every spaceball event */
+ if (currseconds > timeout) {
+ getspaceball(sbval);
+
+ for (i = 0; i < 7; ++i)
+ {
+ if (sbval[0] != 0)
+ break;
+ }
+ if (i == 7)
+ gotSpaceball = 0;
+ else
+ timeout = currseconds - 0.1f;
+
+ /* this in the end, otherwise get_mbut does not work on a PC... */
+ if( !gotSpaceball && (!(get_mbut() & (L_MOUSE|M_MOUSE))))
+ break;
+ }
+ }
+
+ oneframeo = oneframe;
}
}
@@ -1128,7 +1270,7 @@
afm[1]= (max[1]-min[1]);
afm[2]= (max[2]-min[2]);
size= 0.7*MAX3(afm[0], afm[1], afm[2]);
- if(size<=0.01) size= 0.01;
+ if(size<=0.01f) size= 0.01f;
}
if(ok) {
@@ -1152,7 +1294,7 @@
G.vd->persp= 1;
}
- G.vd->near= 0.1;
+ G.vd->near= 0.1f;
G.vd->cursor[0]= -G.vd->ofs[0];
G.vd->cursor[1]= -G.vd->ofs[1];
G.vd->cursor[2]= -G.vd->ofs[2];
@@ -1232,7 +1374,7 @@
afm[2]= (max[2]-min[2]);
size= 0.7*MAX3(afm[0], afm[1], afm[2]);
- if(size<=0.01) size= 0.01;
+ if(size<=0.01f) size= 0.01f;
G.vd->ofs[0]= -(min[0]+max[0])/2.0;
G.vd->ofs[1]= -(min[1]+max[1])/2.0;
Index: source/blender/src/winlay.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/winlay.h,v
retrieving revision 1.11
diff -u -r1.11 winlay.h
--- source/blender/src/winlay.h 23 Mar 2005 21:10:02 -0000 1.11
+++ source/blender/src/winlay.h 30 Dec 2005 22:02:44 -0000
@@ -82,3 +82,5 @@
void winlay_process_events (int wait_for_event);
void winlay_get_screensize (int *width_r, int *height_r);
+
+void window_open_spaceball(Window* win);

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0f/c1/9905fb3514284f3ce684c46bcb2b

Event Timeline