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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-05-08 15:18:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-08 16:35:04 +0300
commita48186c5d74b3d353c5c65cd4a930dd98cc9a603 (patch)
treec49fd2af2aaac151c5fd1265e414392617043253 /source/blender/editors
parent53a56b7b6c169b21df475ae94795208501581489 (diff)
Orientation for 3D cursor
Currently set when setting the cursor location, optionally used as an orientation type. Intended for use by tools too. See: D3208
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/armature/armature_add.c19
-rw-r--r--source/blender/editors/armature/armature_edit.c8
-rw-r--r--source/blender/editors/curve/editcurve.c4
-rw-r--r--source/blender/editors/curve/editcurve_paint.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c2
-rw-r--r--source/blender/editors/include/ED_view3d.h2
-rw-r--r--source/blender/editors/mesh/editmesh_bisect.c2
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c2
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_screw.c2
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin.c2
-rw-r--r--source/blender/editors/mesh/editmesh_polybuild.c2
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c6
-rw-r--r--source/blender/editors/object/object_add.c2
-rw-r--r--source/blender/editors/object/object_hook.c2
-rw-r--r--source/blender/editors/object/object_transform.c2
-rw-r--r--source/blender/editors/object/object_warp.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c77
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c2
-rw-r--r--source/blender/editors/transform/transform.c2
-rw-r--r--source/blender/editors/transform/transform_constraints.c4
-rw-r--r--source/blender/editors/transform/transform_generics.c2
-rw-r--r--source/blender/editors/transform/transform_manipulator_3d.c9
-rw-r--r--source/blender/editors/transform/transform_orientations.c7
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c2
32 files changed, 138 insertions, 66 deletions
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index 8109fc27cea..07c9225c443 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -126,7 +126,6 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
bArmature *arm;
EditBone *ebone, *newbone, *flipbone;
float mat[3][3], imat[3][3];
- const float *curs;
int a, to_root = 0;
Object *obedit;
Scene *scene;
@@ -188,8 +187,8 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
newbone->flag |= BONE_CONNECTED;
}
- curs = ED_view3d_cursor3d_get(scene, v3d);
- copy_v3_v3(newbone->tail, curs);
+ const View3DCursor *curs = ED_view3d_cursor3d_get(scene, v3d);
+ copy_v3_v3(newbone->tail, curs->location);
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
if (a == 1)
@@ -221,26 +220,26 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEv
Scene *scene;
ARegion *ar;
View3D *v3d;
- float *fp, tvec[3], oldcurs[3], mval_f[2];
+ float tvec[3], oldcurs[3], mval_f[2];
int retv;
scene = CTX_data_scene(C);
ar = CTX_wm_region(C);
v3d = CTX_wm_view3d(C);
- fp = ED_view3d_cursor3d_get(scene, v3d);
+ View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
- copy_v3_v3(oldcurs, fp);
+ copy_v3_v3(oldcurs, cursor->location);
VECCOPY2D(mval_f, event->mval);
- ED_view3d_win_to_3d(v3d, ar, fp, mval_f, tvec);
- copy_v3_v3(fp, tvec);
+ ED_view3d_win_to_3d(v3d, ar, cursor->location, mval_f, tvec);
+ copy_v3_v3(cursor->location, tvec);
/* extrude to the where new cursor is and store the operation result */
retv = armature_click_extrude_exec(C, op);
/* restore previous 3d cursor position */
- copy_v3_v3(fp, oldcurs);
+ copy_v3_v3(cursor->location, oldcurs);
return retv;
}
@@ -1013,7 +1012,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "name", name);
- copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C)));
+ copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C))->location);
/* Get inverse point for head and orientation for tail */
invert_m4_m4(obedit->imat, obedit->obmat);
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 6a94443660b..7372be8896f 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -318,10 +318,10 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
float cursor_local[3];
- const float *cursor = ED_view3d_cursor3d_get(scene, v3d);
+ const View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
invert_m4_m4(ob->imat, ob->obmat);
- copy_v3_v3(cursor_local, cursor);
+ copy_v3_v3(cursor_local, cursor->location);
mul_m4_v3(ob->imat, cursor_local);
@@ -705,7 +705,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
/* Get points - cursor (tail) */
invert_m4_m4(obedit->imat, obedit->obmat);
- mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d));
+ mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d)->location);
/* Create a bone */
newbone = add_points_bone(obedit, ebp->vec, curs);
@@ -743,7 +743,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
/* get cursor location */
invert_m4_m4(obedit->imat, obedit->obmat);
- mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d));
+ mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d)->location);
/* get distances */
dist_sq_a = len_squared_v3v3(ebp_a->vec, curs);
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 5cfdec4d5ad..f97ac98107c 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -4528,7 +4528,7 @@ static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
if (rv3d)
copy_v3_v3(axis, rv3d->viewinv[2]);
- RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d));
+ RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d)->location);
RNA_float_set_array(op->ptr, "axis", axis);
return spin_exec(C, op);
@@ -5004,7 +5004,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
mul_v3_m4v3(location, vc.obedit->obmat, bp->vec);
}
else {
- copy_v3_v3(location, ED_view3d_cursor3d_get(vc.scene, vc.v3d));
+ copy_v3_v3(location, ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location);
}
ED_view3d_win_to_3d_int(vc.v3d, vc.ar, location, event->mval, location);
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 669c6283856..05425fbcd6a 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -1117,7 +1117,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* use view plane (when set or as fallback when surface can't be found) */
if (cdd->project.use_depth == false) {
- plane_co = ED_view3d_cursor3d_get(cdd->vc.scene, v3d);
+ plane_co = ED_view3d_cursor3d_get(cdd->vc.scene, v3d)->location;
plane_no = rv3d->viewinv[2];
cdd->project.use_plane = true;
}
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 533ab21dbb6..1cb882e9a43 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -404,7 +404,7 @@ static void gp_brush_grab_calc_dvec(tGP_BrushEditData *gso)
if (gso->sa->spacetype == SPACE_VIEW3D) {
View3D *v3d = gso->sa->spacedata.first;
RegionView3D *rv3d = gso->ar->regiondata;
- float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d);
+ float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d)->location;
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
float mval_f[2];
@@ -504,7 +504,7 @@ static void gp_brush_calc_midpoint(tGP_BrushEditData *gso)
*/
View3D *v3d = gso->sa->spacedata.first;
RegionView3D *rv3d = gso->ar->regiondata;
- float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d);
+ float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d)->location;
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
float mval_f[2] = {UNPACK2(gso->mval)};
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 19663b66f92..6dfe17f227a 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -176,7 +176,7 @@ static void gp_strokepoint_convertcoords(
copy_v3_v3(p3d, &pt->x);
}
else {
- const float *fp = ED_view3d_cursor3d_get(scene, v3d);
+ const float *fp = ED_view3d_cursor3d_get(scene, v3d)->location;
float mvalf[2];
/* get screen coordinate */
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 4f9abff292a..d8cbbb16542 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1464,7 +1464,7 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
const bool use_offset = RNA_boolean_get(op->ptr, "use_offset");
- const float *cursor_global = ED_view3d_cursor3d_get(scene, v3d);
+ const float *cursor_global = ED_view3d_cursor3d_get(scene, v3d)->location;
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* only editable and visible layers are considered */
@@ -1551,7 +1551,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
- float *cursor = ED_view3d_cursor3d_get(scene, v3d);
+ float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
float centroid[3] = {0.0f};
float min[3], max[3];
size_t count = 0;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index ccd47463a9c..3f3349a752c 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -236,7 +236,7 @@ static bool gpencil_project_check(tGPsdata *p)
static void gp_get_3d_reference(tGPsdata *p, float vec[3])
{
View3D *v3d = p->sa->spacedata.first;
- const float *fp = ED_view3d_cursor3d_get(p->scene, v3d);
+ const float *fp = ED_view3d_cursor3d_get(p->scene, v3d)->location;
/* the reference point used depends on the owner... */
#if 0 /* XXX: disabled for now, since we can't draw relative to the owner yet */
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index d7e5b5a92aa..babe68ba439 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -745,7 +745,7 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen
{
View3D *v3d = gsc->sa->spacedata.first;
RegionView3D *rv3d = gsc->ar->regiondata;
- float *rvec = ED_view3d_cursor3d_get(scene, v3d);
+ float *rvec = ED_view3d_cursor3d_get(scene, v3d)->location;
float ref[3] = {rvec[0], rvec[1], rvec[2]};
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 3ab08967a0d..a34571fef44 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -97,7 +97,7 @@ typedef struct ViewDepths {
bool damaged;
} ViewDepths;
-float *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d);
+struct View3DCursor *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_update(struct bContext *C, const int mval[2]);
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c
index ac8c1f16477..ee06f7abd2b 100644
--- a/source/blender/editors/mesh/editmesh_bisect.c
+++ b/source/blender/editors/mesh/editmesh_bisect.c
@@ -243,7 +243,7 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op)
RNA_property_float_get_array(op->ptr, prop_plane_co, plane_co);
}
else {
- copy_v3_v3(plane_co, ED_view3d_cursor3d_get(scene, v3d));
+ copy_v3_v3(plane_co, ED_view3d_cursor3d_get(scene, v3d)->location);
RNA_property_float_set_array(op->ptr, prop_plane_co, plane_co);
}
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index ca49d4e5448..41053d423de 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -973,7 +973,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
BM_ELEM_SELECT, ofs);
}
else {
- const float *cursor = ED_view3d_cursor3d_get(vc.scene, vc.v3d);
+ const float *cursor = ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location;
BMOperator bmop;
BMOIter oiter;
diff --git a/source/blender/editors/mesh/editmesh_extrude_screw.c b/source/blender/editors/mesh/editmesh_extrude_screw.c
index debab7edf21..3be8ab9c2e4 100644
--- a/source/blender/editors/mesh/editmesh_extrude_screw.c
+++ b/source/blender/editors/mesh/editmesh_extrude_screw.c
@@ -148,7 +148,7 @@ static int edbm_screw_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
PropertyRNA *prop;
prop = RNA_struct_find_property(op->ptr, "center");
if (!RNA_property_is_set(op->ptr, prop)) {
- RNA_property_float_set_array(op->ptr, prop, ED_view3d_cursor3d_get(scene, v3d));
+ RNA_property_float_set_array(op->ptr, prop, ED_view3d_cursor3d_get(scene, v3d)->location);
}
if (rv3d) {
prop = RNA_struct_find_property(op->ptr, "axis");
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c
index a4106ebcde1..4195f7daef3 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin.c
@@ -487,7 +487,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
PropertyRNA *prop;
prop = RNA_struct_find_property(op->ptr, "center");
if (!RNA_property_is_set(op->ptr, prop)) {
- RNA_property_float_set_array(op->ptr, prop, ED_view3d_cursor3d_get(scene, v3d));
+ RNA_property_float_set_array(op->ptr, prop, ED_view3d_cursor3d_get(scene, v3d)->location);
}
if (rv3d) {
prop = RNA_struct_find_property(op->ptr, "axis");
diff --git a/source/blender/editors/mesh/editmesh_polybuild.c b/source/blender/editors/mesh/editmesh_polybuild.c
index dff501ece13..e8bcfb5eb08 100644
--- a/source/blender/editors/mesh/editmesh_polybuild.c
+++ b/source/blender/editors/mesh/editmesh_polybuild.c
@@ -89,7 +89,7 @@ static int edbm_polybuild_face_at_cursor_invoke(
if (ele_act == NULL || ele_act->head.htype == BM_FACE) {
/* Just add vert */
- copy_v3_v3(center, ED_view3d_cursor3d_get(vc.scene, vc.v3d));
+ copy_v3_v3(center, ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location);
mul_v3_m4v3(center, vc.obedit->obmat, center);
ED_view3d_win_to_3d_int(vc.v3d, vc.ar, center, event->mval, center);
mul_m4_v3(vc.obedit->imat, center);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index e6eec41e4d6..219c3acd2f7 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -2608,7 +2608,7 @@ static bool merge_target(
const float *vco = NULL;
if (use_cursor) {
- vco = ED_view3d_cursor3d_get(scene, v3d);
+ vco = ED_view3d_cursor3d_get(scene, v3d)->location;
copy_v3_v3(co, vco);
invert_m4_m4(ob->imat, ob->obmat);
mul_m4_v3(ob->imat, co);
@@ -5469,9 +5469,9 @@ static void sort_bmelem_flag(
float fact = reverse ? -1.0 : 1.0;
if (v3d && v3d->localvd)
- copy_v3_v3(cur, v3d->cursor);
+ copy_v3_v3(cur, v3d->cursor.location);
else
- copy_v3_v3(cur, scene->cursor);
+ copy_v3_v3(cur, scene->cursor.location);
invert_m4_m4(mat, ob->obmat);
mul_m4_v3(mat, cur);
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index c2934b916d0..7a0bd44411e 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -165,7 +165,7 @@ void ED_object_location_from_view(bContext *C, float loc[3])
Scene *scene = CTX_data_scene(C);
const float *cursor;
- cursor = ED_view3d_cursor3d_get(scene, v3d);
+ cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
copy_v3_v3(loc, cursor);
}
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index b5a71bb7a35..8c68431c19a 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -781,7 +781,7 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op)
copy_m3_m4(bmat, ob->obmat);
invert_m3_m3(imat, bmat);
- sub_v3_v3v3(hmd->cent, scene->cursor, ob->obmat[3]);
+ sub_v3_v3v3(hmd->cent, scene->cursor.location, ob->obmat[3]);
mul_m3_v3(imat, hmd->cent);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index f3045d44826..0db880a22c6 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -787,7 +787,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
else {
/* get the view settings if 'around' isn't set and the view is available */
View3D *v3d = CTX_wm_view3d(C);
- copy_v3_v3(cursor, ED_view3d_cursor3d_get(scene, v3d));
+ copy_v3_v3(cursor, ED_view3d_cursor3d_get(scene, v3d)->location);
if (v3d && !RNA_struct_property_is_set(op->ptr, "center"))
around = v3d->around;
}
diff --git a/source/blender/editors/object/object_warp.c b/source/blender/editors/object/object_warp.c
index 92b82e2a31b..008593739ba 100644
--- a/source/blender/editors/object/object_warp.c
+++ b/source/blender/editors/object/object_warp.c
@@ -227,7 +227,7 @@ static int object_warp_verts_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
const float *cursor;
- cursor = ED_view3d_cursor3d_get(scene, v3d);
+ cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
copy_v3_v3(center, cursor);
RNA_property_float_set_array(op->ptr, prop_center, center);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 8c148dcb313..fd8fe84cffc 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -3905,7 +3905,7 @@ static void paint_proj_begin_clone(ProjPaintState *ps, const float mouse[2])
/* setup clone offset */
if (ps->tool == PAINT_TOOL_CLONE) {
float projCo[4];
- copy_v3_v3(projCo, ED_view3d_cursor3d_get(ps->scene, ps->v3d));
+ copy_v3_v3(projCo, ED_view3d_cursor3d_get(ps->scene, ps->v3d)->location);
mul_m4_v3(ps->obmat_imat, projCo);
projCo[3] = 1.0f;
@@ -5015,7 +5015,7 @@ void paint_proj_stroke(
struct Depsgraph *graph = CTX_data_depsgraph(C);
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
- float *cursor = ED_view3d_cursor3d_get(scene, v3d);
+ float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
int mval_i[2] = {(int)pos[0], (int)pos[1]};
view3d_operator_needs_opengl(C);
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index f51acff3ba2..ab08d6a0025 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -550,7 +550,7 @@ static void group_instance_cb(
{
Group *group = (Group *)tselem->id;
- Object *ob = ED_object_add_type(C, OB_EMPTY, group->id.name + 2, scene->cursor, NULL, false, scene->layact);
+ Object *ob = ED_object_add_type(C, OB_EMPTY, group->id.name + 2, scene->cursor.location, NULL, false, scene->layact);
ob->dup_group = group;
ob->transflag |= OB_DUPLIGROUP;
id_lib_extern(&group->id);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 7e05a80781c..95e688dcc08 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -78,6 +78,7 @@
#include "ED_mesh.h"
#include "ED_gpencil.h"
#include "ED_view3d.h"
+#include "ED_transform_snap_object_context.h"
#include "UI_resources.h"
@@ -2706,7 +2707,6 @@ static int view3d_all_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base;
- float *curs;
const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions");
const bool skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) ||
/* any one of the regions may be locked */
@@ -2719,10 +2719,11 @@ static int view3d_all_exec(bContext *C, wmOperator *op)
if (center) {
/* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */
- curs = ED_view3d_cursor3d_get(scene, v3d);
+ View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
zero_v3(min);
zero_v3(max);
- zero_v3(curs);
+ zero_v3(cursor->location);
+ unit_qt(cursor->rotation);
}
else {
INIT_MINMAX(min, max);
@@ -3038,7 +3039,7 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *op)
/* non camera center */
float new_ofs[3];
- negate_v3_v3(new_ofs, ED_view3d_cursor3d_get(scene, v3d));
+ negate_v3_v3(new_ofs, ED_view3d_cursor3d_get(scene, v3d)->location);
ED_view3d_smooth_view(
C, v3d, ar, smooth_viewtx,
&(const V3D_SmoothParams) {.ofs = new_ofs});
@@ -4572,25 +4573,75 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
+ RegionView3D *rv3d = ar->regiondata;
- float *fp_curr = ED_view3d_cursor3d_get(scene, v3d);
- float fp_prev[3];
+ View3DCursor *cursor_curr = ED_view3d_cursor3d_get(scene, v3d);
+ View3DCursor cursor_prev = *cursor_curr;
- copy_v3_v3(fp_prev, fp_curr);
+ ED_view3d_cursor3d_position(C, cursor_curr->location, mval);
+ copy_qt_qt(cursor_curr->rotation, rv3d->viewquat);
+ cursor_curr->rotation[0] *= -1.0f;
+
+ {
+ struct Main *bmain = CTX_data_main(C);
+ const float mval_fl[2] = {UNPACK2(mval)};
+ float ray_no[3];
+
+ struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
+ bmain, scene, CTX_data_depsgraph(C), 0, ar, v3d);
+
+ float obmat[4][4];
+ Object *ob_dummy = NULL;
+ float dist_px = 0;
+ if (ED_transform_snap_object_project_view3d_ex(
+ snap_context,
+ SCE_SNAP_MODE_FACE,
+ &(const struct SnapObjectParams){
+ .snap_select = SNAP_ALL,
+ .use_object_edit_cage = false,
+ },
+ mval_fl, &dist_px, NULL,
+ cursor_curr->location, ray_no, NULL,
+ &ob_dummy, obmat))
+ {
+ float tquat[4];
+ /* Math normal (Z). */
+ {
+ float z_src[3] = {0, 0, 1};
+ mul_qt_v3(cursor_curr->rotation, z_src);
+ rotation_between_vecs_to_quat(tquat, z_src, ray_no);
+ mul_qt_qtqt(cursor_curr->rotation, tquat, cursor_curr->rotation);
+ }
- ED_view3d_cursor3d_position(C, fp_curr, mval);
+ /* Match object matrix (X). */
+ {
+ const float ortho_axis_dot[3] = {
+ dot_v3v3(ray_no, obmat[0]),
+ dot_v3v3(ray_no, obmat[1]),
+ dot_v3v3(ray_no, obmat[2]),
+ };
+ const int ortho_axis = axis_dominant_v3_ortho_single(ortho_axis_dot);
+ float x_src[3] = {1, 0, 0};
+ float x_dst[3];
+ mul_qt_v3(cursor_curr->rotation, x_src);
+ project_plane_v3_v3v3(x_dst, obmat[ortho_axis], ray_no);
+ normalize_v3(x_dst);
+ rotation_between_vecs_to_quat(tquat, x_src, x_dst);
+ mul_qt_qtqt(cursor_curr->rotation, tquat, cursor_curr->rotation);
+ }
+ }
+ ED_transform_snap_object_context_destroy(snap_context);
+ }
/* offset the cursor lock to avoid jumping to new offset */
if (v3d->ob_centre_cursor) {
- ARegion *ar = CTX_wm_region(C);
- RegionView3D *rv3d = ar->regiondata;
-
if (U.uiflag & USER_LOCK_CURSOR_ADJUST) {
float co_curr[2], co_prev[2];
- if ((ED_view3d_project_float_global(ar, fp_prev, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
- (ED_view3d_project_float_global(ar, fp_curr, co_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
+ if ((ED_view3d_project_float_global(ar, cursor_prev.location, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
+ (ED_view3d_project_float_global(ar, cursor_curr->location, co_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[1] += (co_curr[1] - co_prev[1]) / (ar->winy * 0.5f);
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 970fb5f5b9d..f177a88240c 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -407,7 +407,7 @@ static int snap_selected_to_cursor_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
- const float *snap_target_global = ED_view3d_cursor3d_get(scene, v3d);
+ const float *snap_target_global = ED_view3d_cursor3d_get(scene, v3d)->location;
return snap_selected_to_location(C, snap_target_global, use_offset);
}
@@ -468,7 +468,7 @@ static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
float gridf, *curs;
gridf = rv3d->gridview;
- curs = ED_view3d_cursor3d_get(scene, v3d);
+ curs = ED_view3d_cursor3d_get(scene, v3d)->location;
curs[0] = gridf * floorf(0.5f + curs[0] / gridf);
curs[1] = gridf * floorf(0.5f + curs[1] / gridf);
@@ -651,7 +651,7 @@ static int snap_curs_to_sel_exec(bContext *C, wmOperator *UNUSED(op))
View3D *v3d = CTX_wm_view3d(C);
float *curs;
- curs = ED_view3d_cursor3d_get(scene, v3d);
+ curs = ED_view3d_cursor3d_get(scene, v3d)->location;
if (snap_curs_to_sel_ex(C, curs)) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
@@ -725,7 +725,7 @@ static int snap_curs_to_active_exec(bContext *C, wmOperator *UNUSED(op))
View3D *v3d = CTX_wm_view3d(C);
float *curs;
- curs = ED_view3d_cursor3d_get(scene, v3d);
+ curs = ED_view3d_cursor3d_get(scene, v3d)->location;
if (snap_calc_active_center(C, false, curs)) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
@@ -758,7 +758,7 @@ static int snap_curs_to_center_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
float *curs;
- curs = ED_view3d_cursor3d_get(scene, v3d);
+ curs = ED_view3d_cursor3d_get(scene, v3d)->location;
zero_v3(curs);
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index 09a3202c85e..9ce427fb830 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -71,10 +71,14 @@
*
* \{ */
-float *ED_view3d_cursor3d_get(Scene *scene, View3D *v3d)
+View3DCursor *ED_view3d_cursor3d_get(Scene *scene, View3D *v3d)
{
- if (v3d && v3d->localvd) return v3d->cursor;
- else return scene->cursor;
+ if (v3d && v3d->localvd) {
+ return &v3d->cursor;
+ }
+ else {
+ return &scene->cursor;
+ }
}
Camera *ED_view3d_camera_data_get(View3D *v3d, RegionView3D *rv3d)
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index b6ea68c8fe4..0e78fd02b30 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -791,7 +791,7 @@ void view3d_viewmatrix_set(
}
else if (v3d->ob_centre_cursor) {
float vec[3];
- copy_v3_v3(vec, ED_view3d_cursor3d_get(scene, (View3D *)v3d));
+ copy_v3_v3(vec, ED_view3d_cursor3d_get(scene, (View3D *)v3d)->location);
translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]);
use_lock_ofs = true;
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 6b36e738cc0..41cc2087dea 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2953,7 +2953,7 @@ static void initBend(TransInfo *t)
data = MEM_callocN(sizeof(*data), __func__);
- curs = ED_view3d_cursor3d_get(t->scene, t->view);
+ curs = ED_view3d_cursor3d_get(t->scene, t->view)->location;
copy_v3_v3(data->warp_sta, curs);
ED_view3d_win_to_3d(t->sa->spacedata.first, t->ar, curs, mval_fl, data->warp_end);
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index bd03c0cedba..0b222e54a67 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -689,6 +689,10 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
BLI_snprintf(text, sizeof(text), ftext, IFACE_("view"));
setConstraint(t, t->spacemtx, mode, text);
break;
+ case V3D_MANIP_CURSOR:
+ BLI_snprintf(text, sizeof(text), ftext, IFACE_("cursor"));
+ setConstraint(t, t->spacemtx, mode, text);
+ break;
case V3D_MANIP_GIMBAL:
BLI_snprintf(text, sizeof(text), ftext, IFACE_("gimbal"));
setConstraint(t, t->spacemtx, mode, text);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 195c2ef3986..c3acf8c4350 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1791,7 +1791,7 @@ void calculateCenterCursor(TransInfo *t, float r_center[3])
{
const float *cursor;
- cursor = ED_view3d_cursor3d_get(t->scene, t->view);
+ cursor = ED_view3d_cursor3d_get(t->scene, t->view)->location;
copy_v3_v3(r_center, cursor);
/* If edit or pose mode, move cursor in local space */
diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c
index c3c4abbda37..502cff9a243 100644
--- a/source/blender/editors/transform/transform_manipulator_3d.c
+++ b/source/blender/editors/transform/transform_manipulator_3d.c
@@ -669,6 +669,13 @@ int ED_transform_calc_manipulator_stats(
copy_m4_m3(rv3d->twmat, mat);
break;
}
+ case V3D_MANIP_CURSOR:
+ {
+ float mat[3][3];
+ quat_to_mat3(mat, ED_view3d_cursor3d_get(scene, v3d)->rotation);
+ copy_m4_m3(rv3d->twmat, mat);
+ break;
+ }
case V3D_MANIP_CUSTOM:
{
TransformOrientation *custom_orientation = BKE_scene_transform_orientation_find(
@@ -1083,7 +1090,7 @@ static void manipulator_prepare_mat(
copy_v3_v3(rv3d->twmat[3], tbounds->center);
break;
case V3D_AROUND_CURSOR:
- copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d));
+ copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d)->location);
break;
}
}
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 9e6f4847b5b..c1a2c99e26d 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -481,6 +481,13 @@ void initTransformOrientation(bContext *C, TransInfo *t)
unit_m3(t->spacemtx);
}
break;
+ case V3D_MANIP_CURSOR:
+ {
+ const View3DCursor *cursor = ED_view3d_cursor3d_get(t->scene, CTX_wm_view3d(C));
+ BLI_strncpy(t->spacename, IFACE_("cursor"), sizeof(t->spacename));
+ quat_to_mat3(t->spacemtx, cursor->rotation);
+ break;
+ }
case V3D_MANIP_CUSTOM:
BLI_strncpy(t->spacename, t->custom_orientation->name, sizeof(t->spacename));
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 1442266a3aa..74521edf45f 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -1039,7 +1039,7 @@ static void uv_map_transform_center(
case V3D_AROUND_CURSOR: /* cursor center */
{
invert_m4_m4(ob->imat, ob->obmat);
- mul_v3_m4v3(r_center, ob->imat, ED_view3d_cursor3d_get(scene, v3d));
+ mul_v3_m4v3(r_center, ob->imat, ED_view3d_cursor3d_get(scene, v3d)->location);
break;
}
case V3D_AROUND_ACTIVE: