Cleanup: Move some space_view3d files to C++ #109936

Merged
Germano Cavalcante merged 1 commits from mano-wii/blender:move_to_cpp into main 2023-07-10 21:48:46 +02:00
16 changed files with 464 additions and 492 deletions

View File

@ -49,26 +49,26 @@ set(SRC
view3d_header.c
view3d_iterators.cc
view3d_navigate.cc
view3d_navigate_dolly.c
view3d_navigate_fly.c
view3d_navigate_move.c
view3d_navigate_ndof.c
view3d_navigate_roll.c
view3d_navigate_rotate.c
view3d_navigate_smoothview.c
view3d_navigate_walk.c
view3d_navigate_zoom.c
view3d_navigate_zoom_border.c
view3d_ops.c
view3d_navigate_dolly.cc
view3d_navigate_fly.cc
view3d_navigate_move.cc
view3d_navigate_ndof.cc
view3d_navigate_roll.cc
view3d_navigate_rotate.cc
view3d_navigate_smoothview.cc
view3d_navigate_walk.cc
view3d_navigate_zoom.cc
view3d_navigate_zoom_border.cc
view3d_ops.cc
view3d_placement.c
view3d_project.c
view3d_select.cc
view3d_snap.c
view3d_utils.c
view3d_view.c
view3d_view.cc
view3d_intern.h
view3d_navigate.h
view3d_navigate.hh
)
set(LIB

View File

@ -88,7 +88,7 @@
#include "DEG_depsgraph_build.h"
#include "view3d_intern.h" /* own include */
#include "view3d_navigate.h"
#include "view3d_navigate.hh"
/* ******************** manage regions ********************* */
@ -1179,7 +1179,7 @@ static void view3d_main_region_listener(const wmRegionListenerParams *params)
break;
case ND_OB_ACTIVE:
case ND_OB_SELECT:
ATTR_FALLTHROUGH;
[[fallthrough]];
case ND_FRAME:
case ND_TRANSFORM:
case ND_OB_VISIBLE:

View File

@ -43,7 +43,7 @@
#include "view3d_intern.h"
#include "view3d_navigate.h" /* own include */
#include "view3d_navigate.hh" /* own include */
/* Prototypes. */
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)
{
viewops_data_free(C, (ViewOpsData *)op->customdata);
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
op->customdata = nullptr;
}

View File

