Cleanup: Move some space_view3d files to C++
See: #103343 Pull Request: https://projects.blender.org/blender/blender/pulls/109936
This commit is contained in:
parent
3d383d383f
commit
093a4d63f3
@ -49,26 +49,26 @@ set(SRC
|
|||||||
view3d_header.c
|
view3d_header.c
|
||||||
view3d_iterators.cc
|
view3d_iterators.cc
|
||||||
view3d_navigate.cc
|
view3d_navigate.cc
|
||||||
view3d_navigate_dolly.c
|
view3d_navigate_dolly.cc
|
||||||
view3d_navigate_fly.c
|
view3d_navigate_fly.cc
|
||||||
view3d_navigate_move.c
|
view3d_navigate_move.cc
|
||||||
view3d_navigate_ndof.c
|
view3d_navigate_ndof.cc
|
||||||
view3d_navigate_roll.c
|
view3d_navigate_roll.cc
|
||||||
view3d_navigate_rotate.c
|
view3d_navigate_rotate.cc
|
||||||
view3d_navigate_smoothview.c
|
view3d_navigate_smoothview.cc
|
||||||
view3d_navigate_walk.c
|
view3d_navigate_walk.cc
|
||||||
view3d_navigate_zoom.c
|
view3d_navigate_zoom.cc
|
||||||
view3d_navigate_zoom_border.c
|
view3d_navigate_zoom_border.cc
|
||||||
view3d_ops.c
|
view3d_ops.cc
|
||||||
view3d_placement.c
|
view3d_placement.c
|
||||||
view3d_project.c
|
view3d_project.c
|
||||||
view3d_select.cc
|
view3d_select.cc
|
||||||
view3d_snap.c
|
view3d_snap.c
|
||||||
view3d_utils.c
|
view3d_utils.c
|
||||||
view3d_view.c
|
view3d_view.cc
|
||||||
|
|
||||||
view3d_intern.h
|
view3d_intern.h
|
||||||
view3d_navigate.h
|
view3d_navigate.hh
|
||||||
)
|
)
|
||||||
|
|
||||||
set(LIB
|
set(LIB
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
#include "DEG_depsgraph_build.h"
|
#include "DEG_depsgraph_build.h"
|
||||||
|
|
||||||
#include "view3d_intern.h" /* own include */
|
#include "view3d_intern.h" /* own include */
|
||||||
#include "view3d_navigate.h"
|
#include "view3d_navigate.hh"
|
||||||
|
|
||||||
/* ******************** manage regions ********************* */
|
/* ******************** manage regions ********************* */
|
||||||
|
|
||||||
@ -1179,7 +1179,7 @@ static void view3d_main_region_listener(const wmRegionListenerParams *params)
|
|||||||
break;
|
break;
|
||||||
case ND_OB_ACTIVE:
|
case ND_OB_ACTIVE:
|
||||||
case ND_OB_SELECT:
|
case ND_OB_SELECT:
|
||||||
ATTR_FALLTHROUGH;
|
[[fallthrough]];
|
||||||
case ND_FRAME:
|
case ND_FRAME:
|
||||||
case ND_TRANSFORM:
|
case ND_TRANSFORM:
|
||||||
case ND_OB_VISIBLE:
|
case ND_OB_VISIBLE:
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
#include "view3d_intern.h"
|
#include "view3d_intern.h"
|
||||||
|
|
||||||
#include "view3d_navigate.h" /* own include */
|
#include "view3d_navigate.hh" /* own include */
|
||||||
|
|
||||||
/* Prototypes. */
|
/* Prototypes. */
|
||||||
static void viewops_data_init_context(bContext *C, ViewOpsData *vod);
|
static void viewops_data_init_context(bContext *C, ViewOpsData *vod);
|
||||||
@ -278,7 +278,7 @@ int view3d_navigate_modal_fn(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
|
|
||||||
void view3d_navigate_cancel_fn(bContext *C, wmOperator *op)
|
void view3d_navigate_cancel_fn(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
viewops_data_free(C, (ViewOpsData *)op->customdata);
|
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
|
||||||
op->customdata = nullptr;
|
op->customdata = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,10 +10,6 @@
|
|||||||
|
|
||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Size of the sphere being dragged for trackball rotation within the view bounds.
|
* Size of the sphere being dragged for trackball rotation within the view bounds.
|
||||||
* also affects speed (smaller is faster).
|
* also affects speed (smaller is faster).
|
||||||
@ -31,9 +27,13 @@ struct View3D;
|
|||||||
struct bContext;
|
struct bContext;
|
||||||
struct rcti;
|
struct rcti;
|
||||||
struct wmEvent;
|
struct wmEvent;
|
||||||
|
struct wmKeyConfig;
|
||||||
|
struct wmKeyMap;
|
||||||
struct wmOperator;
|
struct wmOperator;
|
||||||
|
struct wmOperatorType;
|
||||||
|
struct wmWindowManager;
|
||||||
|
|
||||||
typedef enum eV3D_OpMode {
|
enum eV3D_OpMode {
|
||||||
V3D_OP_MODE_NONE = -1,
|
V3D_OP_MODE_NONE = -1,
|
||||||
V3D_OP_MODE_ZOOM = 0,
|
V3D_OP_MODE_ZOOM = 0,
|
||||||
V3D_OP_MODE_ROTATE,
|
V3D_OP_MODE_ROTATE,
|
||||||
@ -47,7 +47,7 @@ typedef enum eV3D_OpMode {
|
|||||||
V3D_OP_MODE_NDOF_PAN,
|
V3D_OP_MODE_NDOF_PAN,
|
||||||
V3D_OP_MODE_NDOF_ALL,
|
V3D_OP_MODE_NDOF_ALL,
|
||||||
#endif
|
#endif
|
||||||
} eV3D_OpMode;
|
};
|
||||||
#ifndef WITH_INPUT_NDOF
|
#ifndef WITH_INPUT_NDOF
|
||||||
# define V3D_OP_MODE_LEN V3D_OP_MODE_DOLLY + 1
|
# define V3D_OP_MODE_LEN V3D_OP_MODE_DOLLY + 1
|
||||||
#else
|
#else
|
||||||
@ -60,14 +60,15 @@ enum eV3D_OpPropFlag {
|
|||||||
V3D_OP_PROP_USE_ALL_REGIONS = (1 << 2),
|
V3D_OP_PROP_USE_ALL_REGIONS = (1 << 2),
|
||||||
V3D_OP_PROP_USE_MOUSE_INIT = (1 << 3),
|
V3D_OP_PROP_USE_MOUSE_INIT = (1 << 3),
|
||||||
};
|
};
|
||||||
|
ENUM_OPERATORS(eV3D_OpPropFlag, V3D_OP_PROP_USE_MOUSE_INIT);
|
||||||
|
|
||||||
typedef enum eV3D_OpEvent {
|
enum eV3D_OpEvent {
|
||||||
VIEW_PASS = 0,
|
VIEW_PASS = 0,
|
||||||
VIEW_APPLY,
|
VIEW_APPLY,
|
||||||
VIEW_CONFIRM,
|
VIEW_CONFIRM,
|
||||||
/** Only supported by some viewport operators. */
|
/** Only supported by some viewport operators. */
|
||||||
VIEW_CANCEL,
|
VIEW_CANCEL,
|
||||||
} eV3D_OpEvent;
|
};
|
||||||
|
|
||||||
/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
|
/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
|
||||||
enum {
|
enum {
|
||||||
@ -80,7 +81,7 @@ enum {
|
|||||||
VIEWROT_MODAL_SWITCH_ROTATE = 6,
|
VIEWROT_MODAL_SWITCH_ROTATE = 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum eViewOpsFlag {
|
enum eViewOpsFlag {
|
||||||
VIEWOPS_FLAG_NONE = 0,
|
VIEWOPS_FLAG_NONE = 0,
|
||||||
/** When enabled, rotate around the selection. */
|
/** When enabled, rotate around the selection. */
|
||||||
VIEWOPS_FLAG_ORBIT_SELECT = (1 << 0),
|
VIEWOPS_FLAG_ORBIT_SELECT = (1 << 0),
|
||||||
@ -96,22 +97,22 @@ typedef enum eViewOpsFlag {
|
|||||||
VIEWOPS_FLAG_USE_MOUSE_INIT = (1 << 3),
|
VIEWOPS_FLAG_USE_MOUSE_INIT = (1 << 3),
|
||||||
|
|
||||||
VIEWOPS_FLAG_ZOOM_TO_MOUSE = (1 << 4),
|
VIEWOPS_FLAG_ZOOM_TO_MOUSE = (1 << 4),
|
||||||
} eViewOpsFlag;
|
};
|
||||||
ENUM_OPERATORS(eViewOpsFlag, VIEWOPS_FLAG_ZOOM_TO_MOUSE);
|
ENUM_OPERATORS(eViewOpsFlag, VIEWOPS_FLAG_ZOOM_TO_MOUSE);
|
||||||
|
|
||||||
/** Generic View Operator Custom-Data */
|
/** Generic View Operator Custom-Data */
|
||||||
typedef struct ViewOpsData {
|
struct ViewOpsData {
|
||||||
/** Context pointers (assigned by #viewops_data_create). */
|
/** Context pointers (assigned by #viewops_data_create). */
|
||||||
struct Main *bmain;
|
Main *bmain;
|
||||||
struct Scene *scene;
|
Scene *scene;
|
||||||
struct ScrArea *area;
|
ScrArea *area;
|
||||||
struct ARegion *region;
|
ARegion *region;
|
||||||
struct View3D *v3d;
|
View3D *v3d;
|
||||||
struct RegionView3D *rv3d;
|
RegionView3D *rv3d;
|
||||||
struct Depsgraph *depsgraph;
|
Depsgraph *depsgraph;
|
||||||
|
|
||||||
/** Needed for continuous zoom. */
|
/** Needed for continuous zoom. */
|
||||||
struct wmTimer *timer;
|
wmTimer *timer;
|
||||||
|
|
||||||
/** Viewport state on initialization, don't change afterwards. */
|
/** Viewport state on initialization, don't change afterwards. */
|
||||||
struct {
|
struct {
|
||||||
@ -193,7 +194,7 @@ typedef struct ViewOpsData {
|
|||||||
/** Used for navigation on non view3d operators. */
|
/** Used for navigation on non view3d operators. */
|
||||||
wmKeyMap *keymap;
|
wmKeyMap *keymap;
|
||||||
bool is_modal_event;
|
bool is_modal_event;
|
||||||
} ViewOpsData;
|
};
|
||||||
|
|
||||||
/* view3d_navigate.cc */
|
/* view3d_navigate.cc */
|
||||||
|
|
||||||
@ -202,18 +203,18 @@ typedef struct ViewOpsData {
|
|||||||
*/
|
*/
|
||||||
const char *viewops_operator_idname_get(eV3D_OpMode nav_type);
|
const char *viewops_operator_idname_get(eV3D_OpMode nav_type);
|
||||||
|
|
||||||
bool view3d_location_poll(struct bContext *C);
|
bool view3d_location_poll(bContext *C);
|
||||||
bool view3d_rotation_poll(struct bContext *C);
|
bool view3d_rotation_poll(bContext *C);
|
||||||
bool view3d_zoom_or_dolly_poll(struct bContext *C);
|
bool view3d_zoom_or_dolly_poll(bContext *C);
|
||||||
|
|
||||||
int view3d_navigate_invoke_impl(bContext *C,
|
int view3d_navigate_invoke_impl(bContext *C,
|
||||||
wmOperator *op,
|
wmOperator *op,
|
||||||
const wmEvent *event,
|
const wmEvent *event,
|
||||||
const eV3D_OpMode nav_type);
|
const eV3D_OpMode nav_type);
|
||||||
int view3d_navigate_modal_fn(bContext *C, wmOperator *op, const wmEvent *event);
|
int view3d_navigate_modal_fn(bContext *C, wmOperator *op, const wmEvent *event);
|
||||||
void view3d_navigate_cancel_fn(struct bContext *C, struct wmOperator *op);
|
void view3d_navigate_cancel_fn(bContext *C, wmOperator *op);
|
||||||
|
|
||||||
void calctrackballvec(const struct rcti *rect, const int event_xy[2], float r_dir[3]);
|
void calctrackballvec(const rcti *rect, const int event_xy[2], float r_dir[3]);
|
||||||
void viewmove_apply(ViewOpsData *vod, int x, int y);
|
void viewmove_apply(ViewOpsData *vod, int x, int y);
|
||||||
void view3d_orbit_apply_dyn_ofs(float r_ofs[3],
|
void view3d_orbit_apply_dyn_ofs(float r_ofs[3],
|
||||||
const float ofs_old[3],
|
const float ofs_old[3],
|
||||||
@ -221,14 +222,14 @@ void view3d_orbit_apply_dyn_ofs(float r_ofs[3],
|
|||||||
const float viewquat_new[4],
|
const float viewquat_new[4],
|
||||||
const float dyn_ofs[3]);
|
const float dyn_ofs[3]);
|
||||||
void viewrotate_apply_dyn_ofs(ViewOpsData *vod, const float viewquat_new[4]);
|
void viewrotate_apply_dyn_ofs(ViewOpsData *vod, const float viewquat_new[4]);
|
||||||
bool view3d_orbit_calc_center(struct bContext *C, float r_dyn_ofs[3]);
|
bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]);
|
||||||
|
|
||||||
void view3d_operator_properties_common(struct wmOperatorType *ot, const enum eV3D_OpPropFlag flag);
|
void view3d_operator_properties_common(wmOperatorType *ot, const eV3D_OpPropFlag flag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate and fill in context pointers for #ViewOpsData
|
* Allocate and fill in context pointers for #ViewOpsData
|
||||||
*/
|
*/
|
||||||
void viewops_data_free(struct bContext *C, ViewOpsData *vod);
|
void viewops_data_free(bContext *C, ViewOpsData *vod);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate, fill in context pointers and calculate the values for #ViewOpsData
|
* Allocate, fill in context pointers and calculate the values for #ViewOpsData
|
||||||
@ -239,37 +240,37 @@ ViewOpsData *viewops_data_create(bContext *C,
|
|||||||
const bool use_cursor_init);
|
const bool use_cursor_init);
|
||||||
void viewops_data_state_restore(ViewOpsData *vod);
|
void viewops_data_state_restore(ViewOpsData *vod);
|
||||||
|
|
||||||
void VIEW3D_OT_view_all(struct wmOperatorType *ot);
|
void VIEW3D_OT_view_all(wmOperatorType *ot);
|
||||||
void VIEW3D_OT_view_selected(struct wmOperatorType *ot);
|
void VIEW3D_OT_view_selected(wmOperatorType *ot);
|
||||||
void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot);
|
void VIEW3D_OT_view_center_cursor(wmOperatorType *ot);
|
||||||
void VIEW3D_OT_view_center_pick(struct wmOperatorType *ot);
|
void VIEW3D_OT_view_center_pick(wmOperatorType *ot);
|
||||||
void VIEW3D_OT_view_axis(struct wmOperatorType *ot);
|
void VIEW3D_OT_view_axis(wmOperatorType *ot);
|
||||||
void VIEW3D_OT_view_camera(struct wmOperatorType *ot);
|
void VIEW3D_OT_view_camera(wmOperatorType *ot);
|
||||||
void VIEW3D_OT_view_orbit(struct wmOperatorType *ot);
|
void VIEW3D_OT_view_orbit(wmOperatorType *ot);
|
||||||
void VIEW3D_OT_view_pan(struct wmOperatorType *ot);
|
void VIEW3D_OT_view_pan(wmOperatorType *ot);
|
||||||
|
|
||||||
/* view3d_navigate_dolly.c */
|
/* view3d_navigate_dolly.cc */
|
||||||
|
|
||||||
void viewdolly_modal_keymap(struct wmKeyConfig *keyconf);
|
void viewdolly_modal_keymap(wmKeyConfig *keyconf);
|
||||||
void VIEW3D_OT_dolly(struct wmOperatorType *ot);
|
void VIEW3D_OT_dolly(wmOperatorType *ot);
|
||||||
|
|
||||||
/* view3d_navigate_fly.c */
|
/* view3d_navigate_fly.cc */
|
||||||
|
|
||||||
void fly_modal_keymap(struct wmKeyConfig *keyconf);
|
void fly_modal_keymap(wmKeyConfig *keyconf);
|
||||||
void view3d_keymap(struct wmKeyConfig *keyconf);
|
void view3d_keymap(wmKeyConfig *keyconf);
|
||||||
void VIEW3D_OT_fly(struct wmOperatorType *ot);
|
void VIEW3D_OT_fly(wmOperatorType *ot);
|
||||||
|
|
||||||
/* view3d_navigate_move.c */
|
/* view3d_navigate_move.cc */
|
||||||
|
|
||||||
int viewmove_modal_impl(bContext *C,
|
int viewmove_modal_impl(bContext *C,
|
||||||
ViewOpsData *vod,
|
ViewOpsData *vod,
|
||||||
const eV3D_OpEvent event_code,
|
const eV3D_OpEvent event_code,
|
||||||
const int xy[2]);
|
const int xy[2]);
|
||||||
int viewmove_invoke_impl(ViewOpsData *vod, const wmEvent *event);
|
int viewmove_invoke_impl(ViewOpsData *vod, const wmEvent *event);
|
||||||
void viewmove_modal_keymap(struct wmKeyConfig *keyconf);
|
void viewmove_modal_keymap(wmKeyConfig *keyconf);
|
||||||
void VIEW3D_OT_move(struct wmOperatorType *ot);
|
void VIEW3D_OT_move(wmOperatorType *ot);
|
||||||
|
|
||||||
/* view3d_navigate_ndof.c */
|
/* view3d_navigate_ndof.cc */
|
||||||
|
|
||||||
#ifdef WITH_INPUT_NDOF
|
#ifdef WITH_INPUT_NDOF
|
||||||
struct wmNDOFMotionData;
|
struct wmNDOFMotionData;
|
||||||
@ -282,41 +283,41 @@ int ndof_all_invoke_impl(bContext *C, ViewOpsData *vod, const wmEvent *event);
|
|||||||
/**
|
/**
|
||||||
* Called from both fly mode and walk mode,
|
* Called from both fly mode and walk mode,
|
||||||
*/
|
*/
|
||||||
void view3d_ndof_fly(const struct wmNDOFMotionData *ndof,
|
void view3d_ndof_fly(const wmNDOFMotionData *ndof,
|
||||||
struct View3D *v3d,
|
View3D *v3d,
|
||||||
struct RegionView3D *rv3d,
|
RegionView3D *rv3d,
|
||||||
bool use_precision,
|
bool use_precision,
|
||||||
short protectflag,
|
short protectflag,
|
||||||
bool *r_has_translate,
|
bool *r_has_translate,
|
||||||
bool *r_has_rotate);
|
bool *r_has_rotate);
|
||||||
void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot);
|
void VIEW3D_OT_ndof_orbit(wmOperatorType *ot);
|
||||||
void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot);
|
void VIEW3D_OT_ndof_orbit_zoom(wmOperatorType *ot);
|
||||||
void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot);
|
void VIEW3D_OT_ndof_pan(wmOperatorType *ot);
|
||||||
void VIEW3D_OT_ndof_all(struct wmOperatorType *ot);
|
void VIEW3D_OT_ndof_all(wmOperatorType *ot);
|
||||||
#endif /* WITH_INPUT_NDOF */
|
#endif /* WITH_INPUT_NDOF */
|
||||||
|
|
||||||
/* view3d_navigate_roll.c */
|
/* view3d_navigate_roll.cc */
|
||||||
|
|
||||||
void VIEW3D_OT_view_roll(struct wmOperatorType *ot);
|
void VIEW3D_OT_view_roll(wmOperatorType *ot);
|
||||||
|
|
||||||
/* view3d_navigate_rotate.c */
|
/* view3d_navigate_rotate.cc */
|
||||||
|
|
||||||
int viewrotate_modal_impl(bContext *C,
|
int viewrotate_modal_impl(bContext *C,
|
||||||
ViewOpsData *vod,
|
ViewOpsData *vod,
|
||||||
const eV3D_OpEvent event_code,
|
const eV3D_OpEvent event_code,
|
||||||
const int xy[2]);
|
const int xy[2]);
|
||||||
int viewrotate_invoke_impl(ViewOpsData *vod, const wmEvent *event);
|
int viewrotate_invoke_impl(ViewOpsData *vod, const wmEvent *event);
|
||||||
void viewrotate_modal_keymap(struct wmKeyConfig *keyconf);
|
void viewrotate_modal_keymap(wmKeyConfig *keyconf);
|
||||||
void VIEW3D_OT_rotate(struct wmOperatorType *ot);
|
void VIEW3D_OT_rotate(wmOperatorType *ot);
|
||||||
|
|
||||||
/* view3d_navigate_smoothview.c */
|
/* view3d_navigate_smoothview.cc */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameters for setting the new 3D Viewport state.
|
* Parameters for setting the new 3D Viewport state.
|
||||||
*
|
*
|
||||||
* Each of the struct members may be NULL to signify they aren't to be adjusted.
|
* Each of the struct members may be NULL to signify they aren't to be adjusted.
|
||||||
*/
|
*/
|
||||||
typedef struct V3D_SmoothParams {
|
struct V3D_SmoothParams {
|
||||||
struct Object *camera_old, *camera;
|
struct Object *camera_old, *camera;
|
||||||
const float *ofs, *quat, *dist, *lens;
|
const float *ofs, *quat, *dist, *lens;
|
||||||
|
|
||||||
@ -330,25 +331,22 @@ typedef struct V3D_SmoothParams {
|
|||||||
* which are likely to be activated by holding a key or from the mouse-wheel.
|
* which are likely to be activated by holding a key or from the mouse-wheel.
|
||||||
*/
|
*/
|
||||||
bool undo_grouped;
|
bool undo_grouped;
|
||||||
} V3D_SmoothParams;
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The arguments are the desired situation.
|
* The arguments are the desired situation.
|
||||||
*/
|
*/
|
||||||
void ED_view3d_smooth_view_ex(const struct Depsgraph *depsgraph,
|
void ED_view3d_smooth_view_ex(const Depsgraph *depsgraph,
|
||||||
struct wmWindowManager *wm,
|
wmWindowManager *wm,
|
||||||
struct wmWindow *win,
|
wmWindow *win,
|
||||||
struct ScrArea *area,
|
ScrArea *area,
|
||||||
struct View3D *v3d,
|
View3D *v3d,
|
||||||
struct ARegion *region,
|
ARegion *region,
|
||||||
int smooth_viewtx,
|
int smooth_viewtx,
|
||||||
const V3D_SmoothParams *sview);
|
const V3D_SmoothParams *sview);
|
||||||
|
|
||||||
void ED_view3d_smooth_view(struct bContext *C,
|
void ED_view3d_smooth_view(
|
||||||
struct View3D *v3d,
|
bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview);
|
||||||
struct ARegion *region,
|
|
||||||
int smooth_viewtx,
|
|
||||||
const V3D_SmoothParams *sview);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call before multiple smooth-view operations begin to properly handle undo.
|
* Call before multiple smooth-view operations begin to properly handle undo.
|
||||||
@ -357,12 +355,12 @@ void ED_view3d_smooth_view(struct bContext *C,
|
|||||||
* or when calling #ED_view3d_smooth_view_ex.
|
* or when calling #ED_view3d_smooth_view_ex.
|
||||||
* Otherwise pass in #V3D_SmoothParams.undo_str so an undo step is pushed as needed.
|
* Otherwise pass in #V3D_SmoothParams.undo_str so an undo step is pushed as needed.
|
||||||
*/
|
*/
|
||||||
void ED_view3d_smooth_view_undo_begin(struct bContext *C, const struct ScrArea *area);
|
void ED_view3d_smooth_view_undo_begin(bContext *C, const ScrArea *area);
|
||||||
/**
|
/**
|
||||||
* Run after multiple smooth-view operations have run to push undo as needed.
|
* Run after multiple smooth-view operations have run to push undo as needed.
|
||||||
*/
|
*/
|
||||||
void ED_view3d_smooth_view_undo_end(struct bContext *C,
|
void ED_view3d_smooth_view_undo_end(bContext *C,
|
||||||
const struct ScrArea *area,
|
const ScrArea *area,
|
||||||
const char *undo_str,
|
const char *undo_str,
|
||||||
bool undo_grouped);
|
bool undo_grouped);
|
||||||
|
|
||||||
@ -370,31 +368,25 @@ void ED_view3d_smooth_view_undo_end(struct bContext *C,
|
|||||||
* Apply the smooth-view immediately, use when we need to start a new view operation.
|
* Apply the smooth-view immediately, use when we need to start a new view operation.
|
||||||
* (so we don't end up half-applying a view operation when pressing keys quickly).
|
* (so we don't end up half-applying a view operation when pressing keys quickly).
|
||||||
*/
|
*/
|
||||||
void ED_view3d_smooth_view_force_finish(struct bContext *C,
|
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region);
|
||||||
struct View3D *v3d,
|
|
||||||
struct ARegion *region);
|
|
||||||
|
|
||||||
void VIEW3D_OT_smoothview(struct wmOperatorType *ot);
|
void VIEW3D_OT_smoothview(wmOperatorType *ot);
|
||||||
|
|
||||||
/* view3d_navigate_walk.c */
|
/* view3d_navigate_walk.cc */
|
||||||
|
|
||||||
void walk_modal_keymap(struct wmKeyConfig *keyconf);
|
void walk_modal_keymap(wmKeyConfig *keyconf);
|
||||||
void VIEW3D_OT_walk(struct wmOperatorType *ot);
|
void VIEW3D_OT_walk(wmOperatorType *ot);
|
||||||
|
|
||||||
/* view3d_navigate_zoom.c */
|
/* view3d_navigate_zoom.cc */
|
||||||
|
|
||||||
int viewzoom_modal_impl(bContext *C,
|
int viewzoom_modal_impl(bContext *C,
|
||||||
ViewOpsData *vod,
|
ViewOpsData *vod,
|
||||||
const eV3D_OpEvent event_code,
|
const eV3D_OpEvent event_code,
|
||||||
const int xy[2]);
|
const int xy[2]);
|
||||||
int viewzoom_invoke_impl(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr);
|
int viewzoom_invoke_impl(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr);
|
||||||
void viewzoom_modal_keymap(struct wmKeyConfig *keyconf);
|
void viewzoom_modal_keymap(wmKeyConfig *keyconf);
|
||||||
void VIEW3D_OT_zoom(struct wmOperatorType *ot);
|
void VIEW3D_OT_zoom(wmOperatorType *ot);
|
||||||
|
|
||||||
/* view3d_navigate_zoom_border.c */
|
/* view3d_navigate_zoom_border.cc */
|
||||||
|
|
||||||
void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);
|
void VIEW3D_OT_zoom_border(wmOperatorType *ot);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -20,7 +20,7 @@
|
|||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
|
|
||||||
#include "view3d_intern.h"
|
#include "view3d_intern.h"
|
||||||
#include "view3d_navigate.h" /* own include */
|
#include "view3d_navigate.hh" /* own include */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name View Dolly Operator
|
/** \name View Dolly Operator
|
||||||
@ -39,7 +39,7 @@ void viewdolly_modal_keymap(wmKeyConfig *keyconf)
|
|||||||
{VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"},
|
{VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"},
|
||||||
{VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"},
|
{VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"},
|
||||||
|
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Dolly Modal");
|
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Dolly Modal");
|
||||||
@ -71,7 +71,7 @@ static void view_dolly_to_vector_3d(ARegion *region,
|
|||||||
const float dvec[3],
|
const float dvec[3],
|
||||||
float dfac)
|
float dfac)
|
||||||
{
|
{
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, -(1.0f - dfac));
|
madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, -(1.0f - dfac));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ static void viewdolly_apply(ViewOpsData *vod, const int xy[2], const bool zoom_i
|
|||||||
|
|
||||||
static int viewdolly_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
static int viewdolly_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
ViewOpsData *vod = op->customdata;
|
ViewOpsData *vod = static_cast<ViewOpsData *>(op->customdata);
|
||||||
short event_code = VIEW_PASS;
|
short event_code = VIEW_PASS;
|
||||||
bool use_autokey = false;
|
bool use_autokey = false;
|
||||||
int ret = OPERATOR_RUNNING_MODAL;
|
int ret = OPERATOR_RUNNING_MODAL;
|
||||||
@ -124,11 +124,11 @@ static int viewdolly_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
event_code = VIEW_CONFIRM;
|
event_code = VIEW_CONFIRM;
|
||||||
break;
|
break;
|
||||||
case VIEWROT_MODAL_SWITCH_MOVE:
|
case VIEWROT_MODAL_SWITCH_MOVE:
|
||||||
WM_operator_name_call(C, "VIEW3D_OT_move", WM_OP_INVOKE_DEFAULT, NULL, event);
|
WM_operator_name_call(C, "VIEW3D_OT_move", WM_OP_INVOKE_DEFAULT, nullptr, event);
|
||||||
event_code = VIEW_CONFIRM;
|
event_code = VIEW_CONFIRM;
|
||||||
break;
|
break;
|
||||||
case VIEWROT_MODAL_SWITCH_ROTATE:
|
case VIEWROT_MODAL_SWITCH_ROTATE:
|
||||||
WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, NULL, event);
|
WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, nullptr, event);
|
||||||
event_code = VIEW_CONFIRM;
|
event_code = VIEW_CONFIRM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ static int viewdolly_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
ED_view3d_camera_lock_undo_push(op->type->name, vod->v3d, vod->rv3d, C);
|
ED_view3d_camera_lock_undo_push(op->type->name, vod->v3d, vod->rv3d, C);
|
||||||
}
|
}
|
||||||
viewops_data_free(C, vod);
|
viewops_data_free(C, vod);
|
||||||
op->customdata = NULL;
|
op->customdata = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -195,7 +195,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
|
|||||||
const int delta = RNA_int_get(op->ptr, "delta");
|
const int delta = RNA_int_get(op->ptr, "delta");
|
||||||
|
|
||||||
if (op->customdata) {
|
if (op->customdata) {
|
||||||
ViewOpsData *vod = op->customdata;
|
ViewOpsData *vod = static_cast<ViewOpsData *>(op->customdata);
|
||||||
|
|
||||||
area = vod->area;
|
area = vod->area;
|
||||||
region = vod->region;
|
region = vod->region;
|
||||||
@ -204,12 +204,12 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
|
|||||||
else {
|
else {
|
||||||
area = CTX_wm_area(C);
|
area = CTX_wm_area(C);
|
||||||
region = CTX_wm_region(C);
|
region = CTX_wm_region(C);
|
||||||
negate_v3_v3(mousevec, ((RegionView3D *)region->regiondata)->viewinv[2]);
|
negate_v3_v3(mousevec, static_cast<RegionView3D *>(region->regiondata)->viewinv[2]);
|
||||||
normalize_v3(mousevec);
|
normalize_v3(mousevec);
|
||||||
}
|
}
|
||||||
|
|
||||||
v3d = area->spacedata.first;
|
v3d = static_cast<View3D *>(area->spacedata.first);
|
||||||
rv3d = region->regiondata;
|
rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
|
|
||||||
const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
|
const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
|
||||||
|
|
||||||
@ -229,8 +229,8 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
ED_region_tag_redraw(region);
|
ED_region_tag_redraw(region);
|
||||||
|
|
||||||
viewops_data_free(C, op->customdata);
|
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
|
||||||
op->customdata = NULL;
|
op->customdata = nullptr;
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
@ -246,7 +246,8 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
|
|
||||||
const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
|
const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
|
||||||
|
|
||||||
vod = op->customdata = viewops_data_create(C, event, V3D_OP_MODE_DOLLY, use_cursor_init);
|
vod = viewops_data_create(C, event, V3D_OP_MODE_DOLLY, use_cursor_init);
|
||||||
|
op->customdata = vod;
|
||||||
|
|
||||||
ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region);
|
ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region);
|
||||||
|
|
||||||
@ -293,8 +294,8 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
}
|
}
|
||||||
viewdolly_apply(vod, event->prev_xy, (U.uiflag & USER_ZOOM_INVERT) == 0);
|
viewdolly_apply(vod, event->prev_xy, (U.uiflag & USER_ZOOM_INVERT) == 0);
|
||||||
|
|
||||||
viewops_data_free(C, op->customdata);
|
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
|
||||||
op->customdata = NULL;
|
op->customdata = nullptr;
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* Interactive fly navigation modal operator (flying around in space).
|
* Interactive fly navigation modal operator (flying around in space).
|
||||||
*
|
*
|
||||||
* \note Similar logic to `view3d_navigate_walk.c` changes here may apply there too.
|
* \note Similar logic to `view3d_navigate_walk.cc` changes here may apply there too.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* defines VIEW3D_OT_fly modal operator */
|
/* defines VIEW3D_OT_fly modal operator */
|
||||||
@ -47,7 +47,7 @@
|
|||||||
#include "DEG_depsgraph.h"
|
#include "DEG_depsgraph.h"
|
||||||
|
|
||||||
#include "view3d_intern.h" /* own include */
|
#include "view3d_intern.h" /* own include */
|
||||||
#include "view3d_navigate.h"
|
#include "view3d_navigate.hh"
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name Modal Key-map
|
/** \name Modal Key-map
|
||||||
@ -119,7 +119,7 @@ void fly_modal_keymap(wmKeyConfig *keyconf)
|
|||||||
{FLY_MODAL_FREELOOK_ENABLE, "FREELOOK_ENABLE", 0, "Rotation", ""},
|
{FLY_MODAL_FREELOOK_ENABLE, "FREELOOK_ENABLE", 0, "Rotation", ""},
|
||||||
{FLY_MODAL_FREELOOK_DISABLE, "FREELOOK_DISABLE", 0, "Rotation (Off)", ""},
|
{FLY_MODAL_FREELOOK_DISABLE, "FREELOOK_DISABLE", 0, "Rotation (Off)", ""},
|
||||||
|
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Fly Modal");
|
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Fly Modal");
|
||||||
@ -141,7 +141,7 @@ void fly_modal_keymap(wmKeyConfig *keyconf)
|
|||||||
/** \name Internal Fly Structs
|
/** \name Internal Fly Structs
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
typedef struct FlyInfo {
|
struct FlyInfo {
|
||||||
/* context stuff */
|
/* context stuff */
|
||||||
RegionView3D *rv3d;
|
RegionView3D *rv3d;
|
||||||
View3D *v3d;
|
View3D *v3d;
|
||||||
@ -204,9 +204,8 @@ typedef struct FlyInfo {
|
|||||||
/** Keep the previous value to smooth transitions (use lag). */
|
/** Keep the previous value to smooth transitions (use lag). */
|
||||||
float dvec_prev[3];
|
float dvec_prev[3];
|
||||||
|
|
||||||
struct View3DCameraControl *v3d_camera_control;
|
View3DCameraControl *v3d_camera_control;
|
||||||
|
};
|
||||||
} FlyInfo;
|
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
@ -220,9 +219,9 @@ static void flyApply_ndof(bContext *C, FlyInfo *fly, bool is_confirm);
|
|||||||
#endif /* WITH_INPUT_NDOF */
|
#endif /* WITH_INPUT_NDOF */
|
||||||
static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm);
|
static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm);
|
||||||
|
|
||||||
static void drawFlyPixel(const bContext *UNUSED(C), ARegion *UNUSED(region), void *arg)
|
static void drawFlyPixel(const bContext * /*C*/, ARegion * /*region*/, void *arg)
|
||||||
{
|
{
|
||||||
FlyInfo *fly = arg;
|
FlyInfo *fly = static_cast<FlyInfo *>(arg);
|
||||||
rctf viewborder;
|
rctf viewborder;
|
||||||
int xoff, yoff;
|
int xoff, yoff;
|
||||||
float x1, x2, y1, y2;
|
float x1, x2, y1, y2;
|
||||||
@ -320,7 +319,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* sanity check: for rare but possible case (if lib-linking the camera fails) */
|
/* sanity check: for rare but possible case (if lib-linking the camera fails) */
|
||||||
if ((fly->rv3d->persp == RV3D_CAMOB) && (fly->v3d->camera == NULL)) {
|
if ((fly->rv3d->persp == RV3D_CAMOB) && (fly->v3d->camera == nullptr)) {
|
||||||
fly->rv3d->persp = RV3D_PERSP;
|
fly->rv3d->persp = RV3D_PERSP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +365,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
|
|||||||
copy_v2_v2_int(fly->mval, event->mval);
|
copy_v2_v2_int(fly->mval, event->mval);
|
||||||
|
|
||||||
#ifdef WITH_INPUT_NDOF
|
#ifdef WITH_INPUT_NDOF
|
||||||
fly->ndof = NULL;
|
fly->ndof = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fly->time_lastdraw = fly->time_lastwheel = PIL_check_seconds_timer();
|
fly->time_lastdraw = fly->time_lastwheel = PIL_check_seconds_timer();
|
||||||
@ -479,7 +478,8 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event)
|
|||||||
// puts("ndof motion detected in fly mode!");
|
// puts("ndof motion detected in fly mode!");
|
||||||
// static const char *tag_name = "3D mouse position";
|
// static const char *tag_name = "3D mouse position";
|
||||||
|
|
||||||
const wmNDOFMotionData *incoming_ndof = event->customdata;
|
const wmNDOFMotionData *incoming_ndof = static_cast<const wmNDOFMotionData *>(
|
||||||
|
event->customdata);
|
||||||
switch (incoming_ndof->progress) {
|
switch (incoming_ndof->progress) {
|
||||||
case P_STARTING:
|
case P_STARTING:
|
||||||
/* start keeping track of 3D mouse position */
|
/* start keeping track of 3D mouse position */
|
||||||
@ -493,9 +493,9 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event)
|
|||||||
putchar('.');
|
putchar('.');
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
# endif
|
# endif
|
||||||
if (fly->ndof == NULL) {
|
if (fly->ndof == nullptr) {
|
||||||
// fly->ndof = MEM_mallocN(sizeof(wmNDOFMotionData), tag_name);
|
// fly->ndof = MEM_mallocN(sizeof(wmNDOFMotionData), tag_name);
|
||||||
fly->ndof = MEM_dupallocN(incoming_ndof);
|
fly->ndof = static_cast<wmNDOFMotionData *>(MEM_dupallocN(incoming_ndof));
|
||||||
// fly->ndof = malloc(sizeof(wmNDOFMotionData));
|
// fly->ndof = malloc(sizeof(wmNDOFMotionData));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -510,7 +510,7 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event)
|
|||||||
if (fly->ndof) {
|
if (fly->ndof) {
|
||||||
MEM_freeN(fly->ndof);
|
MEM_freeN(fly->ndof);
|
||||||
// free(fly->ndof);
|
// free(fly->ndof);
|
||||||
fly->ndof = NULL;
|
fly->ndof = nullptr;
|
||||||
}
|
}
|
||||||
/* update the time else the view will jump when 2D mouse/timer resume */
|
/* update the time else the view will jump when 2D mouse/timer resume */
|
||||||
fly->time_lastdraw = PIL_check_seconds_timer();
|
fly->time_lastdraw = PIL_check_seconds_timer();
|
||||||
@ -558,7 +558,7 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
time_currwheel = PIL_check_seconds_timer();
|
time_currwheel = PIL_check_seconds_timer();
|
||||||
time_wheel = (float)(time_currwheel - fly->time_lastwheel);
|
time_wheel = float(time_currwheel - fly->time_lastwheel);
|
||||||
fly->time_lastwheel = time_currwheel;
|
fly->time_lastwheel = time_currwheel;
|
||||||
/* Mouse wheel delays range from (0.5 == slow) to (0.01 == fast) */
|
/* Mouse wheel delays range from (0.5 == slow) to (0.01 == fast) */
|
||||||
/* 0-0.5 -> 0-5.0 */
|
/* 0-0.5 -> 0-5.0 */
|
||||||
@ -583,7 +583,7 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
time_currwheel = PIL_check_seconds_timer();
|
time_currwheel = PIL_check_seconds_timer();
|
||||||
time_wheel = (float)(time_currwheel - fly->time_lastwheel);
|
time_wheel = float(time_currwheel - fly->time_lastwheel);
|
||||||
fly->time_lastwheel = time_currwheel;
|
fly->time_lastwheel = time_currwheel;
|
||||||
/* 0-0.5 -> 0-5.0 */
|
/* 0-0.5 -> 0-5.0 */
|
||||||
time_wheel = 1.0f + (10.0f - (20.0f * min_ff(time_wheel, 0.5f)));
|
time_wheel = 1.0f + (10.0f - (20.0f * min_ff(time_wheel, 0.5f)));
|
||||||
@ -832,7 +832,7 @@ static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm)
|
|||||||
fly->redraw = 1;
|
fly->redraw = 1;
|
||||||
#endif
|
#endif
|
||||||
time_current = PIL_check_seconds_timer();
|
time_current = PIL_check_seconds_timer();
|
||||||
time_redraw = (float)(time_current - fly->time_lastdraw);
|
time_redraw = float(time_current - fly->time_lastdraw);
|
||||||
|
|
||||||
/* clamp redraw time to avoid jitter in roll correction */
|
/* clamp redraw time to avoid jitter in roll correction */
|
||||||
time_redraw_clamped = min_ff(0.05f, time_redraw);
|
time_redraw_clamped = min_ff(0.05f, time_redraw);
|
||||||
@ -1052,7 +1052,7 @@ static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
fly = MEM_callocN(sizeof(FlyInfo), "FlyOperation");
|
fly = MEM_cnew<FlyInfo>("FlyOperation");
|
||||||
|
|
||||||
op->customdata = fly;
|
op->customdata = fly;
|
||||||
|
|
||||||
@ -1070,18 +1070,18 @@ static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
|
|
||||||
static void fly_cancel(bContext *C, wmOperator *op)
|
static void fly_cancel(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
FlyInfo *fly = op->customdata;
|
FlyInfo *fly = static_cast<FlyInfo *>(op->customdata);
|
||||||
|
|
||||||
fly->state = FLY_CANCEL;
|
fly->state = FLY_CANCEL;
|
||||||
flyEnd(C, fly);
|
flyEnd(C, fly);
|
||||||
op->customdata = NULL;
|
op->customdata = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
int exit_code;
|
int exit_code;
|
||||||
bool do_draw = false;
|
bool do_draw = false;
|
||||||
FlyInfo *fly = op->customdata;
|
FlyInfo *fly = static_cast<FlyInfo *>(op->customdata);
|
||||||
View3D *v3d = fly->v3d;
|
View3D *v3d = fly->v3d;
|
||||||
RegionView3D *rv3d = fly->rv3d;
|
RegionView3D *rv3d = fly->rv3d;
|
||||||
Object *fly_object = ED_view3d_cameracontrol_object_get(fly->v3d_camera_control);
|
Object *fly_object = ED_view3d_cameracontrol_object_get(fly->v3d_camera_control);
|
@ -18,7 +18,7 @@
|
|||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
|
|
||||||
#include "view3d_intern.h"
|
#include "view3d_intern.h"
|
||||||
#include "view3d_navigate.h" /* own include */
|
#include "view3d_navigate.hh" /* own include */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name View Move (Pan) Operator
|
/** \name View Move (Pan) Operator
|
||||||
@ -35,7 +35,7 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf)
|
|||||||
{VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"},
|
{VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"},
|
||||||
{VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"},
|
{VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"},
|
||||||
|
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Move Modal");
|
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Move Modal");
|
@ -17,7 +17,7 @@
|
|||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
|
|
||||||
#include "view3d_intern.h"
|
#include "view3d_intern.h"
|
||||||
#include "view3d_navigate.h" /* own include */
|
#include "view3d_navigate.hh" /* own include */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name NDOF Utility Functions
|
/** \name NDOF Utility Functions
|
||||||
@ -95,7 +95,7 @@ static void view3d_ndof_pan_zoom(const wmNDOFMotionData *ndof,
|
|||||||
const bool has_translate,
|
const bool has_translate,
|
||||||
const bool has_zoom)
|
const bool has_zoom)
|
||||||
{
|
{
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
float view_inv[4];
|
float view_inv[4];
|
||||||
float pan_vec[3];
|
float pan_vec[3];
|
||||||
|
|
||||||
@ -159,8 +159,8 @@ static void view3d_ndof_orbit(const wmNDOFMotionData *ndof,
|
|||||||
ViewOpsData *vod,
|
ViewOpsData *vod,
|
||||||
const bool apply_dyn_ofs)
|
const bool apply_dyn_ofs)
|
||||||
{
|
{
|
||||||
View3D *v3d = area->spacedata.first;
|
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
|
|
||||||
float view_inv[4];
|
float view_inv[4];
|
||||||
|
|
||||||
@ -431,7 +431,7 @@ int ndof_orbit_invoke_impl(bContext *C, ViewOpsData *vod, const wmEvent *event)
|
|||||||
RegionView3D *rv3d = vod->rv3d;
|
RegionView3D *rv3d = vod->rv3d;
|
||||||
char xform_flag = 0;
|
char xform_flag = 0;
|
||||||
|
|
||||||
const wmNDOFMotionData *ndof = event->customdata;
|
const wmNDOFMotionData *ndof = static_cast<const wmNDOFMotionData *>(event->customdata);
|
||||||
|
|
||||||
/* off by default, until changed later this function */
|
/* off by default, until changed later this function */
|
||||||
rv3d->rot_angle = 0.0f;
|
rv3d->rot_angle = 0.0f;
|
||||||
@ -501,7 +501,7 @@ int ndof_orbit_zoom_invoke_impl(bContext *C, ViewOpsData *vod, const wmEvent *ev
|
|||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wmNDOFMotionData *ndof = event->customdata;
|
const wmNDOFMotionData *ndof = static_cast<const wmNDOFMotionData *>(event->customdata);
|
||||||
|
|
||||||
if (U.ndof_flag & NDOF_CAMERA_PAN_ZOOM) {
|
if (U.ndof_flag & NDOF_CAMERA_PAN_ZOOM) {
|
||||||
const int camera_retval = view3d_ndof_cameraview_pan_zoom(vod, ndof);
|
const int camera_retval = view3d_ndof_cameraview_pan_zoom(vod, ndof);
|
||||||
@ -616,7 +616,7 @@ int ndof_pan_invoke_impl(bContext *C, ViewOpsData *vod, const wmEvent *event)
|
|||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wmNDOFMotionData *ndof = event->customdata;
|
const wmNDOFMotionData *ndof = static_cast<const wmNDOFMotionData *>(event->customdata);
|
||||||
|
|
||||||
if (U.ndof_flag & NDOF_CAMERA_PAN_ZOOM) {
|
if (U.ndof_flag & NDOF_CAMERA_PAN_ZOOM) {
|
||||||
const int camera_retval = view3d_ndof_cameraview_pan_zoom(vod, ndof);
|
const int camera_retval = view3d_ndof_cameraview_pan_zoom(vod, ndof);
|
@ -22,7 +22,7 @@
|
|||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
|
|
||||||
#include "view3d_intern.h"
|
#include "view3d_intern.h"
|
||||||
#include "view3d_navigate.h" /* own include */
|
#include "view3d_navigate.hh" /* own include */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name View Roll Operator
|
/** \name View Roll Operator
|
||||||
@ -40,7 +40,7 @@ static void view_roll_angle(ARegion *region,
|
|||||||
float angle,
|
float angle,
|
||||||
bool use_axis_view)
|
bool use_axis_view)
|
||||||
{
|
{
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
float quat_mul[4];
|
float quat_mul[4];
|
||||||
|
|
||||||
/* camera axis */
|
/* camera axis */
|
||||||
@ -51,7 +51,7 @@ static void view_roll_angle(ARegion *region,
|
|||||||
/* avoid precision loss over time */
|
/* avoid precision loss over time */
|
||||||
normalize_qt(quat);
|
normalize_qt(quat);
|
||||||
|
|
||||||
if (use_axis_view && RV3D_VIEW_IS_AXIS(rv3d->view) && (fabsf(angle) == (float)M_PI_2)) {
|
if (use_axis_view && RV3D_VIEW_IS_AXIS(rv3d->view) && (fabsf(angle) == float(M_PI_2))) {
|
||||||
ED_view3d_quat_to_axis_view_and_reset_quat(quat, 0.01f, &rv3d->view, &rv3d->view_axis_roll);
|
ED_view3d_quat_to_axis_view_and_reset_quat(quat, 0.01f, &rv3d->view, &rv3d->view_axis_roll);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -61,7 +61,8 @@ static void view_roll_angle(ARegion *region,
|
|||||||
|
|
||||||
static void viewroll_apply(ViewOpsData *vod, int x, int y)
|
static void viewroll_apply(ViewOpsData *vod, int x, int y)
|
||||||
{
|
{
|
||||||
float angle = BLI_dial_angle(vod->init.dial, (const float[2]){x, y});
|
const float current_position[2] = {float(x), float(y)};
|
||||||
|
float angle = BLI_dial_angle(vod->init.dial, current_position);
|
||||||
|
|
||||||
if (angle != 0.0f) {
|
if (angle != 0.0f) {
|
||||||
view_roll_angle(
|
view_roll_angle(
|
||||||
@ -84,7 +85,7 @@ static void viewroll_apply(ViewOpsData *vod, int x, int y)
|
|||||||
|
|
||||||
static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
ViewOpsData *vod = op->customdata;
|
ViewOpsData *vod = static_cast<ViewOpsData *>(op->customdata);
|
||||||
short event_code = VIEW_PASS;
|
short event_code = VIEW_PASS;
|
||||||
bool use_autokey = false;
|
bool use_autokey = false;
|
||||||
int ret = OPERATOR_RUNNING_MODAL;
|
int ret = OPERATOR_RUNNING_MODAL;
|
||||||
@ -99,11 +100,11 @@ static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
event_code = VIEW_CANCEL;
|
event_code = VIEW_CANCEL;
|
||||||
break;
|
break;
|
||||||
case VIEWROT_MODAL_SWITCH_MOVE:
|
case VIEWROT_MODAL_SWITCH_MOVE:
|
||||||
WM_operator_name_call(C, "VIEW3D_OT_move", WM_OP_INVOKE_DEFAULT, NULL, event);
|
WM_operator_name_call(C, "VIEW3D_OT_move", WM_OP_INVOKE_DEFAULT, nullptr, event);
|
||||||
event_code = VIEW_CONFIRM;
|
event_code = VIEW_CONFIRM;
|
||||||
break;
|
break;
|
||||||
case VIEWROT_MODAL_SWITCH_ROTATE:
|
case VIEWROT_MODAL_SWITCH_ROTATE:
|
||||||
WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, NULL, event);
|
WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, nullptr, event);
|
||||||
event_code = VIEW_CONFIRM;
|
event_code = VIEW_CONFIRM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -151,8 +152,8 @@ static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((ret & OPERATOR_RUNNING_MODAL) == 0) {
|
if ((ret & OPERATOR_RUNNING_MODAL) == 0) {
|
||||||
viewops_data_free(C, op->customdata);
|
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
|
||||||
op->customdata = NULL;
|
op->customdata = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -167,7 +168,7 @@ static const EnumPropertyItem prop_view_roll_items[] = {
|
|||||||
{0, "ANGLE", 0, "Roll Angle", "Roll the view using an angle value"},
|
{0, "ANGLE", 0, "Roll Angle", "Roll the view using an angle value"},
|
||||||
{V3D_VIEW_STEPLEFT, "LEFT", 0, "Roll Left", "Roll the view around to the left"},
|
{V3D_VIEW_STEPLEFT, "LEFT", 0, "Roll Left", "Roll the view around to the left"},
|
||||||
{V3D_VIEW_STEPRIGHT, "RIGHT", 0, "Roll Right", "Roll the view around to the right"},
|
{V3D_VIEW_STEPRIGHT, "RIGHT", 0, "Roll Right", "Roll the view around to the right"},
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int viewroll_exec(bContext *C, wmOperator *op)
|
static int viewroll_exec(bContext *C, wmOperator *op)
|
||||||
@ -177,7 +178,7 @@ static int viewroll_exec(bContext *C, wmOperator *op)
|
|||||||
ARegion *region;
|
ARegion *region;
|
||||||
|
|
||||||
if (op->customdata) {
|
if (op->customdata) {
|
||||||
ViewOpsData *vod = op->customdata;
|
ViewOpsData *vod = static_cast<ViewOpsData *>(op->customdata);
|
||||||
region = vod->region;
|
region = vod->region;
|
||||||
v3d = vod->v3d;
|
v3d = vod->v3d;
|
||||||
}
|
}
|
||||||
@ -185,7 +186,7 @@ static int viewroll_exec(bContext *C, wmOperator *op)
|
|||||||
ED_view3d_context_user_region(C, &v3d, ®ion);
|
ED_view3d_context_user_region(C, &v3d, ®ion);
|
||||||
}
|
}
|
||||||
|
|
||||||
rv3d = region->regiondata;
|
rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
|
|
||||||
const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d);
|
const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d);
|
||||||
if ((rv3d->persp != RV3D_CAMOB) || is_camera_lock) {
|
if ((rv3d->persp != RV3D_CAMOB) || is_camera_lock) {
|
||||||
@ -211,7 +212,7 @@ static int viewroll_exec(bContext *C, wmOperator *op)
|
|||||||
negate_v3(mousevec);
|
negate_v3(mousevec);
|
||||||
view_roll_angle(region, quat_new, rv3d->viewquat, mousevec, angle, true);
|
view_roll_angle(region, quat_new, rv3d->viewquat, mousevec, angle, true);
|
||||||
|
|
||||||
const float *dyn_ofs_pt = NULL;
|
const float *dyn_ofs_pt = nullptr;
|
||||||
float dyn_ofs[3];
|
float dyn_ofs[3];
|
||||||
if (U.uiflag & USER_ORBIT_SELECTION) {
|
if (U.uiflag & USER_ORBIT_SELECTION) {
|
||||||
if (view3d_orbit_calc_center(C, dyn_ofs)) {
|
if (view3d_orbit_calc_center(C, dyn_ofs)) {
|
||||||
@ -220,25 +221,22 @@ static int viewroll_exec(bContext *C, wmOperator *op)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ED_view3d_smooth_view(C,
|
V3D_SmoothParams sview_params = {};
|
||||||
v3d,
|
sview_params.quat = quat_new;
|
||||||
region,
|
sview_params.dyn_ofs = dyn_ofs_pt;
|
||||||
smooth_viewtx,
|
/* Group as successive roll may run by holding a key. */
|
||||||
&(const V3D_SmoothParams){
|
sview_params.undo_str = op->type->name;
|
||||||
.quat = quat_new,
|
sview_params.undo_grouped = true;
|
||||||
.dyn_ofs = dyn_ofs_pt,
|
|
||||||
/* Group as successive roll may run by holding a key. */
|
|
||||||
.undo_str = op->type->name,
|
|
||||||
.undo_grouped = true,
|
|
||||||
});
|
|
||||||
|
|
||||||
viewops_data_free(C, op->customdata);
|
ED_view3d_smooth_view(C, v3d, region, smooth_viewtx, &sview_params);
|
||||||
op->customdata = NULL;
|
|
||||||
|
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
|
||||||
|
op->customdata = nullptr;
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewops_data_free(C, op->customdata);
|
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
|
||||||
op->customdata = NULL;
|
op->customdata = nullptr;
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,10 +251,11 @@ static int viewroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* makes op->customdata */
|
/* makes op->customdata */
|
||||||
vod = op->customdata = viewops_data_create(C, event, V3D_OP_MODE_VIEW_ROLL, false);
|
vod = viewops_data_create(C, event, V3D_OP_MODE_VIEW_ROLL, false);
|
||||||
vod->init.dial = BLI_dial_init((const float[2]){BLI_rcti_cent_x(&vod->region->winrct),
|
const float start_position[2] = {float(BLI_rcti_cent_x(&vod->region->winrct)),
|
||||||
BLI_rcti_cent_y(&vod->region->winrct)},
|
float(BLI_rcti_cent_y(&vod->region->winrct))};
|
||||||
FLT_EPSILON);
|
vod->init.dial = BLI_dial_init(start_position, FLT_EPSILON);
|
||||||
|
op->customdata = vod;
|
||||||
|
|
||||||
ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region);
|
ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region);
|
||||||
|
|
||||||
@ -268,8 +267,8 @@ static int viewroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
vod->init.event_xy[0] = vod->prev.event_xy[0] = event->xy[0];
|
vod->init.event_xy[0] = vod->prev.event_xy[0] = event->xy[0];
|
||||||
viewroll_apply(vod, event->prev_xy[0], event->prev_xy[1]);
|
viewroll_apply(vod, event->prev_xy[0], event->prev_xy[1]);
|
||||||
|
|
||||||
viewops_data_free(C, op->customdata);
|
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
|
||||||
op->customdata = NULL;
|
op->customdata = nullptr;
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
@ -17,7 +17,7 @@
|
|||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
|
|
||||||
#include "view3d_intern.h"
|
#include "view3d_intern.h"
|
||||||
#include "view3d_navigate.h" /* own include */
|
#include "view3d_navigate.hh" /* own include */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name View Rotate Operator
|
/** \name View Rotate Operator
|
||||||
@ -35,7 +35,7 @@ void viewrotate_modal_keymap(wmKeyConfig *keyconf)
|
|||||||
{VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"},
|
{VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"},
|
||||||
{VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"},
|
{VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"},
|
||||||
|
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Rotate Modal");
|
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Rotate Modal");
|
||||||
@ -72,7 +72,7 @@ static void viewrotate_apply_snap(ViewOpsData *vod)
|
|||||||
for (y = -1; y < 2; y++) {
|
for (y = -1; y < 2; y++) {
|
||||||
for (z = -1; z < 2; z++) {
|
for (z = -1; z < 2; z++) {
|
||||||
if (x || y || z) {
|
if (x || y || z) {
|
||||||
float zaxis_test[3] = {x, y, z};
|
float zaxis_test[3] = {float(x), float(y), float(z)};
|
||||||
|
|
||||||
normalize_v3(zaxis_test);
|
normalize_v3(zaxis_test);
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ static void viewrotate_apply_snap(ViewOpsData *vod)
|
|||||||
float xaxis2[3] = {1, 0, 0};
|
float xaxis2[3] = {1, 0, 0};
|
||||||
float quat_final_inv[4];
|
float quat_final_inv[4];
|
||||||
|
|
||||||
axis_angle_to_quat(quat_roll, zaxis_best, (float)j * DEG2RADF(45.0f));
|
axis_angle_to_quat(quat_roll, zaxis_best, float(j * DEG2RADF(45.0f)));
|
||||||
normalize_qt(quat_roll);
|
normalize_qt(quat_roll);
|
||||||
|
|
||||||
mul_qt_qtqt(quat_final, quat_snap, quat_roll);
|
mul_qt_qtqt(quat_final, quat_snap, quat_roll);
|
||||||
@ -181,7 +181,7 @@ static void viewrotate_apply(ViewOpsData *vod, const int event_xy[2])
|
|||||||
|
|
||||||
sub_v3_v3v3(dvec, newvec, vod->init.trackvec);
|
sub_v3_v3v3(dvec, newvec, vod->init.trackvec);
|
||||||
|
|
||||||
angle = (len_v3(dvec) / (2.0f * V3D_OP_TRACKBALLSIZE)) * (float)M_PI;
|
angle = (len_v3(dvec) / (2.0f * V3D_OP_TRACKBALLSIZE)) * float(M_PI);
|
||||||
|
|
||||||
/* Before applying the sensitivity this is rotating 1:1,
|
/* Before applying the sensitivity this is rotating 1:1,
|
||||||
* where the cursor would match the surface of a sphere in the view. */
|
* where the cursor would match the surface of a sphere in the view. */
|
||||||
@ -248,7 +248,7 @@ static void viewrotate_apply(ViewOpsData *vod, const int event_xy[2])
|
|||||||
if (dot_v3v3(xaxis, m_inv[0]) < 0) {
|
if (dot_v3v3(xaxis, m_inv[0]) < 0) {
|
||||||
negate_v3(xaxis);
|
negate_v3(xaxis);
|
||||||
}
|
}
|
||||||
fac = angle_normalized_v3v3(zvec_global, m_inv[2]) / (float)M_PI;
|
fac = angle_normalized_v3v3(zvec_global, m_inv[2]) / float(M_PI);
|
||||||
fac = fabsf(fac - 0.5f) * 2;
|
fac = fabsf(fac - 0.5f) * 2;
|
||||||
fac = fac * fac;
|
fac = fac * fac;
|
||||||
interp_v3_v3v3(xaxis, xaxis, m_inv[0], fac);
|
interp_v3_v3v3(xaxis, xaxis, m_inv[0], fac);
|
@ -22,7 +22,7 @@
|
|||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
|
|
||||||
#include "view3d_intern.h"
|
#include "view3d_intern.h"
|
||||||
#include "view3d_navigate.h" /* own include */
|
#include "view3d_navigate.hh" /* own include */
|
||||||
|
|
||||||
static void view3d_smoothview_apply_with_interp(
|
static void view3d_smoothview_apply_with_interp(
|
||||||
bContext *C, View3D *v3d, RegionView3D *rv3d, const bool use_autokey, const float factor);
|
bContext *C, View3D *v3d, RegionView3D *rv3d, const bool use_autokey, const float factor);
|
||||||
@ -44,7 +44,7 @@ static void view3d_smoothview_apply_with_interp(
|
|||||||
|
|
||||||
void ED_view3d_smooth_view_undo_begin(bContext *C, const ScrArea *area)
|
void ED_view3d_smooth_view_undo_begin(bContext *C, const ScrArea *area)
|
||||||
{
|
{
|
||||||
const View3D *v3d = area->spacedata.first;
|
const View3D *v3d = static_cast<const View3D *>(area->spacedata.first);
|
||||||
Object *camera = v3d->camera;
|
Object *camera = v3d->camera;
|
||||||
if (!camera) {
|
if (!camera) {
|
||||||
return;
|
return;
|
||||||
@ -59,7 +59,7 @@ void ED_view3d_smooth_view_undo_begin(bContext *C, const ScrArea *area)
|
|||||||
if (region->regiontype != RGN_TYPE_WINDOW) {
|
if (region->regiontype != RGN_TYPE_WINDOW) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const RegionView3D *rv3d = region->regiondata;
|
const RegionView3D *rv3d = static_cast<const RegionView3D *>(region->regiondata);
|
||||||
if (ED_view3d_camera_lock_undo_test(v3d, rv3d, C)) {
|
if (ED_view3d_camera_lock_undo_test(v3d, rv3d, C)) {
|
||||||
camera->id.tag |= LIB_TAG_DOIT;
|
camera->id.tag |= LIB_TAG_DOIT;
|
||||||
break;
|
break;
|
||||||
@ -72,7 +72,7 @@ void ED_view3d_smooth_view_undo_end(bContext *C,
|
|||||||
const char *undo_str,
|
const char *undo_str,
|
||||||
const bool undo_grouped)
|
const bool undo_grouped)
|
||||||
{
|
{
|
||||||
View3D *v3d = area->spacedata.first;
|
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
|
||||||
Object *camera = v3d->camera;
|
Object *camera = v3d->camera;
|
||||||
if (!camera) {
|
if (!camera) {
|
||||||
return;
|
return;
|
||||||
@ -91,7 +91,7 @@ void ED_view3d_smooth_view_undo_end(bContext *C,
|
|||||||
* so even in the case there is a quad-view with multiple camera views set, these will all
|
* so even in the case there is a quad-view with multiple camera views set, these will all
|
||||||
* reference the same camera. In this case it doesn't matter which region is used.
|
* reference the same camera. In this case it doesn't matter which region is used.
|
||||||
* If in the future multiple cameras are supported, this logic can be extended. */
|
* If in the future multiple cameras are supported, this logic can be extended. */
|
||||||
const ARegion *region_camera = NULL;
|
const ARegion *region_camera = nullptr;
|
||||||
|
|
||||||
/* An undo push should be performed. */
|
/* An undo push should be performed. */
|
||||||
bool is_interactive = false;
|
bool is_interactive = false;
|
||||||
@ -99,7 +99,7 @@ void ED_view3d_smooth_view_undo_end(bContext *C,
|
|||||||
if (region->regiontype != RGN_TYPE_WINDOW) {
|
if (region->regiontype != RGN_TYPE_WINDOW) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const RegionView3D *rv3d = region->regiondata;
|
const RegionView3D *rv3d = static_cast<const RegionView3D *>(region->regiondata);
|
||||||
if (ED_view3d_camera_lock_undo_test(v3d, rv3d, C)) {
|
if (ED_view3d_camera_lock_undo_test(v3d, rv3d, C)) {
|
||||||
region_camera = region;
|
region_camera = region;
|
||||||
if (rv3d->sms) {
|
if (rv3d->sms) {
|
||||||
@ -108,11 +108,11 @@ void ED_view3d_smooth_view_undo_end(bContext *C,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (region_camera == NULL) {
|
if (region_camera == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionView3D *rv3d = region_camera->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region_camera->regiondata);
|
||||||
|
|
||||||
/* Fast forward, undo push, then rewind. */
|
/* Fast forward, undo push, then rewind. */
|
||||||
if (is_interactive) {
|
if (is_interactive) {
|
||||||
@ -150,9 +150,9 @@ struct SmoothView3DState {
|
|||||||
|
|
||||||
struct SmoothView3DStore {
|
struct SmoothView3DStore {
|
||||||
/* Source. */
|
/* Source. */
|
||||||
struct SmoothView3DState src; /* source */
|
SmoothView3DState src; /* source */
|
||||||
struct SmoothView3DState dst; /* destination */
|
SmoothView3DState dst; /* destination */
|
||||||
struct SmoothView3DState org; /* original */
|
SmoothView3DState org; /* original */
|
||||||
|
|
||||||
bool to_camera;
|
bool to_camera;
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ struct SmoothView3DStore {
|
|||||||
double time_allowed;
|
double time_allowed;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void view3d_smooth_view_state_backup(struct SmoothView3DState *sms_state,
|
static void view3d_smooth_view_state_backup(SmoothView3DState *sms_state,
|
||||||
const View3D *v3d,
|
const View3D *v3d,
|
||||||
const RegionView3D *rv3d)
|
const RegionView3D *rv3d)
|
||||||
{
|
{
|
||||||
@ -176,7 +176,7 @@ static void view3d_smooth_view_state_backup(struct SmoothView3DState *sms_state,
|
|||||||
sms_state->lens = v3d->lens;
|
sms_state->lens = v3d->lens;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void view3d_smooth_view_state_restore(const struct SmoothView3DState *sms_state,
|
static void view3d_smooth_view_state_restore(const SmoothView3DState *sms_state,
|
||||||
View3D *v3d,
|
View3D *v3d,
|
||||||
RegionView3D *rv3d)
|
RegionView3D *rv3d)
|
||||||
{
|
{
|
||||||
@ -200,17 +200,17 @@ void ED_view3d_smooth_view_ex(
|
|||||||
{
|
{
|
||||||
/* In this case use #ED_view3d_smooth_view_undo_begin & end functions
|
/* In this case use #ED_view3d_smooth_view_undo_begin & end functions
|
||||||
* instead of passing in undo. */
|
* instead of passing in undo. */
|
||||||
BLI_assert_msg(sview->undo_str == NULL,
|
BLI_assert_msg(sview->undo_str == nullptr,
|
||||||
"Only the 'ED_view3d_smooth_view' version of this function handles undo!");
|
"Only the 'ED_view3d_smooth_view' version of this function handles undo!");
|
||||||
|
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
struct SmoothView3DStore sms = {{0}};
|
SmoothView3DStore sms = {{0}};
|
||||||
|
|
||||||
/* initialize sms */
|
/* initialize sms */
|
||||||
view3d_smooth_view_state_backup(&sms.dst, v3d, rv3d);
|
view3d_smooth_view_state_backup(&sms.dst, v3d, rv3d);
|
||||||
view3d_smooth_view_state_backup(&sms.src, v3d, rv3d);
|
view3d_smooth_view_state_backup(&sms.src, v3d, rv3d);
|
||||||
/* If smooth-view runs multiple times. */
|
/* If smooth-view runs multiple times. */
|
||||||
if (rv3d->sms == NULL) {
|
if (rv3d->sms == nullptr) {
|
||||||
view3d_smooth_view_state_backup(&sms.org, v3d, rv3d);
|
view3d_smooth_view_state_backup(&sms.org, v3d, rv3d);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -228,7 +228,7 @@ void ED_view3d_smooth_view_ex(
|
|||||||
* camera to be moved or changed, so only when the camera is not being set should
|
* camera to be moved or changed, so only when the camera is not being set should
|
||||||
* we allow camera option locking to initialize the view settings from the camera.
|
* we allow camera option locking to initialize the view settings from the camera.
|
||||||
*/
|
*/
|
||||||
if (sview->camera == NULL && sview->camera_old == NULL) {
|
if (sview->camera == nullptr && sview->camera_old == nullptr) {
|
||||||
ED_view3d_camera_lock_init(depsgraph, v3d, rv3d);
|
ED_view3d_camera_lock_init(depsgraph, v3d, rv3d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,8 +247,8 @@ void ED_view3d_smooth_view_ex(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sview->dyn_ofs) {
|
if (sview->dyn_ofs) {
|
||||||
BLI_assert(sview->ofs == NULL);
|
BLI_assert(sview->ofs == nullptr);
|
||||||
BLI_assert(sview->quat != NULL);
|
BLI_assert(sview->quat != nullptr);
|
||||||
|
|
||||||
copy_v3_v3(sms.dyn_ofs, sview->dyn_ofs);
|
copy_v3_v3(sms.dyn_ofs, sview->dyn_ofs);
|
||||||
sms.use_dyn_ofs = true;
|
sms.use_dyn_ofs = true;
|
||||||
@ -259,7 +259,7 @@ void ED_view3d_smooth_view_ex(
|
|||||||
|
|
||||||
if (sview->camera) {
|
if (sview->camera) {
|
||||||
Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
|
Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
|
||||||
if (sview->ofs != NULL) {
|
if (sview->ofs != nullptr) {
|
||||||
sms.dst.dist = ED_view3d_offset_distance(
|
sms.dst.dist = ED_view3d_offset_distance(
|
||||||
ob_camera_eval->object_to_world, sview->ofs, VIEW3D_DIST_FALLBACK);
|
ob_camera_eval->object_to_world, sview->ofs, VIEW3D_DIST_FALLBACK);
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ void ED_view3d_smooth_view_ex(
|
|||||||
/* original values */
|
/* original values */
|
||||||
if (sview->camera_old) {
|
if (sview->camera_old) {
|
||||||
Object *ob_camera_old_eval = DEG_get_evaluated_object(depsgraph, sview->camera_old);
|
Object *ob_camera_old_eval = DEG_get_evaluated_object(depsgraph, sview->camera_old);
|
||||||
if (sview->ofs != NULL) {
|
if (sview->ofs != nullptr) {
|
||||||
sms.src.dist = ED_view3d_offset_distance(
|
sms.src.dist = ED_view3d_offset_distance(
|
||||||
ob_camera_old_eval->object_to_world, sview->ofs, 0.0f);
|
ob_camera_old_eval->object_to_world, sview->ofs, 0.0f);
|
||||||
}
|
}
|
||||||
@ -298,14 +298,14 @@ void ED_view3d_smooth_view_ex(
|
|||||||
rv3d->view = RV3D_VIEW_USER;
|
rv3d->view = RV3D_VIEW_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
sms.time_allowed = (double)smooth_viewtx / 1000.0;
|
sms.time_allowed = double(smooth_viewtx / 1000.0);
|
||||||
|
|
||||||
/* If this is view rotation only we can decrease the time allowed by the angle between quats
|
/* If this is view rotation only we can decrease the time allowed by the angle between quats
|
||||||
* this means small rotations won't lag. */
|
* this means small rotations won't lag. */
|
||||||
if (sview->quat && !sview->ofs && !sview->dist) {
|
if (sview->quat && !sview->ofs && !sview->dist) {
|
||||||
/* scale the time allowed by the rotation */
|
/* scale the time allowed by the rotation */
|
||||||
/* 180deg == 1.0 */
|
/* 180deg == 1.0 */
|
||||||
sms.time_allowed *= (double)fabsf(angle_signed_normalized_qtqt(sms.dst.quat, sms.src.quat)) /
|
sms.time_allowed *= double(fabsf(angle_signed_normalized_qtqt(sms.dst.quat, sms.src.quat))) /
|
||||||
M_PI;
|
M_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,10 +313,10 @@ void ED_view3d_smooth_view_ex(
|
|||||||
if (sms.to_camera) {
|
if (sms.to_camera) {
|
||||||
/* use ortho if we move from an ortho view to an ortho camera */
|
/* use ortho if we move from an ortho view to an ortho camera */
|
||||||
Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
|
Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
|
||||||
rv3d->persp = (((rv3d->is_persp == false) && (ob_camera_eval->type == OB_CAMERA) &&
|
rv3d->persp = ((rv3d->is_persp == false) && (ob_camera_eval->type == OB_CAMERA) &&
|
||||||
(((Camera *)ob_camera_eval->data)->type == CAM_ORTHO)) ?
|
(static_cast<Camera *>(ob_camera_eval->data)->type == CAM_ORTHO)) ?
|
||||||
RV3D_ORTHO :
|
RV3D_ORTHO :
|
||||||
RV3D_PERSP);
|
RV3D_PERSP;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv3d->rflag |= RV3D_NAVIGATING;
|
rv3d->rflag |= RV3D_NAVIGATING;
|
||||||
@ -326,8 +326,9 @@ void ED_view3d_smooth_view_ex(
|
|||||||
view3d_smooth_view_state_restore(&sms.src, v3d, rv3d);
|
view3d_smooth_view_state_restore(&sms.src, v3d, rv3d);
|
||||||
|
|
||||||
/* keep track of running timer! */
|
/* keep track of running timer! */
|
||||||
if (rv3d->sms == NULL) {
|
if (rv3d->sms == nullptr) {
|
||||||
rv3d->sms = MEM_mallocN(sizeof(struct SmoothView3DStore), "smoothview v3d");
|
rv3d->sms = static_cast<SmoothView3DStore *>(
|
||||||
|
MEM_mallocN(sizeof(SmoothView3DStore), "smoothview v3d"));
|
||||||
}
|
}
|
||||||
*rv3d->sms = sms;
|
*rv3d->sms = sms;
|
||||||
if (rv3d->smooth_timer) {
|
if (rv3d->smooth_timer) {
|
||||||
@ -377,10 +378,10 @@ void ED_view3d_smooth_view(bContext *C,
|
|||||||
|
|
||||||
/* #ED_view3d_smooth_view_ex asserts this is not set as it doesn't support undo. */
|
/* #ED_view3d_smooth_view_ex asserts this is not set as it doesn't support undo. */
|
||||||
V3D_SmoothParams sview_no_undo = *sview;
|
V3D_SmoothParams sview_no_undo = *sview;
|
||||||
sview_no_undo.undo_str = NULL;
|
sview_no_undo.undo_str = nullptr;
|
||||||
sview_no_undo.undo_grouped = false;
|
sview_no_undo.undo_grouped = false;
|
||||||
|
|
||||||
const bool do_undo = (sview->undo_str != NULL);
|
const bool do_undo = (sview->undo_str != nullptr);
|
||||||
if (do_undo) {
|
if (do_undo) {
|
||||||
ED_view3d_smooth_view_undo_begin(C, area);
|
ED_view3d_smooth_view_undo_begin(C, area);
|
||||||
}
|
}
|
||||||
@ -398,7 +399,7 @@ void ED_view3d_smooth_view(bContext *C,
|
|||||||
static void view3d_smoothview_apply_with_interp(
|
static void view3d_smoothview_apply_with_interp(
|
||||||
bContext *C, View3D *v3d, RegionView3D *rv3d, const bool use_autokey, const float factor)
|
bContext *C, View3D *v3d, RegionView3D *rv3d, const bool use_autokey, const float factor)
|
||||||
{
|
{
|
||||||
struct SmoothView3DStore *sms = rv3d->sms;
|
SmoothView3DStore *sms = rv3d->sms;
|
||||||
|
|
||||||
interp_qt_qtqt(rv3d->viewquat, sms->src.quat, sms->dst.quat, factor);
|
interp_qt_qtqt(rv3d->viewquat, sms->src.quat, sms->dst.quat, factor);
|
||||||
|
|
||||||
@ -427,7 +428,7 @@ static void view3d_smoothview_apply_with_interp(
|
|||||||
static void view3d_smoothview_apply_and_finish(bContext *C, View3D *v3d, RegionView3D *rv3d)
|
static void view3d_smoothview_apply_and_finish(bContext *C, View3D *v3d, RegionView3D *rv3d)
|
||||||
{
|
{
|
||||||
wmWindowManager *wm = CTX_wm_manager(C);
|
wmWindowManager *wm = CTX_wm_manager(C);
|
||||||
struct SmoothView3DStore *sms = rv3d->sms;
|
SmoothView3DStore *sms = rv3d->sms;
|
||||||
|
|
||||||
wmWindow *win = CTX_wm_window(C);
|
wmWindow *win = CTX_wm_window(C);
|
||||||
|
|
||||||
@ -451,10 +452,10 @@ static void view3d_smoothview_apply_and_finish(bContext *C, View3D *v3d, RegionV
|
|||||||
}
|
}
|
||||||
|
|
||||||
MEM_freeN(rv3d->sms);
|
MEM_freeN(rv3d->sms);
|
||||||
rv3d->sms = NULL;
|
rv3d->sms = nullptr;
|
||||||
|
|
||||||
WM_event_remove_timer(wm, win, rv3d->smooth_timer);
|
WM_event_remove_timer(wm, win, rv3d->smooth_timer);
|
||||||
rv3d->smooth_timer = NULL;
|
rv3d->smooth_timer = nullptr;
|
||||||
rv3d->rflag &= ~RV3D_NAVIGATING;
|
rv3d->rflag &= ~RV3D_NAVIGATING;
|
||||||
|
|
||||||
/* Event handling won't know if a UI item has been moved under the pointer. */
|
/* Event handling won't know if a UI item has been moved under the pointer. */
|
||||||
@ -473,12 +474,12 @@ static void view3d_smoothview_apply_and_finish(bContext *C, View3D *v3d, RegionV
|
|||||||
static void view3d_smoothview_apply_from_timer(bContext *C, View3D *v3d, ARegion *region)
|
static void view3d_smoothview_apply_from_timer(bContext *C, View3D *v3d, ARegion *region)
|
||||||
{
|
{
|
||||||
wmWindowManager *wm = CTX_wm_manager(C);
|
wmWindowManager *wm = CTX_wm_manager(C);
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
struct SmoothView3DStore *sms = rv3d->sms;
|
SmoothView3DStore *sms = rv3d->sms;
|
||||||
float factor;
|
float factor;
|
||||||
|
|
||||||
if (sms->time_allowed != 0.0) {
|
if (sms->time_allowed != 0.0) {
|
||||||
factor = (float)((rv3d->smooth_timer->duration) / sms->time_allowed);
|
factor = float(rv3d->smooth_timer->duration / sms->time_allowed);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
factor = 1.0f;
|
factor = 1.0f;
|
||||||
@ -500,14 +501,14 @@ static void view3d_smoothview_apply_from_timer(bContext *C, View3D *v3d, ARegion
|
|||||||
ED_region_tag_redraw(region);
|
ED_region_tag_redraw(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
static int view3d_smoothview_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
|
||||||
{
|
{
|
||||||
View3D *v3d = CTX_wm_view3d(C);
|
View3D *v3d = CTX_wm_view3d(C);
|
||||||
ARegion *region = CTX_wm_region(C);
|
ARegion *region = CTX_wm_region(C);
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
|
|
||||||
/* escape if not our timer */
|
/* escape if not our timer */
|
||||||
if (rv3d->smooth_timer == NULL || rv3d->smooth_timer != event->customdata) {
|
if (rv3d->smooth_timer == nullptr || rv3d->smooth_timer != event->customdata) {
|
||||||
return OPERATOR_PASS_THROUGH;
|
return OPERATOR_PASS_THROUGH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,7 +519,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w
|
|||||||
|
|
||||||
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
|
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
|
||||||
{
|
{
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
if (rv3d && rv3d->sms) {
|
if (rv3d && rv3d->sms) {
|
||||||
view3d_smoothview_apply_and_finish(C, v3d, rv3d);
|
view3d_smoothview_apply_and_finish(C, v3d, rv3d);
|
||||||
|
|
||||||
@ -526,7 +527,7 @@ void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *regio
|
|||||||
* can use them without redrawing first */
|
* can use them without redrawing first */
|
||||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||||
Scene *scene = CTX_data_scene(C);
|
Scene *scene = CTX_data_scene(C);
|
||||||
ED_view3d_update_viewmat(depsgraph, scene, v3d, region, NULL, NULL, NULL, false);
|
ED_view3d_update_viewmat(depsgraph, scene, v3d, region, nullptr, nullptr, nullptr, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8,7 +8,7 @@
|
|||||||
* Interactive walk navigation modal operator
|
* Interactive walk navigation modal operator
|
||||||
* (similar to walking around in a first person game).
|
* (similar to walking around in a first person game).
|
||||||
*
|
*
|
||||||
* \note Similar logic to `view3d_navigate_fly.c` changes here may apply there too.
|
* \note Similar logic to `view3d_navigate_fly.cc` changes here may apply there too.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* defines VIEW3D_OT_navigate - walk modal operator */
|
/* defines VIEW3D_OT_navigate - walk modal operator */
|
||||||
@ -47,7 +47,7 @@
|
|||||||
#include "DEG_depsgraph.h"
|
#include "DEG_depsgraph.h"
|
||||||
|
|
||||||
#include "view3d_intern.h" /* own include */
|
#include "view3d_intern.h" /* own include */
|
||||||
#include "view3d_navigate.h"
|
#include "view3d_navigate.hh"
|
||||||
|
|
||||||
#ifdef WITH_INPUT_NDOF
|
#ifdef WITH_INPUT_NDOF
|
||||||
//# define NDOF_WALK_DEBUG
|
//# define NDOF_WALK_DEBUG
|
||||||
@ -167,7 +167,7 @@ void walk_modal_keymap(wmKeyConfig *keyconf)
|
|||||||
|
|
||||||
{WALK_MODAL_AXIS_LOCK_Z, "AXIS_LOCK_Z", 0, "Z Axis Correction", "Z axis correction"},
|
{WALK_MODAL_AXIS_LOCK_Z, "AXIS_LOCK_Z", 0, "Z Axis Correction", "Z axis correction"},
|
||||||
|
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Walk Modal");
|
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Walk Modal");
|
||||||
@ -189,17 +189,16 @@ void walk_modal_keymap(wmKeyConfig *keyconf)
|
|||||||
/** \name Internal Walk Structs
|
/** \name Internal Walk Structs
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
typedef struct WalkTeleport {
|
struct WalkTeleport {
|
||||||
eWalkTeleportState state;
|
eWalkTeleportState state;
|
||||||
float duration; /* from user preferences */
|
float duration; /* from user preferences */
|
||||||
float origin[3];
|
float origin[3];
|
||||||
float direction[3];
|
float direction[3];
|
||||||
double initial_time;
|
double initial_time;
|
||||||
eWalkMethod navigation_mode; /* teleport always set FREE mode on */
|
eWalkMethod navigation_mode; /* teleport always set FREE mode on */
|
||||||
|
};
|
||||||
|
|
||||||
} WalkTeleport;
|
struct WalkInfo {
|
||||||
|
|
||||||
typedef struct WalkInfo {
|
|
||||||
/* context stuff */
|
/* context stuff */
|
||||||
RegionView3D *rv3d;
|
RegionView3D *rv3d;
|
||||||
View3D *v3d;
|
View3D *v3d;
|
||||||
@ -296,9 +295,8 @@ typedef struct WalkInfo {
|
|||||||
|
|
||||||
SnapObjectContext *snap_context;
|
SnapObjectContext *snap_context;
|
||||||
|
|
||||||
struct View3DCameraControl *v3d_camera_control;
|
View3DCameraControl *v3d_camera_control;
|
||||||
|
};
|
||||||
} WalkInfo;
|
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
@ -313,10 +311,10 @@ static void walkApply_ndof(bContext *C, WalkInfo *walk, bool is_confirm);
|
|||||||
static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm);
|
static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm);
|
||||||
static float getVelocityZeroTime(const float gravity, const float velocity);
|
static float getVelocityZeroTime(const float gravity, const float velocity);
|
||||||
|
|
||||||
static void drawWalkPixel(const bContext *UNUSED(C), ARegion *region, void *arg)
|
static void drawWalkPixel(const bContext * /*C*/, ARegion *region, void *arg)
|
||||||
{
|
{
|
||||||
/* draws an aim/cross in the center */
|
/* draws an aim/cross in the center */
|
||||||
WalkInfo *walk = arg;
|
WalkInfo *walk = static_cast<WalkInfo *>(arg);
|
||||||
|
|
||||||
const int outter_length = 24;
|
const int outter_length = 24;
|
||||||
const int inner_length = 14;
|
const int inner_length = 14;
|
||||||
@ -403,20 +401,20 @@ static bool walk_floor_distance_get(RegionView3D *rv3d,
|
|||||||
mul_v3_v3fl(dvec_tmp, dvec, walk->grid);
|
mul_v3_v3fl(dvec_tmp, dvec, walk->grid);
|
||||||
add_v3_v3(ray_start, dvec_tmp);
|
add_v3_v3(ray_start, dvec_tmp);
|
||||||
|
|
||||||
ret = ED_transform_snap_object_project_ray(
|
SnapObjectParams snap_params = {};
|
||||||
walk->snap_context,
|
snap_params.snap_target_select = SCE_SNAP_TARGET_ALL;
|
||||||
walk->depsgraph,
|
/* Avoid having to convert the edit-mesh to a regular mesh. */
|
||||||
walk->v3d,
|
snap_params.edit_mode_type = SNAP_GEOM_EDIT;
|
||||||
&(const struct SnapObjectParams){
|
|
||||||
.snap_target_select = SCE_SNAP_TARGET_ALL,
|
ret = ED_transform_snap_object_project_ray(walk->snap_context,
|
||||||
/* Avoid having to convert the edit-mesh to a regular mesh. */
|
walk->depsgraph,
|
||||||
.edit_mode_type = SNAP_GEOM_EDIT,
|
walk->v3d,
|
||||||
},
|
&snap_params,
|
||||||
ray_start,
|
ray_start,
|
||||||
ray_normal,
|
ray_normal,
|
||||||
r_distance,
|
r_distance,
|
||||||
r_location,
|
r_location,
|
||||||
r_normal_dummy);
|
r_normal_dummy);
|
||||||
|
|
||||||
/* artificially scale the distance to the scene size */
|
/* artificially scale the distance to the scene size */
|
||||||
*r_distance /= walk->grid;
|
*r_distance /= walk->grid;
|
||||||
@ -446,15 +444,16 @@ static bool walk_ray_cast(RegionView3D *rv3d,
|
|||||||
|
|
||||||
normalize_v3(ray_normal);
|
normalize_v3(ray_normal);
|
||||||
|
|
||||||
|
SnapObjectParams snap_params = {};
|
||||||
|
snap_params.snap_target_select = SCE_SNAP_TARGET_ALL;
|
||||||
|
|
||||||
ret = ED_transform_snap_object_project_ray(walk->snap_context,
|
ret = ED_transform_snap_object_project_ray(walk->snap_context,
|
||||||
walk->depsgraph,
|
walk->depsgraph,
|
||||||
walk->v3d,
|
walk->v3d,
|
||||||
&(const struct SnapObjectParams){
|
&snap_params,
|
||||||
.snap_target_select = SCE_SNAP_TARGET_ALL,
|
|
||||||
},
|
|
||||||
ray_start,
|
ray_start,
|
||||||
ray_normal,
|
ray_normal,
|
||||||
NULL,
|
nullptr,
|
||||||
r_location,
|
r_location,
|
||||||
r_normal);
|
r_normal);
|
||||||
|
|
||||||
@ -496,7 +495,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op, const int
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* sanity check: for rare but possible case (if lib-linking the camera fails) */
|
/* sanity check: for rare but possible case (if lib-linking the camera fails) */
|
||||||
if ((walk->rv3d->persp == RV3D_CAMOB) && (walk->v3d->camera == NULL)) {
|
if ((walk->rv3d->persp == RV3D_CAMOB) && (walk->v3d->camera == nullptr)) {
|
||||||
walk->rv3d->persp = RV3D_PERSP;
|
walk->rv3d->persp = RV3D_PERSP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,7 +574,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op, const int
|
|||||||
walk->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f);
|
walk->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f);
|
||||||
|
|
||||||
#ifdef WITH_INPUT_NDOF
|
#ifdef WITH_INPUT_NDOF
|
||||||
walk->ndof = NULL;
|
walk->ndof = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
walk->anim_playing = ED_screen_animation_playing(wm);
|
walk->anim_playing = ED_screen_animation_playing(wm);
|
||||||
@ -597,7 +596,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op, const int
|
|||||||
copy_v2_v2_int(walk->init_mval, mval);
|
copy_v2_v2_int(walk->init_mval, mval);
|
||||||
copy_v2_v2_int(walk->prev_mval, mval);
|
copy_v2_v2_int(walk->prev_mval, mval);
|
||||||
|
|
||||||
WM_cursor_grab_enable(win, 0, NULL, true);
|
WM_cursor_grab_enable(win, WM_CURSOR_WRAP_NONE, nullptr, true);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -646,7 +645,7 @@ static int walkEnd(bContext *C, WalkInfo *walk)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WM_cursor_grab_disable(win, NULL);
|
WM_cursor_grab_disable(win, nullptr);
|
||||||
|
|
||||||
if (walk->state == WALK_CONFIRM) {
|
if (walk->state == WALK_CONFIRM) {
|
||||||
MEM_freeN(walk);
|
MEM_freeN(walk);
|
||||||
@ -685,7 +684,8 @@ static void walkEvent(WalkInfo *walk, const wmEvent *event)
|
|||||||
// puts("ndof motion detected in walk mode!");
|
// puts("ndof motion detected in walk mode!");
|
||||||
// static const char *tag_name = "3D mouse position";
|
// static const char *tag_name = "3D mouse position";
|
||||||
|
|
||||||
const wmNDOFMotionData *incoming_ndof = event->customdata;
|
const wmNDOFMotionData *incoming_ndof = static_cast<const wmNDOFMotionData *>(
|
||||||
|
event->customdata);
|
||||||
switch (incoming_ndof->progress) {
|
switch (incoming_ndof->progress) {
|
||||||
case P_STARTING:
|
case P_STARTING:
|
||||||
/* start keeping track of 3D mouse position */
|
/* start keeping track of 3D mouse position */
|
||||||
@ -699,9 +699,9 @@ static void walkEvent(WalkInfo *walk, const wmEvent *event)
|
|||||||
putchar('.');
|
putchar('.');
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
# endif
|
# endif
|
||||||
if (walk->ndof == NULL) {
|
if (walk->ndof == nullptr) {
|
||||||
// walk->ndof = MEM_mallocN(sizeof(wmNDOFMotionData), tag_name);
|
// walk->ndof = MEM_mallocN(sizeof(wmNDOFMotionData), tag_name);
|
||||||
walk->ndof = MEM_dupallocN(incoming_ndof);
|
walk->ndof = static_cast<wmNDOFMotionData *>(MEM_dupallocN(incoming_ndof));
|
||||||
// walk->ndof = malloc(sizeof(wmNDOFMotionData));
|
// walk->ndof = malloc(sizeof(wmNDOFMotionData));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -716,7 +716,7 @@ static void walkEvent(WalkInfo *walk, const wmEvent *event)
|
|||||||
if (walk->ndof) {
|
if (walk->ndof) {
|
||||||
MEM_freeN(walk->ndof);
|
MEM_freeN(walk->ndof);
|
||||||
// free(walk->ndof);
|
// free(walk->ndof);
|
||||||
walk->ndof = NULL;
|
walk->ndof = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the time else the view will jump when 2D mouse/timer resume */
|
/* update the time else the view will jump when 2D mouse/timer resume */
|
||||||
@ -806,7 +806,7 @@ static void walkEvent(WalkInfo *walk, const wmEvent *event)
|
|||||||
float t;
|
float t;
|
||||||
|
|
||||||
/* delta time */
|
/* delta time */
|
||||||
t = (float)(PIL_check_seconds_timer() - walk->teleport.initial_time);
|
t = float(PIL_check_seconds_timer() - walk->teleport.initial_time);
|
||||||
|
|
||||||
/* Reduce the velocity, if JUMP wasn't hold for long enough. */
|
/* Reduce the velocity, if JUMP wasn't hold for long enough. */
|
||||||
t = min_ff(t, JUMP_TIME_MAX);
|
t = min_ff(t, JUMP_TIME_MAX);
|
||||||
@ -985,7 +985,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm)
|
|||||||
walk->redraw = 1;
|
walk->redraw = 1;
|
||||||
#endif
|
#endif
|
||||||
time_current = PIL_check_seconds_timer();
|
time_current = PIL_check_seconds_timer();
|
||||||
time_redraw = (float)(time_current - walk->time_lastdraw);
|
time_redraw = float(time_current - walk->time_lastdraw);
|
||||||
|
|
||||||
/* Clamp redraw time to avoid jitter in roll correction. */
|
/* Clamp redraw time to avoid jitter in roll correction. */
|
||||||
time_redraw_clamped = min_ff(0.05f, time_redraw);
|
time_redraw_clamped = min_ff(0.05f, time_redraw);
|
||||||
@ -1012,7 +1012,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm)
|
|||||||
float y;
|
float y;
|
||||||
|
|
||||||
/* relative offset */
|
/* relative offset */
|
||||||
y = (float)moffset[1];
|
y = float(moffset[1]);
|
||||||
|
|
||||||
/* Speed factor. */
|
/* Speed factor. */
|
||||||
#ifdef USE_TABLET_SUPPORT
|
#ifdef USE_TABLET_SUPPORT
|
||||||
@ -1061,7 +1061,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* relative offset */
|
/* relative offset */
|
||||||
x = (float)moffset[0];
|
x = float(moffset[0]);
|
||||||
|
|
||||||
/* Speed factor. */
|
/* Speed factor. */
|
||||||
#ifdef USE_TABLET_SUPPORT
|
#ifdef USE_TABLET_SUPPORT
|
||||||
@ -1232,7 +1232,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm)
|
|||||||
float ray_distance, difference = -100.0f;
|
float ray_distance, difference = -100.0f;
|
||||||
|
|
||||||
/* delta time */
|
/* delta time */
|
||||||
t = (float)(PIL_check_seconds_timer() - walk->teleport.initial_time);
|
t = float(PIL_check_seconds_timer() - walk->teleport.initial_time);
|
||||||
|
|
||||||
/* keep moving if we were moving */
|
/* keep moving if we were moving */
|
||||||
copy_v2_v2(dvec, walk->teleport.direction);
|
copy_v2_v2(dvec, walk->teleport.direction);
|
||||||
@ -1277,7 +1277,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm)
|
|||||||
float cur_loc[3];
|
float cur_loc[3];
|
||||||
|
|
||||||
/* linear interpolation */
|
/* linear interpolation */
|
||||||
t = (float)(PIL_check_seconds_timer() - walk->teleport.initial_time);
|
t = float(PIL_check_seconds_timer() - walk->teleport.initial_time);
|
||||||
t /= walk->teleport.duration;
|
t /= walk->teleport.duration;
|
||||||
|
|
||||||
/* clamp so we don't go past our limit */
|
/* clamp so we don't go past our limit */
|
||||||
@ -1364,7 +1364,7 @@ static int walk_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
walk = MEM_callocN(sizeof(WalkInfo), "NavigationWalkOperation");
|
walk = MEM_cnew<WalkInfo>("NavigationWalkOperation");
|
||||||
|
|
||||||
op->customdata = walk;
|
op->customdata = walk;
|
||||||
|
|
||||||
@ -1382,18 +1382,18 @@ static int walk_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
|
|
||||||
static void walk_cancel(bContext *C, wmOperator *op)
|
static void walk_cancel(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
WalkInfo *walk = op->customdata;
|
WalkInfo *walk = static_cast<WalkInfo *>(op->customdata);
|
||||||
|
|
||||||
walk->state = WALK_CANCEL;
|
walk->state = WALK_CANCEL;
|
||||||
walkEnd(C, walk);
|
walkEnd(C, walk);
|
||||||
op->customdata = NULL;
|
op->customdata = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
int exit_code;
|
int exit_code;
|
||||||
bool do_draw = false;
|
bool do_draw = false;
|
||||||
WalkInfo *walk = op->customdata;
|
WalkInfo *walk = static_cast<WalkInfo *>(op->customdata);
|
||||||
View3D *v3d = walk->v3d;
|
View3D *v3d = walk->v3d;
|
||||||
RegionView3D *rv3d = walk->rv3d;
|
RegionView3D *rv3d = walk->rv3d;
|
||||||
Object *walk_object = ED_view3d_cameracontrol_object_get(walk->v3d_camera_control);
|
Object *walk_object = ED_view3d_cameracontrol_object_get(walk->v3d_camera_control);
|
@ -23,7 +23,7 @@
|
|||||||
#include "PIL_time.h"
|
#include "PIL_time.h"
|
||||||
|
|
||||||
#include "view3d_intern.h"
|
#include "view3d_intern.h"
|
||||||
#include "view3d_navigate.h" /* own include */
|
#include "view3d_navigate.hh" /* own include */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name View Zoom Operator
|
/** \name View Zoom Operator
|
||||||
@ -39,7 +39,7 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf)
|
|||||||
{VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"},
|
{VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"},
|
||||||
{VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"},
|
{VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"},
|
||||||
|
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Zoom Modal");
|
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Zoom Modal");
|
||||||
@ -57,7 +57,7 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \param zoom_xy: Optionally zoom to window location
|
* \param zoom_xy: Optionally zoom to window location
|
||||||
* (coords compatible w/ #wmEvent.xy). Use when not NULL.
|
* (coords compatible w/ #wmEvent.xy). Use when not nullptr.
|
||||||
*/
|
*/
|
||||||
static void view_zoom_to_window_xy_camera(Scene *scene,
|
static void view_zoom_to_window_xy_camera(Scene *scene,
|
||||||
Depsgraph *depsgraph,
|
Depsgraph *depsgraph,
|
||||||
@ -66,18 +66,18 @@ static void view_zoom_to_window_xy_camera(Scene *scene,
|
|||||||
float dfac,
|
float dfac,
|
||||||
const int zoom_xy[2])
|
const int zoom_xy[2])
|
||||||
{
|
{
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
const float zoomfac = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom);
|
const float zoomfac = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom);
|
||||||
const float zoomfac_new = clamp_f(
|
const float zoomfac_new = clamp_f(
|
||||||
zoomfac * (1.0f / dfac), RV3D_CAMZOOM_MIN_FACTOR, RV3D_CAMZOOM_MAX_FACTOR);
|
zoomfac * (1.0f / dfac), RV3D_CAMZOOM_MIN_FACTOR, RV3D_CAMZOOM_MAX_FACTOR);
|
||||||
const float camzoom_new = BKE_screen_view3d_zoom_from_fac(zoomfac_new);
|
const float camzoom_new = BKE_screen_view3d_zoom_from_fac(zoomfac_new);
|
||||||
|
|
||||||
if (zoom_xy != NULL) {
|
if (zoom_xy != nullptr) {
|
||||||
float zoomfac_px;
|
float zoomfac_px;
|
||||||
rctf camera_frame_old;
|
rctf camera_frame_old;
|
||||||
rctf camera_frame_new;
|
rctf camera_frame_new;
|
||||||
|
|
||||||
const float pt_src[2] = {zoom_xy[0], zoom_xy[1]};
|
const float pt_src[2] = {float(zoom_xy[0]), float(zoom_xy[1])};
|
||||||
float pt_dst[2];
|
float pt_dst[2];
|
||||||
float delta_px[2];
|
float delta_px[2];
|
||||||
|
|
||||||
@ -110,14 +110,14 @@ static void view_zoom_to_window_xy_camera(Scene *scene,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \param zoom_xy: Optionally zoom to window location
|
* \param zoom_xy: Optionally zoom to window location
|
||||||
* (coords compatible w/ #wmEvent.xy). Use when not NULL.
|
* (coords compatible w/ #wmEvent.xy). Use when not nullptr.
|
||||||
*/
|
*/
|
||||||
static void view_zoom_to_window_xy_3d(ARegion *region, float dfac, const int zoom_xy[2])
|
static void view_zoom_to_window_xy_3d(ARegion *region, float dfac, const int zoom_xy[2])
|
||||||
{
|
{
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
const float dist_new = rv3d->dist * dfac;
|
const float dist_new = rv3d->dist * dfac;
|
||||||
|
|
||||||
if (zoom_xy != NULL) {
|
if (zoom_xy != nullptr) {
|
||||||
float dvec[3];
|
float dvec[3];
|
||||||
float tvec[3];
|
float tvec[3];
|
||||||
float tpos[3];
|
float tpos[3];
|
||||||
@ -127,8 +127,8 @@ static void view_zoom_to_window_xy_3d(ARegion *region, float dfac, const int zoo
|
|||||||
|
|
||||||
negate_v3_v3(tpos, rv3d->ofs);
|
negate_v3_v3(tpos, rv3d->ofs);
|
||||||
|
|
||||||
xy_delta[0] = (float)(((zoom_xy[0] - region->winrct.xmin) * 2) - region->winx) / 2.0f;
|
xy_delta[0] = float(((zoom_xy[0] - region->winrct.xmin) * 2) - region->winx) / 2.0f;
|
||||||
xy_delta[1] = (float)(((zoom_xy[1] - region->winrct.ymin) * 2) - region->winy) / 2.0f;
|
xy_delta[1] = float(((zoom_xy[1] - region->winrct.ymin) * 2) - region->winy) / 2.0f;
|
||||||
|
|
||||||
/* Project cursor position into 3D space */
|
/* Project cursor position into 3D space */
|
||||||
zfac = ED_view3d_calc_zfac(rv3d, tpos);
|
zfac = ED_view3d_calc_zfac(rv3d, tpos);
|
||||||
@ -164,14 +164,14 @@ static float viewzoom_scale_value(const rcti *winrct,
|
|||||||
|
|
||||||
if (viewzoom == USER_ZOOM_CONTINUE) {
|
if (viewzoom == USER_ZOOM_CONTINUE) {
|
||||||
double time = PIL_check_seconds_timer();
|
double time = PIL_check_seconds_timer();
|
||||||
float time_step = (float)(time - *r_timer_lastdraw);
|
float time_step = float(time - *r_timer_lastdraw);
|
||||||
float fac;
|
float fac;
|
||||||
|
|
||||||
if (U.uiflag & USER_ZOOM_HORIZ) {
|
if (U.uiflag & USER_ZOOM_HORIZ) {
|
||||||
fac = (float)(xy_init[0] - xy_curr[0]);
|
fac = float(xy_init[0] - xy_curr[0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fac = (float)(xy_init[1] - xy_curr[1]);
|
fac = float(xy_init[1] - xy_curr[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fac /= UI_SCALE_FAC;
|
fac /= UI_SCALE_FAC;
|
||||||
@ -190,8 +190,8 @@ static float viewzoom_scale_value(const rcti *winrct,
|
|||||||
BLI_rcti_cent_x(winrct),
|
BLI_rcti_cent_x(winrct),
|
||||||
BLI_rcti_cent_y(winrct),
|
BLI_rcti_cent_y(winrct),
|
||||||
};
|
};
|
||||||
float len_new = (5 * UI_SCALE_FAC) + ((float)len_v2v2_int(ctr, xy_curr) / UI_SCALE_FAC);
|
float len_new = (5 * UI_SCALE_FAC) + (float(len_v2v2_int(ctr, xy_curr)) / UI_SCALE_FAC);
|
||||||
float len_old = (5 * UI_SCALE_FAC) + ((float)len_v2v2_int(ctr, xy_init) / UI_SCALE_FAC);
|
float len_old = (5 * UI_SCALE_FAC) + (float(len_v2v2_int(ctr, xy_init)) / UI_SCALE_FAC);
|
||||||
|
|
||||||
/* intentionally ignore 'zoom_invert' for scale */
|
/* intentionally ignore 'zoom_invert' for scale */
|
||||||
if (zoom_invert_force) {
|
if (zoom_invert_force) {
|
||||||
@ -282,7 +282,7 @@ static void viewzoom_apply_camera(ViewOpsData *vod,
|
|||||||
vod->v3d,
|
vod->v3d,
|
||||||
vod->region,
|
vod->region,
|
||||||
zfac,
|
zfac,
|
||||||
zoom_to_pos ? vod->prev.event_xy : NULL);
|
zoom_to_pos ? vod->prev.event_xy : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ED_region_tag_redraw(vod->region);
|
ED_region_tag_redraw(vod->region);
|
||||||
@ -315,7 +315,7 @@ static void viewzoom_apply_3d(ViewOpsData *vod,
|
|||||||
const float zfac_max = dist_range[1] / vod->rv3d->dist;
|
const float zfac_max = dist_range[1] / vod->rv3d->dist;
|
||||||
CLAMP(zfac, zfac_min, zfac_max);
|
CLAMP(zfac, zfac_min, zfac_max);
|
||||||
|
|
||||||
view_zoom_to_window_xy_3d(vod->region, zfac, zoom_to_pos ? vod->prev.event_xy : NULL);
|
view_zoom_to_window_xy_3d(vod->region, zfac, zoom_to_pos ? vod->prev.event_xy : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* these limits were in old code too */
|
/* these limits were in old code too */
|
||||||
@ -392,8 +392,8 @@ static void view_zoom_apply_step(bContext *C,
|
|||||||
const int delta,
|
const int delta,
|
||||||
const int zoom_xy[2])
|
const int zoom_xy[2])
|
||||||
{
|
{
|
||||||
View3D *v3d = area->spacedata.first;
|
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
bool use_cam_zoom;
|
bool use_cam_zoom;
|
||||||
float dist_range[2];
|
float dist_range[2];
|
||||||
|
|
||||||
@ -437,20 +437,20 @@ static void view_zoom_apply_step(bContext *C,
|
|||||||
|
|
||||||
static int viewzoom_exec(bContext *C, wmOperator *op)
|
static int viewzoom_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
BLI_assert(op->customdata == NULL);
|
BLI_assert(op->customdata == nullptr);
|
||||||
|
|
||||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||||
Scene *scene = CTX_data_scene(C);
|
Scene *scene = CTX_data_scene(C);
|
||||||
ScrArea *area = CTX_wm_area(C);
|
ScrArea *area = CTX_wm_area(C);
|
||||||
ARegion *region = CTX_wm_region(C);
|
ARegion *region = CTX_wm_region(C);
|
||||||
View3D *v3d = area->spacedata.first;
|
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
|
|
||||||
const int delta = RNA_int_get(op->ptr, "delta");
|
const int delta = RNA_int_get(op->ptr, "delta");
|
||||||
const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
|
const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
|
||||||
|
|
||||||
int zoom_xy_buf[2];
|
int zoom_xy_buf[2];
|
||||||
const int *zoom_xy = NULL;
|
const int *zoom_xy = nullptr;
|
||||||
const bool do_zoom_to_mouse_pos = (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS));
|
const bool do_zoom_to_mouse_pos = (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS));
|
||||||
if (do_zoom_to_mouse_pos) {
|
if (do_zoom_to_mouse_pos) {
|
||||||
zoom_xy_buf[0] = RNA_struct_property_is_set(op->ptr, "mx") ? RNA_int_get(op->ptr, "mx") :
|
zoom_xy_buf[0] = RNA_struct_property_is_set(op->ptr, "mx") ? RNA_int_get(op->ptr, "mx") :
|
||||||
@ -488,7 +488,7 @@ int viewzoom_invoke_impl(bContext *C, ViewOpsData *vod, const wmEvent *event, Po
|
|||||||
vod->area,
|
vod->area,
|
||||||
vod->region,
|
vod->region,
|
||||||
delta,
|
delta,
|
||||||
do_zoom_to_mouse_pos ? xy : NULL);
|
do_zoom_to_mouse_pos ? xy : nullptr);
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
@ -23,7 +23,7 @@
|
|||||||
#include "RNA_access.h"
|
#include "RNA_access.h"
|
||||||
|
|
||||||
#include "view3d_intern.h"
|
#include "view3d_intern.h"
|
||||||
#include "view3d_navigate.h" /* own include */
|
#include "view3d_navigate.hh" /* own include */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name Border Zoom Operator
|
/** \name Border Zoom Operator
|
||||||
@ -61,7 +61,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
|
|||||||
ED_view3d_dist_range_get(v3d, dist_range);
|
ED_view3d_dist_range_get(v3d, dist_range);
|
||||||
|
|
||||||
ED_view3d_depth_override(
|
ED_view3d_depth_override(
|
||||||
CTX_data_ensure_evaluated_depsgraph(C), region, v3d, NULL, V3D_DEPTH_NO_GPENCIL, NULL);
|
CTX_data_ensure_evaluated_depsgraph(C), region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, nullptr);
|
||||||
{
|
{
|
||||||
/* avoid allocating the whole depth buffer */
|
/* avoid allocating the whole depth buffer */
|
||||||
ViewDepths depth_temp = {0};
|
ViewDepths depth_temp = {0};
|
||||||
@ -77,17 +77,17 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
/* Resize border to the same ratio as the window. */
|
/* Resize border to the same ratio as the window. */
|
||||||
{
|
{
|
||||||
const float region_aspect = (float)region->winx / (float)region->winy;
|
const float region_aspect = float(region->winx) / float(region->winy);
|
||||||
if (((float)BLI_rcti_size_x(&rect) / (float)BLI_rcti_size_y(&rect)) < region_aspect) {
|
if ((float(BLI_rcti_size_x(&rect)) / float(BLI_rcti_size_y(&rect))) < region_aspect) {
|
||||||
BLI_rcti_resize_x(&rect, (int)(BLI_rcti_size_y(&rect) * region_aspect));
|
BLI_rcti_resize_x(&rect, int(BLI_rcti_size_y(&rect) * region_aspect));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BLI_rcti_resize_y(&rect, (int)(BLI_rcti_size_x(&rect) / region_aspect));
|
BLI_rcti_resize_y(&rect, int(BLI_rcti_size_x(&rect) / region_aspect));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cent[0] = (((float)rect.xmin) + ((float)rect.xmax)) / 2;
|
cent[0] = (float(rect.xmin) + float(rect.xmax)) / 2;
|
||||||
cent[1] = (((float)rect.ymin) + ((float)rect.ymax)) / 2;
|
cent[1] = (float(rect.ymin) + float(rect.ymax)) / 2;
|
||||||
|
|
||||||
if (rv3d->is_persp) {
|
if (rv3d->is_persp) {
|
||||||
float p_corner[3];
|
float p_corner[3];
|
||||||
@ -172,16 +172,12 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
|
|||||||
ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, RV3D_PERSP);
|
ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, RV3D_PERSP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
V3D_SmoothParams sview_params = {};
|
||||||
|
sview_params.ofs = new_ofs;
|
||||||
|
sview_params.dist = &new_dist;
|
||||||
|
sview_params.undo_str = op->type->name;
|
||||||
|
|
||||||
ED_view3d_smooth_view(C,
|
ED_view3d_smooth_view(C, v3d, region, smooth_viewtx, &sview_params);
|
||||||
v3d,
|
|
||||||
region,
|
|
||||||
smooth_viewtx,
|
|
||||||
&(const V3D_SmoothParams){
|
|
||||||
.ofs = new_ofs,
|
|
||||||
.dist = &new_dist,
|
|
||||||
.undo_str = op->type->name,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
|
if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
|
||||||
view3d_boxview_sync(CTX_wm_area(C), region);
|
view3d_boxview_sync(CTX_wm_area(C), region);
|
7
source/blender/editors/space_view3d/view3d_ops.c → source/blender/editors/space_view3d/view3d_ops.cc
7
source/blender/editors/space_view3d/view3d_ops.c → source/blender/editors/space_view3d/view3d_ops.cc
@ -6,8 +6,7 @@
|
|||||||
* \ingroup spview3d
|
* \ingroup spview3d
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
@ -35,7 +34,7 @@
|
|||||||
#include "ED_transform.h"
|
#include "ED_transform.h"
|
||||||
|
|
||||||
#include "view3d_intern.h"
|
#include "view3d_intern.h"
|
||||||
#include "view3d_navigate.h"
|
#include "view3d_navigate.hh"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include "BLI_math_base.h" /* M_PI */
|
# include "BLI_math_base.h" /* M_PI */
|
||||||
@ -119,7 +118,7 @@ static int view3d_pastebuffer_exec(bContext *C, wmOperator *op)
|
|||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
WM_event_add_notifier(C, NC_WINDOW, nullptr);
|
||||||
ED_outliner_select_sync_from_object_tag(C);
|
ED_outliner_select_sync_from_object_tag(C);
|
||||||
|
|
||||||
BKE_reportf(op->reports, RPT_INFO, "%d object(s) pasted", num_pasted);
|
BKE_reportf(op->reports, RPT_INFO, "%d object(s) pasted", num_pasted);
|
@ -45,13 +45,13 @@
|
|||||||
#include "RNA_define.h"
|
#include "RNA_define.h"
|
||||||
|
|
||||||
#include "view3d_intern.h" /* own include */
|
#include "view3d_intern.h" /* own include */
|
||||||
#include "view3d_navigate.h"
|
#include "view3d_navigate.hh"
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name Camera to View Operator
|
/** \name Camera to View Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op))
|
static int view3d_camera_to_view_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||||
View3D *v3d;
|
View3D *v3d;
|
||||||
@ -61,7 +61,7 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
ObjectTfmProtectedChannels obtfm;
|
ObjectTfmProtectedChannels obtfm;
|
||||||
|
|
||||||
ED_view3d_context_user_region(C, &v3d, ®ion);
|
ED_view3d_context_user_region(C, &v3d, ®ion);
|
||||||
rv3d = region->regiondata;
|
rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
|
|
||||||
ED_view3d_lastview_store(rv3d);
|
ED_view3d_lastview_store(rv3d);
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ static bool view3d_camera_to_view_poll(bContext *C)
|
|||||||
ARegion *region;
|
ARegion *region;
|
||||||
|
|
||||||
if (ED_view3d_context_user_region(C, &v3d, ®ion)) {
|
if (ED_view3d_context_user_region(C, &v3d, ®ion)) {
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
if (v3d && v3d->camera && BKE_id_is_editable(CTX_data_main(C), &v3d->camera->id)) {
|
if (v3d && v3d->camera && BKE_id_is_editable(CTX_data_main(C), &v3d->camera->id)) {
|
||||||
if (rv3d && (RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ANY_TRANSFORM) == 0) {
|
if (rv3d && (RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ANY_TRANSFORM) == 0) {
|
||||||
if (rv3d->persp != RV3D_CAMOB) {
|
if (rv3d->persp != RV3D_CAMOB) {
|
||||||
@ -126,10 +126,10 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
|
|||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||||
Scene *scene = CTX_data_scene(C);
|
Scene *scene = CTX_data_scene(C);
|
||||||
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
|
View3D *v3d = CTX_wm_view3d(C); /* can be nullptr */
|
||||||
Object *camera_ob = v3d ? v3d->camera : scene->camera;
|
Object *camera_ob = v3d ? v3d->camera : scene->camera;
|
||||||
|
|
||||||
if (camera_ob == NULL) {
|
if (camera_ob == nullptr) {
|
||||||
BKE_report(op->reports, RPT_ERROR, "No active camera");
|
BKE_report(op->reports, RPT_ERROR, "No active camera");
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
@ -168,13 +168,11 @@ static void sync_viewport_camera_smoothview(bContext *C,
|
|||||||
const int smooth_viewtx)
|
const int smooth_viewtx)
|
||||||
{
|
{
|
||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
for (bScreen *screen = bmain->screens.first; screen != NULL; screen = screen->id.next) {
|
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||||
for (ScrArea *area = screen->areabase.first; area != NULL; area = area->next) {
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||||
for (SpaceLink *space_link = area->spacedata.first; space_link != NULL;
|
LISTBASE_FOREACH (SpaceLink *, space_link, &area->spacedata) {
|
||||||
space_link = space_link->next)
|
|
||||||
{
|
|
||||||
if (space_link->spacetype == SPACE_VIEW3D) {
|
if (space_link->spacetype == SPACE_VIEW3D) {
|
||||||
View3D *other_v3d = (View3D *)space_link;
|
View3D *other_v3d = reinterpret_cast<View3D *>(space_link);
|
||||||
if (other_v3d == v3d) {
|
if (other_v3d == v3d) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -185,29 +183,27 @@ static void sync_viewport_camera_smoothview(bContext *C,
|
|||||||
if (v3d->scenelock && other_v3d->scenelock) {
|
if (v3d->scenelock && other_v3d->scenelock) {
|
||||||
ListBase *lb = (space_link == area->spacedata.first) ? &area->regionbase :
|
ListBase *lb = (space_link == area->spacedata.first) ? &area->regionbase :
|
||||||
&space_link->regionbase;
|
&space_link->regionbase;
|
||||||
for (ARegion *other_region = lb->first; other_region != NULL;
|
LISTBASE_FOREACH (ARegion *, other_region, lb) {
|
||||||
other_region = other_region->next) {
|
|
||||||
if (other_region->regiontype == RGN_TYPE_WINDOW) {
|
if (other_region->regiontype == RGN_TYPE_WINDOW) {
|
||||||
if (other_region->regiondata) {
|
if (other_region->regiondata) {
|
||||||
RegionView3D *other_rv3d = other_region->regiondata;
|
RegionView3D *other_rv3d = static_cast<RegionView3D *>(other_region->regiondata);
|
||||||
if (other_rv3d->persp == RV3D_CAMOB) {
|
if (other_rv3d->persp == RV3D_CAMOB) {
|
||||||
Object *other_camera_old = other_v3d->camera;
|
Object *other_camera_old = other_v3d->camera;
|
||||||
other_v3d->camera = ob;
|
other_v3d->camera = ob;
|
||||||
|
|
||||||
|
V3D_SmoothParams sview_params = {};
|
||||||
|
sview_params.camera_old = other_camera_old;
|
||||||
|
sview_params.camera = other_v3d->camera;
|
||||||
|
sview_params.ofs = other_rv3d->ofs;
|
||||||
|
sview_params.quat = other_rv3d->viewquat;
|
||||||
|
sview_params.dist = &other_rv3d->dist;
|
||||||
|
sview_params.lens = &other_v3d->lens;
|
||||||
|
/* No undo because this switches cameras. */
|
||||||
|
sview_params.undo_str = nullptr;
|
||||||
|
|
||||||
ED_view3d_lastview_store(other_rv3d);
|
ED_view3d_lastview_store(other_rv3d);
|
||||||
ED_view3d_smooth_view(C,
|
ED_view3d_smooth_view(
|
||||||
other_v3d,
|
C, other_v3d, other_region, smooth_viewtx, &sview_params);
|
||||||
other_region,
|
|
||||||
smooth_viewtx,
|
|
||||||
&(const V3D_SmoothParams){
|
|
||||||
.camera_old = other_camera_old,
|
|
||||||
.camera = other_v3d->camera,
|
|
||||||
.ofs = other_rv3d->ofs,
|
|
||||||
.quat = other_rv3d->viewquat,
|
|
||||||
.dist = &other_rv3d->dist,
|
|
||||||
.lens = &other_v3d->lens,
|
|
||||||
/* No undo because this switches cameras. */
|
|
||||||
.undo_str = NULL,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
other_v3d->camera = ob;
|
other_v3d->camera = ob;
|
||||||
@ -233,12 +229,12 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
|
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
|
||||||
|
|
||||||
/* no NULL check is needed, poll checks */
|
/* no nullptr check is needed, poll checks */
|
||||||
ED_view3d_context_user_region(C, &v3d, ®ion);
|
ED_view3d_context_user_region(C, &v3d, ®ion);
|
||||||
rv3d = region->regiondata;
|
rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
|
|
||||||
if (ob) {
|
if (ob) {
|
||||||
Object *camera_old = (rv3d->persp == RV3D_CAMOB) ? V3D_CAMERA_SCENE(scene, v3d) : NULL;
|
Object *camera_old = (rv3d->persp == RV3D_CAMOB) ? V3D_CAMERA_SCENE(scene, v3d) : nullptr;
|
||||||
rv3d->persp = RV3D_CAMOB;
|
rv3d->persp = RV3D_CAMOB;
|
||||||
v3d->camera = ob;
|
v3d->camera = ob;
|
||||||
if (v3d->scenelock && scene->camera != ob) {
|
if (v3d->scenelock && scene->camera != ob) {
|
||||||
@ -248,22 +244,18 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
/* unlikely but looks like a glitch when set to the same */
|
/* unlikely but looks like a glitch when set to the same */
|
||||||
if (camera_old != ob) {
|
if (camera_old != ob) {
|
||||||
ED_view3d_lastview_store(rv3d);
|
V3D_SmoothParams sview_params = {};
|
||||||
|
sview_params.camera_old = camera_old;
|
||||||
|
sview_params.camera = v3d->camera;
|
||||||
|
sview_params.ofs = rv3d->ofs;
|
||||||
|
sview_params.quat = rv3d->viewquat;
|
||||||
|
sview_params.dist = &rv3d->dist;
|
||||||
|
sview_params.lens = &v3d->lens;
|
||||||
|
/* No undo because this switches cameras. */
|
||||||
|
sview_params.undo_str = nullptr;
|
||||||
|
|
||||||
ED_view3d_smooth_view(C,
|
ED_view3d_lastview_store(rv3d);
|
||||||
v3d,
|
ED_view3d_smooth_view(C, v3d, region, smooth_viewtx, &sview_params);
|
||||||
region,
|
|
||||||
smooth_viewtx,
|
|
||||||
&(const V3D_SmoothParams){
|
|
||||||
.camera_old = camera_old,
|
|
||||||
.camera = v3d->camera,
|
|
||||||
.ofs = rv3d->ofs,
|
|
||||||
.quat = rv3d->viewquat,
|
|
||||||
.dist = &rv3d->dist,
|
|
||||||
.lens = &v3d->lens,
|
|
||||||
/* No undo because this switches cameras. */
|
|
||||||
.undo_str = NULL,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v3d->scenelock) {
|
if (v3d->scenelock) {
|
||||||
@ -310,13 +302,20 @@ void view3d_winmatrix_set(Depsgraph *depsgraph,
|
|||||||
const View3D *v3d,
|
const View3D *v3d,
|
||||||
const rcti *rect)
|
const rcti *rect)
|
||||||
{
|
{
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
rctf full_viewplane;
|
rctf full_viewplane;
|
||||||
float clipsta, clipend;
|
float clipsta, clipend;
|
||||||
bool is_ortho;
|
bool is_ortho;
|
||||||
|
|
||||||
is_ortho = ED_view3d_viewplane_get(
|
is_ortho = ED_view3d_viewplane_get(depsgraph,
|
||||||
depsgraph, v3d, rv3d, region->winx, region->winy, &full_viewplane, &clipsta, &clipend, NULL);
|
v3d,
|
||||||
|
rv3d,
|
||||||
|
region->winx,
|
||||||
|
region->winy,
|
||||||
|
&full_viewplane,
|
||||||
|
&clipsta,
|
||||||
|
&clipend,
|
||||||
|
nullptr);
|
||||||
rv3d->is_persp = !is_ortho;
|
rv3d->is_persp = !is_ortho;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -337,13 +336,13 @@ void view3d_winmatrix_set(Depsgraph *depsgraph,
|
|||||||
if (rect) {
|
if (rect) {
|
||||||
/* Smaller viewplane subset for selection picking. */
|
/* Smaller viewplane subset for selection picking. */
|
||||||
viewplane.xmin = full_viewplane.xmin +
|
viewplane.xmin = full_viewplane.xmin +
|
||||||
(BLI_rctf_size_x(&full_viewplane) * (rect->xmin / (float)region->winx));
|
(BLI_rctf_size_x(&full_viewplane) * (rect->xmin / float(region->winx)));
|
||||||
viewplane.ymin = full_viewplane.ymin +
|
viewplane.ymin = full_viewplane.ymin +
|
||||||
(BLI_rctf_size_y(&full_viewplane) * (rect->ymin / (float)region->winy));
|
(BLI_rctf_size_y(&full_viewplane) * (rect->ymin / float(region->winy)));
|
||||||
viewplane.xmax = full_viewplane.xmin +
|
viewplane.xmax = full_viewplane.xmin +
|
||||||
(BLI_rctf_size_x(&full_viewplane) * (rect->xmax / (float)region->winx));
|
(BLI_rctf_size_x(&full_viewplane) * (rect->xmax / float(region->winx)));
|
||||||
viewplane.ymax = full_viewplane.ymin +
|
viewplane.ymax = full_viewplane.ymin +
|
||||||
(BLI_rctf_size_y(&full_viewplane) * (rect->ymax / (float)region->winy));
|
(BLI_rctf_size_y(&full_viewplane) * (rect->ymax / float(region->winy)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
viewplane = full_viewplane;
|
viewplane = full_viewplane;
|
||||||
@ -486,7 +485,7 @@ struct DrawSelectLoopUserData {
|
|||||||
static bool drw_select_loop_pass(eDRWSelectStage stage, void *user_data)
|
static bool drw_select_loop_pass(eDRWSelectStage stage, void *user_data)
|
||||||
{
|
{
|
||||||
bool continue_pass = false;
|
bool continue_pass = false;
|
||||||
struct DrawSelectLoopUserData *data = user_data;
|
DrawSelectLoopUserData *data = static_cast<DrawSelectLoopUserData *>(user_data);
|
||||||
if (stage == DRW_SELECT_PASS_PRE) {
|
if (stage == DRW_SELECT_PASS_PRE) {
|
||||||
GPU_select_begin_next(
|
GPU_select_begin_next(
|
||||||
data->buffer, data->buffer_len, data->rect, data->gpu_select_mode, data->hits);
|
data->buffer, data->buffer_len, data->rect, data->gpu_select_mode, data->hits);
|
||||||
@ -527,8 +526,8 @@ eV3DSelectObjectFilter ED_view3d_select_filter_from_mode(const Scene *scene, con
|
|||||||
/** Implement #VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK. */
|
/** Implement #VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK. */
|
||||||
static bool drw_select_filter_object_mode_lock(Object *ob, void *user_data)
|
static bool drw_select_filter_object_mode_lock(Object *ob, void *user_data)
|
||||||
{
|
{
|
||||||
const Object *obact = user_data;
|
const Object *obact = static_cast<const Object *>(user_data);
|
||||||
return BKE_object_is_mode_compat(ob, obact->mode);
|
return BKE_object_is_mode_compat(ob, eObjectMode(obact->mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -537,7 +536,7 @@ static bool drw_select_filter_object_mode_lock(Object *ob, void *user_data)
|
|||||||
*/
|
*/
|
||||||
static bool drw_select_filter_object_mode_lock_for_weight_paint(Object *ob, void *user_data)
|
static bool drw_select_filter_object_mode_lock_for_weight_paint(Object *ob, void *user_data)
|
||||||
{
|
{
|
||||||
LinkNode *ob_pose_list = user_data;
|
LinkNode *ob_pose_list = static_cast<LinkNode *>(user_data);
|
||||||
return ob_pose_list && (BLI_linklist_index(ob_pose_list, DEG_get_original_object(ob)) != -1);
|
return ob_pose_list && (BLI_linklist_index(ob_pose_list, DEG_get_original_object(ob)) != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,7 +548,7 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
|||||||
eV3DSelectObjectFilter select_filter,
|
eV3DSelectObjectFilter select_filter,
|
||||||
const bool do_material_slot_selection)
|
const bool do_material_slot_selection)
|
||||||
{
|
{
|
||||||
struct bThemeState theme_state;
|
bThemeState theme_state;
|
||||||
const wmWindowManager *wm = CTX_wm_manager(vc->C);
|
const wmWindowManager *wm = CTX_wm_manager(vc->C);
|
||||||
Depsgraph *depsgraph = vc->depsgraph;
|
Depsgraph *depsgraph = vc->depsgraph;
|
||||||
Scene *scene = vc->scene;
|
Scene *scene = vc->scene;
|
||||||
@ -558,8 +557,8 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
|||||||
rcti rect;
|
rcti rect;
|
||||||
int hits = 0;
|
int hits = 0;
|
||||||
BKE_view_layer_synced_ensure(scene, vc->view_layer);
|
BKE_view_layer_synced_ensure(scene, vc->view_layer);
|
||||||
const bool use_obedit_skip = (BKE_view_layer_edit_object_get(vc->view_layer) != NULL) &&
|
const bool use_obedit_skip = (BKE_view_layer_edit_object_get(vc->view_layer) != nullptr) &&
|
||||||
(vc->obedit == NULL);
|
(vc->obedit == nullptr);
|
||||||
const bool is_pick_select = (U.gpu_flag & USER_GPU_FLAG_NO_DEPT_PICK) == 0;
|
const bool is_pick_select = (U.gpu_flag & USER_GPU_FLAG_NO_DEPT_PICK) == 0;
|
||||||
const bool do_passes = ((is_pick_select == false) &&
|
const bool do_passes = ((is_pick_select == false) &&
|
||||||
(select_mode == VIEW3D_SELECT_PICK_NEAREST));
|
(select_mode == VIEW3D_SELECT_PICK_NEAREST));
|
||||||
@ -570,8 +569,9 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
|||||||
|
|
||||||
/* case not a box select */
|
/* case not a box select */
|
||||||
if (input->xmin == input->xmax) {
|
if (input->xmin == input->xmax) {
|
||||||
|
const int xy[2] = {input->xmin, input->ymin};
|
||||||
/* seems to be default value for bones only now */
|
/* seems to be default value for bones only now */
|
||||||
BLI_rcti_init_pt_radius(&rect, (const int[2]){input->xmin, input->ymin}, 12);
|
BLI_rcti_init_pt_radius(&rect, xy, 12);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rect = *input;
|
rect = *input;
|
||||||
@ -597,6 +597,13 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Important to use 'vc->obact', not 'BKE_view_layer_active_object_get(vc->view_layer)' below,
|
||||||
|
* so it will be nullptr when hidden. */
|
||||||
|
struct {
|
||||||
|
DRW_ObjectFilterFn fn;
|
||||||
|
void *user_data;
|
||||||
|
} object_filter = {nullptr, nullptr};
|
||||||
|
|
||||||
/* Re-use cache (rect must be smaller than the cached)
|
/* Re-use cache (rect must be smaller than the cached)
|
||||||
* other context is assumed to be unchanged */
|
* other context is assumed to be unchanged */
|
||||||
if (GPU_select_is_cached()) {
|
if (GPU_select_is_cached()) {
|
||||||
@ -606,12 +613,6 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
|||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Important to use 'vc->obact', not 'BKE_view_layer_active_object_get(vc->view_layer)' below,
|
|
||||||
* so it will be NULL when hidden. */
|
|
||||||
struct {
|
|
||||||
DRW_ObjectFilterFn fn;
|
|
||||||
void *user_data;
|
|
||||||
} object_filter = {NULL, NULL};
|
|
||||||
switch (select_filter) {
|
switch (select_filter) {
|
||||||
case VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK: {
|
case VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK: {
|
||||||
Object *obact = vc->obact;
|
Object *obact = vc->obact;
|
||||||
@ -626,7 +627,7 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
|||||||
BLI_assert(obact && (obact->mode & OB_MODE_ALL_WEIGHT_PAINT));
|
BLI_assert(obact && (obact->mode & OB_MODE_ALL_WEIGHT_PAINT));
|
||||||
/* While this uses 'alloca' in a loop (which we typically avoid),
|
/* While this uses 'alloca' in a loop (which we typically avoid),
|
||||||
* the number of items is nearly always 1, maybe 2..3 in rare cases. */
|
* the number of items is nearly always 1, maybe 2..3 in rare cases. */
|
||||||
LinkNode *ob_pose_list = NULL;
|
LinkNode *ob_pose_list = nullptr;
|
||||||
if (obact->type == OB_GPENCIL_LEGACY) {
|
if (obact->type == OB_GPENCIL_LEGACY) {
|
||||||
GpencilVirtualModifierData virtualModifierData;
|
GpencilVirtualModifierData virtualModifierData;
|
||||||
const GpencilModifierData *md = BKE_gpencil_modifiers_get_virtual_modifierlist(
|
const GpencilModifierData *md = BKE_gpencil_modifiers_get_virtual_modifierlist(
|
||||||
@ -673,7 +674,7 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
|||||||
/* Important we use the 'viewmat' and don't re-calculate since
|
/* Important we use the 'viewmat' and don't re-calculate since
|
||||||
* the object & bone view locking takes 'rect' into account, see: #51629. */
|
* the object & bone view locking takes 'rect' into account, see: #51629. */
|
||||||
ED_view3d_draw_setup_view(
|
ED_view3d_draw_setup_view(
|
||||||
wm, vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, NULL, &rect);
|
wm, vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, nullptr, &rect);
|
||||||
|
|
||||||
if (!XRAY_ACTIVE(v3d)) {
|
if (!XRAY_ACTIVE(v3d)) {
|
||||||
GPU_depth_test(GPU_DEPTH_LESS_EQUAL);
|
GPU_depth_test(GPU_DEPTH_LESS_EQUAL);
|
||||||
@ -683,14 +684,14 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
|||||||
if (XRAY_ACTIVE(v3d) && use_nearest) {
|
if (XRAY_ACTIVE(v3d) && use_nearest) {
|
||||||
/* We need to call "GPU_select_*" API's inside DRW_draw_select_loop
|
/* We need to call "GPU_select_*" API's inside DRW_draw_select_loop
|
||||||
* because the OpenGL context created & destroyed inside this function. */
|
* because the OpenGL context created & destroyed inside this function. */
|
||||||
struct DrawSelectLoopUserData drw_select_loop_user_data = {
|
DrawSelectLoopUserData drw_select_loop_user_data = {};
|
||||||
.pass = 0,
|
drw_select_loop_user_data.pass = 0;
|
||||||
.hits = 0,
|
drw_select_loop_user_data.hits = 0;
|
||||||
.buffer = buffer,
|
drw_select_loop_user_data.buffer = buffer;
|
||||||
.buffer_len = buffer_len,
|
drw_select_loop_user_data.buffer_len = buffer_len;
|
||||||
.rect = &rect,
|
drw_select_loop_user_data.rect = ▭
|
||||||
.gpu_select_mode = gpu_select_mode,
|
drw_select_loop_user_data.gpu_select_mode = gpu_select_mode;
|
||||||
};
|
|
||||||
draw_surface = false;
|
draw_surface = false;
|
||||||
DRW_draw_select_loop(depsgraph,
|
DRW_draw_select_loop(depsgraph,
|
||||||
region,
|
region,
|
||||||
@ -713,14 +714,14 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
|||||||
if (hits == 0) {
|
if (hits == 0) {
|
||||||
/* We need to call "GPU_select_*" API's inside DRW_draw_select_loop
|
/* We need to call "GPU_select_*" API's inside DRW_draw_select_loop
|
||||||
* because the OpenGL context created & destroyed inside this function. */
|
* because the OpenGL context created & destroyed inside this function. */
|
||||||
struct DrawSelectLoopUserData drw_select_loop_user_data = {
|
DrawSelectLoopUserData drw_select_loop_user_data = {};
|
||||||
.pass = 0,
|
drw_select_loop_user_data.pass = 0;
|
||||||
.hits = 0,
|
drw_select_loop_user_data.hits = 0;
|
||||||
.buffer = buffer,
|
drw_select_loop_user_data.buffer = buffer;
|
||||||
.buffer_len = buffer_len,
|
drw_select_loop_user_data.buffer_len = buffer_len;
|
||||||
.rect = &rect,
|
drw_select_loop_user_data.rect = ▭
|
||||||
.gpu_select_mode = gpu_select_mode,
|
drw_select_loop_user_data.gpu_select_mode = gpu_select_mode;
|
||||||
};
|
|
||||||
/* If are not in wireframe mode, we need to use the mesh surfaces to check for hits */
|
/* If are not in wireframe mode, we need to use the mesh surfaces to check for hits */
|
||||||
draw_surface = (v3d->shading.type > OB_WIRE) || !XRAY_ENABLED(v3d);
|
draw_surface = (v3d->shading.type > OB_WIRE) || !XRAY_ENABLED(v3d);
|
||||||
DRW_draw_select_loop(depsgraph,
|
DRW_draw_select_loop(depsgraph,
|
||||||
@ -740,7 +741,7 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
|||||||
|
|
||||||
G.f &= ~G_FLAG_PICKSEL;
|
G.f &= ~G_FLAG_PICKSEL;
|
||||||
ED_view3d_draw_setup_view(
|
ED_view3d_draw_setup_view(
|
||||||
wm, vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, NULL, NULL);
|
wm, vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, nullptr, nullptr);
|
||||||
|
|
||||||
if (!XRAY_ACTIVE(v3d)) {
|
if (!XRAY_ACTIVE(v3d)) {
|
||||||
GPU_depth_test(GPU_DEPTH_NONE);
|
GPU_depth_test(GPU_DEPTH_NONE);
|
||||||
@ -795,19 +796,16 @@ int view3d_opengl_select_with_id_filter(ViewContext *vc,
|
|||||||
|
|
||||||
static uint free_localview_bit(Main *bmain)
|
static uint free_localview_bit(Main *bmain)
|
||||||
{
|
{
|
||||||
ScrArea *area;
|
|
||||||
bScreen *screen;
|
|
||||||
|
|
||||||
ushort local_view_bits = 0;
|
ushort local_view_bits = 0;
|
||||||
|
|
||||||
/* Sometimes we lose a local-view: when an area is closed.
|
/* Sometimes we lose a local-view: when an area is closed.
|
||||||
* Check all areas: which local-views are in use? */
|
* Check all areas: which local-views are in use? */
|
||||||
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
|
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||||
for (area = screen->areabase.first; area; area = area->next) {
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||||
SpaceLink *sl = area->spacedata.first;
|
SpaceLink *sl = static_cast<SpaceLink *>(area->spacedata.first);
|
||||||
for (; sl; sl = sl->next) {
|
for (; sl; sl = sl->next) {
|
||||||
if (sl->spacetype == SPACE_VIEW3D) {
|
if (sl->spacetype == SPACE_VIEW3D) {
|
||||||
View3D *v3d = (View3D *)sl;
|
View3D *v3d = reinterpret_cast<View3D *>(sl);
|
||||||
if (v3d->localvd) {
|
if (v3d->localvd) {
|
||||||
local_view_bits |= v3d->local_view_uuid;
|
local_view_bits |= v3d->local_view_uuid;
|
||||||
}
|
}
|
||||||
@ -836,7 +834,7 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
|
|||||||
const int smooth_viewtx,
|
const int smooth_viewtx,
|
||||||
ReportList *reports)
|
ReportList *reports)
|
||||||
{
|
{
|
||||||
View3D *v3d = area->spacedata.first;
|
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
|
||||||
float min[3], max[3], box[3];
|
float min[3], max[3], box[3];
|
||||||
float size = 0.0f;
|
float size = 0.0f;
|
||||||
uint local_view_bit;
|
uint local_view_bit;
|
||||||
@ -893,23 +891,22 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ARegion *region;
|
v3d->localvd = static_cast<View3D *>(MEM_mallocN(sizeof(View3D), "localview"));
|
||||||
|
|
||||||
v3d->localvd = MEM_mallocN(sizeof(View3D), "localview");
|
|
||||||
|
|
||||||
memcpy(v3d->localvd, v3d, sizeof(View3D));
|
memcpy(v3d->localvd, v3d, sizeof(View3D));
|
||||||
v3d->local_view_uuid = local_view_bit;
|
v3d->local_view_uuid = local_view_bit;
|
||||||
|
|
||||||
for (region = area->regionbase.first; region; region = region->next) {
|
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
||||||
if (region->regiontype == RGN_TYPE_WINDOW) {
|
if (region->regiontype == RGN_TYPE_WINDOW) {
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
bool ok_dist = true;
|
bool ok_dist = true;
|
||||||
|
|
||||||
/* New view values. */
|
/* New view values. */
|
||||||
Object *camera_old = NULL;
|
Object *camera_old = nullptr;
|
||||||
float dist_new, ofs_new[3];
|
float dist_new, ofs_new[3];
|
||||||
|
|
||||||
rv3d->localvd = MEM_mallocN(sizeof(RegionView3D), "localview region");
|
rv3d->localvd = static_cast<RegionView3D *>(
|
||||||
|
MEM_mallocN(sizeof(RegionView3D), "localview region"));
|
||||||
memcpy(rv3d->localvd, rv3d, sizeof(RegionView3D));
|
memcpy(rv3d->localvd, rv3d, sizeof(RegionView3D));
|
||||||
|
|
||||||
if (frame_selected) {
|
if (frame_selected) {
|
||||||
@ -938,22 +935,17 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ED_view3d_smooth_view_ex(depsgraph,
|
V3D_SmoothParams sview_params = {};
|
||||||
wm,
|
sview_params.camera_old = camera_old;
|
||||||
win,
|
sview_params.ofs = ofs_new;
|
||||||
area,
|
sview_params.quat = rv3d->viewquat;
|
||||||
v3d,
|
sview_params.dist = ok_dist ? &dist_new : nullptr;
|
||||||
region,
|
sview_params.lens = &v3d->lens;
|
||||||
smooth_viewtx,
|
/* No undo because this doesn't move the camera. */
|
||||||
&(const V3D_SmoothParams){
|
sview_params.undo_str = nullptr;
|
||||||
.camera_old = camera_old,
|
|
||||||
.ofs = ofs_new,
|
ED_view3d_smooth_view_ex(
|
||||||
.quat = rv3d->viewquat,
|
depsgraph, wm, win, area, v3d, region, smooth_viewtx, &sview_params);
|
||||||
.dist = ok_dist ? &dist_new : NULL,
|
|
||||||
.lens = &v3d->lens,
|
|
||||||
/* No undo because this doesn't move the camera. */
|
|
||||||
.undo_str = NULL,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -970,9 +962,9 @@ static void view3d_localview_exit(const Depsgraph *depsgraph,
|
|||||||
const bool frame_selected,
|
const bool frame_selected,
|
||||||
const int smooth_viewtx)
|
const int smooth_viewtx)
|
||||||
{
|
{
|
||||||
View3D *v3d = area->spacedata.first;
|
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
|
||||||
|
|
||||||
if (v3d->localvd == NULL) {
|
if (v3d->localvd == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BKE_view_layer_synced_ensure(scene, view_layer);
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||||
@ -989,47 +981,42 @@ static void view3d_localview_exit(const Depsgraph *depsgraph,
|
|||||||
v3d->camera = v3d->localvd->camera;
|
v3d->camera = v3d->localvd->camera;
|
||||||
|
|
||||||
MEM_freeN(v3d->localvd);
|
MEM_freeN(v3d->localvd);
|
||||||
v3d->localvd = NULL;
|
v3d->localvd = nullptr;
|
||||||
MEM_SAFE_FREE(v3d->runtime.local_stats);
|
MEM_SAFE_FREE(v3d->runtime.local_stats);
|
||||||
|
|
||||||
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
||||||
if (region->regiontype == RGN_TYPE_WINDOW) {
|
if (region->regiontype == RGN_TYPE_WINDOW) {
|
||||||
RegionView3D *rv3d = region->regiondata;
|
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
|
|
||||||
if (rv3d->localvd == NULL) {
|
if (rv3d->localvd == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame_selected) {
|
if (frame_selected) {
|
||||||
Object *camera_old_rv3d, *camera_new_rv3d;
|
Object *camera_old_rv3d, *camera_new_rv3d;
|
||||||
|
|
||||||
camera_old_rv3d = (rv3d->persp == RV3D_CAMOB) ? camera_old : NULL;
|
camera_old_rv3d = (rv3d->persp == RV3D_CAMOB) ? camera_old : nullptr;
|
||||||
camera_new_rv3d = (rv3d->localvd->persp == RV3D_CAMOB) ? camera_new : NULL;
|
camera_new_rv3d = (rv3d->localvd->persp == RV3D_CAMOB) ? camera_new : nullptr;
|
||||||
|
|
||||||
rv3d->view = rv3d->localvd->view;
|
rv3d->view = rv3d->localvd->view;
|
||||||
rv3d->persp = rv3d->localvd->persp;
|
rv3d->persp = rv3d->localvd->persp;
|
||||||
rv3d->camzoom = rv3d->localvd->camzoom;
|
rv3d->camzoom = rv3d->localvd->camzoom;
|
||||||
|
|
||||||
ED_view3d_smooth_view_ex(depsgraph,
|
V3D_SmoothParams sview_params = {};
|
||||||
wm,
|
sview_params.camera_old = camera_old_rv3d;
|
||||||
win,
|
sview_params.camera = camera_new_rv3d;
|
||||||
area,
|
sview_params.ofs = rv3d->localvd->ofs;
|
||||||
v3d,
|
sview_params.quat = rv3d->localvd->viewquat;
|
||||||
region,
|
sview_params.dist = &rv3d->localvd->dist;
|
||||||
smooth_viewtx,
|
/* No undo because this doesn't move the camera. */
|
||||||
&(const V3D_SmoothParams){
|
sview_params.undo_str = nullptr;
|
||||||
.camera_old = camera_old_rv3d,
|
|
||||||
.camera = camera_new_rv3d,
|
ED_view3d_smooth_view_ex(
|
||||||
.ofs = rv3d->localvd->ofs,
|
depsgraph, wm, win, area, v3d, region, smooth_viewtx, &sview_params);
|
||||||
.quat = rv3d->localvd->viewquat,
|
|
||||||
.dist = &rv3d->localvd->dist,
|
|
||||||
/* No undo because this doesn't move the camera. */
|
|
||||||
.undo_str = NULL,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MEM_freeN(rv3d->localvd);
|
MEM_freeN(rv3d->localvd);
|
||||||
rv3d->localvd = NULL;
|
rv3d->localvd = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1071,7 +1058,7 @@ static int localview_exec(bContext *C, wmOperator *op)
|
|||||||
ED_area_tag_redraw(area);
|
ED_area_tag_redraw(area);
|
||||||
|
|
||||||
/* Unselected objects become selected when exiting. */
|
/* Unselected objects become selected when exiting. */
|
||||||
if (v3d->localvd == NULL) {
|
if (v3d->localvd == nullptr) {
|
||||||
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
|
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
|
||||||
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
||||||
}
|
}
|
||||||
@ -1118,7 +1105,7 @@ static int localview_remove_from_exec(bContext *C, wmOperator *op)
|
|||||||
ED_object_base_select(base, BA_DESELECT);
|
ED_object_base_select(base, BA_DESELECT);
|
||||||
|
|
||||||
if (base == view_layer->basact) {
|
if (base == view_layer->basact) {
|
||||||
view_layer->basact = NULL;
|
view_layer->basact = nullptr;
|
||||||
}
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@ -1138,7 +1125,7 @@ static int localview_remove_from_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
static bool localview_remove_from_poll(bContext *C)
|
static bool localview_remove_from_poll(bContext *C)
|
||||||
{
|
{
|
||||||
if (CTX_data_edit_object(C) != NULL) {
|
if (CTX_data_edit_object(C) != nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1167,18 +1154,14 @@ void VIEW3D_OT_localview_remove_from(wmOperatorType *ot)
|
|||||||
|
|
||||||
static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid, bool *r_reset)
|
static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid, bool *r_reset)
|
||||||
{
|
{
|
||||||
ScrArea *area;
|
|
||||||
bScreen *screen;
|
|
||||||
|
|
||||||
ushort local_view_bits = 0;
|
ushort local_view_bits = 0;
|
||||||
|
|
||||||
/* Check all areas: which local-views are in use? */
|
/* Check all areas: which local-views are in use? */
|
||||||
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
|
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||||
for (area = screen->areabase.first; area; area = area->next) {
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||||
SpaceLink *sl = area->spacedata.first;
|
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||||
for (; sl; sl = sl->next) {
|
|
||||||
if (sl->spacetype == SPACE_VIEW3D) {
|
if (sl->spacetype == SPACE_VIEW3D) {
|
||||||
View3D *v3d = (View3D *)sl;
|
View3D *v3d = reinterpret_cast<View3D *>(sl);
|
||||||
if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
|
if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
|
||||||
local_view_bits |= v3d->local_collections_uuid;
|
local_view_bits |= v3d->local_collections_uuid;
|
||||||
}
|
}
|
||||||
@ -1264,7 +1247,7 @@ void ED_view3d_local_collections_reset(bContext *C, const bool reset_all)
|
|||||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||||
if (sl->spacetype == SPACE_VIEW3D) {
|
if (sl->spacetype == SPACE_VIEW3D) {
|
||||||
View3D *v3d = (View3D *)sl;
|
View3D *v3d = reinterpret_cast<View3D *>(sl);
|
||||||
if (v3d->local_collections_uuid) {
|
if (v3d->local_collections_uuid) {
|
||||||
if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
|
if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
|
||||||
local_view_bit &= ~v3d->local_collections_uuid;
|
local_view_bit &= ~v3d->local_collections_uuid;
|
||||||
@ -1283,7 +1266,8 @@ void ED_view3d_local_collections_reset(bContext *C, const bool reset_all)
|
|||||||
}
|
}
|
||||||
else if (reset_all && (do_reset || (local_view_bit != ~(0)))) {
|
else if (reset_all && (do_reset || (local_view_bit != ~(0)))) {
|
||||||
view3d_local_collections_reset(bmain, ~(0));
|
view3d_local_collections_reset(bmain, ~(0));
|
||||||
View3D v3d = {.local_collections_uuid = ~(0)};
|
View3D v3d = {};
|
||||||
|
v3d.local_collections_uuid = ~(0);
|
||||||
BKE_layer_collection_local_sync(CTX_data_scene(C), CTX_data_view_layer(C), &v3d);
|
BKE_layer_collection_local_sync(CTX_data_scene(C), CTX_data_view_layer(C), &v3d);
|
||||||
DEG_id_tag_update(&CTX_data_scene(C)->id, ID_RECALC_BASE_FLAGS);
|
DEG_id_tag_update(&CTX_data_scene(C)->id, ID_RECALC_BASE_FLAGS);
|
||||||
}
|
}
|
||||||
@ -1320,10 +1304,10 @@ void ED_view3d_xr_mirror_update(const ScrArea *area, const View3D *v3d, const bo
|
|||||||
|
|
||||||
if (ED_view3d_area_user_region(area, v3d, ®ion_rv3d)) {
|
if (ED_view3d_area_user_region(area, v3d, ®ion_rv3d)) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
view3d_xr_mirror_begin(region_rv3d->regiondata);
|
view3d_xr_mirror_begin(static_cast<RegionView3D *>(region_rv3d->regiondata));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
view3d_xr_mirror_end(region_rv3d->regiondata);
|
view3d_xr_mirror_end(static_cast<RegionView3D *>(region_rv3d->regiondata));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1352,7 +1336,7 @@ void ED_view3d_xr_shading_update(wmWindowManager *wm, const View3D *v3d, const S
|
|||||||
|
|
||||||
if (xr_shading->prop) {
|
if (xr_shading->prop) {
|
||||||
IDP_FreeProperty(xr_shading->prop);
|
IDP_FreeProperty(xr_shading->prop);
|
||||||
xr_shading->prop = NULL;
|
xr_shading->prop = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy shading from View3D to VR view. */
|
/* Copy shading from View3D to VR view. */
|
Loading…
Reference in New Issue
Block a user