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:
Diffstat (limited to 'source/blender/editors/transform/transform_snap.c')
-rw-r--r--source/blender/editors/transform/transform_snap.c101
1 files changed, 46 insertions, 55 deletions
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 4b6ab2045c0..86e99c986f8 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -21,36 +21,36 @@
* \ingroup edtransform
*/
-#include <stdlib.h>
-#include <math.h>
#include <float.h>
+#include <math.h>
#include <stdio.h>
+#include <stdlib.h>
#include "PIL_time.h"
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h"
#include "DNA_meshdata_types.h" /* Temporary, for snapping to other unselected meshes */
#include "DNA_node_types.h"
-#include "DNA_space_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
-#include "BLI_math.h"
#include "BLI_blenlib.h"
+#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "GPU_immediate.h"
#include "GPU_state.h"
-#include "BKE_layer.h"
-#include "BKE_object.h"
#include "BKE_anim.h" /* for duplis */
#include "BKE_context.h"
#include "BKE_editmesh.h"
-#include "BKE_sequencer.h"
+#include "BKE_layer.h"
#include "BKE_main.h"
+#include "BKE_object.h"
+#include "BKE_sequencer.h"
#include "RNA_access.h"
@@ -59,9 +59,9 @@
#include "ED_image.h"
#include "ED_markers.h"
#include "ED_node.h"
+#include "ED_transform_snap_object_context.h"
#include "ED_uvedit.h"
#include "ED_view3d.h"
-#include "ED_transform_snap_object_context.h"
#include "DEG_depsgraph.h"
@@ -283,7 +283,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_NODE) {
if (validSnap(t)) {
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
TransSnapPoint *p;
float size;
@@ -304,13 +304,13 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
immUniformColor4ubv(col);
}
- ED_node_draw_snap(&ar->v2d, p->co, size, 0, pos);
+ ED_node_draw_snap(&region->v2d, p->co, size, 0, pos);
}
if (t->tsnap.status & POINT_INIT) {
immUniformColor4ubv(activeCol);
- ED_node_draw_snap(&ar->v2d, t->tsnap.snapPoint, size, t->tsnap.snapNodeBorder, pos);
+ ED_node_draw_snap(&region->v2d, t->tsnap.snapPoint, size, t->tsnap.snapNodeBorder, pos);
}
immUnbindProgram();
@@ -373,10 +373,11 @@ void applyProject(TransInfo *t)
copy_v3_v3(iloc, td->ob->obmat[3]);
}
- if (ED_view3d_project_float_global(t->ar, iloc, mval_fl, V3D_PROJ_TEST_NOP) ==
+ if (ED_view3d_project_float_global(t->region, iloc, mval_fl, V3D_PROJ_TEST_NOP) ==
V3D_PROJ_RET_OK) {
if (ED_transform_snap_object_project_view3d(
t->tsnap.object_context,
+ t->depsgraph,
SCE_SNAP_MODE_FACE,
&(const struct SnapObjectParams){
.snap_select = t->tsnap.modeSelect,
@@ -686,7 +687,7 @@ static void initSnappingMode(TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
if (t->tsnap.object_context == NULL) {
t->tsnap.object_context = ED_transform_snap_object_context_create_view3d(
- bmain, t->scene, t->depsgraph, 0, t->ar, t->view);
+ bmain, t->scene, 0, t->region, t->view);
ED_transform_snap_object_context_set_editmesh_callbacks(
t->tsnap.object_context,
@@ -847,7 +848,7 @@ eRedrawFlag updateSelectedSnapPoint(TransInfo *t)
for (p = t->tsnap.points.first; p; p = p->next) {
float dist_sq;
- if (ED_view3d_project_float_global(t->ar, p->co, screen_loc, V3D_PROJ_TEST_NOP) !=
+ if (ED_view3d_project_float_global(t->region, p->co, screen_loc, V3D_PROJ_TEST_NOP) !=
V3D_PROJ_RET_OK) {
continue;
}
@@ -936,7 +937,7 @@ static void ApplySnapTranslation(TransInfo *t, float vec[3])
else {
if (t->spacetype == SPACE_VIEW3D) {
if (t->options & CTX_PAINT_CURVE) {
- if (ED_view3d_project_float_global(t->ar, point, point, V3D_PROJ_TEST_NOP) !=
+ if (ED_view3d_project_float_global(t->region, point, point, V3D_PROJ_TEST_NOP) !=
V3D_PROJ_RET_OK) {
zero_v3(point); /* no good answer here... */
}
@@ -1108,7 +1109,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
Image *ima = ED_space_image(t->sa->spacedata.first);
float co[2];
- UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], &co[0], &co[1]);
+ UI_view2d_region_to_view(&t->region->v2d, t->mval[0], t->mval[1], &co[0], &co[1]);
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
@@ -1365,6 +1366,7 @@ short snapObjectsTransform(
float *target = (t->tsnap.status & TARGET_INIT) ? t->tsnap.snapTarget : t->center_global;
return ED_transform_snap_object_project_view3d_ex(
t->tsnap.object_context,
+ t->depsgraph,
t->scene->toolsettings->snap_mode,
&(const struct SnapObjectParams){
.snap_select = t->tsnap.modeSelect,
@@ -1389,17 +1391,26 @@ short snapObjectsTransform(
/** \name Peeling
* \{ */
-bool peelObjectsSnapContext(SnapObjectContext *sctx,
- const float mval[2],
- const struct SnapObjectParams *params,
- const bool use_peel_object,
- /* return args */
- float r_loc[3],
- float r_no[3],
- float *r_thickness)
+bool peelObjectsTransform(TransInfo *t,
+ const float mval[2],
+ const bool use_peel_object,
+ /* return args */
+ float r_loc[3],
+ float r_no[3],
+ float *r_thickness)
{
ListBase depths_peel = {0};
- ED_transform_snap_object_project_all_view3d_ex(sctx, params, mval, -1.0f, false, &depths_peel);
+ ED_transform_snap_object_project_all_view3d_ex(
+ t->tsnap.object_context,
+ t->depsgraph,
+ &(const struct SnapObjectParams){
+ .snap_select = t->tsnap.modeSelect,
+ .use_object_edit_cage = (t->flag & T_EDIT) != 0,
+ },
+ mval,
+ -1.0f,
+ false,
+ &depths_peel);
if (!BLI_listbase_is_empty(&depths_peel)) {
/* At the moment we only use the hits of the first object */
@@ -1455,26 +1466,6 @@ bool peelObjectsSnapContext(SnapObjectContext *sctx,
return false;
}
-bool peelObjectsTransform(TransInfo *t,
- const float mval[2],
- const bool use_peel_object,
- /* return args */
- float r_loc[3],
- float r_no[3],
- float *r_thickness)
-{
- return peelObjectsSnapContext(t->tsnap.object_context,
- mval,
- &(const struct SnapObjectParams){
- .snap_select = t->tsnap.modeSelect,
- .use_object_edit_cage = (t->flag & T_EDIT) != 0,
- },
- use_peel_object,
- r_loc,
- r_no,
- r_thickness);
-}
-
/** \} */
/* -------------------------------------------------------------------- */
@@ -1504,14 +1495,14 @@ static NodeBorder snapNodeBorder(int snap_node_mode)
static bool snapNode(ToolSettings *ts,
SpaceNode *UNUSED(snode),
- ARegion *ar,
+ ARegion *region,
bNode *node,
const int mval[2],
float r_loc[2],
float *r_dist_px,
char *r_node_border)
{
- View2D *v2d = &ar->v2d;
+ View2D *v2d = &region->v2d;
NodeBorder border = snapNodeBorder(ts->snap_node_mode);
bool retval = false;
rcti totr;
@@ -1564,7 +1555,7 @@ static bool snapNode(ToolSettings *ts,
static bool snapNodes(ToolSettings *ts,
SpaceNode *snode,
- ARegion *ar,
+ ARegion *region,
const int mval[2],
eSnapSelect snap_select,
float r_loc[2],
@@ -1578,8 +1569,8 @@ static bool snapNodes(ToolSettings *ts,
*r_node_border = 0;
for (node = ntree->nodes.first; node; node = node->next) {
- if (snapNodeTest(&ar->v2d, node, snap_select)) {
- retval |= snapNode(ts, snode, ar, node, mval, r_loc, r_dist_px, r_node_border);
+ if (snapNodeTest(&region->v2d, node, snap_select)) {
+ retval |= snapNode(ts, snode, region, node, mval, r_loc, r_dist_px, r_node_border);
}
}
@@ -1591,7 +1582,7 @@ bool snapNodesTransform(
{
return snapNodes(t->settings,
t->sa->spacedata.first,
- t->ar,
+ t->region,
mval,
t->tsnap.modeSelect,
r_loc,
@@ -1691,7 +1682,7 @@ void snapSequenceBounds(TransInfo *t, const int mval[2])
}
/* convert to frame range */
- UI_view2d_region_to_view(&t->ar->v2d, mval[0], mval[1], &xmouse, &ymouse);
+ UI_view2d_region_to_view(&t->region->v2d, mval[0], mval[1], &xmouse, &ymouse);
mframe = round_fl_to_int(xmouse);
/* now find the closest sequence */
frame = BKE_sequencer_find_next_prev_edit(t->scene, mframe, SEQ_SIDE_BOTH, true, false, true);
@@ -1723,7 +1714,7 @@ static void applyGridIncrement(
if (use_aspect) {
/* custom aspect for fcurve */
if (t->spacetype == SPACE_GRAPH) {
- View2D *v2d = &t->ar->v2d;
+ View2D *v2d = &t->region->v2d;
Scene *scene = t->scene;
SpaceGraph *sipo = t->sa->spacedata.first;
asp_local[0] = UI_view2d_grid_resolution_x__frames_or_seconds(