@ -10,10 +10,6 @@
#include "BLI_utildefines.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Size of the sphere being dragged for trackball rotation within the view bounds.
* also affects speed (smaller is faster).
@ -31,9 +27,13 @@ struct View3D;
struct bContext;
struct rcti;
struct wmEvent;
struct wmKeyConfig;
struct wmKeyMap;
struct wmOperator;
struct wmOperatorType;
struct wmWindowManager;
typedef enum eV3D_OpMode {
enum eV3D_OpMode {
V3D_OP_MODE_NONE = -1,
V3D_OP_MODE_ZOOM = 0,
V3D_OP_MODE_ROTATE,
@ -47,7 +47,7 @@ typedef enum eV3D_OpMode {
V3D_OP_MODE_NDOF_PAN,
V3D_OP_MODE_NDOF_ALL,
#endif
} eV3D_OpMode;
};
#ifndef WITH_INPUT_NDOF
# define V3D_OP_MODE_LEN V3D_OP_MODE_DOLLY + 1
#else
@ -60,14 +60,15 @@ enum eV3D_OpPropFlag {
V3D_OP_PROP_USE_ALL_REGIONS = (1 << 2),
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_APPLY,
VIEW_CONFIRM,
/** Only supported by some viewport operators. */
VIEW_CANCEL,
} eV3D_OpEvent;
};
/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
enum {
@ -80,7 +81,7 @@ enum {
VIEWROT_MODAL_SWITCH_ROTATE = 6,
};
typedef enum eViewOpsFlag {
enum eViewOpsFlag {
VIEWOPS_FLAG_NONE = 0,
/** When enabled, rotate around the selection. */
VIEWOPS_FLAG_ORBIT_SELECT = (1 << 0),
@ -96,22 +97,22 @@ typedef enum eViewOpsFlag {
VIEWOPS_FLAG_USE_MOUSE_INIT = (1 << 3),
VIEWOPS_FLAG_ZOOM_TO_MOUSE = (1 << 4),
} eViewOpsFlag;
};
ENUM_OPERATORS(eViewOpsFlag, VIEWOPS_FLAG_ZOOM_TO_MOUSE);
/** Generic View Operator Custom-Data */
typedef struct ViewOpsData {
struct ViewOpsData {
/** Context pointers (assigned by #viewops_data_create). */
struct Main *bmain;
struct Scene *scene;
struct ScrArea *area;
struct ARegion *region;
struct View3D *v3d;
struct RegionView3D *rv3d;
struct Depsgraph *depsgraph;
Main *bmain;
Scene *scene;
ScrArea *area;
ARegion *region;
View3D *v3d;
RegionView3D *rv3d;
Depsgraph *depsgraph;
/** Needed for continuous zoom. */
struct wmTimer *timer;
wmTimer *timer;
/** Viewport state on initialization, don't change afterwards. */
struct {
@ -193,7 +194,7 @@ typedef struct ViewOpsData {
/** Used for navigation on non view3d operators. */
wmKeyMap *keymap;
bool is_modal_event;
} ViewOpsData;
};
/* view3d_navigate.cc */
@ -202,18 +203,18 @@ typedef struct ViewOpsData {
*/
const char *viewops_operator_idname_get(eV3D_OpMode nav_type);
bool view3d_location_poll(struct bContext *C);
bool view3d_rotation_poll(struct bContext *C);
bool view3d_zoom_or_dolly_poll(struct bContext *C);
bool view3d_location_poll(bContext *C);
bool view3d_rotation_poll(bContext *C);
bool view3d_zoom_or_dolly_poll(bContext *C);
int view3d_navigate_invoke_impl(bContext *C,
wmOperator *op,
const wmEvent *event,
const eV3D_OpMode nav_type);
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 view3d_orbit_apply_dyn_ofs(float r_ofs[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 dyn_ofs[3]);
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
*/
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
@ -239,37 +240,37 @@ ViewOpsData *viewops_data_create(bContext *C,
const bool use_cursor_init);
void viewops_data_state_restore(ViewOpsData *vod);
void VIEW3D_OT_view_all(struct wmOperatorType *ot);
void VIEW3D_OT_view_selected(struct wmOperatorType *ot);
void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot);
void VIEW3D_OT_view_center_pick(struct wmOperatorType *ot);
void VIEW3D_OT_view_axis(struct wmOperatorType *ot);
void VIEW3D_OT_view_camera(struct wmOperatorType *ot);
void VIEW3D_OT_view_orbit(struct wmOperatorType *ot);
void VIEW3D_OT_view_pan(struct wmOperatorType *ot);
void VIEW3D_OT_view_all(wmOperatorType *ot);
void VIEW3D_OT_view_selected(wmOperatorType *ot);
void VIEW3D_OT_view_center_cursor(wmOperatorType *ot);
void VIEW3D_OT_view_center_pick(wmOperatorType *ot);
void VIEW3D_OT_view_axis(wmOperatorType *ot);
void VIEW3D_OT_view_camera(wmOperatorType *ot);
void VIEW3D_OT_view_orbit(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 VIEW3D_OT_dolly(struct wmOperatorType *ot);
void viewdolly_modal_keymap(wmKeyConfig *keyconf);
void VIEW3D_OT_dolly(wmOperatorType *ot);
/* view3d_navigate_fly.c */
/* view3d_navigate_fly.cc */
void fly_modal_keymap(struct wmKeyConfig *keyconf);
void view3d_keymap(struct wmKeyConfig *keyconf);
void VIEW3D_OT_fly(struct wmOperatorType *ot);
void fly_modal_keymap(wmKeyConfig *keyconf);
void view3d_keymap(wmKeyConfig *keyconf);
void VIEW3D_OT_fly(wmOperatorType *ot);
/* view3d_navigate_move.c */
/* view3d_navigate_move.cc */
int viewmove_modal_impl(bContext *C,
ViewOpsData *vod,
const eV3D_OpEvent event_code,
const int xy[2]);
int viewmove_invoke_impl(ViewOpsData *vod, const wmEvent *event);
void viewmove_modal_keymap(struct wmKeyConfig *keyconf);
void VIEW3D_OT_move(struct wmOperatorType *ot);
void viewmove_modal_keymap(wmKeyConfig *keyconf);
void VIEW3D_OT_move(wmOperatorType *ot);
/* view3d_navigate_ndof.c */
/* view3d_navigate_ndof.cc */
#ifdef WITH_INPUT_NDOF
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,
*/
void view3d_ndof_fly(const struct wmNDOFMotionData *ndof,
struct View3D *v3d,
struct RegionView3D *rv3d,
void view3d_ndof_fly(const wmNDOFMotionData *ndof,
View3D *v3d,
RegionView3D *rv3d,
bool use_precision,
short protectflag,
bool *r_has_translate,
bool *r_has_rotate);
void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot);
void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot);
void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot);
void VIEW3D_OT_ndof_all(struct wmOperatorType *ot);
void VIEW3D_OT_ndof_orbit(wmOperatorType *ot);
void VIEW3D_OT_ndof_orbit_zoom(wmOperatorType *ot);
void VIEW3D_OT_ndof_pan(wmOperatorType *ot);
void VIEW3D_OT_ndof_all(wmOperatorType *ot);
#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,
ViewOpsData *vod,
const eV3D_OpEvent event_code,
const int xy[2]);
int viewrotate_invoke_impl(ViewOpsData *vod, const wmEvent *event);
void viewrotate_modal_keymap(struct wmKeyConfig *keyconf);
void VIEW3D_OT_rotate(struct wmOperatorType *ot);
void viewrotate_modal_keymap(wmKeyConfig *keyconf);
void VIEW3D_OT_rotate(wmOperatorType *ot);
/* view3d_navigate_smoothview.c */
/* view3d_navigate_smoothview.cc */
/**
* Parameters for setting the new 3D Viewport state.
*
* 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;
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.
*/
bool undo_grouped;
} V3D_SmoothParams;
};
/**
* The arguments are the desired situation.
*/
void ED_view3d_smooth_view_ex(const struct Depsgraph *depsgraph,
struct wmWindowManager *wm,
struct wmWindow *win,
struct ScrArea *area,
struct View3D *v3d,
struct ARegion *region,
void ED_view3d_smooth_view_ex(const Depsgraph *depsgraph,
wmWindowManager *wm,
wmWindow *win,
ScrArea *area,
View3D *v3d,
ARegion *region,
int smooth_viewtx,
const V3D_SmoothParams *sview);
void ED_view3d_smooth_view(struct bContext *C,
struct View3D *v3d,
struct ARegion *region,
int smooth_viewtx,
const V3D_SmoothParams *sview);
void ED_view3d_smooth_view(
bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview);
/**
* 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.
* 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.
*/
void ED_view3d_smooth_view_undo_end(struct bContext *C,
const struct ScrArea *area,
void ED_view3d_smooth_view_undo_end(bContext *C,
const ScrArea *area,
const char *undo_str,
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.
* (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,
struct View3D *v3d,
struct ARegion *region);
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, 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 VIEW3D_OT_walk(struct wmOperatorType *ot);
void walk_modal_keymap(wmKeyConfig *keyconf);
void VIEW3D_OT_walk(wmOperatorType *ot);
/* view3d_navigate_zoom.c */
/* view3d_navigate_zoom.cc */
int viewzoom_modal_impl(bContext *C,
ViewOpsData *vod,
const eV3D_OpEvent event_code,
const int xy[2]);
int viewzoom_invoke_impl(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr);
void viewzoom_modal_keymap(struct wmKeyConfig *keyconf);
void VIEW3D_OT_zoom(struct wmOperatorType *ot);
void viewzoom_modal_keymap(wmKeyConfig *keyconf);
void VIEW3D_OT_zoom(wmOperatorType *ot);
/* view3d_navigate_zoom_border.c */
/* view3d_navigate_zoom_border.cc */
void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);
#ifdef __cplusplus
}
#endif
void VIEW3D_OT_zoom_border(wmOperatorType *ot);

View File

@ -20,7 +20,7 @@
#include "ED_screen.h"
#include "view3d_intern.h"
#include "view3d_navigate.h" /* own include */
#include "view3d_navigate.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \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_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");
@ -71,7 +71,7 @@ static void view_dolly_to_vector_3d(ARegion *region,
const float dvec[3],
float dfac)
{
RegionView3D *rv3d = region->regiondata;
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
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)
{
ViewOpsData *vod = op->customdata;
ViewOpsData *vod = static_cast<ViewOpsData *>(op->customdata);
short event_code = VIEW_PASS;
bool use_autokey = false;
int ret = OPERATOR_RUNNING_MODAL;
@ -124,11 +124,11 @@ static int viewdolly_modal(bContext *C, wmOperator *op, const wmEvent *event)
event_code = VIEW_CONFIRM;
break;
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;
break;
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;
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);
}
viewops_data_free(C, vod);
op->customdata = NULL;
op->customdata = nullptr;
}
return ret;
@ -195,7 +195,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
const int delta = RNA_int_get(op->ptr, "delta");
if (op->customdata) {
ViewOpsData *vod = op->customdata;
ViewOpsData *vod = static_cast<ViewOpsData *>(op->customdata);
area = vod->area;
region = vod->region;
@ -204,12 +204,12 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
else {
area = CTX_wm_area(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);
}
v3d = area->spacedata.first;
rv3d = region->regiondata;
v3d = static_cast<View3D *>(area->spacedata.first);
rv3d = static_cast<RegionView3D *>(region->regiondata);
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);
viewops_data_free(C, op->customdata);
op->customdata = NULL;
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
op->customdata = nullptr;
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");
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);
@ -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);
viewops_data_free(C, op->customdata);
op->customdata = NULL;
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
op->customdata = nullptr;
return OPERATOR_FINISHED;
}

