Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ED_transform_snap_object_context.h « include « editors « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ebaa32941f2e9b180de1df50f11fa753cf4787cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

/** \file
 * \ingroup editors
 */

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

struct BMEdge;
struct BMFace;
struct BMVert;

struct ARegion;
struct Depsgraph;
struct ListBase;
struct Main;
struct Object;
struct Scene;
struct View3D;

/* transform_snap_object.c */

/* ED_transform_snap_object_*** API */

typedef enum eSnapSelect {
  SNAP_ALL = 0,
  SNAP_NOT_SELECTED = 1,
  SNAP_NOT_ACTIVE = 2,
} eSnapSelect;

/** used for storing multiple hits */
struct SnapObjectHitDepth {
  struct SnapObjectHitDepth *next, *prev;

  float depth;
  float co[3];
  float no[3];
  int index;

  struct Object *ob;
  float obmat[4][4];

  /* needed to tell which ray-cast this was part of,
   * the same object may be part of many ray-casts when dupli's are used. */
  unsigned int ob_uuid;
};

/** parameters that define which objects will be used to snap. */
struct SnapObjectParams {
  /* special context sensitive handling for the active or selected object */
  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;
  /* exclude back facing geometry from snapping */
  unsigned int use_backface_culling : 1;
};

typedef struct SnapObjectContext SnapObjectContext;
SnapObjectContext *ED_transform_snap_object_context_create(struct Scene *scene, int flag);
SnapObjectContext *ED_transform_snap_object_context_create_view3d(struct Scene *scene,
                                                                  int flag,
                                                                  /* extra args for view3d */
                                                                  const struct ARegion *region,
                                                                  const struct View3D *v3d);
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx);

/* callbacks to filter how snap works */
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_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,
                                             /* return args */
                                             float r_loc[3],
                                             float r_no[3],
                                             int *r_index,
                                             struct Object **r_ob,
                                             float r_obmat[4][4]);
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]);

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);

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]);
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,
                                             /* return args */
                                             float r_loc[3],
                                             float r_no[3]);

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);

#ifdef __cplusplus
}
#endif