[Bf-blender-cvs] [a5c0964] master: Cleanup: transform snap arguments
Campbell Barton
noreply at git.blender.org
Wed Dec 2 09:26:35 CET 2015
Commit: a5c0964c70cc4c12e574ef7e51fcf6c0b5f38680
Author: Campbell Barton
Date: Wed Dec 2 18:08:48 2015 +1100
Branches: master
https://developer.blender.org/rBa5c0964c70cc4c12e574ef7e51fcf6c0b5f38680
Cleanup: transform snap arguments
This was getting very hard to follow,
- mixing input/output args.
- mixing arg order between functions.
- arg names (mode, snap_mode) rename to (snap_to, snap_select)
===================================================================
M source/blender/editors/armature/editarmature_sketch.c
M source/blender/editors/curve/editcurve.c
M source/blender/editors/include/ED_transform.h
M source/blender/editors/mesh/editmesh_tools.c
M source/blender/editors/space_view3d/view3d_edit.c
M source/blender/editors/space_view3d/view3d_walk.c
M source/blender/editors/transform/transform_snap.c
M source/blender/makesrna/intern/rna_scene_api.c
M source/blenderplayer/bad_level_call_stubs/stubs.c
===================================================================
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 9319ccf..87d75aa 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -982,7 +982,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
mvalf[0] = dd->mval[0];
mvalf[1] = dd->mval[1];
- peelObjectsContext(C, &sketch->depth_peels, mvalf, SNAP_ALL);
+ peelObjectsContext(C, mvalf, SNAP_ALL, &sketch->depth_peels);
if (stk->nb_points > 0 && stk->points[stk->nb_points - 1].type == PT_CONTINUOUS) {
last_p = stk->points[stk->nb_points - 1].p;
@@ -1086,7 +1086,9 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
mval[1] = dd->mval[1];
/* try to snap to closer object */
- found = snapObjectsContext(C, mval, &dist_px, vec, no, SNAP_NOT_SELECTED);
+ found = snapObjectsContext(
+ C, mval, SNAP_NOT_SELECTED,
+ vec, no, &dist_px);
if (found == 1) {
pt->type = dd->type;
pt->mode = PT_SNAP;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 500bb1e..22cb479 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -4975,7 +4975,9 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const float mval[2] = {UNPACK2(event->mval)};
float no_dummy[3];
float dist_px_dummy;
- snapObjectsContext(C, mval, &dist_px_dummy, location, no_dummy, SNAP_NOT_OBEDIT);
+ snapObjectsContext(
+ C, mval, SNAP_NOT_OBEDIT,
+ location, no_dummy, &dist_px_dummy);
}
RNA_float_set_array(op->ptr, "location", location);
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index b0866a5..874c693 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -168,30 +168,53 @@ typedef struct DepthPeel {
struct ListBase;
-typedef enum SnapMode {
+typedef enum SnapSelect {
SNAP_ALL = 0,
SNAP_NOT_SELECTED = 1,
SNAP_NOT_OBEDIT = 2
-} SnapMode;
+} SnapSelect;
#define SNAP_MIN_DISTANCE 30
#define TRANSFORM_DIST_MAX_RAY (FLT_MAX / 2.0f)
-bool peelObjectsTransForm(struct TransInfo *t, struct ListBase *depth_peels, const float mval[2], SnapMode mode);
-bool peelObjectsContext(struct bContext *C, struct ListBase *depth_peels, const float mval[2], SnapMode mode);
-bool snapObjectsTransform(struct TransInfo *t, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode);
-bool snapObjectsContext(struct bContext *C, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode);
+bool peelObjectsTransForm(
+ struct TransInfo *t, const float mval[2], SnapSelect snap_select,
+ /* return args */
+ struct ListBase *r_depth_peels);
+bool peelObjectsContext(
+ struct bContext *C, const float mval[2], SnapSelect snap_select,
+ /* return args */
+ struct ListBase *r_depth_peels);
+bool snapObjectsTransform(
+ struct TransInfo *t, const float mval[2], SnapSelect snap_select,
+ /* return args */
+ float r_loc[3], float r_no[3], float *r_dist_px);
+bool snapObjectsContext(
+ struct bContext *C, const float mval[2], SnapSelect snap_select,
+ /* return args */
+ float r_loc[3], float r_no[3], float *r_dist_px);
/* taks args for all settings */
-bool snapObjectsEx(struct Scene *scene, struct Base *base_act, struct View3D *v3d, struct ARegion *ar, struct Object *obedit, short snap_mode,
- const float mval[2], float *r_dist_px,
- float r_loc[3], float r_no[3], float *r_ray_dist, SnapMode mode);
-bool snapObjectsRayEx(struct Scene *scene, struct Base *base_act, struct View3D *v3d, struct ARegion *ar, struct Object *obedit, short snap_mode,
- struct Object **r_ob, float r_obmat[4][4],
- const float ray_start[3], const float ray_normal[3], float *r_ray_dist,
- const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode);
-
-bool snapNodesTransform(struct TransInfo *t, const int mval[2], float *r_dist_px, float r_loc[2], char *r_node_border, SnapMode mode);
-bool snapNodesContext(struct bContext *C, const int mval[2], float *r_dist_px, float r_loc[2], char *r_node_border, SnapMode mode);
-
-#endif
-
+bool snapObjectsEx(
+ struct Scene *scene, struct View3D *v3d, struct ARegion *ar, struct Base *base_act, struct Object *obedit,
+ const float mval[2], SnapSelect snap_select, short snap_mode,
+ float *ray_depth,
+ /* return args */
+ float r_loc[3], float r_no[3], float *r_dist_px);
+bool snapObjectsRayEx(
+ struct Scene *scene, struct View3D *v3d, struct ARegion *ar, struct Base *base_act, struct Object *obedit,
+ const float mval[2], SnapSelect snap_select, short snap_mode,
+ const float ray_start[3], const float ray_normal[3], float *ray_depth,
+ /* return args */
+ float r_loc[3], float r_no[3], float *r_dist_px,
+ struct Object **r_ob, float r_obmat[4][4]);
+
+bool snapNodesTransform(
+ struct TransInfo *t, const int mval[2], SnapSelect snap_select,
+ /* return args */
+ float r_loc[2], float *r_dist_px, char *r_node_border);
+bool snapNodesContext(
+ struct bContext *C, const int mval[2], SnapSelect snap_select,
+ /* return args */
+ float r_loc[2], float *r_dist_px, char *r_node_border);
+
+#endif /* __ED_TRANSFORM_H__ */
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 8e591ec..b240836 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -306,7 +306,10 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
float mval[2], co_proj[3], no_dummy[3];
float dist_px_dummy;
if (ED_view3d_project_float_object(ar, eve->co, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- if (snapObjectsContext(C, mval, &dist_px_dummy, co_proj, no_dummy, SNAP_NOT_OBEDIT)) {
+ if (snapObjectsContext(
+ C, mval, SNAP_NOT_OBEDIT,
+ co_proj, no_dummy, &dist_px_dummy))
+ {
mul_v3_m4v3(eve->co, obedit->imat, co_proj);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index d278d94..498aa3a 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -5168,10 +5168,11 @@ bool ED_view3d_snap_from_ray(
/* try snap edge, then face if it fails */
ret = snapObjectsRayEx(
- scene, NULL, NULL, NULL, obedit, SCE_SNAP_MODE_FACE,
- NULL, NULL,
+ scene, NULL, NULL, NULL, obedit,
+ NULL, SNAP_ALL, SCE_SNAP_MODE_FACE,
ray_start, ray_normal, &ray_dist,
- NULL, NULL, r_co, r_no_dummy, SNAP_ALL);
+ r_co, r_no_dummy, NULL,
+ NULL, NULL);
return ret;
}
@@ -5216,8 +5217,10 @@ bool ED_view3d_snap_from_region(
ray_dist = TRANSFORM_DIST_MAX_RAY;
}
if (snapObjectsEx(
- scene, NULL, v3d, ar, obedit, elem_type[i],
- mval, &dist_px, r_co, r_no_ptr, &ray_dist, SNAP_ALL))
+ scene, v3d, ar, NULL, obedit,
+ mval, SNAP_ALL, elem_type[i],
+ &ray_dist,
+ r_co, r_no_ptr, &dist_px))
{
is_hit = true;
}
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 4d36d70..b71b6b8 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -403,7 +403,6 @@ static void walk_navigation_mode_set(bContext *C, wmOperator *op, WalkInfo *walk
*/
static bool walk_floor_distance_get(bContext *C, RegionView3D *rv3d, WalkInfo *walk, const float dvec[3], float *r_distance)
{
- float dummy_dist_px = 0;
float ray_normal[3] = {0, 0, -1}; /* down */
float ray_start[3];
float r_location[3];
@@ -418,10 +417,12 @@ static bool walk_floor_distance_get(bContext *C, RegionView3D *rv3d, WalkInfo *w
mul_v3_v3fl(dvec_tmp, dvec, walk->grid);
add_v3_v3(ray_start, dvec_tmp);
- ret = snapObjectsRayEx(CTX_data_scene(C), NULL, NULL, NULL, NULL, SCE_SNAP_MODE_FACE,
- NULL, NULL,
- ray_start, ray_normal, r_distance,
- NULL, &dummy_dist_px, r_location, r_normal, SNAP_ALL);
+ ret = snapObjectsRayEx(
+ CTX_data_scene(C), NULL, NULL, NULL, NULL,
+ NULL, SNAP_ALL, SCE_SNAP_MODE_FACE,
+ ray_start, ray_normal, r_distance,
+ r_location, r_normal, NULL,
+ NULL, NULL);
/* artifically scale the distance to the scene size */
*r_distance /= walk->grid;
@@ -435,7 +436,6 @@ static bool walk_floor_distance_get(bContext *C, RegionView3D *rv3d, WalkInfo *w
*/
static bool walk_ray_cast(bContext *C, RegionView3D *rv3d, WalkInfo *walk, float r_location[3], float r_normal[3], float *ray_distance)
{
- float dummy_dist_px = 0;
float ray_normal[3] = {0, 0, 1}; /* forward */
float ray_start[3];
float mat[3][3]; /* 3x3 copy of the view matrix so we can move along the view axis */
@@ -451,10 +451,12 @@ static bool walk_ray_cast(bContext *C, RegionView3D *rv3d, WalkInfo *walk, float
mul_v3_fl(ray_normal, -1);
normalize_v3(ray_normal);
- ret = snapObjectsRayEx(CTX_data_scene(C), NULL, NULL, NULL, NULL, SCE_SNAP_MODE_FACE,
- NULL, NULL,
- ray_start, ray_normal, ray_distance,
- NULL, &dummy_dist_px, r_location, r_normal, SNAP_ALL);
+ ret = snapObjectsRayEx(
+ CTX_data_scene(C), NULL, NULL, NULL, NULL,
+ NULL, SNAP_ALL, SCE_SNAP_MODE_FACE,
+ ray_start, ray_normal, ray_distance,
+ r_location, r_normal, NULL,
+ NULL, NULL);
/* dot is positive if both rays are facing the same direction */
diff --git a/source/blender/editors/t
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list