View File

@ -7,7 +7,7 @@
*
* 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 */
@ -47,7 +47,7 @@
#include "DEG_depsgraph.h"
#include "view3d_intern.h" /* own include */
#include "view3d_navigate.h"
#include "view3d_navigate.hh"
/* -------------------------------------------------------------------- */
/** \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_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");
@ -141,7 +141,7 @@ void fly_modal_keymap(wmKeyConfig *keyconf)
/** \name Internal Fly Structs
* \{ */
typedef struct FlyInfo {
struct FlyInfo {
/* context stuff */
RegionView3D *rv3d;
View3D *v3d;
@ -204,9 +204,8 @@ typedef struct FlyInfo {
/** Keep the previous value to smooth transitions (use lag). */
float dvec_prev[3];
struct View3DCameraControl *v3d_camera_control;
} FlyInfo;
View3DCameraControl *v3d_camera_control;
};
/** \} */
@ -220,9 +219,9 @@ static void flyApply_ndof(bContext *C, FlyInfo *fly, bool is_confirm);
#endif /* WITH_INPUT_NDOF */
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;
int xoff, yoff;
float x1, x2, y1, y2;
@ -320,7 +319,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
#endif
/* 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;
}
@ -366,7 +365,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
copy_v2_v2_int(fly->mval, event->mval);
#ifdef WITH_INPUT_NDOF
fly->ndof = NULL;
fly->ndof = nullptr;
#endif
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!");
// 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) {
case P_STARTING:
/* start keeping track of 3D mouse position */
@ -493,9 +493,9 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event)
putchar('.');
fflush(stdout);
# endif
if (fly->ndof == NULL) {
if (fly->ndof == nullptr) {
// 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));
}
else {
@ -510,7 +510,7 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event)
if (fly->ndof) {
MEM_freeN(fly->ndof);
// free(fly->ndof);
fly->ndof = NULL;
fly->ndof = nullptr;
}
/* update the time else the view will jump when 2D mouse/timer resume */
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_wheel = (float)(time_currwheel - fly->time_lastwheel);
time_wheel = float(time_currwheel - fly->time_lastwheel);
fly->time_lastwheel = time_currwheel;
/* Mouse wheel delays range from (0.5 == slow) to (0.01 == fast) */
/* 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_wheel = (float)(time_currwheel - fly->time_lastwheel);
time_wheel = float(time_currwheel - fly->time_lastwheel);
fly->time_lastwheel = time_currwheel;
/* 0-0.5 -> 0-5.0 */
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;
#endif
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 */
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;
}
fly = MEM_callocN(sizeof(FlyInfo), "FlyOperation");
fly = MEM_cnew<FlyInfo>("FlyOperation");
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)
{
FlyInfo *fly = op->customdata;
FlyInfo *fly = static_cast<FlyInfo *>(op->customdata);
fly->state = FLY_CANCEL;
flyEnd(C, fly);
op->customdata = NULL;
op->customdata = nullptr;
}
static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
int exit_code;
bool do_draw = false;
FlyInfo *fly = op->customdata;
FlyInfo *fly = static_cast<FlyInfo *>(op->customdata);
View3D *v3d = fly->v3d;
RegionView3D *rv3d = fly->rv3d;
Object *fly_object = ED_view3d_cameracontrol_object_get(fly->v3d_camera_control);

