Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2016-08-18 07:21:55 +0300
committerMike Erwin <significant.bit@gmail.com>2016-08-18 07:22:18 +0300
commitb10d0058d72da3051895481ae5830a7b668b7d80 (patch)
tree987bcae7e565745b1371e60c7d74ffce2668aac7 /source/blender/editors/space_view3d/view3d_walk.c
parenta195dd15d4373ff0e240566795ff7795ca7485e6 (diff)
NDOF: compile 3D mouse code only if WITH_INPUT_NDOF
When WITH_INPUT_NDOF is disabled, 3D mouse handling code is removed from: - GHOST (was mostly done, finished the job) - window manager - various editors - RNA - keymaps The input tab of user prefs does not show 3D mouse settings. Key map editor does not show NDOF mappings. DNA does not change. On my Mac the compiled binary is 42KB smaller after this change. It runs fine WITH_INPUT_NDOF on or off.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_walk.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index c9e4bb301b8..17c08ed4205 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -59,8 +59,10 @@
#include "view3d_intern.h" /* own include */
-//#define NDOF_WALK_DEBUG
-//#define NDOF_WALK_DRAW_TOOMUCH /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */
+#ifdef WITH_INPUT_NDOF
+//# define NDOF_WALK_DEBUG
+//# define NDOF_WALK_DRAW_TOOMUCH /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */
+#endif
#define USE_TABLET_SUPPORT
@@ -254,7 +256,10 @@ typedef struct WalkInfo {
int prev_mval[2]; /* previous 2D mouse values */
int center_mval[2]; /* center mouse values */
int moffset[2];
+
+#ifdef WITH_INPUT_NDOF
wmNDOFMotionData *ndof; /* latest 3D mouse values */
+#endif
/* walk state state */
float base_speed; /* the base speed without run/slow down modifications */
@@ -572,7 +577,9 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f);
+#ifdef WITH_INPUT_NDOF
walk->ndof = NULL;
+#endif
walk->time_lastdraw = PIL_check_seconds_timer();
@@ -639,8 +646,10 @@ static int walkEnd(bContext *C, WalkInfo *walk)
rv3d->rflag &= ~RV3D_NAVIGATING;
+#ifdef WITH_INPUT_NDOF
if (walk->ndof)
MEM_freeN(walk->ndof);
+#endif
/* restore the cursor */
WM_cursor_modal_restore(win);
@@ -743,6 +752,7 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
}
}
}
+#ifdef WITH_INPUT_NDOF
else if (event->type == NDOF_MOTION) {
/* do these automagically get delivered? yes. */
// puts("ndof motion detected in walk mode!");
@@ -752,15 +762,15 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
switch (incoming_ndof->progress) {
case P_STARTING:
/* start keeping track of 3D mouse position */
-#ifdef NDOF_WALK_DEBUG
+# ifdef NDOF_WALK_DEBUG
puts("start keeping track of 3D mouse position");
-#endif
+# endif
/* fall-through */
case P_IN_PROGRESS:
/* update 3D mouse position */
-#ifdef NDOF_WALK_DEBUG
+# ifdef NDOF_WALK_DEBUG
putchar('.'); fflush(stdout);
-#endif
+# endif
if (walk->ndof == NULL) {
// walk->ndof = MEM_mallocN(sizeof(wmNDOFMotionData), tag_name);
walk->ndof = MEM_dupallocN(incoming_ndof);
@@ -772,9 +782,9 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
break;
case P_FINISHING:
/* stop keeping track of 3D mouse position */
-#ifdef NDOF_WALK_DEBUG
+# ifdef NDOF_WALK_DEBUG
puts("stop keeping track of 3D mouse position");
-#endif
+# endif
if (walk->ndof) {
MEM_freeN(walk->ndof);
// free(walk->ndof);
@@ -789,6 +799,7 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
break; /* should always be one of the above 3 */
}
}
+#endif /* WITH_INPUT_NDOF */
/* handle modal keymap first */
else if (event->type == EVT_MODAL_MAP) {
switch (event->val) {
@@ -1323,6 +1334,7 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
#undef WALK_BOOST_FACTOR
}
+#ifdef WITH_INPUT_NDOF
static void walkApply_ndof(bContext *C, WalkInfo *walk)
{
Object *lock_ob = ED_view3d_cameracontrol_object_get(walk->v3d_camera_control);
@@ -1341,6 +1353,7 @@ static void walkApply_ndof(bContext *C, WalkInfo *walk)
}
}
}
+#endif /* WITH_INPUT_NDOF */
/****** walk operator ******/
static int walk_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -1388,12 +1401,15 @@ static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event)
walkEvent(C, op, walk, event);
+#ifdef WITH_INPUT_NDOF
if (walk->ndof) { /* 3D mouse overrules [2D mouse + timer] */
if (event->type == NDOF_MOTION) {
walkApply_ndof(C, walk);
}
}
- else if (event->type == TIMER && event->customdata == walk->timer) {
+ else
+#endif /* WITH_INPUT_NDOF */
+ if (event->type == TIMER && event->customdata == walk->timer) {
walkApply(C, op, walk);
}