Fix T96776: Assets dropped upside down when looking through camera
In perspective mode the snap point direction needs to be taken into account to define which side of the face is being looked at. If there is no face under the mouse cursor, there is no direction adjustment and the element normal will be used.
This commit is contained in:
parent
17a773cdce
commit
317dfc1735
Notes:
blender-bot
2023-02-14 00:37:17 +01:00
Referenced by issue #98661, 3.2: Potential candidates for corrective releases Referenced by issue #96776, Assets dropped upside down when looking through camera
|
@ -660,10 +660,6 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
|
|||
face_nor);
|
||||
}
|
||||
|
||||
if (is_zero_v3(face_nor)) {
|
||||
face_nor[state->plane_axis] = 1.0f;
|
||||
}
|
||||
|
||||
if (calc_plane_omat) {
|
||||
RegionView3D *rv3d = region->regiondata;
|
||||
bool orient_surface = (snap_elem != SCE_SNAP_MODE_NONE) &&
|
||||
|
@ -691,8 +687,28 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
|
|||
orthogonalize_m3(omat, state->plane_axis);
|
||||
|
||||
if (orient_surface) {
|
||||
if (dot_v3v3(rv3d->viewinv[2], face_nor) < 0.0f) {
|
||||
negate_v3(face_nor);
|
||||
if (!is_zero_v3(face_nor)) {
|
||||
/* Negate the face normal according to the view. */
|
||||
float ray_dir[3];
|
||||
if (rv3d->is_persp) {
|
||||
BLI_assert_msg(snap_elem != SCE_SNAP_MODE_NONE,
|
||||
"Use of variable `co` without it being computed");
|
||||
|
||||
sub_v3_v3v3(ray_dir, co, rv3d->viewinv[3]); /* No need to normalize. */
|
||||
}
|
||||
else {
|
||||
negate_v3_v3(ray_dir, rv3d->viewinv[2]);
|
||||
}
|
||||
|
||||
if (dot_v3v3(ray_dir, face_nor) >= 0.0f) {
|
||||
negate_v3(face_nor);
|
||||
}
|
||||
}
|
||||
else if (!is_zero_v3(no)) {
|
||||
copy_v3_v3(face_nor, no);
|
||||
}
|
||||
else {
|
||||
face_nor[state->plane_axis] = 1.0f;
|
||||
}
|
||||
v3d_cursor_poject_surface_normal(face_nor, obmat, omat);
|
||||
}
|
||||
|
@ -700,7 +716,7 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
|
|||
|
||||
float *co_depth = (snap_elem != SCE_SNAP_MODE_NONE) ? co : scene->cursor.location;
|
||||
snap_elem &= ~data_intern->snap_elem_hidden;
|
||||
if (snap_elem == 0) {
|
||||
if (snap_elem == SCE_SNAP_MODE_NONE) {
|
||||
RegionView3D *rv3d = region->regiondata;
|
||||
const float *plane_normal = omat[state->plane_axis];
|
||||
bool do_plane_isect = (state->plane_depth != V3D_PLACE_DEPTH_CURSOR_VIEW) &&
|
||||
|
|
|
@ -3179,10 +3179,6 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont
|
|||
if (r_index) {
|
||||
*r_index = index;
|
||||
}
|
||||
if (r_face_nor && !has_hit) {
|
||||
/* Fallback. */
|
||||
copy_v3_v3(r_face_nor, no);
|
||||
}
|
||||
|
||||
*dist_px = dist_px_tmp;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue