[Bf-blender-cvs] [0b9cd0c88d4] blender2.8: Merge branch 'master' into blender2.8
Campbell Barton
noreply at git.blender.org
Fri Jun 22 12:58:46 CEST 2018
Commit: 0b9cd0c88d43b637a652154c945494d36f0ad996
Author: Campbell Barton
Date: Fri Jun 22 12:56:02 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB0b9cd0c88d43b637a652154c945494d36f0ad996
Merge branch 'master' into blender2.8
===================================================================
===================================================================
diff --cc source/blender/editors/include/ED_view3d.h
index 343bffa0082,fe1fc7dc0cc..bc131b45d37
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@@ -98,11 -91,9 +98,11 @@@ typedef struct ViewDepths
bool damaged;
} ViewDepths;
-float *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d);
-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]);
+struct View3DCursor *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d);
- void ED_view3d_cursor3d_calc_mat3(const struct Scene *scene, const struct View3D *v3d, float mat[3][3]);
- void ED_view3d_cursor3d_calc_mat4(const struct Scene *scene, const struct View3D *v3d, float mat[4][4]);
- 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]);
++void ED_view3d_cursor3d_calc_mat3(const struct Scene *scene, const struct View3D *v3d, float mat[3][3]);
++void ED_view3d_cursor3d_calc_mat4(const struct Scene *scene, const struct View3D *v3d, float mat[4][4]);
++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]);
struct Camera *ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d);
diff --cc source/blender/editors/object/object_add.c
index 21ace255a4c,9f016e13f49..f8399558dbc
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@@ -2421,11 -2384,11 +2421,11 @@@ static int add_named_exec(bContext *C,
const int mval[2] = {event->x - ar->winrct.xmin,
event->y - ar->winrct.ymin};
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_activate(C, basen);
+ ED_object_base_select(basen, BA_SELECT);
+ ED_object_base_activate(C, basen);
copy_object_set_idnew(C);
diff --cc source/blender/editors/space_view3d/view3d_edit.c
index bae186097a8,5cf167165cd..977421e7fad
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@@ -4553,8 -4529,10 +4553,8 @@@ void VIEW3D_OT_clip_border(wmOperatorTy
/* cursor position in vec, result in vec, mval in region coords */
/* 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);
- Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ar->regiondata;
@@@ -4576,12 -4554,9 +4576,12 @@@
}
if (U.uiflag & USER_DEPTH_CURSOR) { /* maybe this should be accessed some other way */
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+
view3d_operator_needs_opengl(C);
- if (ED_view3d_autodist(depsgraph, ar, v3d, mval, fp, true, NULL)) {
- if (ED_view3d_autodist(bmain, scene, ar, v3d, mval, cursor_co, true, NULL))
++ if (ED_view3d_autodist(depsgraph, ar, v3d, mval, cursor_co, true, NULL)) {
depth_used = true;
+ }
}
if (depth_used == false) {
@@@ -4593,80 -4568,32 +4593,82 @@@
void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
+ RegionView3D *rv3d = ar->regiondata;
- float *cursor_co_curr = ED_view3d_cursor3d_get(scene, v3d);
- float cursor_co_prev[3];
+ View3DCursor *cursor_curr = ED_view3d_cursor3d_get(scene, v3d);
+ View3DCursor cursor_prev = *cursor_curr;
- ED_view3d_cursor3d_position(C, cursor_curr->location, mval);
- copy_v3_v3(cursor_co_prev, cursor_co_curr);
++ ED_view3d_cursor3d_position(C, mval, cursor_curr->location);
+ copy_qt_qt(cursor_curr->rotation, rv3d->viewquat);
+ cursor_curr->rotation[0] *= -1.0f;
- ED_view3d_cursor3d_position(C, mval, cursor_co_curr);
+ {
+ 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,
+ 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);
+ }
+
+ /* 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];
+ float co_2d_curr[2], co_2d_prev[2];
- 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))
+ if ((ED_view3d_project_float_global(
- ar, cursor_co_prev, co_2d_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
++ ar, cursor_prev.location, 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))
++ ar, cursor_curr->location, 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[1] += (co_curr[1] - co_prev[1]) / (ar->winy * 0.5f);
+ rv3d->ofs_lock[0] += (co_2d_curr[0] - co_2d_prev[0]) / (ar->winx * 0.5f);
+ rv3d->ofs_lock[1] += (co_2d_curr[1] - co_2d_prev[1]) / (ar->winy * 0.5f);
}
}
else {
More information about the Bf-blender-cvs
mailing list