Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Wed, 5 Dec 2018 00:03:48 +0000 (11:03 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 5 Dec 2018 00:03:48 +0000 (11:03 +1100)
1  2 
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/space_view3d/view3d_walk.c

index 345d9fe39dea86f1522eca1066bb1c003483731e,175dab28cbe36a6113e0d3efb06ed29b784b949e..de5d5d29e52ba110457d1a1055039f770871416e
  #include "UI_interface.h"
  #include "UI_resources.h"
  
 +#include "GPU_immediate.h"
 +
 +#include "DEG_depsgraph.h"
 +
  #include "view3d_intern.h"  /* own include */
  
  /* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
@@@ -137,6 -133,56 +137,6 @@@ void fly_modal_keymap(wmKeyConfig *keyc
  
        keymap = WM_modalkeymap_add(keyconf, "View3D Fly Modal", modal_items);
  
 -      /* items for modal map */
 -      WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, FLY_MODAL_CANCEL);
 -      WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_CANCEL);
 -
 -      WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, FLY_MODAL_CONFIRM);
 -      WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_CONFIRM);
 -      WM_modalkeymap_add_item(keymap, SPACEKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_CONFIRM);
 -      WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, FLY_MODAL_CONFIRM);
 -
 -      WM_modalkeymap_add_item(keymap, PADPLUSKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_ACCELERATE);
 -      WM_modalkeymap_add_item(keymap, PADMINUS, KM_PRESS, KM_ANY, 0, FLY_MODAL_DECELERATE);
 -      WM_modalkeymap_add_item(keymap, WHEELUPMOUSE, KM_PRESS, KM_ANY, 0, FLY_MODAL_ACCELERATE);
 -      WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, KM_ANY, 0, FLY_MODAL_DECELERATE);
 -
 -      WM_modalkeymap_add_item(keymap, MOUSEPAN, 0, 0, 0, FLY_MODAL_SPEED);
 -
 -      WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, KM_ANY, 0, FLY_MODAL_PAN_ENABLE);
 -      /* XXX - Bug in the event system, middle mouse release doesn't work */
 -      WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, FLY_MODAL_PAN_DISABLE);
 -
 -      /* WASD */
 -      WM_modalkeymap_add_item(keymap, WKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_FORWARD);
 -      WM_modalkeymap_add_item(keymap, SKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_BACKWARD);
 -      WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_LEFT);
 -      WM_modalkeymap_add_item(keymap, DKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_RIGHT);
 -      WM_modalkeymap_add_item(keymap, EKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_UP);
 -      WM_modalkeymap_add_item(keymap, QKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_DOWN);
 -
 -      /* for legacy reasons, leave R/F working */
 -      WM_modalkeymap_add_item(keymap, RKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_UP);
 -      WM_modalkeymap_add_item(keymap, FKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_DOWN);
 -
 -      WM_modalkeymap_add_item(keymap, UPARROWKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_FORWARD);
 -      WM_modalkeymap_add_item(keymap, DOWNARROWKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_BACKWARD);
 -      WM_modalkeymap_add_item(keymap, LEFTARROWKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_LEFT);
 -      WM_modalkeymap_add_item(keymap, RIGHTARROWKEY, KM_PRESS, 0, 0, FLY_MODAL_DIR_RIGHT);
 -
 -      WM_modalkeymap_add_item(keymap, XKEY, KM_PRESS, 0, 0, FLY_MODAL_AXIS_LOCK_X);
 -      WM_modalkeymap_add_item(keymap, ZKEY, KM_PRESS, 0, 0, FLY_MODAL_AXIS_LOCK_Z);
 -
 -      WM_modalkeymap_add_item(keymap, LEFTALTKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_PRECISION_ENABLE);
 -      WM_modalkeymap_add_item(keymap, LEFTALTKEY, KM_RELEASE, KM_ANY, 0, FLY_MODAL_PRECISION_DISABLE);
 -
 -      /* for legacy reasons, leave shift working */
 -      WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_PRECISION_ENABLE);
 -      WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, FLY_MODAL_PRECISION_DISABLE);
 -
 -      WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_FREELOOK_ENABLE);
 -      WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, FLY_MODAL_FREELOOK_DISABLE);
 -
        /* assign map to operators */
        WM_modalkeymap_assign(keymap, "VIEW3D_OT_fly");
  }
@@@ -146,7 -192,6 +146,7 @@@ typedef struct FlyInfo 
        RegionView3D *rv3d;
        View3D *v3d;
        ARegion *ar;
 +      struct Depsgraph *depsgraph;
        Scene *scene;
  
        wmTimer *timer; /* needed for redraws */