View File

@ -18,7 +18,7 @@
#include "ED_screen.h"
#include "view3d_intern.h"
#include "view3d_navigate.h" /* own include */
#include "view3d_navigate.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \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_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");

View File

@ -17,7 +17,7 @@
#include "ED_screen.h"
#include "view3d_intern.h"
#include "view3d_navigate.h" /* own include */
#include "view3d_navigate.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name NDOF Utility Functions
@ -95,7 +95,7 @@ static void view3d_ndof_pan_zoom(const wmNDOFMotionData *ndof,
const bool has_translate,
const bool has_zoom)
{
RegionView3D *rv3d = region->regiondata;
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
float view_inv[4];
float pan_vec[3];
@ -159,8 +159,8 @@ static void view3d_ndof_orbit(const wmNDOFMotionData *ndof,
ViewOpsData *vod,
const bool apply_dyn_ofs)
{
View3D *v3d = area->spacedata.first;
RegionView3D *rv3d = region->regiondata;
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
float view_inv[4];
@ -431,7 +431,7 @@ int ndof_orbit_invoke_impl(bContext *C, ViewOpsData *vod, const wmEvent *event)
RegionView3D *rv3d = vod->rv3d;
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 */
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;
}
const wmNDOFMotionData *ndof = event->customdata;
const wmNDOFMotionData *ndof = static_cast<const wmNDOFMotionData *>(event->customdata);
if (U.ndof_flag & NDOF_CAMERA_PAN_ZOOM) {
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;
}
const wmNDOFMotionData *ndof = event->customdata;
const wmNDOFMotionData *ndof = static_cast<const wmNDOFMotionData *>(event->customdata);
if (U.ndof_flag & NDOF_CAMERA_PAN_ZOOM) {
const int camera_retval = view3d_ndof_cameraview_pan_zoom(vod, ndof);

View File

@ -22,7 +22,7 @@
#include "ED_screen.h"
#include "view3d_intern.h"
#include "view3d_navigate.h" /* own include */
#include "view3d_navigate.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name View Roll Operator
@ -40,7 +40,7 @@ static void view_roll_angle(ARegion *region,
float angle,
bool use_axis_view)
{
RegionView3D *rv3d = region->regiondata;
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
float quat_mul[4];
/* camera axis */
@ -51,7 +51,7 @@ static void view_roll_angle(ARegion *region,
/* avoid precision loss over time */
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);
}
else {
@ -61,7 +61,8 @@ static void view_roll_angle(ARegion *region,
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) {
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)
{
ViewOpsData *vod = op->customdata;
ViewOpsData *vod = static_cast<ViewOpsData *>(op->customdata);
short event_code = VIEW_PASS;
bool use_autokey = false;
int ret = OPERATOR_RUNNING_MODAL;
@ -99,11 +100,11 @@ static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
event_code = VIEW_CANCEL;
break;
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;
break;
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;
break;
}
@ -151,8 +152,8 @@ static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
if ((ret & OPERATOR_RUNNING_MODAL) == 0) {
viewops_data_free(C, op->customdata);
op->customdata = NULL;
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
op->customdata = nullptr;
}
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"},
{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"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static int viewroll_exec(bContext *C, wmOperator *op)
@ -177,7 +178,7 @@ static int viewroll_exec(bContext *C, wmOperator *op)
ARegion *region;
if (op->customdata) {
ViewOpsData *vod = op->customdata;
ViewOpsData *vod = static_cast<ViewOpsData *>(op->customdata);
region = vod->region;
v3d = vod->v3d;
}
@ -185,7 +186,7 @@ static int viewroll_exec(bContext *C, wmOperator *op)
ED_view3d_context_user_region(C, &v3d, &region);
}
rv3d = region->regiondata;
rv3d = static_cast<RegionView3D *>(region->regiondata);
const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d);
if ((rv3d->persp != RV3D_CAMOB) || is_camera_lock) {
@ -211,7 +212,7 @@ static int viewroll_exec(bContext *C, wmOperator *op)
negate_v3(mousevec);
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];
if (U.uiflag & USER_ORBIT_SELECTION) {
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,
region,
smooth_viewtx,
&(const V3D_SmoothParams){
.quat = quat_new,
.dyn_ofs = dyn_ofs_pt,
/* Group as successive roll may run by holding a key. */
.undo_str = op->type->name,
.undo_grouped = true,
});
V3D_SmoothParams sview_params = {};
sview_params.quat = quat_new;
sview_params.dyn_ofs = dyn_ofs_pt;
/* Group as successive roll may run by holding a key. */
sview_params.undo_str = op->type->name;
sview_params.undo_grouped = true;
viewops_data_free(C, op->customdata);
op->customdata = NULL;
ED_view3d_smooth_view(C, v3d, region, smooth_viewtx, &sview_params);
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
op->customdata = nullptr;
return OPERATOR_FINISHED;
}
viewops_data_free(C, op->customdata);
op->customdata = NULL;
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
op->customdata = nullptr;
return OPERATOR_CANCELLED;
}
@ -253,10 +251,11 @@ static int viewroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
else {
/* makes op->customdata */
vod = op->customdata = 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),
BLI_rcti_cent_y(&vod->region->winrct)},
FLT_EPSILON);
vod = viewops_data_create(C, event, V3D_OP_MODE_VIEW_ROLL, false);
const float start_position[2] = {float(BLI_rcti_cent_x(&vod->region->winrct)),
float(BLI_rcti_cent_y(&vod->region->winrct))};
vod->init.dial = BLI_dial_init(start_position, FLT_EPSILON);
op->customdata = vod;
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];
viewroll_apply(vod, event->prev_xy[0], event->prev_xy[1]);
viewops_data_free(C, op->customdata);
op->customdata = NULL;
viewops_data_free(C, static_cast<ViewOpsData *>(op->customdata));
op->customdata = nullptr;
return OPERATOR_FINISHED;
}

