Blender  V2.93
ED_transform_snap_object_context.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #pragma once
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 struct BMEdge;
28 struct BMFace;
29 struct BMVert;
30 
31 struct ARegion;
32 struct Depsgraph;
33 struct ListBase;
34 struct Object;
35 struct Scene;
36 struct View3D;
37 
38 /* transform_snap_object.c */
39 
40 /* ED_transform_snap_object_*** API */
41 
42 typedef enum eSnapSelect {
43  SNAP_ALL = 0,
47 
51 
52  float depth;
53  float co[3];
54  float no[3];
55  int index;
56 
57  struct Object *ob;
58  float obmat[4][4];
59 
60  /* needed to tell which ray-cast this was part of,
61  * the same object may be part of many ray-casts when dupli's are used. */
62  unsigned int ob_uuid;
63 };
64 
67  /* special context sensitive handling for the active or selected object */
69  /* use editmode cage */
70  unsigned int use_object_edit_cage : 1;
71  /* snap to the closest element, use when using more than one snap type */
72  unsigned int use_occlusion_test : 1;
73  /* exclude back facing geometry from snapping */
74  unsigned int use_backface_culling : 1;
75 };
76 
80  int flag,
81  /* extra args for view3d */
82  const struct ARegion *region,
83  const struct View3D *v3d);
85 
86 /* callbacks to filter how snap works */
88  SnapObjectContext *sctx,
89  bool (*test_vert_fn)(struct BMVert *, void *user_data),
90  bool (*test_edge_fn)(struct BMEdge *, void *user_data),
91  bool (*test_face_fn)(struct BMFace *, void *user_data),
92  void *user_data);
93 
95  struct Depsgraph *depsgraph,
96  const struct SnapObjectParams *params,
97  const float ray_start[3],
98  const float ray_normal[3],
99  float *ray_depth,
100  /* return args */
101  float r_loc[3],
102  float r_no[3],
103  int *r_index,
104  struct Object **r_ob,
105  float r_obmat[4][4]);
107  struct Depsgraph *depsgraph,
108  const struct SnapObjectParams *params,
109  const float ray_origin[3],
110  const float ray_direction[3],
111  float *ray_depth,
112  float r_co[3],
113  float r_no[3]);
114 
116  struct Depsgraph *depsgraph,
117  const struct SnapObjectParams *params,
118  const float ray_start[3],
119  const float ray_normal[3],
120  float ray_depth,
121  bool sort,
122  struct ListBase *r_hit_list);
123 
125  struct Depsgraph *depsgraph,
126  const unsigned short snap_to,
127  const struct SnapObjectParams *params,
128  const float mval[2],
129  const float prev_co[3],
130  float *dist_px,
131  float r_loc[3],
132  float r_no[3],
133  int *r_index,
134  struct Object **r_ob,
135  float r_obmat[4][4]);
137  struct Depsgraph *depsgraph,
138  const unsigned short snap_to,
139  const struct SnapObjectParams *params,
140  const float mval[2],
141  const float prev_co[3],
142  float *dist_px,
143  /* return args */
144  float r_loc[3],
145  float r_no[3]);
146 
148  struct Depsgraph *depsgraph,
149  const struct SnapObjectParams *params,
150  const float mval[2],
151  float ray_depth,
152  bool sort,
153  ListBase *r_hit_list);
154 
155 #ifdef __cplusplus
156 }
157 #endif
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
bool ED_transform_snap_object_project_ray_all(SnapObjectContext *sctx, struct Depsgraph *depsgraph, const struct SnapObjectParams *params, const float ray_start[3], const float ray_normal[3], float ray_depth, bool sort, struct ListBase *r_hit_list)
bool ED_transform_snap_object_project_ray(SnapObjectContext *sctx, struct Depsgraph *depsgraph, const struct SnapObjectParams *params, const float ray_origin[3], const float ray_direction[3], float *ray_depth, float r_co[3], float r_no[3])
SnapObjectContext * ED_transform_snap_object_context_create_view3d(struct Scene *scene, int flag, const struct ARegion *region, const struct View3D *v3d)
void ED_transform_snap_object_context_set_editmesh_callbacks(SnapObjectContext *sctx, bool(*test_vert_fn)(struct BMVert *, void *user_data), bool(*test_edge_fn)(struct BMEdge *, void *user_data), bool(*test_face_fn)(struct BMFace *, void *user_data), void *user_data)
bool ED_transform_snap_object_project_all_view3d_ex(SnapObjectContext *sctx, struct Depsgraph *depsgraph, const struct SnapObjectParams *params, const float mval[2], float ray_depth, bool sort, ListBase *r_hit_list)
short ED_transform_snap_object_project_view3d_ex(struct SnapObjectContext *sctx, struct Depsgraph *depsgraph, const unsigned short snap_to, const struct SnapObjectParams *params, const float mval[2], const float prev_co[3], float *dist_px, float r_loc[3], float r_no[3], int *r_index, struct Object **r_ob, float r_obmat[4][4])
SnapObjectContext * ED_transform_snap_object_context_create(struct Scene *scene, int flag)
bool ED_transform_snap_object_project_view3d(struct SnapObjectContext *sctx, struct Depsgraph *depsgraph, const unsigned short snap_to, const struct SnapObjectParams *params, const float mval[2], const float prev_co[3], float *dist_px, float r_loc[3], float r_no[3])
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx)
bool ED_transform_snap_object_project_ray_ex(struct SnapObjectContext *sctx, struct Depsgraph *depsgraph, const struct SnapObjectParams *params, const float ray_start[3], const float ray_normal[3], float *ray_depth, float r_loc[3], float r_no[3], int *r_index, struct Object **r_ob, float r_obmat[4][4])
void sort(btMatrix3x3 &U, btVector3 &sigma, btMatrix3x3 &V, int t)
Helper function of 3X3 SVD for sorting singular values.
Scene scene
const Depsgraph * depsgraph
void * user_data
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
const struct ARegion * region
bool(* test_face_fn)(BMFace *, void *user_data)
bool(* test_edge_fn)(BMEdge *, void *user_data)
bool(* test_vert_fn)(BMVert *, void *user_data)
const struct View3D * v3d
struct SnapObjectHitDepth * next
struct SnapObjectHitDepth * prev