@@@ -195,8 -240,8 +195,8 @@@ static void drawFlyPixel(const struct b
        int xoff, yoff;
        float x1, x2, y1, y2;
  
-       if (fly->scene->camera) {
+       if (ED_view3d_cameracontrol_object_get(fly->v3d_camera_control)) {
 -              ED_view3d_calc_camera_border(fly->scene, fly->ar, fly->v3d, fly->rv3d, &viewborder, false);
 +              ED_view3d_calc_camera_border(fly->scene, fly->depsgraph, fly->ar, fly->v3d, fly->rv3d, &viewborder, false);
                xoff = viewborder.xmin;
                yoff = viewborder.ymin;
        }
        x2 = xoff + 0.55f * fly->width;
        y2 = yoff + 0.55f * fly->height;
  
 -      UI_ThemeColor(TH_VIEW_OVERLAY);
 -      glBegin(GL_LINES);
 +      GPUVertFormat *format = immVertexFormat();
 +      uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
 +
 +      immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 +
 +      immUniformThemeColor(TH_VIEW_OVERLAY);
 +
 +      immBegin(GPU_PRIM_LINES, 16);
 +
        /* bottom left */
 -      glVertex2f(x1, y1);
 -      glVertex2f(x1, y1 + 5);
 +      immVertex2f(pos, x1, y1);
 +      immVertex2f(pos, x1, y1 + 5);
  
 -      glVertex2f(x1, y1);
 -      glVertex2f(x1 + 5, y1);
 +      immVertex2f(pos, x1, y1);
 +      immVertex2f(pos, x1 + 5, y1);
  
        /* top right */
 -      glVertex2f(x2, y2);
 -      glVertex2f(x2, y2 - 5);
 +      immVertex2f(pos, x2, y2);
 +      immVertex2f(pos, x2, y2 - 5);
  
 -      glVertex2f(x2, y2);
 -      glVertex2f(x2 - 5, y2);
 +      immVertex2f(pos, x2, y2);
 +      immVertex2f(pos, x2 - 5, y2);
  
        /* top left */
 -      glVertex2f(x1, y2);
 -      glVertex2f(x1, y2 - 5);
 +      immVertex2f(pos, x1, y2);
 +      immVertex2f(pos, x1, y2 - 5);
  
 -      glVertex2f(x1, y2);
 -      glVertex2f(x1 + 5, y2);
 +      immVertex2f(pos, x1, y2);
 +      immVertex2f(pos, x1 + 5, y2);
  
        /* bottom right */
 -      glVertex2f(x2, y1);
 -      glVertex2f(x2, y1 + 5);
 +      immVertex2f(pos, x2, y1);
 +      immVertex2f(pos, x2, y1 + 5);
 +
 +      immVertex2f(pos, x2, y1);
 +      immVertex2f(pos, x2 - 5, y1);
  
 -      glVertex2f(x2, y1);
 -      glVertex2f(x2 - 5, y1);
 -      glEnd();
 +      immEnd();
 +      immUnbindProgram();
  }
  
  static void fly_update_header(bContext *C, wmOperator *op, FlyInfo *fly)
  
  #undef WM_MODALKEY
  
 -      ED_area_headerprint(CTX_wm_area(C), header);
 +      ED_workspace_status_text(C, header);
  }
  
  /* FlyInfo->state */
@@@ -297,7 -333,6 +297,6 @@@ enum 
  static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent *event)
  {
        wmWindow *win = CTX_wm_window(C);
        rctf viewborder;
  
        float upvec[3]; /* tmp */
        fly->rv3d = CTX_wm_region_view3d(C);
        fly->v3d = CTX_wm_view3d(C);
        fly->ar = CTX_wm_region(C);
 +      fly->depsgraph = CTX_data_depsgraph(C);
        fly->scene = CTX_data_scene(C);
  
  #ifdef NDOF_FLY_DEBUG
        }
  
        fly->v3d_camera_control = ED_view3d_cameracontrol_acquire(
 -              fly->scene, fly->v3d, fly->rv3d,
 +              CTX_data_depsgraph(C), fly->scene, fly->v3d, fly->rv3d,
                (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);
  
        /* calculate center */
-       if (fly->scene->camera) {
+       if (ED_view3d_cameracontrol_object_get(fly->v3d_camera_control)) {
 -              ED_view3d_calc_camera_border(fly->scene, fly->ar, fly->v3d, fly->rv3d, &viewborder, false);
 +              ED_view3d_calc_camera_border(fly->scene, fly->depsgraph, fly->ar, fly->v3d, fly->rv3d, &viewborder, false);
  
                fly->width = BLI_rctf_size_x(&viewborder);
                fly->height = BLI_rctf_size_y(&viewborder);
@@@ -1033,7 -1067,7 +1032,7 @@@ static int fly_modal(bContext *C, wmOpe
        }
  
        if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED))
 -              ED_area_headerprint(CTX_wm_area(C), NULL);
 +              ED_workspace_status_text(C, NULL);
  
        return exit_code;
  }