View File

@ -17,7 +17,7 @@
#include "ED_screen.h"
#include "view3d_intern.h"
#include "view3d_navigate.h" /* own include */
#include "view3d_navigate.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \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_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");
@ -72,7 +72,7 @@ static void viewrotate_apply_snap(ViewOpsData *vod)
for (y = -1; y < 2; y++) {
for (z = -1; z < 2; 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);
@ -116,7 +116,7 @@ static void viewrotate_apply_snap(ViewOpsData *vod)
float xaxis2[3] = {1, 0, 0};
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);
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);
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,
* 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) {
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 = fac * fac;
interp_v3_v3v3(xaxis, xaxis, m_inv[0], fac);

View File

@ -22,7 +22,7 @@
#include "ED_screen.h"
#include "view3d_intern.h"
#include "view3d_navigate.h" /* own include */
#include "view3d_navigate.hh" /* own include */
static void view3d_smoothview_apply_with_interp(
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)
{
const View3D *v3d = area->spacedata.first;
const View3D *v3d = static_cast<const View3D *>(area->spacedata.first);
Object *camera = v3d->camera;
if (!camera) {
return;
@ -59,7 +59,7 @@ void ED_view3d_smooth_view_undo_begin(bContext *C, const ScrArea *area)
if (region->regiontype != RGN_TYPE_WINDOW) {
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)) {
camera->id.tag |= LIB_TAG_DOIT;
break;
@ -72,7 +72,7 @@ void ED_view3d_smooth_view_undo_end(bContext *C,
const char *undo_str,
const bool undo_grouped)
{
View3D *v3d = area->spacedata.first;
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
Object *camera = v3d->camera;
if (!camera) {
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
* 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. */
const ARegion *region_camera = NULL;
const ARegion *region_camera = nullptr;
/* An undo push should be performed. */
bool is_interactive = false;
@ -99,7 +99,7 @@ void ED_view3d_smooth_view_undo_end(bContext *C,
if (region->regiontype != RGN_TYPE_WINDOW) {
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)) {
region_camera = region;
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;
}
RegionView3D *rv3d = region_camera->regiondata;
RegionView3D *rv3d = static_cast<RegionView3D *>(region_camera->regiondata);
/* Fast forward, undo push, then rewind. */
if (is_interactive) {
@ -150,9 +150,9 @@ struct SmoothView3DState {
struct SmoothView3DStore {
/* Source. */
struct SmoothView3DState src; /* source */
struct SmoothView3DState dst; /* destination */
struct SmoothView3DState org; /* original */
SmoothView3DState src; /* source */
SmoothView3DState dst; /* destination */
SmoothView3DState org; /* original */
bool to_camera;
@ -166,7 +166,7 @@ struct SmoothView3DStore {
double time_allowed;
};
static void view3d_smooth_view_state_backup(struct SmoothView3DState *sms_state,
static void view3d_smooth_view_state_backup(