Cleanup: pass the use_depth parameter to the `SnapObjectParams` struct in the ED_transform_snap_object_project_view3d_mixed.

This commit is contained in:
Germano Cavalcante 2018-05-15 14:32:30 -03:00
parent 717dd4cecd
commit 50c29e2391
6 changed files with 17 additions and 12 deletions

View File

@ -5021,8 +5021,9 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
&(const struct SnapObjectParams){
.snap_select = (vc.obedit != NULL) ? SNAP_NOT_ACTIVE : SNAP_ALL,
.use_object_edit_cage = false,
.use_occlusion_test = true,
},
mval, NULL, true,
mval, NULL,
location, NULL);

View File

@ -72,6 +72,9 @@ struct SnapObjectParams {
char snap_select;
/* use editmode cage */
unsigned int use_object_edit_cage : 1;
/* snap to the closest element, use when using more than one snap type */
unsigned int use_occlusion_test : 1;
};
typedef struct SnapObjectContext SnapObjectContext;
@ -132,7 +135,6 @@ bool ED_transform_snap_object_project_view3d_mixed(
const unsigned short snap_to_flag,
const struct SnapObjectParams *params,
const float mval_fl[2], float *dist_px,
bool use_depth,
float r_co[3], float r_no[3]);
bool ED_transform_snap_object_project_all_view3d_ex(

View File

@ -379,8 +379,9 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
&(const struct SnapObjectParams){
.snap_select = SNAP_NOT_ACTIVE,
.use_object_edit_cage = false,
.use_occlusion_test = true,
},
mval, NULL, true,
mval, NULL,
co_proj, NULL))
{
mul_v3_m4v3(eve->co, obedit->imat, co_proj);

View File

@ -326,8 +326,9 @@ static bool view3d_ruler_item_mousemove(
&(const struct SnapObjectParams){
.snap_select = SNAP_ALL,
.use_object_edit_cage = true,
.use_occlusion_test = true,
},
mval_fl, &dist_px, true,
mval_fl, &dist_px,
co, ray_normal))
{
negate_v3(ray_normal);
@ -355,8 +356,9 @@ static bool view3d_ruler_item_mousemove(
&(const struct SnapObjectParams){
.snap_select = SNAP_ALL,
.use_object_edit_cage = true,
.use_occlusion_test = use_depth,
},
mval_fl, &dist_px, use_depth,
mval_fl, &dist_px,
co, NULL))
{
ruler_info->snap_flag |= RULER_SNAP_OK;

View File

@ -767,8 +767,9 @@ static bool view3d_ruler_item_mousemove(
&(const struct SnapObjectParams){
.snap_select = SNAP_ALL,
.use_object_edit_cage = true,
.use_occlusion_test = true,
},
mval_fl, &dist_px, true,
mval_fl, &dist_px,
co, ray_normal))
{
negate_v3(ray_normal);
@ -796,8 +797,9 @@ static bool view3d_ruler_item_mousemove(
&(const struct SnapObjectParams){
.snap_select = SNAP_ALL,
.use_object_edit_cage = true,
.use_occlusion_test = use_depth,
},
mval_fl, &dist_px, use_depth,
mval_fl, &dist_px,
co, NULL))
{
ruler_info->snap_flag |= RULER_SNAP_OK;

View File

@ -2122,7 +2122,6 @@ static bool transform_snap_context_project_view3d_mixed_impl(
const unsigned short snap_to_flag,
const struct SnapObjectParams *params,
const float mval[2], float *dist_px,
bool use_depth,
float r_co[3], float r_no[3])
{
float ray_depth = BVH_RAYCAST_DIST_MAX;
@ -2133,7 +2132,7 @@ static bool transform_snap_context_project_view3d_mixed_impl(
BLI_assert(snap_to_flag != 0);
BLI_assert((snap_to_flag & ~(1 | 2 | 4)) == 0);
if (use_depth) {
if (params->use_occlusion_test) {
const float dist_px_orig = dist_px ? *dist_px : 0;
for (int i = 2; i >= 0; i--) {
if (snap_to_flag & (1 << i)) {
@ -2182,7 +2181,6 @@ static bool transform_snap_context_project_view3d_mixed_impl(
* \param sctx: Snap context.
* \param mval_fl: Screenspace coordinate.
* \param dist_px: Maximum distance to snap (in pixels).
* \param use_depth: Snap to the closest element, use when using more than one snap type.
* \param r_co: hit location.
* \param r_no: hit normal (optional).
* \return Snap success
@ -2192,13 +2190,12 @@ bool ED_transform_snap_object_project_view3d_mixed(
const unsigned short snap_to_flag,
const struct SnapObjectParams *params,
const float mval_fl[2], float *dist_px,
bool use_depth,
float r_co[3], float r_no[3])
{
return transform_snap_context_project_view3d_mixed_impl(
sctx,
snap_to_flag, params,
mval_fl, dist_px, use_depth,
mval_fl, dist_px,
r_co, r_no);
}