index 68a40f3336872476564b933a37596ede6d522367,b81d84a1436747a96fa8071258ccf9a4118477d0..d4bb213e5c72a8b1b0abcc7f22994ee4ad1fba1f
@@@ -37,7 -37,6 +37,7 @@@
  #include "BLI_utildefines.h"
  
  #include "BKE_context.h"
 +#include "BKE_main.h"
  #include "BKE_report.h"
  
  #include "BLT_translation.h"
  #include "UI_interface.h"
  #include "UI_resources.h"
  
 +#include "GPU_immediate.h"
 +
 +#include "DEG_depsgraph.h"
 +
  #include "view3d_intern.h"  /* own include */
  
  #ifdef WITH_INPUT_NDOF
@@@ -177,6 -172,59 +177,6 @@@ void walk_modal_keymap(wmKeyConfig *key
  
        keymap = WM_modalkeymap_add(keyconf, "View3D Walk Modal", modal_items);
  
 -      /* items for modal map */
 -      WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, WALK_MODAL_CANCEL);
 -      WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_CANCEL);
 -
 -      WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, WALK_MODAL_CONFIRM);
 -      WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_CONFIRM);
 -      WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, WALK_MODAL_CONFIRM);
 -
 -      WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_FAST_ENABLE);
 -      WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_FAST_DISABLE);
 -
 -      WM_modalkeymap_add_item(keymap, LEFTALTKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_SLOW_ENABLE);
 -      WM_modalkeymap_add_item(keymap, LEFTALTKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_SLOW_DISABLE);
 -
 -      /* WASD */
 -      WM_modalkeymap_add_item(keymap, WKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_DIR_FORWARD);
 -      WM_modalkeymap_add_item(keymap, SKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_DIR_BACKWARD);
 -      WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_DIR_LEFT);
 -      WM_modalkeymap_add_item(keymap, DKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_DIR_RIGHT);
 -      WM_modalkeymap_add_item(keymap, EKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_DIR_UP);
 -      WM_modalkeymap_add_item(keymap, QKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_DIR_DOWN);
 -
 -      WM_modalkeymap_add_item(keymap, WKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_DIR_FORWARD_STOP);
 -      WM_modalkeymap_add_item(keymap, SKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_DIR_BACKWARD_STOP);
 -      WM_modalkeymap_add_item(keymap, AKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_DIR_LEFT_STOP);
 -      WM_modalkeymap_add_item(keymap, DKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_DIR_RIGHT_STOP);
 -      WM_modalkeymap_add_item(keymap, EKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_DIR_UP_STOP);
 -      WM_modalkeymap_add_item(keymap, QKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_DIR_DOWN_STOP);
 -
 -      WM_modalkeymap_add_item(keymap, UPARROWKEY, KM_PRESS, 0, 0, WALK_MODAL_DIR_FORWARD);
 -      WM_modalkeymap_add_item(keymap, DOWNARROWKEY, KM_PRESS, 0, 0, WALK_MODAL_DIR_BACKWARD);
 -      WM_modalkeymap_add_item(keymap, LEFTARROWKEY, KM_PRESS, 0, 0, WALK_MODAL_DIR_LEFT);
 -      WM_modalkeymap_add_item(keymap, RIGHTARROWKEY, KM_PRESS, 0, 0, WALK_MODAL_DIR_RIGHT);
 -
 -      WM_modalkeymap_add_item(keymap, UPARROWKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_DIR_FORWARD_STOP);
 -      WM_modalkeymap_add_item(keymap, DOWNARROWKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_DIR_BACKWARD_STOP);
 -      WM_modalkeymap_add_item(keymap, LEFTARROWKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_DIR_LEFT_STOP);
 -      WM_modalkeymap_add_item(keymap, RIGHTARROWKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_DIR_RIGHT_STOP);
 -
 -      WM_modalkeymap_add_item(keymap, TABKEY, KM_PRESS, 0, 0, WALK_MODAL_TOGGLE);
 -      WM_modalkeymap_add_item(keymap, GKEY, KM_PRESS, 0, 0, WALK_MODAL_TOGGLE);
 -
 -      WM_modalkeymap_add_item(keymap, VKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_JUMP);
 -      WM_modalkeymap_add_item(keymap, VKEY, KM_RELEASE, KM_ANY, 0, WALK_MODAL_JUMP_STOP);
 -
 -      WM_modalkeymap_add_item(keymap, SPACEKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_TELEPORT);
 -      WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_ANY, KM_ANY, 0, WALK_MODAL_TELEPORT);
 -
 -      WM_modalkeymap_add_item(keymap, PADPLUSKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_ACCELERATE);
 -      WM_modalkeymap_add_item(keymap, PADMINUS, KM_PRESS, KM_ANY, 0, WALK_MODAL_DECELERATE);
 -      WM_modalkeymap_add_item(keymap, WHEELUPMOUSE, KM_PRESS, KM_ANY, 0, WALK_MODAL_ACCELERATE);
 -      WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, KM_ANY, 0, WALK_MODAL_DECELERATE);
 -
        /* assign map to operators */
        WM_modalkeymap_assign(keymap, "VIEW3D_OT_walk");
  }
