forked from bartvdbraak/blender
Cleanup: rename 3D cursor calculation vars
This commit is contained in:
parent
2fe528424d
commit
a5f046f449
@ -92,7 +92,7 @@ typedef struct ViewDepths {
|
|||||||
} ViewDepths;
|
} ViewDepths;
|
||||||
|
|
||||||
float *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d);
|
float *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d);
|
||||||
void ED_view3d_cursor3d_position(struct bContext *C, float fp[3], const int mval[2]);
|
void ED_view3d_cursor3d_position(struct bContext *C, const int mval[2], float cursor_co[3]);
|
||||||
void ED_view3d_cursor3d_update(struct bContext *C, const int mval[2]);
|
void ED_view3d_cursor3d_update(struct bContext *C, const int mval[2]);
|
||||||
|
|
||||||
struct Camera *ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d);
|
struct Camera *ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d);
|
||||||
|
@ -860,7 +860,7 @@ static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEv
|
|||||||
|
|
||||||
/* add under the mouse */
|
/* add under the mouse */
|
||||||
ED_object_location_from_view(C, ob->loc);
|
ED_object_location_from_view(C, ob->loc);
|
||||||
ED_view3d_cursor3d_position(C, ob->loc, event->mval);
|
ED_view3d_cursor3d_position(C, event->mval, ob->loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
BKE_object_empty_draw_type_set(ob, OB_EMPTY_IMAGE);
|
BKE_object_empty_draw_type_set(ob, OB_EMPTY_IMAGE);
|
||||||
@ -984,7 +984,7 @@ static int group_instance_add_exec(bContext *C, wmOperator *op)
|
|||||||
const int mval[2] = {event->x - ar->winrct.xmin,
|
const int mval[2] = {event->x - ar->winrct.xmin,
|
||||||
event->y - ar->winrct.ymin};
|
event->y - ar->winrct.ymin};
|
||||||
ED_object_location_from_view(C, loc);
|
ED_object_location_from_view(C, loc);
|
||||||
ED_view3d_cursor3d_position(C, loc, mval);
|
ED_view3d_cursor3d_position(C, mval, loc);
|
||||||
RNA_float_set_array(op->ptr, "location", loc);
|
RNA_float_set_array(op->ptr, "location", loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2384,7 +2384,7 @@ static int add_named_exec(bContext *C, wmOperator *op)
|
|||||||
const int mval[2] = {event->x - ar->winrct.xmin,
|
const int mval[2] = {event->x - ar->winrct.xmin,
|
||||||
event->y - ar->winrct.ymin};
|
event->y - ar->winrct.ymin};
|
||||||
ED_object_location_from_view(C, basen->object->loc);
|
ED_object_location_from_view(C, basen->object->loc);
|
||||||
ED_view3d_cursor3d_position(C, basen->object->loc, mval);
|
ED_view3d_cursor3d_position(C, mval, basen->object->loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
ED_base_object_select(basen, BA_SELECT);
|
ED_base_object_select(basen, BA_SELECT);
|
||||||
|
@ -4529,7 +4529,7 @@ void VIEW3D_OT_clip_border(wmOperatorType *ot)
|
|||||||
|
|
||||||
/* cursor position in vec, result in vec, mval in region coords */
|
/* cursor position in vec, result in vec, mval in region coords */
|
||||||
/* note: cannot use event->mval here (called by object_add() */
|
/* note: cannot use event->mval here (called by object_add() */
|
||||||
void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
|
void ED_view3d_cursor3d_position(bContext *C, const int mval[2], float cursor_co[3])
|
||||||
{
|
{
|
||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
Scene *scene = CTX_data_scene(C);
|
Scene *scene = CTX_data_scene(C);
|
||||||
@ -4544,25 +4544,25 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
|
|||||||
if (rv3d == NULL)
|
if (rv3d == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ED_view3d_calc_zfac(rv3d, fp, &flip);
|
ED_view3d_calc_zfac(rv3d, cursor_co, &flip);
|
||||||
|
|
||||||
/* reset the depth based on the view offset (we _know_ the offset is infront of us) */
|
/* reset the depth based on the view offset (we _know_ the offset is infront of us) */
|
||||||
if (flip) {
|
if (flip) {
|
||||||
negate_v3_v3(fp, rv3d->ofs);
|
negate_v3_v3(cursor_co, rv3d->ofs);
|
||||||
/* re initialize, no need to check flip again */
|
/* re initialize, no need to check flip again */
|
||||||
ED_view3d_calc_zfac(rv3d, fp, NULL /* &flip */ );
|
ED_view3d_calc_zfac(rv3d, cursor_co, NULL /* &flip */ );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (U.uiflag & USER_DEPTH_CURSOR) { /* maybe this should be accessed some other way */
|
if (U.uiflag & USER_DEPTH_CURSOR) { /* maybe this should be accessed some other way */
|
||||||
view3d_operator_needs_opengl(C);
|
view3d_operator_needs_opengl(C);
|
||||||
if (ED_view3d_autodist(bmain, scene, ar, v3d, mval, fp, true, NULL))
|
if (ED_view3d_autodist(bmain, scene, ar, v3d, mval, cursor_co, true, NULL))
|
||||||
depth_used = true;
|
depth_used = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depth_used == false) {
|
if (depth_used == false) {
|
||||||
float depth_pt[3];
|
float depth_pt[3];
|
||||||
copy_v3_v3(depth_pt, fp);
|
copy_v3_v3(depth_pt, cursor_co);
|
||||||
ED_view3d_win_to_3d_int(v3d, ar, depth_pt, mval, fp);
|
ED_view3d_win_to_3d_int(v3d, ar, depth_pt, mval, cursor_co);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4571,12 +4571,12 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
|
|||||||
Scene *scene = CTX_data_scene(C);
|
Scene *scene = CTX_data_scene(C);
|
||||||
View3D *v3d = CTX_wm_view3d(C);
|
View3D *v3d = CTX_wm_view3d(C);
|
||||||
|
|
||||||
float *fp_curr = ED_view3d_cursor3d_get(scene, v3d);
|
float *cursor_co_curr = ED_view3d_cursor3d_get(scene, v3d);
|
||||||
float fp_prev[3];
|
float cursor_co_prev[3];
|
||||||
|
|
||||||
copy_v3_v3(fp_prev, fp_curr);
|
copy_v3_v3(cursor_co_prev, cursor_co_curr);
|
||||||
|
|
||||||
ED_view3d_cursor3d_position(C, fp_curr, mval);
|
ED_view3d_cursor3d_position(C, mval, cursor_co_curr);
|
||||||
|
|
||||||
/* offset the cursor lock to avoid jumping to new offset */
|
/* offset the cursor lock to avoid jumping to new offset */
|
||||||
if (v3d->ob_centre_cursor) {
|
if (v3d->ob_centre_cursor) {
|
||||||
@ -4585,13 +4585,15 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
|
|||||||
|
|
||||||
if (U.uiflag & USER_LOCK_CURSOR_ADJUST) {
|
if (U.uiflag & USER_LOCK_CURSOR_ADJUST) {
|
||||||
|
|
||||||
float co_curr[2], co_prev[2];
|
float co_2d_curr[2], co_2d_prev[2];
|
||||||
|
|
||||||
if ((ED_view3d_project_float_global(ar, fp_prev, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
|
if ((ED_view3d_project_float_global(
|
||||||
(ED_view3d_project_float_global(ar, fp_curr, co_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
|
ar, cursor_co_prev, co_2d_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
|
||||||
|
(ED_view3d_project_float_global(
|
||||||
|
ar, cursor_co_curr, co_2d_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
|
||||||
{
|
{
|
||||||
rv3d->ofs_lock[0] += (co_curr[0] - co_prev[0]) / (ar->winx * 0.5f);
|
rv3d->ofs_lock[0] += (co_2d_curr[0] - co_2d_prev[0]) / (ar->winx * 0.5f);
|
||||||
rv3d->ofs_lock[1] += (co_curr[1] - co_prev[1]) / (ar->winy * 0.5f);
|
rv3d->ofs_lock[1] += (co_2d_curr[1] - co_2d_prev[1]) / (ar->winy * 0.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user