@@@ -197,7 -245,6 +197,7 @@@ typedef struct WalkInfo 
        RegionView3D *rv3d;
        View3D *v3d;
        ARegion *ar;
 +      struct Depsgraph *depsgraph;
        Scene *scene;
  
        wmTimer *timer; /* needed for redraws */
@@@ -280,8 -327,8 +280,8 @@@ static void drawWalkPixel(const struct 
        int xoff, yoff;
        rctf viewborder;
  
-       if (walk->scene->camera) {
+       if (ED_view3d_cameracontrol_object_get(walk->v3d_camera_control)) {
 -              ED_view3d_calc_camera_border(walk->scene, ar, walk->v3d, walk->rv3d, &viewborder, false);
 +              ED_view3d_calc_camera_border(walk->scene, walk->depsgraph, ar, walk->v3d, walk->rv3d, &viewborder, false);
                xoff = viewborder.xmin + BLI_rctf_size_x(&viewborder) * 0.5f;
                yoff = viewborder.ymin + BLI_rctf_size_y(&viewborder) * 0.5f;
        }
                yoff = walk->ar->winy / 2;
        }
  
 -      UI_ThemeColor(TH_VIEW_OVERLAY);
 -      glBegin(GL_LINES);
 +      GPUVertFormat *format = immVertexFormat();
 +      uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
 +
 +      immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 +
 +      immUniformThemeColor(TH_VIEW_OVERLAY);
 +
 +      immBegin(GPU_PRIM_LINES, 8);
 +
        /* North */
 -      glVertex2i(xoff, yoff + inner_length);
 -      glVertex2i(xoff, yoff + outter_length);
 +      immVertex2i(pos, xoff, yoff + inner_length);
 +      immVertex2i(pos, xoff, yoff + outter_length);
  
        /* East */
 -      glVertex2i(xoff + inner_length, yoff);
 -      glVertex2i(xoff + outter_length, yoff);
 +      immVertex2i(pos, xoff + inner_length, yoff);
 +      immVertex2i(pos, xoff + outter_length, yoff);
  
        /* South */
 -      glVertex2i(xoff, yoff - inner_length);
 -      glVertex2i(xoff, yoff - outter_length);
 +      immVertex2i(pos, xoff, yoff - inner_length);
 +      immVertex2i(pos, xoff, yoff - outter_length);
  
        /* West */
 -      glVertex2i(xoff - inner_length, yoff);
 -      glVertex2i(xoff - outter_length, yoff);
 -      glEnd();
 +      immVertex2i(pos, xoff - inner_length, yoff);
 +      immVertex2i(pos, xoff - outter_length, yoff);
 +
 +      immEnd();
 +      immUnbindProgram();
  }
  
  static void walk_update_header(bContext *C, wmOperator *op, WalkInfo *walk)
  
  #undef WM_MODALKEY
  
 -      ED_area_headerprint(CTX_wm_area(C), header);
 +      ED_workspace_status_text(C, header);
  }
  
  static void walk_navigation_mode_set(bContext *C, wmOperator *op, WalkInfo *walk, eWalkMethod mode)
@@@ -455,13 -493,11 +455,13 @@@ static float userdef_speed = -1.f
  
  static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
  {
 +      Main *bmain = CTX_data_main(C);
        wmWindow *win = CTX_wm_window(C);
  
        walk->rv3d = CTX_wm_region_view3d(C);
        walk->v3d = CTX_wm_view3d(C);
        walk->ar = CTX_wm_region(C);
 +      walk->depsgraph = CTX_data_depsgraph(C);
        walk->scene = CTX_data_scene(C);
  
  #ifdef NDOF_WALK_DEBUG
        walk->rv3d->rflag |= RV3D_NAVIGATING;
  
        walk->snap_context = ED_transform_snap_object_context_create_view3d(
 -              CTX_data_main(C), walk->scene, 0,
 +              bmain, walk->scene, CTX_data_depsgraph(C), 0,
                walk->ar, walk->v3d);
  
        walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(
 -              walk->scene, walk->v3d, walk->rv3d,
 +              walk->depsgraph, walk->scene, walk->v3d, walk->rv3d,
                (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);
  
        /* center the mouse */
@@@ -1383,7 -1419,7 +1383,7 @@@ static int walk_modal(bContext *C, wmOp
        }
  
        if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED))
 -              ED_area_headerprint(CTX_wm_area(C), NULL);
 +              ED_workspace_status_text(C, NULL);
  
        return exit_code;
  }